]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Simplify calls to init_psymbol_list
authorTom Tromey <tom@tromey.com>
Thu, 10 May 2018 22:23:47 +0000 (16:23 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 10 Jan 2019 14:08:11 +0000 (07:08 -0700)
Existing callers to init_psymbol_list were checking to see if psymbols
had already been initialized.  It seemed better to me to do this check
directly in init_psymbol_list, simplifying the callers.

gdb/ChangeLog
2019-01-10  Tom Tromey  <tom@tromey.com>

* xcoffread.c (xcoff_initial_scan): Unconditionally call
init_psymbol_list.
* psymtab.c (init_psymbol_list): Do nothing if already called.
* psympriv.h (init_psymbol_list): Add comment.
* dwarf2read.c (dwarf2_build_psymtabs): Unconditionally call
init_psymbol_list.
* dbxread.c (dbx_symfile_read): Unconditionally call
init_psymbol_list.

gdb/ChangeLog
gdb/dbxread.c
gdb/dwarf2read.c
gdb/psympriv.h
gdb/psymtab.c
gdb/xcoffread.c

index e00047c27d5b4996c031f6d653355cf4903c9973..e0cf7cbfe2449343df196a67e39e4f22b8bc65a4 100644 (file)
@@ -1,3 +1,14 @@
+2019-01-10  Tom Tromey  <tom@tromey.com>
+
+       * xcoffread.c (xcoff_initial_scan): Unconditionally call
+       init_psymbol_list.
+       * psymtab.c (init_psymbol_list): Do nothing if already called.
+       * psympriv.h (init_psymbol_list): Add comment.
+       * dwarf2read.c (dwarf2_build_psymtabs): Unconditionally call
+       init_psymbol_list.
+       * dbxread.c (dbx_symfile_read): Unconditionally call
+       init_psymbol_list.
+
 2019-01-10  Tom Tromey  <tom@tromey.com>
 
        * xcoffread.c (scan_xcoff_symtab): Update.
index 73e436f4f62fe5f3d5d0ef24f4e9cdf6882788fa..6149175d732d42c5dfd35fc476a7e88c60833bd2 100644 (file)
@@ -536,9 +536,7 @@ dbx_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
     perror_with_name (objfile_name (objfile));
 
   /* Size the symbol table.  */
-  if (objfile->global_psymbols.capacity () == 0
-      && objfile->static_psymbols.capacity () == 0)
-    init_psymbol_list (objfile, DBX_SYMCOUNT (objfile));
+  init_psymbol_list (objfile, DBX_SYMCOUNT (objfile));
 
   symbol_size = DBX_SYMBOL_SIZE (objfile);
   symbol_table_offset = DBX_SYMTAB_OFFSET (objfile);
index 070a0c2195499098afd35ad062ab531d47160bdd..9aa33bfec8f67265282ba668cacdccf0a70a80ed 100644 (file)
@@ -6299,9 +6299,7 @@ dwarf2_build_psymtabs (struct objfile *objfile)
   struct dwarf2_per_objfile *dwarf2_per_objfile
     = get_dwarf2_per_objfile (objfile);
 
-  if (objfile->global_psymbols.capacity () == 0
-      && objfile->static_psymbols.capacity () == 0)
-    init_psymbol_list (objfile, 1024);
+  init_psymbol_list (objfile, 1024);
 
   TRY
     {
index 9f1af742842f2d840b1b8de62e4234db207e049f..9b1e952757c8dd5b25540d71c73ce885610f6053 100644 (file)
@@ -290,7 +290,11 @@ extern void add_psymbol_to_list (const char *, int,
                                 CORE_ADDR,
                                 enum language, struct objfile *);
 
-extern void init_psymbol_list (struct objfile *, int);
+/* Initialize storage for partial symbols.  If partial symbol storage
+   has already been initialized, this does nothing.  TOTAL_SYMBOLS is
+   an estimate of how many symbols there will be.  */
+
+extern void init_psymbol_list (struct objfile *objfile, int total_symbols);
 
 extern struct partial_symtab *start_psymtab_common (struct objfile *,
                                                    const char *, CORE_ADDR);
index ddb8e767bb47b8f3d70dd06ef684812aa6deb0ac..356901f14b75189993c36e456084e76e20641482 100644 (file)
@@ -1662,20 +1662,21 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name,
   append_psymbol_to_list (list, psym, objfile);
 }
 
-/* Initialize storage for partial symbols.  */
+/* See psympriv.h.  */
 
 void
 init_psymbol_list (struct objfile *objfile, int total_symbols)
 {
-  /* Free any previously allocated psymbol lists.  */
-  objfile->global_psymbols.clear ();
-  objfile->static_psymbols.clear ();
-
-  /* Current best guess is that approximately a twentieth
-     of the total symbols (in a debugging file) are global or static
-     oriented symbols, then multiply that by slop factor of two.  */
-  objfile->global_psymbols.reserve (total_symbols / 10);
-  objfile->static_psymbols.reserve (total_symbols / 10);
+  if (objfile->global_psymbols.capacity () == 0
+      && objfile->static_psymbols.capacity () == 0)
+    {
+      /* Current best guess is that approximately a twentieth of the
+        total symbols (in a debugging file) are global or static
+        oriented symbols, then multiply that by slop factor of
+        two.  */
+      objfile->global_psymbols.reserve (total_symbols / 10);
+      objfile->static_psymbols.reserve (total_symbols / 10);
+    }
 }
 
 /* See psympriv.h.  */
index 76c683db0c77253ab4b5c2377028e59addfcc35e..50da0789755289943ac5696dbd45bf0377b0fcbf 100644 (file)
@@ -2991,14 +2991,11 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
   if (val != size)
     perror_with_name (_("reading symbol table"));
 
-  /* If we are reinitializing, or if we have never loaded syms yet, init.  */
-  if (objfile->global_psymbols.capacity () == 0
-      && objfile->static_psymbols.capacity () == 0)
-    /* I'm not sure how how good num_symbols is; the rule of thumb in
-       init_psymbol_list was developed for a.out.  On the one hand,
-       num_symbols includes auxents.  On the other hand, it doesn't
-       include N_SLINE.  */
-    init_psymbol_list (objfile, num_symbols);
+  /* I'm not sure how how good num_symbols is; the rule of thumb in
+     init_psymbol_list was developed for a.out.  On the one hand,
+     num_symbols includes auxents.  On the other hand, it doesn't
+     include N_SLINE.  */
+  init_psymbol_list (objfile, num_symbols);
 
   scoped_free_pendings free_pending;
   minimal_symbol_reader reader (objfile);