aboutsummaryrefslogtreecommitdiff
path: root/gdb/mdebugread.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-10-17 12:34:53 -0600
committerTom Tromey <tom@tromey.com>2020-10-17 12:34:53 -0600
commit932539d7a35ccc15316ec8cc0ef0fefcb3c08f4d (patch)
tree0d5429e890098ea06ec1eec96cc2aafd45fe6e33 /gdb/mdebugread.c
parentcfabbd351a174406fd5aa063303f5c8bf9266bbc (diff)
downloadfsf-binutils-gdb-932539d7a35ccc15316ec8cc0ef0fefcb3c08f4d.zip
fsf-binutils-gdb-932539d7a35ccc15316ec8cc0ef0fefcb3c08f4d.tar.gz
fsf-binutils-gdb-932539d7a35ccc15316ec8cc0ef0fefcb3c08f4d.tar.bz2
Have partial symbol tables own psymbol vectors
Currently pointers to all partial symbols are stored in two vectors; and then indices into these vectors are stored in each partial_symtab. This patch changes this so that each partial symtab instead has vectors of symbols. add_psymbol_to_list can now be changed into a method on partial_symtab as well. My main motivation for doing this is that I am looking into calling sort_pst_symbols in the background. However, I haven't actually implemented this yet. (Also this may make it more feasible to also sort the static psymbols, though I haven't tried that either.) Also, though, this lets us remove the "current_global_psymbols" vector, because now the callers can simply refer directly to the psymtab that they are modifying (formerly this was implicit). The main drawback of this patch is that it increases the size of partial symtab. gdb/ChangeLog 2020-10-17 Tom Tromey <tom@tromey.com> * xcoffread.c (xcoff_end_psymtab): Use partial_symtab::empty. (scan_xcoff_symtab): Update. * psymtab.h (class psymtab_storage) <global_psymbols, static_psymbols, current_global_psymbols, current_static_psymbols>: Remove. * psymtab.c (require_partial_symbols, find_pc_sect_psymbol) (match_partial_symbol, lookup_partial_symbol): Update. (print_partial_symbols): Change parameters. (dump_psymtab, recursively_search_psymtabs) (psym_fill_psymbol_map, psym_find_compunit_symtab_by_address) (sort_pst_symbols, partial_symtab::partial_symtab): Update. (concat): Remove. (end_psymtab_common): Simplify. (append_psymbol_to_list): Change parameters. (partial_symtabs::add_psymbol): Rename from add_psymbol_to_list. (init_psymbol_list): Simplify. (maintenance_info_psymtabs, maintenance_check_psymtabs): Update. * psympriv.h (struct partial_symtab) <empty>: New method. <globals_offset, n_global_syms, statics_offset, n_static_syms>: Remove. <global_psymbols, static_psymbols>: New members. <add_psymbol>: New methods. (add_psymbol_to_list): Don't declare. (psymbol_placement): Move earlier. * mdebugread.c (parse_partial_symbols): Update. (handle_psymbol_enumerators): Change parameters. (mdebug_expand_psymtab): Update. * dwarf2/read.c (process_psymtab_comp_unit_reader) (add_partial_symbol): Update. * dwarf2/index-write.c (write_psymbols): Change parameters. (write_one_signatured_type): Update. (recursively_count_psymbols): Update. (recursively_write_psymbols): Update. (class debug_names) <recursively_write_psymbols>: Update. <write_psymbols>: Change parameters. <write_one_signatured_type>: Update. * dbxread.c (read_dbx_symtab): Update. (dbx_end_psymtab): Use partial_symtab::empty. * ctfread.c (struct ctf_context) <pst>: New member. (create_partial_symtab): Set it. (ctf_psymtab_type_cb, ctf_psymtab_var_cb): Update. (scan_partial_symbols): Use the psymtab's context. Update.
Diffstat (limited to 'gdb/mdebugread.c')
-rw-r--r--gdb/mdebugread.c157
1 files changed, 78 insertions, 79 deletions
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 480b67b..1b2e352 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -264,8 +264,8 @@ static int add_line (struct linetable *, int, CORE_ADDR, int);
static struct linetable *shrink_linetable (struct linetable *);
-static void handle_psymbol_enumerators (struct objfile *, FDR *, int,
- CORE_ADDR);
+static void handle_psymbol_enumerators (struct objfile *, partial_symtab *,
+ FDR *, int, CORE_ADDR);
static const char *mdebug_next_symbol_text (struct objfile *);
@@ -3029,25 +3029,25 @@ parse_partial_symbols (minimal_symbol_reader &reader,
switch (p[1])
{
case 'S':
- add_psymbol_to_list (gdb::string_view (namestring,
- p - namestring),
- true, VAR_DOMAIN, LOC_STATIC,
- SECT_OFF_DATA (objfile),
- psymbol_placement::STATIC,
- sh.value,
- psymtab_language, objfile);
+ pst->add_psymbol (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_STATIC,
+ SECT_OFF_DATA (objfile),
+ psymbol_placement::STATIC,
+ sh.value,
+ psymtab_language, objfile);
continue;
case 'G':
/* The addresses in these entries are reported
to be wrong. See the code that reads 'G's
for symtabs. */
- add_psymbol_to_list (gdb::string_view (namestring,
- p - namestring),
- true, VAR_DOMAIN, LOC_STATIC,
- SECT_OFF_DATA (objfile),
- psymbol_placement::GLOBAL,
- sh.value,
- psymtab_language, objfile);
+ pst->add_psymbol (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_STATIC,
+ SECT_OFF_DATA (objfile),
+ psymbol_placement::GLOBAL,
+ sh.value,
+ psymtab_language, objfile);
continue;
case 'T':
@@ -3061,7 +3061,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
|| (p == namestring + 1
&& namestring[0] != ' '))
{
- add_psymbol_to_list
+ pst->add_psymbol
(gdb::string_view (namestring, p - namestring),
true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
psymbol_placement::STATIC, 0, psymtab_language,
@@ -3069,7 +3069,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
if (p[2] == 't')
{
/* Also a typedef with the same name. */
- add_psymbol_to_list
+ pst->add_psymbol
(gdb::string_view (namestring,
p - namestring),
true, VAR_DOMAIN, LOC_TYPEDEF, -1,
@@ -3083,7 +3083,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
if (p != namestring) /* a name is there, not
just :T... */
{
- add_psymbol_to_list
+ pst->add_psymbol
(gdb::string_view (namestring,
p - namestring),
true, VAR_DOMAIN, LOC_TYPEDEF, -1,
@@ -3149,13 +3149,13 @@ parse_partial_symbols (minimal_symbol_reader &reader,
/* Note that the value doesn't matter for
enum constants in psymtabs, just in
symtabs. */
- add_psymbol_to_list (gdb::string_view (p,
- q - p),
- true, VAR_DOMAIN,
- LOC_CONST, -1,
- psymbol_placement::STATIC,
- 0, psymtab_language,
- objfile);
+ pst->add_psymbol (gdb::string_view (p,
+ q - p),
+ true, VAR_DOMAIN,
+ LOC_CONST, -1,
+ psymbol_placement::STATIC,
+ 0, psymtab_language,
+ objfile);
/* Point past the name. */
p = q;
/* Skip over the value. */
@@ -3169,11 +3169,11 @@ parse_partial_symbols (minimal_symbol_reader &reader,
continue;
case 'c':
/* Constant, e.g. from "const" in Pascal. */
- add_psymbol_to_list (gdb::string_view (namestring,
- p - namestring),
- true, VAR_DOMAIN, LOC_CONST, -1,
- psymbol_placement::STATIC,
- 0, psymtab_language, objfile);
+ pst->add_psymbol (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_CONST, -1,
+ psymbol_placement::STATIC,
+ 0, psymtab_language, objfile);
continue;
case 'f':
@@ -3183,13 +3183,13 @@ parse_partial_symbols (minimal_symbol_reader &reader,
function_outside_compilation_unit_complaint
(copy.c_str ());
}
- add_psymbol_to_list (gdb::string_view (namestring,
- p - namestring),
- true, VAR_DOMAIN, LOC_BLOCK,
- SECT_OFF_TEXT (objfile),
- psymbol_placement::STATIC,
- sh.value,
- psymtab_language, objfile);
+ pst->add_psymbol (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_BLOCK,
+ SECT_OFF_TEXT (objfile),
+ psymbol_placement::STATIC,
+ sh.value,
+ psymtab_language, objfile);
continue;
/* Global functions were ignored here, but now they
@@ -3203,13 +3203,13 @@ parse_partial_symbols (minimal_symbol_reader &reader,
function_outside_compilation_unit_complaint
(copy.c_str ());
}
- add_psymbol_to_list (gdb::string_view (namestring,
- p - namestring),
- true, VAR_DOMAIN, LOC_BLOCK,
- SECT_OFF_TEXT (objfile),
- psymbol_placement::GLOBAL,
- sh.value,
- psymtab_language, objfile);
+ pst->add_psymbol (gdb::string_view (namestring,
+ p - namestring),
+ true, VAR_DOMAIN, LOC_BLOCK,
+ SECT_OFF_TEXT (objfile),
+ psymbol_placement::GLOBAL,
+ sh.value,
+ psymtab_language, objfile);
continue;
/* Two things show up here (hopefully); static
@@ -3439,17 +3439,17 @@ parse_partial_symbols (minimal_symbol_reader &reader,
symbol table, and the MAIN__ symbol via the minimal
symbol table. */
if (sh.st == stProc)
- add_psymbol_to_list (sym_name, true,
- VAR_DOMAIN, LOC_BLOCK,
- section,
- psymbol_placement::GLOBAL,
- sh.value, psymtab_language, objfile);
+ pst->add_psymbol (sym_name, true,
+ VAR_DOMAIN, LOC_BLOCK,
+ section,
+ psymbol_placement::GLOBAL,
+ sh.value, psymtab_language, objfile);
else
- add_psymbol_to_list (sym_name, true,
- VAR_DOMAIN, LOC_BLOCK,
- section,
- psymbol_placement::STATIC,
- sh.value, psymtab_language, objfile);
+ pst->add_psymbol (sym_name, true,
+ VAR_DOMAIN, LOC_BLOCK,
+ section,
+ psymbol_placement::STATIC,
+ sh.value, psymtab_language, objfile);
procaddr = sh.value;
@@ -3512,12 +3512,13 @@ parse_partial_symbols (minimal_symbol_reader &reader,
&& sh.iss != 0
&& sh.index != cur_sdx + 2)
{
- add_psymbol_to_list (sym_name, true,
- STRUCT_DOMAIN, LOC_TYPEDEF, -1,
- psymbol_placement::STATIC,
- 0, psymtab_language, objfile);
+ pst->add_psymbol (sym_name, true,
+ STRUCT_DOMAIN, LOC_TYPEDEF, -1,
+ psymbol_placement::STATIC,
+ 0, psymtab_language, objfile);
}
- handle_psymbol_enumerators (objfile, fh, sh.st, sh.value);
+ handle_psymbol_enumerators (objfile, pst, fh,
+ sh.st, sh.value);
/* Skip over the block. */
new_sdx = sh.index;
@@ -3552,10 +3553,10 @@ parse_partial_symbols (minimal_symbol_reader &reader,
continue;
}
/* Use this gdb symbol. */
- add_psymbol_to_list (sym_name, true,
- VAR_DOMAIN, theclass, section,
- psymbol_placement::STATIC,
- sh.value, psymtab_language, objfile);
+ pst->add_psymbol (sym_name, true,
+ VAR_DOMAIN, theclass, section,
+ psymbol_placement::STATIC,
+ sh.value, psymtab_language, objfile);
skip:
cur_sdx++; /* Go to next file symbol. */
}
@@ -3630,11 +3631,11 @@ parse_partial_symbols (minimal_symbol_reader &reader,
break;
}
char *sym_name = debug_info->ssext + psh->iss;
- add_psymbol_to_list (sym_name, true,
- VAR_DOMAIN, theclass,
- section,
- psymbol_placement::GLOBAL,
- svalue, psymtab_language, objfile);
+ pst->add_psymbol (sym_name, true,
+ VAR_DOMAIN, theclass,
+ section,
+ psymbol_placement::GLOBAL,
+ svalue, psymtab_language, objfile);
}
}
@@ -3728,8 +3729,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
partial_symtab *pst_del = objfile->partial_symtabs->psymtabs;
if (pst_del->next == NULL
&& pst_del->number_of_dependencies == 0
- && pst_del->n_global_syms == 0
- && pst_del->n_static_syms == 0)
+ && pst_del->empty ())
objfile->partial_symtabs->discard_psymtab (pst_del);
}
@@ -3737,8 +3737,8 @@ parse_partial_symbols (minimal_symbol_reader &reader,
all the enum constants to the partial symbol table. */
static void
-handle_psymbol_enumerators (struct objfile *objfile, FDR *fh, int stype,
- CORE_ADDR svalue)
+handle_psymbol_enumerators (struct objfile *objfile, partial_symtab *pst,
+ FDR *fh, int stype, CORE_ADDR svalue)
{
const bfd_size_type external_sym_size = debug_swap->external_sym_size;
void (*const swap_sym_in) (bfd *, void *, SYMR *) = debug_swap->swap_sym_in;
@@ -3793,10 +3793,10 @@ handle_psymbol_enumerators (struct objfile *objfile, FDR *fh, int stype,
/* Note that the value doesn't matter for enum constants
in psymtabs, just in symtabs. */
- add_psymbol_to_list (name, true,
- VAR_DOMAIN, LOC_CONST, -1,
- psymbol_placement::STATIC, 0,
- psymtab_language, objfile);
+ pst->add_psymbol (name, true,
+ VAR_DOMAIN, LOC_CONST, -1,
+ psymbol_placement::STATIC, 0,
+ psymtab_language, objfile);
ext_sym += external_sym_size;
}
}
@@ -3853,8 +3853,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
/* Do nothing if this is a dummy psymtab. */
- if (pst->n_global_syms == 0 && pst->n_static_syms == 0
- && !pst->text_low_valid && !pst->text_high_valid)
+ if (pst->empty () && !pst->text_low_valid && !pst->text_high_valid)
return;
/* Now read the symbols for this symtab. */