This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Change increment_reading_symtab to return a scoped_restore


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c83dd8672698bcdf48d27e267e481230075f5900

commit c83dd8672698bcdf48d27e267e481230075f5900
Author: Tom Tromey <tom@tromey.com>
Date:   Thu Apr 6 20:27:10 2017 -0600

    Change increment_reading_symtab to return a scoped_restore
    
    This changes increment_reading_symtab to return a scoped_restore, then
    fixes up the users.
    
    gdb/ChangeLog
    2017-04-12  Tom Tromey  <tom@tromey.com>
    
    	* symfile.h (increment_reading_symtab): Update type.
    	* symfile.c (decrement_reading_symtab): Remove.
    	(increment_reading_symtab): Return a scoped_restore_tmpl<int>.
    	* psymtab.c (psymtab_to_symtab): Update.
    	* dwarf2read.c (dw2_instantiate_symtab): Update.

Diff:
---
 gdb/ChangeLog    |  8 ++++++++
 gdb/dwarf2read.c |  2 +-
 gdb/psymtab.c    |  3 +--
 gdb/symfile.c    | 17 ++++-------------
 gdb/symfile.h    |  2 +-
 5 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ad4db38..454bbbb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
 2017-04-12  Tom Tromey  <tom@tromey.com>
 
+	* symfile.h (increment_reading_symtab): Update type.
+	* symfile.c (decrement_reading_symtab): Remove.
+	(increment_reading_symtab): Return a scoped_restore_tmpl<int>.
+	* psymtab.c (psymtab_to_symtab): Update.
+	* dwarf2read.c (dw2_instantiate_symtab): Update.
+
+2017-04-12  Tom Tromey  <tom@tromey.com>
+
 	* jit.c (struct jit_reader): Declare separately.  Add constructor
 	and destructor.  Change type of "handle".
 	(loaded_jit_reader): Define separately.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index e390b32..b58d0fc 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2885,7 +2885,7 @@ dw2_instantiate_symtab (struct dwarf2_per_cu_data *per_cu)
   if (!per_cu->v.quick->compunit_symtab)
     {
       struct cleanup *back_to = make_cleanup (free_cached_comp_units, NULL);
-      increment_reading_symtab ();
+      scoped_restore decrementer = increment_reading_symtab ();
       dw2_do_instantiate_symtab (per_cu);
       process_cu_includes ();
       do_cleanups (back_to);
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index bdce8f2..bb482ee 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -770,10 +770,9 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
   /* If it has not yet been read in, read it.  */
   if (!pst->readin)
     {
-      struct cleanup *back_to = increment_reading_symtab ();
+      scoped_restore decrementer = increment_reading_symtab ();
 
       (*pst->read_symtab) (pst, objfile);
-      do_cleanups (back_to);
     }
 
   return pst->compunit_symtab;
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 750039d..7810f2c 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -91,8 +91,6 @@ static void add_symbol_file_command (char *, int);
 
 static const struct sym_fns *find_sym_fns (bfd *);
 
-static void decrement_reading_symtab (void *);
-
 static void overlay_invalidate_all (void);
 
 static void overlay_auto_command (char *, int);
@@ -193,22 +191,15 @@ print_symbol_loading_p (int from_tty, int exec, int full)
 
 int currently_reading_symtab = 0;
 
-static void
-decrement_reading_symtab (void *dummy)
-{
-  currently_reading_symtab--;
-  gdb_assert (currently_reading_symtab >= 0);
-}
-
 /* Increment currently_reading_symtab and return a cleanup that can be
    used to decrement it.  */
 
-struct cleanup *
+scoped_restore_tmpl<int>
 increment_reading_symtab (void)
 {
-  ++currently_reading_symtab;
-  gdb_assert (currently_reading_symtab > 0);
-  return make_cleanup (decrement_reading_symtab, NULL);
+  gdb_assert (currently_reading_symtab >= 0);
+  return make_scoped_restore (&currently_reading_symtab,
+			      currently_reading_symtab + 1);
 }
 
 /* Remember the lowest-addressed loadable section we've seen.
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 6066481..ab536e8 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -556,7 +556,7 @@ extern int symfile_map_offsets_to_segments (bfd *,
 struct symfile_segment_data *get_symfile_segment_data (bfd *abfd);
 void free_symfile_segment_data (struct symfile_segment_data *data);
 
-extern struct cleanup *increment_reading_symtab (void);
+extern scoped_restore_tmpl<int> increment_reading_symtab (void);
 
 void expand_symtabs_matching
   (gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]