From 7b249e470a82063605c3789f4b2d0378400423de Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 20 Mar 2021 17:23:40 -0600 Subject: [PATCH] Add partial_symtabs parameter to psymtab construction functions This adds a partial_symtabs parameter to the psymtab constructors and to add_psymbol. This helps with the overall project of removing the partial symtabs from the objfile. gdb/ChangeLog 2021-03-20 Tom Tromey * xcoffread.c (xcoff_start_psymtab): Add partial_symtabs parameter. (xcoff_end_psymtab, scan_xcoff_symtab): Update. * psymtab.c (partial_symtab::partial_symtab): Add partial_symtabs parameter. (add_psymbol_to_bcache): Remove. (partial_symtab::add_psymbol): Add partial_symtabs parameter. (partial_symtab::add_psymbol, partial_symtab::partial_symtab): Likewise. * psympriv.h (partial_symtab): Add partial_symtabs parameter. : Likewise. (standard_psymtab, legacy_psymtab): Likewise. * mdebugread.c (parse_partial_symbols): Update. (handle_psymbol_enumerators): Add partial_symtabs parameter. (handle_psymbol_enumerators): Update. (new_psymtab): Add partial_symtabs parameter. * dwarf2/read.h (dwarf2_psymtab): Add partial_symtabs parameter. * dwarf2/read.c (dwarf2_include_psymtab): Add partial_symtabs parameter. (dwarf2_create_include_psymtab): Add partial_symtabs parameter. (create_partial_symtab, add_partial_symbol, dwarf_decode_lines): Update. * dbxread.c (read_dbx_symtab): Update. (start_psymtab): Add partial_symtabs parameter. (dbx_end_psymtab): Update. * ctfread.c (struct ctf_context) : New member. (ctf_psymtab): Add partial_symtabs parameter. (create_partial_symtab, ctf_psymtab_type_cb, ctf_psymtab_var_cb): Update. (scan_partial_symbols): Add partial_symtabs parameter. (scan_partial_symbols, elfctf_build_psymtabs) (ctf_psymtab_add_enums): Update. --- gdb/ChangeLog | 34 +++++++++++++++++++++++++ gdb/ctfread.c | 28 ++++++++++++-------- gdb/dbxread.c | 42 ++++++++++++++++++------------ gdb/dwarf2/read.c | 26 +++++++++++++------ gdb/dwarf2/read.h | 6 +++-- gdb/mdebugread.c | 65 ++++++++++++++++++++++++++++++----------------- gdb/psympriv.h | 34 +++++++++++++++++-------- gdb/psymtab.c | 39 ++++++++++++---------------- gdb/xcoffread.c | 39 ++++++++++++++++++---------- 9 files changed, 206 insertions(+), 107 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f647ac48739..bc746a1616a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,37 @@ +2021-03-20 Tom Tromey + + * xcoffread.c (xcoff_start_psymtab): Add partial_symtabs parameter. + (xcoff_end_psymtab, scan_xcoff_symtab): Update. + * psymtab.c (partial_symtab::partial_symtab): Add partial_symtabs + parameter. + (add_psymbol_to_bcache): Remove. + (partial_symtab::add_psymbol): Add partial_symtabs parameter. + (partial_symtab::add_psymbol, partial_symtab::partial_symtab): + Likewise. + * psympriv.h (partial_symtab): Add partial_symtabs parameter. + : Likewise. + (standard_psymtab, legacy_psymtab): Likewise. + * mdebugread.c (parse_partial_symbols): Update. + (handle_psymbol_enumerators): Add partial_symtabs parameter. + (handle_psymbol_enumerators): Update. + (new_psymtab): Add partial_symtabs parameter. + * dwarf2/read.h (dwarf2_psymtab): Add partial_symtabs parameter. + * dwarf2/read.c (dwarf2_include_psymtab): Add partial_symtabs + parameter. + (dwarf2_create_include_psymtab): Add partial_symtabs parameter. + (create_partial_symtab, add_partial_symbol, dwarf_decode_lines): + Update. + * dbxread.c (read_dbx_symtab): Update. + (start_psymtab): Add partial_symtabs parameter. + (dbx_end_psymtab): Update. + * ctfread.c (struct ctf_context) : New member. + (ctf_psymtab): Add partial_symtabs parameter. + (create_partial_symtab, ctf_psymtab_type_cb, ctf_psymtab_var_cb): + Update. + (scan_partial_symbols): Add partial_symtabs parameter. + (scan_partial_symbols, elfctf_build_psymtabs) + (ctf_psymtab_add_enums): Update. + 2021-03-20 Tom Tromey * symfile.c (read_symbols): Use objfile method. diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 4ff475fe22d..7713500c1fe 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -115,6 +115,7 @@ struct ctf_context { ctf_dict_t *fp; struct objfile *of; + psymtab_storage *partial_symtabs; partial_symtab *pst; struct buildsym_compunit *builder; }; @@ -122,8 +123,11 @@ struct ctf_context /* A partial symtab, specialized for this module. */ struct ctf_psymtab : public standard_psymtab { - ctf_psymtab (const char *filename, struct objfile *objfile, CORE_ADDR addr) - : standard_psymtab (filename, objfile, addr) + ctf_psymtab (const char *filename, + psymtab_storage *partial_symtabs, + struct objfile *objfile, + CORE_ADDR addr) + : standard_psymtab (filename, partial_symtabs, objfile, addr) { } @@ -1259,7 +1263,7 @@ ctf_psymtab_add_enums (struct ctf_context *ccp, ctf_id_t tid) ccp->pst->add_psymbol (ename, true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::GLOBAL, - 0, language_c, ccp->of); + 0, language_c, ccp->partial_symtabs, ccp->of); } if (ctf_errno (ccp->fp) != ECTF_NEXT_END) complaint (_("ctf_enum_next ctf_psymtab_add_enums failed - %s"), @@ -1359,16 +1363,18 @@ ctf_psymtab::read_symtab (struct objfile *objfile) static ctf_psymtab * create_partial_symtab (const char *name, ctf_dict_t *cfp, + psymtab_storage *partial_symtabs, struct objfile *objfile) { ctf_psymtab *pst; struct ctf_context *ccx; - pst = new ctf_psymtab (name, objfile, 0); + pst = new ctf_psymtab (name, partial_symtabs, objfile, 0); ccx = XOBNEW (&objfile->objfile_obstack, struct ctf_context); ccx->fp = cfp; ccx->of = objfile; + ccx->partial_symtabs = partial_symtabs; ccx->pst = pst; ccx->builder = nullptr; pst->context = ccx; @@ -1434,7 +1440,7 @@ ctf_psymtab_type_cb (ctf_id_t tid, void *arg) ccp->pst->add_psymbol (name.get (), true, domain, aclass, section, psymbol_placement::GLOBAL, - 0, language_c, ccp->of); + 0, language_c, ccp->partial_symtabs, ccp->of); return 0; } @@ -1449,7 +1455,7 @@ ctf_psymtab_var_cb (const char *name, ctf_id_t id, void *arg) ccp->pst->add_psymbol (name, true, VAR_DOMAIN, LOC_STATIC, -1, psymbol_placement::GLOBAL, - 0, language_c, ccp->of); + 0, language_c, ccp->partial_symtabs, ccp->of); return 0; } @@ -1457,11 +1463,12 @@ ctf_psymtab_var_cb (const char *name, ctf_id_t id, void *arg) debugging information is available. */ static void -scan_partial_symbols (ctf_dict_t *cfp, struct objfile *of) +scan_partial_symbols (ctf_dict_t *cfp, psymtab_storage *partial_symtabs, + struct objfile *of) { bfd *abfd = of->obfd; const char *name = bfd_get_filename (abfd); - ctf_psymtab *pst = create_partial_symtab (name, cfp, of); + ctf_psymtab *pst = create_partial_symtab (name, cfp, partial_symtabs, of); struct ctf_context *ccx = pst->context; @@ -1512,7 +1519,7 @@ scan_partial_symbols (ctf_dict_t *cfp, struct objfile *of) pst->add_psymbol (tname.get (), true, tdomain, aclass, -1, psymbol_placement::STATIC, - 0, language_c, of); + 0, language_c, partial_symtabs, of); } pst->end (); @@ -1539,7 +1546,8 @@ elfctf_build_psymtabs (struct objfile *of) bfd_get_filename (abfd), ctf_errmsg (err)); ctf_dict_key.emplace (of, fp); - scan_partial_symbols (fp, of); + psymtab_storage *partial_symtabs = of->partial_symtabs.get (); + scan_partial_symbols (fp, partial_symtabs, of); } #else diff --git a/gdb/dbxread.c b/gdb/dbxread.c index e0cc2597f73..a6f44d5a564 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -298,8 +298,8 @@ static void add_old_header_file (const char *, int); static void add_this_object_header_file (int); -static legacy_psymtab *start_psymtab (struct objfile *, const char *, - CORE_ADDR, int); +static legacy_psymtab *start_psymtab (psymtab_storage *, struct objfile *, + const char *, CORE_ADDR, int); /* Free up old header file tables. */ @@ -1291,7 +1291,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, if (!pst) { - pst = start_psymtab (objfile, + pst = start_psymtab (partial_symtabs, objfile, namestring, valu, first_so_symnum * symbol_size); pst->dirname = dirname_nso; @@ -1467,7 +1467,8 @@ read_dbx_symtab (minimal_symbol_reader &reader, VAR_DOMAIN, LOC_STATIC, data_sect_index, psymbol_placement::STATIC, - nlist.n_value, psymtab_language, objfile); + nlist.n_value, psymtab_language, + partial_symtabs, objfile); continue; case 'G': @@ -1477,7 +1478,8 @@ read_dbx_symtab (minimal_symbol_reader &reader, VAR_DOMAIN, LOC_STATIC, data_sect_index, psymbol_placement::GLOBAL, - nlist.n_value, psymtab_language, objfile); + nlist.n_value, psymtab_language, + partial_symtabs, objfile); continue; case 'T': @@ -1494,14 +1496,16 @@ read_dbx_symtab (minimal_symbol_reader &reader, pst->add_psymbol (gdb::string_view (sym_name, sym_len), true, STRUCT_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, - 0, psymtab_language, objfile); + 0, psymtab_language, + partial_symtabs, objfile); if (p[2] == 't') { /* Also a typedef with the same name. */ pst->add_psymbol (gdb::string_view (sym_name, sym_len), true, VAR_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, - 0, psymtab_language, objfile); + 0, psymtab_language, + partial_symtabs, objfile); p += 1; } } @@ -1513,7 +1517,8 @@ read_dbx_symtab (minimal_symbol_reader &reader, pst->add_psymbol (gdb::string_view (sym_name, sym_len), true, VAR_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, - 0, psymtab_language, objfile); + 0, psymtab_language, + partial_symtabs, objfile); } check_enum: /* If this is an enumerated type, we need to @@ -1574,7 +1579,8 @@ read_dbx_symtab (minimal_symbol_reader &reader, pst->add_psymbol (gdb::string_view (p, q - p), true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::STATIC, 0, - psymtab_language, objfile); + psymtab_language, + partial_symtabs, objfile); /* Point past the name. */ p = q; /* Skip over the value. */ @@ -1592,7 +1598,8 @@ read_dbx_symtab (minimal_symbol_reader &reader, pst->add_psymbol (gdb::string_view (sym_name, sym_len), true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::STATIC, 0, - psymtab_language, objfile); + psymtab_language, + partial_symtabs, objfile); continue; case 'f': @@ -1648,7 +1655,8 @@ read_dbx_symtab (minimal_symbol_reader &reader, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), psymbol_placement::STATIC, - nlist.n_value, psymtab_language, objfile); + nlist.n_value, psymtab_language, + partial_symtabs, objfile); continue; /* Global functions were ignored here, but now they @@ -1707,7 +1715,8 @@ read_dbx_symtab (minimal_symbol_reader &reader, VAR_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), psymbol_placement::GLOBAL, - nlist.n_value, psymtab_language, objfile); + nlist.n_value, psymtab_language, + partial_symtabs, objfile); continue; /* Two things show up here (hopefully); static symbols of @@ -1902,10 +1911,11 @@ read_dbx_symtab (minimal_symbol_reader &reader, (normal). */ static legacy_psymtab * -start_psymtab (struct objfile *objfile, const char *filename, CORE_ADDR textlow, - int ldsymoff) +start_psymtab (psymtab_storage *partial_symtabs, struct objfile *objfile, + const char *filename, CORE_ADDR textlow, int ldsymoff) { - legacy_psymtab *result = new legacy_psymtab (filename, objfile, textlow); + legacy_psymtab *result = new legacy_psymtab (filename, partial_symtabs, + objfile, textlow); result->read_symtab_private = XOBNEW (&objfile->objfile_obstack, struct symloc); @@ -2028,7 +2038,7 @@ dbx_end_psymtab (struct objfile *objfile, psymtab_storage *partial_symtabs, for (i = 0; i < num_includes; i++) { legacy_psymtab *subpst = - new legacy_psymtab (include_list[i], objfile); + new legacy_psymtab (include_list[i], partial_symtabs, objfile); subpst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, struct symloc); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index c4acf292542..42713983707 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6237,8 +6237,10 @@ read_abbrev_offset (dwarf2_per_objfile *per_objfile, /* A partial symtab that is used only for include files. */ struct dwarf2_include_psymtab : public partial_symtab { - dwarf2_include_psymtab (const char *filename, struct objfile *objfile) - : partial_symtab (filename, objfile) + dwarf2_include_psymtab (const char *filename, + psymtab_storage *partial_symtabs, + struct objfile *objfile) + : partial_symtab (filename, partial_symtabs, objfile) { } @@ -6291,10 +6293,13 @@ private: static void dwarf2_create_include_psymtab (dwarf2_per_bfd *per_bfd, - const char *name, dwarf2_psymtab *pst, + const char *name, + dwarf2_psymtab *pst, + psymtab_storage *partial_symtabs, struct objfile *objfile) { - dwarf2_include_psymtab *subpst = new dwarf2_include_psymtab (name, objfile); + dwarf2_include_psymtab *subpst + = new dwarf2_include_psymtab (name, partial_symtabs, objfile); if (!IS_ABSOLUTE_PATH (subpst->filename)) subpst->dirname = pst->dirname; @@ -7549,7 +7554,8 @@ create_partial_symtab (dwarf2_per_cu_data *per_cu, struct objfile *objfile = per_objfile->objfile; dwarf2_psymtab *pst; - pst = new dwarf2_psymtab (name, objfile, per_cu); + pst = new dwarf2_psymtab (name, per_objfile->per_bfd->partial_symtabs.get (), + objfile, per_cu); pst->psymtabs_addrmap_supported = true; @@ -8663,7 +8669,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) &objfile->objfile_obstack); psymbol.ginfo.set_linkage_name (pdi->linkage_name); } - cu->per_cu->v.psymtab->add_psymbol (psymbol, *where, objfile); + cu->per_cu->v.psymtab->add_psymbol + (psymbol, *where, per_objfile->per_bfd->partial_symtabs.get (), + objfile); } } @@ -21972,8 +21980,10 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir, psymtab_include_file_name (lh, file_entry, pst, comp_dir, &name_holder); if (include_name != NULL) - dwarf2_create_include_psymtab (cu->per_objfile->per_bfd, - include_name, pst, objfile); + dwarf2_create_include_psymtab + (cu->per_objfile->per_bfd, include_name, pst, + cu->per_objfile->per_bfd->partial_symtabs.get (), + objfile); } } else diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 6cfbee95f8f..82ab3879a5b 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -406,9 +406,11 @@ dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile); /* A partial symtab specialized for DWARF. */ struct dwarf2_psymtab : public partial_symtab { - dwarf2_psymtab (const char *filename, struct objfile *objfile, + dwarf2_psymtab (const char *filename, + psymtab_storage *partial_symtabs, + struct objfile *objfile, dwarf2_per_cu_data *per_cu) - : partial_symtab (filename, objfile, 0), + : partial_symtab (filename, partial_symtabs, objfile, 0), per_cu_data (per_cu) { } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index d178beef734..34ee718e22a 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -252,7 +252,8 @@ static struct symbol *mylookup_symbol (const char *, const struct block *, static void sort_blocks (struct symtab *); -static legacy_psymtab *new_psymtab (const char *, struct objfile *); +static legacy_psymtab *new_psymtab (const char *, psymtab_storage *, + struct objfile *); static void mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile); @@ -265,7 +266,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 *, partial_symtab *, +static void handle_psymbol_enumerators (struct objfile *, psymtab_storage *, + partial_symtab *, FDR *, int, CORE_ADDR); static const char *mdebug_next_symbol_text (struct objfile *); @@ -2365,7 +2367,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, fdr_to_pst = fdr_to_pst_holder.data (); fdr_to_pst++; { - legacy_psymtab *new_pst = new_psymtab ("", objfile); + legacy_psymtab *new_pst = new_psymtab ("", partial_symtabs, objfile); fdr_to_pst[-1].pst = new_pst; FDR_IDX (new_pst) = -1; @@ -2601,7 +2603,8 @@ parse_partial_symbols (minimal_symbol_reader &reader, textlow = fh->adr; else textlow = 0; - pst = new legacy_psymtab (fdr_name (fh), objfile, textlow); + pst = new legacy_psymtab (fdr_name (fh), partial_symtabs, objfile, + textlow); pst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, symloc); memset (pst->read_symtab_private, 0, sizeof (struct symloc)); @@ -3038,7 +3041,8 @@ parse_partial_symbols (minimal_symbol_reader &reader, SECT_OFF_DATA (objfile), psymbol_placement::STATIC, sh.value, - psymtab_language, objfile); + psymtab_language, + partial_symtabs, objfile); continue; case 'G': /* The addresses in these entries are reported @@ -3050,7 +3054,8 @@ parse_partial_symbols (minimal_symbol_reader &reader, SECT_OFF_DATA (objfile), psymbol_placement::GLOBAL, sh.value, - psymtab_language, objfile); + psymtab_language, + partial_symtabs, objfile); continue; case 'T': @@ -3068,7 +3073,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, (gdb::string_view (namestring, p - namestring), true, STRUCT_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, 0, psymtab_language, - objfile); + partial_symtabs, objfile); if (p[2] == 't') { /* Also a typedef with the same name. */ @@ -3077,7 +3082,8 @@ parse_partial_symbols (minimal_symbol_reader &reader, p - namestring), true, VAR_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, 0, - psymtab_language, objfile); + psymtab_language, + partial_symtabs, objfile); p += 1; } } @@ -3091,7 +3097,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, p - namestring), true, VAR_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, 0, psymtab_language, - objfile); + partial_symtabs, objfile); } check_enum: /* If this is an enumerated type, we need to add @@ -3158,7 +3164,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, LOC_CONST, -1, psymbol_placement::STATIC, 0, psymtab_language, - objfile); + partial_symtabs, objfile); /* Point past the name. */ p = q; /* Skip over the value. */ @@ -3176,7 +3182,8 @@ parse_partial_symbols (minimal_symbol_reader &reader, p - namestring), true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::STATIC, - 0, psymtab_language, objfile); + 0, psymtab_language, + partial_symtabs, objfile); continue; case 'f': @@ -3192,7 +3199,8 @@ parse_partial_symbols (minimal_symbol_reader &reader, SECT_OFF_TEXT (objfile), psymbol_placement::STATIC, sh.value, - psymtab_language, objfile); + psymtab_language, + partial_symtabs, objfile); continue; /* Global functions were ignored here, but now they @@ -3212,7 +3220,8 @@ parse_partial_symbols (minimal_symbol_reader &reader, SECT_OFF_TEXT (objfile), psymbol_placement::GLOBAL, sh.value, - psymtab_language, objfile); + psymtab_language, + partial_symtabs, objfile); continue; /* Two things show up here (hopefully); static @@ -3446,13 +3455,15 @@ parse_partial_symbols (minimal_symbol_reader &reader, VAR_DOMAIN, LOC_BLOCK, section, psymbol_placement::GLOBAL, - sh.value, psymtab_language, objfile); + sh.value, psymtab_language, + partial_symtabs, objfile); else pst->add_psymbol (sym_name, true, VAR_DOMAIN, LOC_BLOCK, section, psymbol_placement::STATIC, - sh.value, psymtab_language, objfile); + sh.value, psymtab_language, + partial_symtabs, objfile); procaddr = sh.value; @@ -3518,10 +3529,11 @@ parse_partial_symbols (minimal_symbol_reader &reader, pst->add_psymbol (sym_name, true, STRUCT_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, - 0, psymtab_language, objfile); + 0, psymtab_language, + partial_symtabs, objfile); } - handle_psymbol_enumerators (objfile, pst, fh, - sh.st, sh.value); + handle_psymbol_enumerators (objfile, partial_symtabs, + pst, fh, sh.st, sh.value); /* Skip over the block. */ new_sdx = sh.index; @@ -3559,7 +3571,8 @@ parse_partial_symbols (minimal_symbol_reader &reader, pst->add_psymbol (sym_name, true, VAR_DOMAIN, theclass, section, psymbol_placement::STATIC, - sh.value, psymtab_language, objfile); + sh.value, psymtab_language, + partial_symtabs, objfile); skip: cur_sdx++; /* Go to next file symbol. */ } @@ -3638,7 +3651,8 @@ parse_partial_symbols (minimal_symbol_reader &reader, VAR_DOMAIN, theclass, section, psymbol_placement::GLOBAL, - svalue, psymtab_language, objfile); + svalue, psymtab_language, + partial_symtabs, objfile); } } @@ -3740,7 +3754,9 @@ parse_partial_symbols (minimal_symbol_reader &reader, all the enum constants to the partial symbol table. */ static void -handle_psymbol_enumerators (struct objfile *objfile, partial_symtab *pst, +handle_psymbol_enumerators (struct objfile *objfile, + psymtab_storage *partial_symtabs, + partial_symtab *pst, FDR *fh, int stype, CORE_ADDR svalue) { const bfd_size_type external_sym_size = debug_swap->external_sym_size; @@ -3799,7 +3815,7 @@ handle_psymbol_enumerators (struct objfile *objfile, partial_symtab *pst, pst->add_psymbol (name, true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::STATIC, 0, - psymtab_language, objfile); + psymtab_language, partial_symtabs, objfile); ext_sym += external_sym_size; } } @@ -4623,11 +4639,12 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile) /* Allocate a new partial_symtab NAME. */ static legacy_psymtab * -new_psymtab (const char *name, struct objfile *objfile) +new_psymtab (const char *name, psymtab_storage *partial_symtabs, + struct objfile *objfile) { legacy_psymtab *psymtab; - psymtab = new legacy_psymtab (name, objfile); + psymtab = new legacy_psymtab (name, partial_symtabs, objfile); /* Keep a backpointer to the file's symbols. */ diff --git a/gdb/psympriv.h b/gdb/psympriv.h index b1b8027ce3a..8717bd259e1 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -117,14 +117,18 @@ struct partial_symtab partial symtab will also be installed using psymtab_storage::install. */ - partial_symtab (const char *filename, struct objfile *objfile) + partial_symtab (const char *filename, + psymtab_storage *partial_symtabs, + struct objfile *objfile) ATTRIBUTE_NONNULL (2) ATTRIBUTE_NONNULL (3); /* Like the above, but also sets the initial text low and text high from the ADDR argument, and sets the global- and static-offsets. */ - partial_symtab (const char *filename, struct objfile *objfile, + partial_symtab (const char *filename, + psymtab_storage *partial_symtabs, + struct objfile *objfile, CORE_ADDR addr) ATTRIBUTE_NONNULL (2) ATTRIBUTE_NONNULL (3); @@ -236,6 +240,7 @@ struct partial_symtab psymbol_placement where, CORE_ADDR coreaddr, enum language language, + psymtab_storage *partial_symtabs, struct objfile *objfile); /* Add a symbol to this partial symbol table of OBJFILE. The psymbol @@ -244,6 +249,7 @@ struct partial_symtab void add_psymbol (const partial_symbol &psym, psymbol_placement where, + psymtab_storage *partial_symtabs, struct objfile *objfile); @@ -361,14 +367,18 @@ struct partial_symtab object. */ struct standard_psymtab : public partial_symtab { - standard_psymtab (const char *filename, struct objfile *objfile) - : partial_symtab (filename, objfile) + standard_psymtab (const char *filename, + psymtab_storage *partial_symtabs, + struct objfile *objfile) + : partial_symtab (filename, partial_symtabs, objfile) { } - standard_psymtab (const char *filename, struct objfile *objfile, + standard_psymtab (const char *filename, + psymtab_storage *partial_symtabs, + struct objfile *objfile, CORE_ADDR addr) - : partial_symtab (filename, objfile, addr) + : partial_symtab (filename, partial_symtabs, objfile, addr) { } @@ -399,14 +409,18 @@ struct standard_psymtab : public partial_symtab struct legacy_psymtab : public standard_psymtab { - legacy_psymtab (const char *filename, struct objfile *objfile) - : standard_psymtab (filename, objfile) + legacy_psymtab (const char *filename, + psymtab_storage *partial_symtabs, + struct objfile *objfile) + : standard_psymtab (filename, partial_symtabs, objfile) { } - legacy_psymtab (const char *filename, struct objfile *objfile, + legacy_psymtab (const char *filename, + psymtab_storage *partial_symtabs, + struct objfile *objfile, CORE_ADDR addr) - : standard_psymtab (filename, objfile, addr) + : standard_psymtab (filename, partial_symtabs, objfile, addr) { } diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 302ef9a192f..e662ba16cd6 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1447,9 +1447,10 @@ make_psymbol_functions (const std::shared_ptr &storage) the end of the symbol list. */ partial_symtab::partial_symtab (const char *filename, + psymtab_storage *partial_symtabs, struct objfile *objfile, CORE_ADDR textlow) - : partial_symtab (filename, objfile) + : partial_symtab (filename, partial_symtabs, objfile) { set_text_low (textlow); set_text_high (raw_text_low ()); /* default */ @@ -1514,33 +1515,21 @@ psymbol_bcache::compare (const void *addr1, const void *addr2, int length) && sym1->ginfo.linkage_name () == sym2->ginfo.linkage_name ()); } -/* Helper function, initialises partial symbol structure and stashes - it into objfile's bcache. Note that our caching mechanism will - use all fields of struct partial_symbol to determine hash value of the - structure. In other words, having two symbols with the same name but - different domain (or address) is possible and correct. */ - -static struct partial_symbol * -add_psymbol_to_bcache (const partial_symbol &psymbol, struct objfile *objfile, - bool *added) -{ - /* Stash the partial symbol away in the cache. */ - return ((struct partial_symbol *) - objfile->partial_symtabs->psymbol_cache.insert - (&psymbol, sizeof (struct partial_symbol), added)); -} - /* See psympriv.h. */ void partial_symtab::add_psymbol (const partial_symbol &psymbol, psymbol_placement where, + psymtab_storage *partial_symtabs, struct objfile *objfile) { bool added; /* Stash the partial symbol away in the cache. */ - partial_symbol *psym = add_psymbol_to_bcache (psymbol, objfile, &added); + partial_symbol *psym + = ((struct partial_symbol *) + partial_symtabs->psymbol_cache.insert + (&psymbol, sizeof (struct partial_symbol), &added)); /* Do not duplicate global partial symbols. */ if (where == psymbol_placement::GLOBAL && !added) @@ -1563,7 +1552,9 @@ partial_symtab::add_psymbol (gdb::string_view name, bool copy_name, short section, psymbol_placement where, CORE_ADDR coreaddr, - enum language language, struct objfile *objfile) + enum language language, + psymtab_storage *partial_symtabs, + struct objfile *objfile) { struct partial_symbol psymbol; memset (&psymbol, 0, sizeof (psymbol)); @@ -1572,20 +1563,22 @@ partial_symtab::add_psymbol (gdb::string_view name, bool copy_name, psymbol.ginfo.set_section_index (section); psymbol.domain = domain; psymbol.aclass = theclass; - psymbol.ginfo.set_language (language, objfile->partial_symtabs->obstack ()); + psymbol.ginfo.set_language (language, partial_symtabs->obstack ()); psymbol.ginfo.compute_and_set_names (name, copy_name, objfile->per_bfd); - add_psymbol (psymbol, where, objfile); + add_psymbol (psymbol, where, partial_symtabs, objfile); } /* See psympriv.h. */ -partial_symtab::partial_symtab (const char *filename_, struct objfile *objfile) +partial_symtab::partial_symtab (const char *filename_, + psymtab_storage *partial_symtabs, + struct objfile *objfile) : searched_flag (PST_NOT_SEARCHED), text_low_valid (0), text_high_valid (0) { - objfile->partial_symtabs->install_psymtab (this); + partial_symtabs->install_psymtab (this); filename = objfile->intern (filename_); diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 7f2fee3a29c..f8d428127da 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -1960,11 +1960,13 @@ static unsigned int first_fun_line_offset; (normal). */ static legacy_psymtab * -xcoff_start_psymtab (struct objfile *objfile, +xcoff_start_psymtab (psymtab_storage *partial_symtabs, + struct objfile *objfile, const char *filename, int first_symnum) { /* We fill in textlow later. */ - legacy_psymtab *result = new legacy_psymtab (filename, objfile, 0); + legacy_psymtab *result = new legacy_psymtab (filename, partial_symtabs, + objfile, 0); result->read_symtab_private = XOBNEW (&objfile->objfile_obstack, struct symloc); @@ -2020,7 +2022,7 @@ xcoff_end_psymtab (struct objfile *objfile, psymtab_storage *partial_symtabs, for (i = 0; i < num_includes; i++) { legacy_psymtab *subpst = - new legacy_psymtab (include_list[i], objfile); + new legacy_psymtab (include_list[i], partial_symtabs, objfile); subpst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, symloc); ((struct symloc *) subpst->read_symtab_private)->first_symnum = 0; @@ -2244,7 +2246,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, /* Give all psymtabs for this source file the same name. */ pst = xcoff_start_psymtab - (objfile, + (partial_symtabs, objfile, filestring, symnum_before); } @@ -2427,7 +2429,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, else filestring = namestring; - pst = xcoff_start_psymtab (objfile, + pst = xcoff_start_psymtab (partial_symtabs, objfile, filestring, symnum_before); last_csect_name = NULL; @@ -2586,7 +2588,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, SECT_OFF_DATA (objfile), psymbol_placement::STATIC, symbol.n_value, - psymtab_language, objfile); + psymtab_language, + partial_symtabs, objfile); continue; case 'G': @@ -2598,7 +2601,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, SECT_OFF_DATA (objfile), psymbol_placement::GLOBAL, symbol.n_value, - psymtab_language, objfile); + psymtab_language, + partial_symtabs, objfile); continue; case 'T': @@ -2616,7 +2620,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, p - namestring), true, STRUCT_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, - 0, psymtab_language, objfile); + 0, psymtab_language, + partial_symtabs, objfile); if (p[2] == 't') { /* Also a typedef with the same name. */ @@ -2624,7 +2629,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, p - namestring), true, VAR_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, - 0, psymtab_language, objfile); + 0, psymtab_language, + partial_symtabs, objfile); p += 1; } } @@ -2637,7 +2643,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, p - namestring), true, VAR_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, - 0, psymtab_language, objfile); + 0, psymtab_language, + partial_symtabs, objfile); } check_enum: /* If this is an enumerated type, we need to @@ -2699,7 +2706,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, pst->add_psymbol (gdb::string_view (p, q - p), true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::STATIC, - 0, psymtab_language, objfile); + 0, psymtab_language, + partial_symtabs, objfile); /* Point past the name. */ p = q; /* Skip over the value. */ @@ -2718,7 +2726,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, p - namestring), true, VAR_DOMAIN, LOC_CONST, -1, psymbol_placement::STATIC, - 0, psymtab_language, objfile); + 0, psymtab_language, + partial_symtabs, objfile); continue; case 'f': @@ -2738,7 +2747,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, SECT_OFF_TEXT (objfile), psymbol_placement::STATIC, symbol.n_value, - psymtab_language, objfile); + psymtab_language, + partial_symtabs, objfile); continue; /* Global functions were ignored here, but now they @@ -2769,7 +2779,8 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, SECT_OFF_TEXT (objfile), psymbol_placement::GLOBAL, symbol.n_value, - psymtab_language, objfile); + psymtab_language, + partial_symtabs, objfile); continue; /* Two things show up here (hopefully); static symbols of -- 2.30.2