Change increment_reading_symtab to return a scoped_restore
authorTom Tromey <tom@tromey.com>
Fri, 7 Apr 2017 02:27:10 +0000 (20:27 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 12 Apr 2017 17:16:17 +0000 (11:16 -0600)
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.

gdb/ChangeLog
gdb/dwarf2read.c
gdb/psymtab.c
gdb/symfile.c
gdb/symfile.h

index ad4db38a40ad9fb5b9d15be05c18187ef2437a24..454bbbbfd80c55864af6c8964e18e181662dc84c 100644 (file)
@@ -1,3 +1,11 @@
+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
index e390b322978accacee4edf84cd82ea49eb79a116..b58d0fc16e6f1aa32600239af145fa521538dbfb 100644 (file)
@@ -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);
index bdce8f239aa999f8fda242979e74983d27e4f929..bb482ee2cb4afac36fff5b496474cc8e87f7f76e 100644 (file)
@@ -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;
index 750039dbc932d4404958179be986aa43b1eb44af..7810f2c160bf2324e6780992d3fdb488edd0ed3f 100644 (file)
@@ -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.
index 6066481fd590ae439d8ef788cbcb06281e45f06f..ab536e8083d7835c449acfc2de69b4bb71031ef8 100644 (file)
@@ -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,
This page took 0.04116 seconds and 4 git commands to generate.