]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Replace really_free_pendings with a scoped_ class
authorTom Tromey <tom@tromey.com>
Fri, 20 Oct 2017 15:30:48 +0000 (09:30 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 4 Nov 2017 16:27:15 +0000 (10:27 -0600)
This introduces scoped_free_pendings, and changes users of
really_free_pendings to use it instead, removing some clenaups.

I tried to examine the affected code to ensure there aren't dangling
cleanups in the vicinity.

gdb/ChangeLog
2017-11-04  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (process_full_comp_unit, process_full_type_unit):
Use scoped_free_pendings.
* dbxread.c (dbx_symfile_read, dbx_psymtab_to_symtab_1): Use
scoped_free_pendings.
* xcoffread.c (xcoff_psymtab_to_symtab_1): Use scoped_free_pendings.
(xcoff_initial_scan): Likewise.
* buildsym.c (reset_symtab_globals): Update comment.
(scoped_free_pendings): Rename from really_free_pendings.
(prepare_for_building): Update comment.
(buildsym_init): Likewise.
* buildsym.h (class scoped_free_pendings): New class.
(really_free_pendings): Don't declare.

gdb/ChangeLog
gdb/buildsym.c
gdb/buildsym.h
gdb/dbxread.c
gdb/dwarf2read.c
gdb/xcoffread.c

index 1f823ca533e4ae72f4e6c5e0a785130f65fccc52..f7d821c1e27055c584195406d998c314877a212a 100644 (file)
@@ -1,3 +1,18 @@
+2017-11-04  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2read.c (process_full_comp_unit, process_full_type_unit):
+       Use scoped_free_pendings.
+       * dbxread.c (dbx_symfile_read, dbx_psymtab_to_symtab_1): Use
+       scoped_free_pendings.
+       * xcoffread.c (xcoff_psymtab_to_symtab_1): Use scoped_free_pendings.
+       (xcoff_initial_scan): Likewise.
+       * buildsym.c (reset_symtab_globals): Update comment.
+       (scoped_free_pendings): Rename from really_free_pendings.
+       (prepare_for_building): Update comment.
+       (buildsym_init): Likewise.
+       * buildsym.h (class scoped_free_pendings): New class.
+       (really_free_pendings): Don't declare.
+
 2017-11-03  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * doublest.c (convert_doublest_to_floatformat): Fix uninitialized
index 07bfbd5038946bbe09c4d689efda850300493574..d07bfb3d1375ea029c45fe04225f1b11f6609cc2 100644 (file)
    The basic way this module is used is as follows:
 
    buildsym_init ();
-   cleanups = make_cleanup (really_free_pendings, NULL);
+   scoped_free_pendings free_pending;
    cust = start_symtab (...);
    ... read debug info ...
    cust = end_symtab (...);
-   do_cleanups (cleanups);
 
    The compunit symtab pointer ("cust") is returned from both start_symtab
    and end_symtab to simplify the debug info readers.
    Reading DWARF Type Units is another variation:
 
    buildsym_init ();
-   cleanups = make_cleanup (really_free_pendings, NULL);
+   scoped_free_pendings free_pending;
    cust = start_symtab (...);
    ... read debug info ...
    cust = end_expandable_symtab (...);
-   do_cleanups (cleanups);
 
    And then reading subsequent Type Units within the containing "Comp Unit"
    will use a second flow:
 
    buildsym_init ();
-   cleanups = make_cleanup (really_free_pendings, NULL);
+   scoped_free_pendings free_pending;
    cust = restart_symtab (...);
    ... read debug info ...
    cust = augment_type_symtab (...);
-   do_cleanups (cleanups);
 
    dbxread.c and xcoffread.c use another variation:
 
    buildsym_init ();
-   cleanups = make_cleanup (really_free_pendings, NULL);
+   scoped_free_pendings free_pending;
    cust = start_symtab (...);
    ... read debug info ...
    cust = end_symtab (...);
    ... start_symtab + read + end_symtab repeated ...
-   do_cleanups (cleanups);
 */
 
 #include "defs.h"
@@ -269,15 +265,13 @@ find_symbol_in_list (struct pending *list, char *name, int length)
   return (NULL);
 }
 
