This changes increment_reading_symtab to return a scoped_restore, then
fixes up the users.
gdb/ChangeLog
2017-04-12 Tom Tromey <
[email protected]>
* 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.
+
+ * 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.
+
* jit.c (struct jit_reader): Declare separately. Add constructor
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);
/* 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;
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);
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 (¤tly_reading_symtab,
+ currently_reading_symtab + 1);
}
/* Remember the lowest-addressed loadable section we've seen.
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,