From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway22.websitewelcome.com (gateway22.websitewelcome.com [192.185.47.168]) by sourceware.org (Postfix) with ESMTPS id A79323842400 for ; Sun, 28 Feb 2021 20:38:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A79323842400 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 cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 465608DE4 for ; Sun, 28 Feb 2021 14:38:16 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id GSpUlhRQFiQiZGSpUluePp; Sun, 28 Feb 2021 14:38:16 -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=N38V+zBXNJX670gsUVHklTakXfXt6knMJYtJfc3MzVQ=; b=ofw62dxnUorVcJRrc+ALKU9sMr OIJLzGePMxTQF5hojNUuAyQdy7CFvCpopJIcz7LBHvPobUc9MT16MLaxrSkXGc2NhSVwL9SQeCSBs jh0GKeyquezlMmhAg49Asb2+1; 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-T6 for gdb-patches@sourceware.org; Sun, 28 Feb 2021 13:38:16 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 22/26] Remove last objfile partial_symtab references from psymtab.c Date: Sun, 28 Feb 2021 13:37:59 -0700 Message-Id: <20210228203803.1693413-23-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-T6 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: 23 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3034.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, 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 removes the last references to the partial_symtab via the objfile from psymtab.c. require_partial_symbols is now a method on psymbol_functions, and maintenance_print_psymbols is changed to use dynamic_cast to verify that it is examining partial symbols. gdb/ChangeLog 2021-02-28 Tom Tromey * psymtab.c (psymbol_functions::require_partial_symbols): Rename. (psymbol_functions::find_pc_sect_psymtab): Rename. (psymbol_functions::find_pc_sect_compunit_symtab) (maintenance_print_psymbols, maintenance_check_psymtabs): Update. * psympriv.h (struct psymbol_functions) : Declare new method. : Likewise. --- gdb/ChangeLog | 10 +++ gdb/psympriv.h | 23 ++++++ gdb/psymtab.c | 210 ++++++++++++++++++++++++++----------------------- 3 files changed, 143 insertions(+), 100 deletions(-) diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 8717bd259e1..85651f522d2 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -559,6 +559,18 @@ struct psymbol_functions : public quick_symbol_functions m_psymbol_map.clear (); } + /* Ensure the partial symbols for OBJFILE have been loaded. Return + a range adapter for the psymtabs. */ + psymtab_storage::partial_symtab_range require_partial_symbols + (struct objfile *objfile); + + /* Return the partial symbol storage associated with this + object. */ + const std::shared_ptr &get_partial_symtabs () const + { + return m_partial_symtabs; + } + /* Replace the partial symbol table storage in this object with SYMS. */ void set_partial_symtabs (const std::shared_ptr &syms) @@ -566,6 +578,17 @@ struct psymbol_functions : public quick_symbol_functions m_partial_symtabs = syms; } + /* Find which partial symtab contains PC and SECTION. Return NULL if + none. We return the psymtab that contains a symbol whose address + exactly matches PC, or, if we cannot find an exact match, the + psymtab that contains a symbol whose address is closest to PC. */ + + struct partial_symtab *find_pc_sect_psymtab + (struct objfile *objfile, + CORE_ADDR pc, + struct obj_section *section, + struct bound_minimal_symbol msymbol); + private: void fill_psymbol_map (struct objfile *objfile, diff --git a/gdb/psymtab.c b/gdb/psymtab.c index e662ba16cd6..b2f929912ea 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -80,11 +80,11 @@ psymtab_storage::install_psymtab (partial_symtab *pst) returns a range adapter suitable for iterating over the psymtabs of OBJFILE. */ -static psymtab_storage::partial_symtab_range -require_partial_symbols (struct objfile *objfile) +psymtab_storage::partial_symtab_range +psymbol_functions::require_partial_symbols (struct objfile *objfile) { objfile->require_partial_symbols (true); - return objfile->psymtabs (); + return m_partial_symtabs->range (); } /* Helper function for psym_map_symtabs_matching_filename that @@ -255,17 +255,13 @@ find_pc_sect_psymtab_closer (struct objfile *objfile, return best_pst; } -/* Find which partial symtab contains PC and SECTION. Return NULL if - none. We return the psymtab that contains a symbol whose address - exactly matches PC, or, if we cannot find an exact match, the - psymtab that contains a symbol whose address is closest to PC. */ +/* See psympriv.h. */ -static struct partial_symtab * -find_pc_sect_psymtab (struct objfile *objfile, - psymtab_storage *partial_symtabs, - CORE_ADDR pc, - struct obj_section *section, - struct bound_minimal_symbol msymbol) +struct partial_symtab * +psymbol_functions::find_pc_sect_psymtab (struct objfile *objfile, + CORE_ADDR pc, + struct obj_section *section, + struct bound_minimal_symbol msymbol) { /* Try just the PSYMTABS_ADDRMAP mapping first as it has better granularity than the later used TEXTLOW/TEXTHIGH one. However, we need @@ -279,14 +275,14 @@ find_pc_sect_psymtab (struct objfile *objfile, partial symtabs then we will end up returning a pointer to an object that is not a partial_symtab, which doesn't end well. */ - if (partial_symtabs->psymtabs != NULL - && partial_symtabs->psymtabs_addrmap != NULL) + if (m_partial_symtabs->psymtabs != NULL + && m_partial_symtabs->psymtabs_addrmap != NULL) { CORE_ADDR baseaddr = objfile->text_section_offset (); struct partial_symtab *pst = ((struct partial_symtab *) - addrmap_find (partial_symtabs->psymtabs_addrmap, + addrmap_find (m_partial_symtabs->psymtabs_addrmap, pc - baseaddr)); if (pst != NULL) { @@ -356,7 +352,6 @@ psymbol_functions::find_pc_sect_compunit_symtab int warn_if_readin) { struct partial_symtab *ps = find_pc_sect_psymtab (objfile, - m_partial_symtabs.get (), pc, section, msymbol); if (ps != NULL) @@ -1815,7 +1810,12 @@ maintenance_print_psymbols (const char *args, int from_tty) if (!print_for_objfile) continue; - psymtab_storage *partial_symtabs = objfile->partial_symtabs.get (); + psymbol_functions *psf + = dynamic_cast (objfile->qf.get ()); + if (psf == nullptr) + continue; + + psymtab_storage *partial_symtabs = psf->get_partial_symtabs ().get (); if (address_arg != NULL) { @@ -1824,8 +1824,7 @@ maintenance_print_psymbols (const char *args, int from_tty) /* We don't assume each pc has a unique objfile (this is for debugging). */ struct partial_symtab *ps - = find_pc_sect_psymtab (objfile, partial_symtabs, pc, - section, msymbol); + = psf->find_pc_sect_psymtab (objfile, pc, section, msymbol); if (ps != NULL) { if (!printed_objfile_header) @@ -1841,7 +1840,7 @@ maintenance_print_psymbols (const char *args, int from_tty) } else { - for (partial_symtab *ps : require_partial_symbols (objfile)) + for (partial_symtab *ps : psf->require_partial_symbols (objfile)) { int print_for_source = 0; @@ -1905,7 +1904,11 @@ maintenance_info_psymtabs (const char *regexp, int from_tty) actually find a symtab whose name matches. */ int printed_objfile_start = 0; - for (partial_symtab *psymtab : require_partial_symbols (objfile)) + psymbol_functions *psf + = dynamic_cast (objfile->qf.get ()); + if (psf == nullptr) + continue; + for (partial_symtab *psymtab : psf->require_partial_symbols (objfile)) { QUIT; @@ -2005,89 +2008,96 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) const struct block *b; for (objfile *objfile : current_program_space->objfiles ()) - for (partial_symtab *ps : require_partial_symbols (objfile)) - { - struct gdbarch *gdbarch = objfile->arch (); + { + psymbol_functions *psf + = dynamic_cast (objfile->qf.get ()); + if (psf == nullptr) + continue; - /* We don't call psymtab_to_symtab here because that may cause symtab - expansion. When debugging a problem it helps if checkers leave - things unchanged. */ - cust = ps->get_compunit_symtab (objfile); + for (partial_symtab *ps : psf->require_partial_symbols (objfile)) + { + struct gdbarch *gdbarch = objfile->arch (); - /* First do some checks that don't require the associated symtab. */ - if (ps->text_high (objfile) < ps->text_low (objfile)) - { - printf_filtered ("Psymtab "); - puts_filtered (ps->filename); - printf_filtered (" covers bad range "); - fputs_filtered (paddress (gdbarch, ps->text_low (objfile)), - gdb_stdout); - printf_filtered (" - "); - fputs_filtered (paddress (gdbarch, ps->text_high (objfile)), - gdb_stdout); - printf_filtered ("\n"); - continue; - } + /* We don't call psymtab_to_symtab here because that may cause symtab + expansion. When debugging a problem it helps if checkers leave + things unchanged. */ + cust = ps->get_compunit_symtab (objfile); - /* Now do checks requiring the associated symtab. */ - if (cust == NULL) - continue; - bv = COMPUNIT_BLOCKVECTOR (cust); - b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); - for (partial_symbol *psym : ps->static_psymbols) - { - /* Skip symbols for inlined functions without address. These may - or may not have a match in the full symtab. */ - if (psym->aclass == LOC_BLOCK - && psym->ginfo.value.address == 0) + /* First do some checks that don't require the associated symtab. */ + if (ps->text_high (objfile) < ps->text_low (objfile)) + { + printf_filtered ("Psymtab "); + puts_filtered (ps->filename); + printf_filtered (" covers bad range "); + fputs_filtered (paddress (gdbarch, ps->text_low (objfile)), + gdb_stdout); + printf_filtered (" - "); + fputs_filtered (paddress (gdbarch, ps->text_high (objfile)), + gdb_stdout); + printf_filtered ("\n"); continue; + } - sym = block_lookup_symbol (b, psym->ginfo.search_name (), - symbol_name_match_type::SEARCH_NAME, - psym->domain); - if (!sym) - { - printf_filtered ("Static symbol `"); - puts_filtered (psym->ginfo.linkage_name ()); - printf_filtered ("' only found in "); - puts_filtered (ps->filename); - printf_filtered (" psymtab\n"); - } - } - b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); - for (partial_symbol *psym : ps->global_psymbols) - { - sym = block_lookup_symbol (b, psym->ginfo.search_name (), - symbol_name_match_type::SEARCH_NAME, - psym->domain); - if (!sym) - { - printf_filtered ("Global symbol `"); - puts_filtered (psym->ginfo.linkage_name ()); - printf_filtered ("' only found in "); - puts_filtered (ps->filename); - printf_filtered (" psymtab\n"); - } - } - if (ps->raw_text_high () != 0 - && (ps->text_low (objfile) < BLOCK_START (b) - || ps->text_high (objfile) > BLOCK_END (b))) - { - printf_filtered ("Psymtab "); - puts_filtered (ps->filename); - printf_filtered (" covers "); - fputs_filtered (paddress (gdbarch, ps->text_low (objfile)), - gdb_stdout); - printf_filtered (" - "); - fputs_filtered (paddress (gdbarch, ps->text_high (objfile)), - gdb_stdout); - printf_filtered (" but symtab covers only "); - fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout); - printf_filtered (" - "); - fputs_filtered (paddress (gdbarch, BLOCK_END (b)), gdb_stdout); - printf_filtered ("\n"); - } - } + /* Now do checks requiring the associated symtab. */ + if (cust == NULL) + continue; + bv = COMPUNIT_BLOCKVECTOR (cust); + b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); + for (partial_symbol *psym : ps->static_psymbols) + { + /* Skip symbols for inlined functions without address. These may + or may not have a match in the full symtab. */ + if (psym->aclass == LOC_BLOCK + && psym->ginfo.value.address == 0) + continue; + + sym = block_lookup_symbol (b, psym->ginfo.search_name (), + symbol_name_match_type::SEARCH_NAME, + psym->domain); + if (!sym) + { + printf_filtered ("Static symbol `"); + puts_filtered (psym->ginfo.linkage_name ()); + printf_filtered ("' only found in "); + puts_filtered (ps->filename); + printf_filtered (" psymtab\n"); + } + } + b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); + for (partial_symbol *psym : ps->global_psymbols) + { + sym = block_lookup_symbol (b, psym->ginfo.search_name (), + symbol_name_match_type::SEARCH_NAME, + psym->domain); + if (!sym) + { + printf_filtered ("Global symbol `"); + puts_filtered (psym->ginfo.linkage_name ()); + printf_filtered ("' only found in "); + puts_filtered (ps->filename); + printf_filtered (" psymtab\n"); + } + } + if (ps->raw_text_high () != 0 + && (ps->text_low (objfile) < BLOCK_START (b) + || ps->text_high (objfile) > BLOCK_END (b))) + { + printf_filtered ("Psymtab "); + puts_filtered (ps->filename); + printf_filtered (" covers "); + fputs_filtered (paddress (gdbarch, ps->text_low (objfile)), + gdb_stdout); + printf_filtered (" - "); + fputs_filtered (paddress (gdbarch, ps->text_high (objfile)), + gdb_stdout); + printf_filtered (" but symtab covers only "); + fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout); + printf_filtered (" - "); + fputs_filtered (paddress (gdbarch, BLOCK_END (b)), gdb_stdout); + printf_filtered ("\n"); + } + } + } } void _initialize_psymtab (); -- 2.26.2