Make free_pending_blocks static
authorTom Tromey <tom@tromey.com>
Mon, 21 May 2018 04:45:44 +0000 (22:45 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 16 Jul 2018 14:55:21 +0000 (08:55 -0600)
free_pending_blocks can be static because scoped_free_pendings (et al)
arrange for it to be NULL in the "steady state".  This removes a
couple of unnecessary calls to free_pending_blocks and changes it to
be static.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

* xcoffread.c (xcoff_initial_scan): Don't call
free_pending_blocks.
* dbxread.c (dbx_symfile_read): Don't call free_pending_blocks.
* buildsym.h (class scoped_free_pendings): Add constructor.
(free_pending_blocks): Don't declare.
* buildsym.c (scoped_free_pendings::scoped_free_pendings): New.
(free_pending_blocks): Now static.

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

index 7d12bee3b11396df4ccd6fdc8670566f035602d4..0fb349681597e448040e4921f6247c78b75f0b33 100644 (file)
@@ -1,3 +1,13 @@
+2018-07-16  Tom Tromey  <tom@tromey.com>
+
+       * xcoffread.c (xcoff_initial_scan): Don't call
+       free_pending_blocks.
+       * dbxread.c (dbx_symfile_read): Don't call free_pending_blocks.
+       * buildsym.h (class scoped_free_pendings): Add constructor.
+       (free_pending_blocks): Don't declare.
+       * buildsym.c (scoped_free_pendings::scoped_free_pendings): New.
+       (free_pending_blocks): Now static.
+
 2018-07-16  Tom Tromey  <tom@tromey.com>
 
        * buildsym.h (push_subfile, pop_subfile): Update declarations.
index 8d06cec1630f3d9e3868e93bbc81e74814534fc1..4e5da073723e3d05305b3eb97fe315191aa4f35b 100644 (file)
@@ -263,6 +263,8 @@ static void record_pending_block (struct objfile *objfile,
                                  struct block *block,
                                  struct pending_block *opblock);
 
+static void free_pending_blocks ();
+
 /* Initial sizes of data structures.  These are realloc'd larger if
    needed, and realloc'd down to the size actually used, when
    completed.  */
@@ -331,6 +333,11 @@ find_symbol_in_list (struct pending *list, char *name, int length)
   return (NULL);
 }
 
+scoped_free_pendings::scoped_free_pendings ()
+{
+  gdb_assert (pending_blocks == nullptr);
+}
+
 /* At end of reading syms, or in case of quit, ensure everything
    associated with building symtabs is freed.
 
@@ -373,8 +380,8 @@ scoped_free_pendings::~scoped_free_pendings ()
 
 /* This function is called to discard any pending blocks.  */
 
-void
-free_pending_blocks (void)
+static void
+free_pending_blocks ()
 {
   if (pending_blocks != NULL)
     {
index b5ea63d3f48863b69fafc2ae08c5feb17d9a5e4c..512d926dcb9c0eb8d2bd071b2db44d9980a409d5 100644 (file)
@@ -176,7 +176,7 @@ class scoped_free_pendings
 {
 public:
 
-  scoped_free_pendings () = default;
+  scoped_free_pendings ();
   ~scoped_free_pendings ();
 
   DISABLE_COPY_AND_ASSIGN (scoped_free_pendings);
@@ -222,8 +222,6 @@ extern struct compunit_symtab *start_symtab (struct objfile *objfile,
 extern void restart_symtab (struct compunit_symtab *cust,
                            const char *name, CORE_ADDR start_addr);
 
-extern void free_pending_blocks (void);
-
 /* Record the name of the debug format in the current pending symbol
    table.  FORMAT must be a string with a lifetime at least as long as
    the symtab's objfile.  */
index 7729315adb62bcceda8376a8c2fb0e0decf1b318..5d4b97858a05de10aa9058a63d032d81a687e6f9 100644 (file)
@@ -545,7 +545,6 @@ dbx_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   symbol_size = DBX_SYMBOL_SIZE (objfile);
   symbol_table_offset = DBX_SYMTAB_OFFSET (objfile);
 
-  free_pending_blocks ();
   scoped_free_pendings free_pending;
 
   minimal_symbol_reader reader (objfile);
index 31ba503f8ac5b62353783dd9cd846c12a3010815..f9f19e7cbcab8bfa484d69ddba9d49edb263cace 100644 (file)
@@ -3018,8 +3018,6 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
        include N_SLINE.  */
     init_psymbol_list (objfile, num_symbols);
 
-  free_pending_blocks ();
-
   scoped_free_pendings free_pending;
   minimal_symbol_reader reader (objfile);