-/* At end of reading syms, or in case of quit, ensure everything associated
-   with building symtabs is freed.  This is intended to be registered as a
-   cleanup before doing psymtab->symtab expansion.
+/* At end of reading syms, or in case of quit, ensure everything
+   associated with building symtabs is freed.
 
    N.B. This is *not* intended to be used when building psymtabs.  Some debug
    info readers call this anyway, which is harmless if confusing.  */
 
-void
-really_free_pendings (void *dummy)
+scoped_free_pendings::~scoped_free_pendings ()
 {
   struct pending *next, *next1;
 
@@ -1028,7 +1022,7 @@ prepare_for_building (const char *name, CORE_ADDR start_addr)
   context_stack_depth = 0;
 
   /* These should have been reset either by successful completion of building
-     a symtab, or by the really_free_pendings cleanup.  */
+     a symtab, or by the scoped_free_pendings destructor.  */
   gdb_assert (file_symbols == NULL);
   gdb_assert (global_symbols == NULL);
   gdb_assert (global_using_directives == NULL);
@@ -1169,7 +1163,7 @@ watch_main_source_file_lossage (void)
 /* Reset state after a successful building of a symtab.
    This exists because dbxread.c and xcoffread.c can call
    start_symtab+end_symtab multiple times after one call to buildsym_init,
-   and before the really_free_pendings cleanup is called.
+   and before the scoped_free_pendings destructor is called.
    We keep the free_pendings list around for dbx/xcoff sake.  */
 
 static void
@@ -1753,7 +1747,7 @@ buildsym_init (void)
       context_stack = XNEWVEC (struct context_stack, context_stack_size);
     }
 
-  /* Ensure the really_free_pendings cleanup was called after
+  /* Ensure the scoped_free_pendings destructor was called after
      the last time.  */
   gdb_assert (free_pendings == NULL);
   gdb_assert (pending_blocks == NULL);
index 60109a0da2e12c8d804978f5a73858a4b988cf30..accb1f03471730b794a4eba99a9116d893f4c1b2 100644 (file)
@@ -212,7 +212,15 @@ extern struct block *finish_block (struct symbol *symbol,
 extern void record_block_range (struct block *,
                                 CORE_ADDR start, CORE_ADDR end_inclusive);
 
-extern void really_free_pendings (void *dummy);
+class scoped_free_pendings
+{
+public:
+
+  scoped_free_pendings () = default;
+  ~scoped_free_pendings ();
+
+  DISABLE_COPY_AND_ASSIGN (scoped_free_pendings);
+};
 
 extern void start_subfile (const char *name);
 
index ce009628094c3edeeeabcc10789c15be438caa39..1618a561369407d75e0d948bf8cf15bc97c36bd3 100644 (file)
@@ -516,7 +516,6 @@ dbx_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 {
   bfd *sym_bfd;
   int val;
-  struct cleanup *back_to;
 
   sym_bfd = objfile->obfd;
 
@@ -539,7 +538,7 @@ dbx_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   symbol_table_offset = DBX_SYMTAB_OFFSET (objfile);
 
   free_pending_blocks ();
-  back_to = make_cleanup (really_free_pendings, 0);
+  scoped_free_pendings free_pending;
 
   minimal_symbol_reader reader (objfile);
 
@@ -551,8 +550,6 @@ dbx_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
      minimal symbols for this objfile.  */
 
   reader.install ();
-
-  do_cleanups (back_to);
 }
 
 /* Initialize anything that needs initializing when a completely new
@@ -2186,7 +2183,6 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
 static void
 dbx_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
 {
-  struct cleanup *old_chain;
   int i;
 
   if (pst->readin)
@@ -2220,15 +2216,13 @@ dbx_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
       /* Init stuff necessary for reading in symbols */
       stabsread_init ();
       buildsym_init ();
-      old_chain = make_cleanup (really_free_pendings, 0);
+      scoped_free_pendings free_pending;
       file_string_table_offset = FILE_STRING_OFFSET (pst);
       symbol_size = SYMBOL_SIZE (pst);
 
       /* Read in this file's symbols.  */
       bfd_seek (objfile->obfd, SYMBOL_OFFSET (pst), SEEK_SET);
       read_ofile_symtab (objfile, pst);
-
-      do_cleanups (old_chain);
     }
 
   pst->readin = 1;
