From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway31.websitewelcome.com (gateway31.websitewelcome.com [192.185.144.94]) by sourceware.org (Postfix) with ESMTPS id A2116382E830 for ; Sun, 28 Feb 2021 20:38:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A2116382E830 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 cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 53DBB2047E for ; Sun, 28 Feb 2021 14:38:13 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id GSpRlTTlgkscSGSpRlawvD; Sun, 28 Feb 2021 14:38:13 -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=MbLqq8+vmEAs6JUIjrs0RKiGj5lnp/FQ9W0H3peq3K4=; b=cUmWO+KrP5wcaDKWPXDcNHGHeI zZvwvBGLD+Snsv/Ria+OVT2JT84I5e+83x0fUpA/9Qghkki2wXNt02pn/hU+QnGT3SZRGMnhdMYab rH0AL0ih5Wjpw72+gyTYAHDKW; Received: from 97-122-70-152.hlrn.qwest.net ([97.122.70.152]:36732 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 1lGSpQ-000Xkq-Qh for gdb-patches@sourceware.org; Sun, 28 Feb 2021 13:38:12 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 13/26] Change how DWARF indices use addrmap Date: Sun, 28 Feb 2021 13:37:50 -0700 Message-Id: <20210228203803.1693413-14-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: 1lGSpQ-000Xkq-Qh X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-70-152.hlrn.qwest.net (localhost.localdomain) [97.122.70.152]:36732 X-Source-Auth: tom+tromey.com X-Email-Count: 14 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, 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:15 -0000 Currently the DWARF index readers reuse the objfile's partial symbol table in order to store an addrmap. We're going to be remove the partial symbol object, so this patch changes the DWARF reader to store this addrmap in the per_bfd object. This object is chosen, rather than the quick_symbol_functions subclass, because the addrmap can be shared across objfiles. gdb/ChangeLog 2021-02-28 Tom Tromey * dwarf2/read.h (struct dwarf2_per_bfd) : New member. * dwarf2/read.c (create_addrmap_from_index) (create_addrmap_from_aranges): Set per_bfd addrmap. (dwarf2_read_gdb_index): Don't set partial_symtabs. (dwarf2_base_index_functions::find_pc_sect_compunit_symtab): Use per_bfd addrmap. (dwarf2_read_debug_names): Don't set partial_symtabs. (dwarf2_initialize_objfile): Likewise. --- gdb/ChangeLog | 12 ++++++++++++ gdb/dwarf2/read.c | 43 +++++++++++++++++-------------------------- gdb/dwarf2/read.h | 3 +++ 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 12f8cb9b114..773e38d0dc5 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2942,13 +2942,14 @@ create_signatured_type_table_from_debug_names } /* Read the address map data from the mapped index, and use it to - populate the objfile's psymtabs_addrmap. */ + populate the psymtabs_addrmap. */ static void create_addrmap_from_index (dwarf2_per_objfile *per_objfile, struct mapped_index *index) { struct objfile *objfile = per_objfile->objfile; + dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; struct gdbarch *gdbarch = objfile->arch (); const gdb_byte *iter, *end; struct addrmap *mutable_map; @@ -2980,7 +2981,7 @@ create_addrmap_from_index (dwarf2_per_objfile *per_objfile, continue; } - if (cu_index >= per_objfile->per_bfd->all_comp_units.size ()) + if (cu_index >= per_bfd->all_comp_units.size ()) { complaint (_(".gdb_index address table has invalid CU number %u"), (unsigned) cu_index); @@ -2990,15 +2991,15 @@ create_addrmap_from_index (dwarf2_per_objfile *per_objfile, lo = gdbarch_adjust_dwarf2_addr (gdbarch, lo + baseaddr) - baseaddr; hi = gdbarch_adjust_dwarf2_addr (gdbarch, hi + baseaddr) - baseaddr; addrmap_set_empty (mutable_map, lo, hi - 1, - per_objfile->per_bfd->get_cu (cu_index)); + per_bfd->get_cu (cu_index)); } - objfile->partial_symtabs->psymtabs_addrmap - = addrmap_create_fixed (mutable_map, objfile->partial_symtabs->obstack ()); + per_bfd->index_addrmap = addrmap_create_fixed (mutable_map, + &per_bfd->obstack); } /* Read the address map data from DWARF-5 .debug_aranges, and use it to - populate the objfile's psymtabs_addrmap. */ + populate the psymtabs_addrmap. */ static void create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, @@ -3008,6 +3009,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, bfd *abfd = objfile->obfd; struct gdbarch *gdbarch = objfile->arch (); const CORE_ADDR baseaddr = objfile->text_section_offset (); + dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; auto_obstack temp_obstack; addrmap *mutable_map = addrmap_create_mutable (&temp_obstack); @@ -3144,7 +3146,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, addr += address_size; if (start == 0 && length == 0) break; - if (start == 0 && !per_objfile->per_bfd->has_section_at_zero) + if (start == 0 && !per_bfd->has_section_at_zero) { /* Symbol was eliminated due to a COMDAT group. */ continue; @@ -3158,8 +3160,8 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, } } - objfile->partial_symtabs->psymtabs_addrmap - = addrmap_create_fixed (mutable_map, objfile->partial_symtabs->obstack ()); + per_bfd->index_addrmap = addrmap_create_fixed (mutable_map, + &per_bfd->obstack); } /* Find a slot in the mapped index INDEX for the object named NAME. @@ -3426,11 +3428,6 @@ dwarf2_read_gdb_index per_bfd->quick_file_names_table = create_quick_file_names_table (per_bfd->all_comp_units.size ()); - /* Save partial symtabs in the per_bfd object, for the benefit of subsequent - objfiles using the same BFD. */ - gdb_assert (per_bfd->partial_symtabs == nullptr); - per_bfd->partial_symtabs = objfile->partial_symtabs; - return 1; } @@ -5168,16 +5165,17 @@ dwarf2_base_index_functions::find_pc_sect_compunit_symtab struct dwarf2_per_cu_data *data; struct compunit_symtab *result; - if (!objfile->partial_symtabs->psymtabs_addrmap) + dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); + if (per_objfile->per_bfd->index_addrmap == nullptr) return NULL; CORE_ADDR baseaddr = objfile->text_section_offset (); - data = (struct dwarf2_per_cu_data *) addrmap_find - (objfile->partial_symtabs->psymtabs_addrmap, pc - baseaddr); + data = ((struct dwarf2_per_cu_data *) + addrmap_find (per_objfile->per_bfd->index_addrmap, + pc - baseaddr)); if (!data) return NULL; - dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); if (warn_if_readin && per_objfile->symtab_set_p (data)) warning (_("(Internal error: pc %s in read in CU, but not in symtab.)"), paddress (objfile->arch (), pc)); @@ -5588,11 +5586,6 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile) per_bfd->quick_file_names_table = create_quick_file_names_table (per_objfile->per_bfd->all_comp_units.size ()); - /* Save partial symtabs in the per_bfd object, for the benefit of subsequent - objfiles using the same BFD. */ - gdb_assert (per_bfd->partial_symtabs == nullptr); - per_bfd->partial_symtabs = objfile->partial_symtabs; - return true; } @@ -6294,7 +6287,6 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) if (per_bfd->debug_names_table != nullptr) { *index_kind = dw_index_kind::DEBUG_NAMES; - per_objfile->objfile->partial_symtabs = per_bfd->partial_symtabs; per_objfile->resize_symtabs (); return true; } @@ -6304,7 +6296,6 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) if (per_bfd->index_table != nullptr) { *index_kind = dw_index_kind::GDB_INDEX; - per_objfile->objfile->partial_symtabs = per_bfd->partial_symtabs; per_objfile->resize_symtabs (); return true; } @@ -14732,7 +14723,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag, /* Get low and high pc attributes from DW_AT_ranges attribute value OFFSET. Return 1 if the attributes are present and valid, otherwise, return 0. - If RANGES_PST is not NULL we should setup `objfile->psymtabs_addrmap'. */ + If RANGES_PST is not NULL we should set up the `psymtabs_addrmap'. */ static int dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return, diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index fbcd8ad0380..aba1d83e468 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -257,6 +257,9 @@ struct dwarf2_per_bfd partial symbols have been read the first time. */ std::shared_ptr partial_symtabs; + /* The address map that is used by the DWARF index code. */ + struct addrmap *index_addrmap = nullptr; + private: /* The total number of per_cu and signatured_type objects that have -- 2.26.2