From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway20.websitewelcome.com (gateway20.websitewelcome.com [192.185.55.25]) by sourceware.org (Postfix) with ESMTPS id 54CBD388A811 for ; Sun, 28 Feb 2021 20:38:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 54CBD388A811 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 84013400D88BF for ; Sun, 28 Feb 2021 14:29:50 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id GSpTlWcYhA1KVGSpTl0T48; Sun, 28 Feb 2021 14:38:15 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=mjySMqyBNn0hyE3MpHG44VMToTUeoOIyI8IVblIn8eI=; b=tKpjGo1EHpeEyFCdYQGQSrozvk lE9mFrg0C7MAqWS7HamKevEJOmMxgTZkh+AqJqI12N+J6AIKa58epVnXUBzcMDe4gqs87sUfdvVfz Grj6Mqn/MJRGA48drU+jHmKRc; Received: from 97-122-70-152.hlrn.qwest.net ([97.122.70.152]:36736 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lGSpT-000Xpk-KH for gdb-patches@sourceware.org; Sun, 28 Feb 2021 13:38:15 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 21/26] Add partial_symtabs parameter to psymtab construction functions Date: Sun, 28 Feb 2021 13:37:58 -0700 Message-Id: <20210228203803.1693413-22-tom@tromey.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210228203803.1693413-1-tom@tromey.com> References: <20210228203803.1693413-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.70.152 X-Source-L: No X-Exim-ID: 1lGSpT-000Xpk-KH X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-70-152.hlrn.qwest.net (localhost.localdomain) [97.122.70.152]:36736 X-Source-Auth: tom+tromey.com X-Email-Count: 22 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3034.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Feb 2021 20:38:19 -0000 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-02-28 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): Update. --- gdb/ChangeLog | 33 ++++++++++++++++++++++++ gdb/ctfread.c | 26 ++++++++++++------- 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, 204 insertions(+), 106 deletions(-) diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 928cb3025c3..6adfcc12056 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) { } @@ -1311,16 +1315,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; @@ -1383,7 +1389,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; } @@ -1398,7 +1404,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; } @@ -1406,11 +1412,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; @@ -1461,7 +1468,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 (); @@ -1488,7 +1495,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 3a050b351a0..183876bb5b7 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6467,8 +6467,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) { } @@ -6521,10 +6523,13 @@ struct dwarf2_include_psymtab : public partial_symtab 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; @@ -7779,7 +7784,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; @@ -8893,7 +8899,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); } } @@ -22096,8 +22104,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 aba1d83e468..236b3358190 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 aab140d8aba..ee52ba53d92 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -1959,11 +1959,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); @@ -2019,7 +2021,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; @@ -2243,7 +2245,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); } @@ -2426,7 +2428,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; @@ -2585,7 +2587,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': @@ -2597,7 +2600,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': @@ -2615,7 +2619,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. */ @@ -2623,7 +2628,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; } } @@ -2636,7 +2642,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 @@ -2698,7 +2705,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. */ @@ -2717,7 +2725,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': @@ -2737,7 +2746,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 @@ -2768,7 +2778,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.26.2