summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-05-10 16:23:47 -0600
committerTom Tromey <tom@tromey.com>2019-01-10 07:08:11 -0700
commit6eee24ce30f8e95335c2ad8586f9a64398eb2cd4 (patch)
tree621616df26c1fd059c70b00ebdb83cd397ba8371 /gdb
parent75aedd27e6a2c58734ab44cc7cad8491f19d059a (diff)
downloadbinutils-gdb-6eee24ce30f8e95335c2ad8586f9a64398eb2cd4.tar.gz
Simplify calls to init_psymbol_list
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/dbxread.c4
-rw-r--r--gdb/dwarf2read.c4
-rw-r--r--gdb/psympriv.h6
-rw-r--r--gdb/psymtab.c21
-rw-r--r--gdb/xcoffread.c13
6 files changed, 34 insertions, 25 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e00047c27d5..e0cf7cbfe24 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
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.
* psymtab.c (add_psymbol_to_list): Replace "list" parameter with
"where".
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 73e436f4f62..6149175d732 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -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);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 070a0c21954..9aa33bfec8f 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -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
{
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 9f1af742842..9b1e952757c 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -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);
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index ddb8e767bb4..356901f14b7 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -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. */
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 76c683db0c7..50da0789755 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -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);