index 686fa3f3d3134708902e379ab7e34bd889ab6212..433a9272b8ed429dae838c33688515ecdb290e91 100644 (file)
@@ -8317,7 +8317,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   CORE_ADDR lowpc, highpc;
   struct compunit_symtab *cust;
-  struct cleanup *back_to, *delayed_list_cleanup;
+  struct cleanup *delayed_list_cleanup;
   CORE_ADDR baseaddr;
   struct block *static_block;
   CORE_ADDR addr;
@@ -8325,7 +8325,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
   buildsym_init ();
-  back_to = make_cleanup (really_free_pendings, NULL);
+  scoped_free_pendings free_pending;
   delayed_list_cleanup = make_cleanup (free_delayed_list, cu);
 
   cu->list_in_scope = &file_symbols;
@@ -8407,8 +8407,6 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
 
   /* Push it for inclusion processing later.  */
   VEC_safe_push (dwarf2_per_cu_ptr, dwarf2_per_objfile->just_read_cus, per_cu);
-
-  do_cleanups (back_to);
 }
 
 /* Generate full symbol information for type unit PER_CU, whose DIEs have
@@ -8421,14 +8419,14 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
   struct dwarf2_cu *cu = per_cu->cu;
   struct objfile *objfile = per_cu->objfile;
   struct compunit_symtab *cust;
-  struct cleanup *back_to, *delayed_list_cleanup;
+  struct cleanup *delayed_list_cleanup;
   struct signatured_type *sig_type;
 
   gdb_assert (per_cu->is_debug_types);
   sig_type = (struct signatured_type *) per_cu;
 
   buildsym_init ();
-  back_to = make_cleanup (really_free_pendings, NULL);
+  scoped_free_pendings free_pending;
   delayed_list_cleanup = make_cleanup (free_delayed_list, cu);
 
   cu->list_in_scope = &file_symbols;
@@ -8483,8 +8481,6 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
       pst->compunit_symtab = cust;
       pst->readin = 1;
     }
-
-  do_cleanups (back_to);
 }
 
 /* Process an imported unit DIE.  */
index ea11b3f966ccca4facfe748406cca9a2450795d7..2e4f30f291230b08f1735be223d1f4cba77a075e 100644 (file)
@@ -1833,7 +1833,6 @@ find_linenos (struct bfd *abfd, struct bfd_section *asect, void *vpinfo)
 static void
 xcoff_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
 {
-  struct cleanup *old_chain;
   int i;
 
   if (!pst)
@@ -1870,11 +1869,9 @@ xcoff_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
       /* Init stuff necessary for reading in symbols.  */
       stabsread_init ();
       buildsym_init ();
-      old_chain = make_cleanup (really_free_pendings, 0);
 
+      scoped_free_pendings free_pending;
       read_xcoff_symtab (objfile, pst);
-
-      do_cleanups (old_chain);
     }
 
   pst->readin = 1;
@@ -2950,7 +2947,6 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
 {
   bfd *abfd;
   int val;
-  struct cleanup *back_to;
   int num_symbols;             /* # of symbols */
   file_ptr symtab_offset;      /* symbol table and */
   file_ptr stringtab_offset;   /* string table file offsets */
@@ -3027,8 +3023,8 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
     init_psymbol_list (objfile, num_symbols);
 
   free_pending_blocks ();
-  back_to = make_cleanup (really_free_pendings, 0);
 
+  scoped_free_pendings free_pending;
   minimal_symbol_reader reader (objfile);
 
   /* Now that the symbol table data of the executable file are all in core,
@@ -3047,8 +3043,6 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
     dwarf2_build_psymtabs (objfile);
 
   dwarf2_build_frame_info (objfile);
-
-  do_cleanups (back_to);
 }
 \f
 static void