From patchwork Thu Oct 20 20:12:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 59241 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 281C4384BC3F for ; Thu, 20 Oct 2022 20:13:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id E7F70384BC30 for ; Thu, 20 Oct 2022 20:13:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E7F70384BC30 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id 336191004DE6F for ; Thu, 20 Oct 2022 20:13:10 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id lbufo0fMVFZ44lbufoUD4f; Thu, 20 Oct 2022 20:13:10 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Z+MpoFdA c=1 sm=1 tr=0 ts=6351abd6 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=Qawa6l4ZSaYA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=yLZ7aMWLt355Beqsa90A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=IeZOMKzreNZXEcHgQgFAeW2wE1ZeNcbod1e5nhIKd2o=; b=fS1B3bEFkavXziqlFvq9Oe5+fh 8s4Fs6p8XF1sORrn+apJ6E3WROr1JJ6oPsvOHfP7drNPe6laJAxUEpWTtfEo6fsZFWBnGF6/Wbclv hi/l/2NjfAfKNvAdDe9FVDbf7; Received: from 71-211-181-169.hlrn.qwest.net ([71.211.181.169]:44986 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1olbuf-002ivV-04; Thu, 20 Oct 2022 14:13:09 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH] Remove quick_symbol_functions::relocated Date: Thu, 20 Oct 2022 14:12:58 -0600 Message-Id: <20221020201258.1142449-1-tom@tromey.com> X-Mailer: git-send-email 2.34.3 MIME-Version: 1.0 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: 71.211.181.169 X-Source-L: No X-Exim-ID: 1olbuf-002ivV-04 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-181-169.hlrn.qwest.net (localhost.localdomain) [71.211.181.169]:44986 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3028.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Cc: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" quick_symbol_functions::relocated is only needed for psymtabs, and there it is only needed for Rust. However, because we've switched the DWARF reader away from psymtabs, this means there's no longer a need for this method at all. --- gdb/objfiles.c | 4 --- gdb/psympriv.h | 15 +++------- gdb/psymtab.c | 69 ---------------------------------------------- gdb/quick-symbol.h | 7 ----- 4 files changed, 4 insertions(+), 91 deletions(-) diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 09aba0f80f0..ffdb36ab633 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -667,10 +667,6 @@ objfile_relocate1 (struct objfile *objfile, } } - /* Notify the quick symbol object. */ - for (const auto &iter : objfile->qf) - iter->relocated (); - /* Relocate isolated symbols. */ { struct symbol *iter; diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 61fb5c0f6c1..8dc79e92ca6 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -536,17 +536,15 @@ struct psymbol_functions : public quick_symbol_functions CORE_ADDR pc, struct obj_section *section, int warn_if_readin) override; struct compunit_symtab *find_compunit_symtab_by_address - (struct objfile *objfile, CORE_ADDR address) override; + (struct objfile *objfile, CORE_ADDR address) override + { + return nullptr; + } void map_symbol_filenames (struct objfile *objfile, gdb::function_view fun, bool need_fullname) override; - void relocated () override - { - m_psymbol_map.clear (); - } - /* Return a range adapter for the psymtabs. */ psymtab_storage::partial_symtab_range partial_symbols (struct objfile *objfile); @@ -588,11 +586,6 @@ struct psymbol_functions : public quick_symbol_functions /* Storage for the partial symbols. */ std::shared_ptr m_partial_symtabs; - - /* Map symbol addresses to the partial symtab that defines the - object at that address. */ - - std::vector> m_psymbol_map; }; #endif /* PSYMPRIV_H */ diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 424e611b87b..35832ae71da 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1103,75 +1103,6 @@ psymbol_functions::has_unexpanded_symtabs (struct objfile *objfile) return false; } -/* Helper function for psym_find_compunit_symtab_by_address that fills - in m_psymbol_map for a given range of psymbols. */ - -void -psymbol_functions::fill_psymbol_map - (struct objfile *objfile, - struct partial_symtab *psymtab, - std::set *seen_addrs, - const std::vector &symbols) -{ - for (partial_symbol *psym : symbols) - { - if (psym->aclass == LOC_STATIC) - { - CORE_ADDR addr = psym->address (objfile); - if (seen_addrs->find (addr) == seen_addrs->end ()) - { - seen_addrs->insert (addr); - m_psymbol_map.emplace_back (addr, psymtab); - } - } - } -} - -/* See find_compunit_symtab_by_address in quick_symbol_functions, in - symfile.h. */ - -compunit_symtab * -psymbol_functions::find_compunit_symtab_by_address (struct objfile *objfile, - CORE_ADDR address) -{ - if (m_psymbol_map.empty ()) - { - std::set seen_addrs; - - for (partial_symtab *pst : partial_symbols (objfile)) - { - fill_psymbol_map (objfile, pst, - &seen_addrs, - pst->global_psymbols); - fill_psymbol_map (objfile, pst, - &seen_addrs, - pst->static_psymbols); - } - - m_psymbol_map.shrink_to_fit (); - - std::sort (m_psymbol_map.begin (), m_psymbol_map.end (), - [] (const std::pair &a, - const std::pair &b) - { - return a.first < b.first; - }); - } - - auto iter = std::lower_bound - (m_psymbol_map.begin (), m_psymbol_map.end (), address, - [] (const std::pair &a, - CORE_ADDR b) - { - return a.first < b; - }); - - if (iter == m_psymbol_map.end () || iter->first != address) - return NULL; - - return psymtab_to_symtab (objfile, iter->second); -} - /* Partially fill a partial symtab. It will be completely filled at diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h index c55989e0a2c..f4120b0a7a4 100644 --- a/gdb/quick-symbol.h +++ b/gdb/quick-symbol.h @@ -212,13 +212,6 @@ struct quick_symbol_functions gdb::function_view fun, bool need_fullname) = 0; - /* This is called when the objfile is relocated. It can be used to - clean up any internal caches. */ - virtual void relocated () - { - /* Do nothing. */ - } - /* Return true if this class can lazily read the symbols. This may only return true if there are in fact symbols to be read, because this is used in the implementation of 'has_partial_symbols'. */