From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 6E6A13857C41 for ; Mon, 4 Apr 2022 19:53:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6E6A13857C41 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 progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id D940D1004818F for ; Mon, 4 Apr 2022 19:53:45 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bSllnd5dR2s5dbSllnKBOZ; Mon, 04 Apr 2022 19:53:45 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Nagja0P4 c=1 sm=1 tr=0 ts=624b4cc9 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=z0gMJWrwH1QA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=iVXygZY8AAAA:8 a=AmuFdWREKHvEOCTbwxIA:9 a=r_HcymJbbFSFhMRbe23N:22 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: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=boDkjObYLMdz0GgFQY4C4l/QxBQ9U5paFOrhHAbcNRw=; b=ygaIswRZJ53IyciePpZcEh1Lp0 qIedEGlywKVm9Cnv26a1zMJy5X1kYP724OjWzs7vf42jfDHUe/8Y+UFQHQpW8sVYWh9WmRxUu101v SBDC3aVcQbmuN7z283eJgEiU2; Received: from 71-211-176-135.hlrn.qwest.net ([71.211.176.135]:34802 helo=prentzel.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nbSll-003uHX-5s; Mon, 04 Apr 2022 13:53:45 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v4 23/34] Pre-read DWARF section data Date: Mon, 4 Apr 2022 13:53:24 -0600 Message-Id: <20220404195335.2111906-24-tom@tromey.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220404195335.2111906-1-tom@tromey.com> References: <20220404195335.2111906-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: 71.211.176.135 X-Source-L: No X-Exim-ID: 1nbSll-003uHX-5s X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-176-135.hlrn.qwest.net (prentzel.Home) [71.211.176.135]:34802 X-Source-Auth: tom+tromey.com X-Email-Count: 31 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3030.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_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Mon, 04 Apr 2022 19:53:48 -0000 Because BFD is not thread-safe, we need to be sure that any section data that is needed is read before trying to do any DWARF indexing in the background. This patch takes a simple approach to this -- it pre-reads the "info"-related sections. This is done for the main file, but also any auxiliary files as well, such as the DWO file. This patch could be perhaps enhanced by removing some now-redundant calls to dwarf2_section_info::read. --- gdb/dwarf2/read.c | 221 +++++++++++++++++++++------------------------- gdb/dwarf2/read.h | 4 + 2 files changed, 103 insertions(+), 122 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index c329ba5057b..094aa21303e 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2039,6 +2039,25 @@ dwarf2_get_section_info (struct objfile *objfile, *sizep = info->size; } +/* See dwarf2/read.h. */ + +void +dwarf2_per_bfd::map_info_sections (struct objfile *objfile) +{ + info.read (objfile); + abbrev.read (objfile); + line.read (objfile); + str.read (objfile); + str_offsets.read (objfile); + line_str.read (objfile); + ranges.read (objfile); + rnglists.read (objfile); + addr.read (objfile); + + for (auto §ion : types) + section.read (objfile); +} + /* DWARF quick_symbol_functions support. */ @@ -7831,7 +7850,7 @@ dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile) scoped_restore restore_reading_psyms = make_scoped_restore (&per_bfd->reading_partial_symbols, true); - per_bfd->info.read (objfile); + per_bfd->map_info_sections (objfile); /* Any cached compilation units will be linked by the per-objfile read_in_chain. Make sure to free them when we're done. */ @@ -8018,8 +8037,16 @@ create_all_comp_units (dwarf2_per_objfile *per_objfile) dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd); if (dwz != NULL) - read_comp_units_from_section (per_objfile, &dwz->info, &dwz->abbrev, 1, - types_htab, rcuh_kind::COMPILE); + { + /* Pre-read the sections we'll need to construct an index. */ + struct objfile *objfile = per_objfile->objfile; + dwz->abbrev.read (objfile); + dwz->info.read (objfile); + dwz->str.read (objfile); + dwz->line.read (objfile); + read_comp_units_from_section (per_objfile, &dwz->info, &dwz->abbrev, 1, + types_htab, rcuh_kind::COMPILE); + } per_objfile->per_bfd->signatured_types = std::move (types_htab); } @@ -12635,69 +12662,47 @@ open_dwo_file (dwarf2_per_objfile *per_objfile, size of each of the DWO debugging sections we are interested in. */ static void -dwarf2_locate_dwo_sections (bfd *abfd, asection *sectp, - dwo_sections *dwo_sections) +dwarf2_locate_dwo_sections (struct objfile *objfile, bfd *abfd, + asection *sectp, dwo_sections *dwo_sections) { const struct dwop_section_names *names = &dwop_section_names; + struct dwarf2_section_info *dw_sect = nullptr; + if (names->abbrev_dwo.matches (sectp->name)) - { - dwo_sections->abbrev.s.section = sectp; - dwo_sections->abbrev.size = bfd_section_size (sectp); - } + dw_sect = &dwo_sections->abbrev; else if (names->info_dwo.matches (sectp->name)) - { - dwo_sections->info.s.section = sectp; - dwo_sections->info.size = bfd_section_size (sectp); - } + dw_sect = &dwo_sections->info; else if (names->line_dwo.matches (sectp->name)) - { - dwo_sections->line.s.section = sectp; - dwo_sections->line.size = bfd_section_size (sectp); - } + dw_sect = &dwo_sections->line; else if (names->loc_dwo.matches (sectp->name)) - { - dwo_sections->loc.s.section = sectp; - dwo_sections->loc.size = bfd_section_size (sectp); - } + dw_sect = &dwo_sections->loc; else if (names->loclists_dwo.matches (sectp->name)) - { - dwo_sections->loclists.s.section = sectp; - dwo_sections->loclists.size = bfd_section_size (sectp); - } + dw_sect = &dwo_sections->loclists; else if (names->macinfo_dwo.matches (sectp->name)) - { - dwo_sections->macinfo.s.section = sectp; - dwo_sections->macinfo.size = bfd_section_size (sectp); - } + dw_sect = &dwo_sections->macinfo; else if (names->macro_dwo.matches (sectp->name)) - { - dwo_sections->macro.s.section = sectp; - dwo_sections->macro.size = bfd_section_size (sectp); - } + dw_sect = &dwo_sections->macro; else if (names->rnglists_dwo.matches (sectp->name)) - { - dwo_sections->rnglists.s.section = sectp; - dwo_sections->rnglists.size = bfd_section_size (sectp); - } + dw_sect = &dwo_sections->rnglists; else if (names->str_dwo.matches (sectp->name)) - { - dwo_sections->str.s.section = sectp; - dwo_sections->str.size = bfd_section_size (sectp); - } + dw_sect = &dwo_sections->str; else if (names->str_offsets_dwo.matches (sectp->name)) - { - dwo_sections->str_offsets.s.section = sectp; - dwo_sections->str_offsets.size = bfd_section_size (sectp); - } + dw_sect = &dwo_sections->str_offsets; else if (names->types_dwo.matches (sectp->name)) { struct dwarf2_section_info type_section; memset (&type_section, 0, sizeof (type_section)); - type_section.s.section = sectp; - type_section.size = bfd_section_size (sectp); dwo_sections->types.push_back (type_section); + dw_sect = &dwo_sections->types.back (); + } + + if (dw_sect != nullptr) + { + dw_sect->s.section = sectp; + dw_sect->size = bfd_section_size (sectp); + dw_sect->read (objfile); } } @@ -12725,8 +12730,8 @@ open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name, dwo_file->dbfd = std::move (dbfd); for (asection *sec : gdb_bfd_sections (dwo_file->dbfd)) - dwarf2_locate_dwo_sections (dwo_file->dbfd.get (), sec, - &dwo_file->sections); + dwarf2_locate_dwo_sections (per_objfile->objfile, dwo_file->dbfd.get (), + sec, &dwo_file->sections); create_cus_hash_table (per_objfile, cu, *dwo_file, dwo_file->sections.info, dwo_file->cus); @@ -12753,8 +12758,8 @@ open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name, we are interested in. */ static void -dwarf2_locate_common_dwp_sections (bfd *abfd, asection *sectp, - dwp_file *dwp_file) +dwarf2_locate_common_dwp_sections (struct objfile *objfile, bfd *abfd, + asection *sectp, dwp_file *dwp_file) { const struct dwop_section_names *names = &dwop_section_names; unsigned int elf_section_nr = elf_section_data (sectp)->this_idx; @@ -12765,20 +12770,19 @@ dwarf2_locate_common_dwp_sections (bfd *abfd, asection *sectp, dwp_file->elf_sections[elf_section_nr] = sectp; /* Look for specific sections that we need. */ + struct dwarf2_section_info *dw_sect = nullptr; if (names->str_dwo.matches (sectp->name)) - { - dwp_file->sections.str.s.section = sectp; - dwp_file->sections.str.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.str; else if (names->cu_index.matches (sectp->name)) - { - dwp_file->sections.cu_index.s.section = sectp; - dwp_file->sections.cu_index.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.cu_index; else if (names->tu_index.matches (sectp->name)) + dw_sect = &dwp_file->sections.tu_index; + + if (dw_sect != nullptr) { - dwp_file->sections.tu_index.s.section = sectp; - dwp_file->sections.tu_index.size = bfd_section_size (sectp); + dw_sect->s.section = sectp; + dw_sect->size = bfd_section_size (sectp); + dw_sect->read (objfile); } } @@ -12788,7 +12792,8 @@ dwarf2_locate_common_dwp_sections (bfd *abfd, asection *sectp, have version 1 or 2 or 5 until we parse the cu_index/tu_index sections. */ static void -dwarf2_locate_v2_dwp_sections (bfd *abfd, asection *sectp, void *dwp_file_ptr) +dwarf2_locate_v2_dwp_sections (struct objfile *objfile, bfd *abfd, + asection *sectp, void *dwp_file_ptr) { struct dwp_file *dwp_file = (struct dwp_file *) dwp_file_ptr; const struct dwop_section_names *names = &dwop_section_names; @@ -12800,45 +12805,29 @@ dwarf2_locate_v2_dwp_sections (bfd *abfd, asection *sectp, void *dwp_file_ptr) dwp_file->elf_sections[elf_section_nr] = sectp; /* Look for specific sections that we need. */ + struct dwarf2_section_info *dw_sect = nullptr; if (names->abbrev_dwo.matches (sectp->name)) - { - dwp_file->sections.abbrev.s.section = sectp; - dwp_file->sections.abbrev.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.abbrev; else if (names->info_dwo.matches (sectp->name)) - { - dwp_file->sections.info.s.section = sectp; - dwp_file->sections.info.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.info; else if (names->line_dwo.matches (sectp->name)) - { - dwp_file->sections.line.s.section = sectp; - dwp_file->sections.line.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.line; else if (names->loc_dwo.matches (sectp->name)) - { - dwp_file->sections.loc.s.section = sectp; - dwp_file->sections.loc.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.loc; else if (names->macinfo_dwo.matches (sectp->name)) - { - dwp_file->sections.macinfo.s.section = sectp; - dwp_file->sections.macinfo.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.macinfo; else if (names->macro_dwo.matches (sectp->name)) - { - dwp_file->sections.macro.s.section = sectp; - dwp_file->sections.macro.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.macro; else if (names->str_offsets_dwo.matches (sectp->name)) - { - dwp_file->sections.str_offsets.s.section = sectp; - dwp_file->sections.str_offsets.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.str_offsets; else if (names->types_dwo.matches (sectp->name)) + dw_sect = &dwp_file->sections.types; + + if (dw_sect != nullptr) { - dwp_file->sections.types.s.section = sectp; - dwp_file->sections.types.size = bfd_section_size (sectp); + dw_sect->s.section = sectp; + dw_sect->size = bfd_section_size (sectp); + dw_sect->read (objfile); } } @@ -12848,7 +12837,8 @@ dwarf2_locate_v2_dwp_sections (bfd *abfd, asection *sectp, void *dwp_file_ptr) have version 1 or 2 or 5 until we parse the cu_index/tu_index sections. */ static void -dwarf2_locate_v5_dwp_sections (bfd *abfd, asection *sectp, void *dwp_file_ptr) +dwarf2_locate_v5_dwp_sections (struct objfile *objfile, bfd *abfd, + asection *sectp, void *dwp_file_ptr) { struct dwp_file *dwp_file = (struct dwp_file *) dwp_file_ptr; const struct dwop_section_names *names = &dwop_section_names; @@ -12860,40 +12850,27 @@ dwarf2_locate_v5_dwp_sections (bfd *abfd, asection *sectp, void *dwp_file_ptr) dwp_file->elf_sections[elf_section_nr] = sectp; /* Look for specific sections that we need. */ + struct dwarf2_section_info *dw_sect = nullptr; if (names->abbrev_dwo.matches (sectp->name)) - { - dwp_file->sections.abbrev.s.section = sectp; - dwp_file->sections.abbrev.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.abbrev; else if (names->info_dwo.matches (sectp->name)) - { - dwp_file->sections.info.s.section = sectp; - dwp_file->sections.info.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.info; else if (names->line_dwo.matches (sectp->name)) - { - dwp_file->sections.line.s.section = sectp; - dwp_file->sections.line.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.line; else if (names->loclists_dwo.matches (sectp->name)) - { - dwp_file->sections.loclists.s.section = sectp; - dwp_file->sections.loclists.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.loclists; else if (names->macro_dwo.matches (sectp->name)) - { - dwp_file->sections.macro.s.section = sectp; - dwp_file->sections.macro.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.macro; else if (names->rnglists_dwo.matches (sectp->name)) - { - dwp_file->sections.rnglists.s.section = sectp; - dwp_file->sections.rnglists.size = bfd_section_size (sectp); - } + dw_sect = &dwp_file->sections.rnglists; else if (names->str_offsets_dwo.matches (sectp->name)) + dw_sect = &dwp_file->sections.str_offsets; + + if (dw_sect != nullptr) { - dwp_file->sections.str_offsets.s.section = sectp; - dwp_file->sections.str_offsets.size = bfd_section_size (sectp); + dw_sect->s.section = sectp; + dw_sect->size = bfd_section_size (sectp); + dw_sect->read (objfile); } } @@ -13020,7 +12997,7 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile) dwp_file->num_sections, asection *); for (asection *sec : gdb_bfd_sections (dwp_file->dbfd)) - dwarf2_locate_common_dwp_sections (dwp_file->dbfd.get (), sec, + dwarf2_locate_common_dwp_sections (objfile, dwp_file->dbfd.get (), sec, dwp_file.get ()); dwp_file->cus = create_dwp_hash_table (per_objfile, dwp_file.get (), 0); @@ -13050,10 +13027,10 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile) for (asection *sec : gdb_bfd_sections (dwp_file->dbfd)) { if (dwp_file->version == 2) - dwarf2_locate_v2_dwp_sections (dwp_file->dbfd.get (), sec, + dwarf2_locate_v2_dwp_sections (objfile, dwp_file->dbfd.get (), sec, dwp_file.get ()); else - dwarf2_locate_v5_dwp_sections (dwp_file->dbfd.get (), sec, + dwarf2_locate_v5_dwp_sections (objfile, dwp_file->dbfd.get (), sec, dwp_file.get ()); } diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 4158a06e2bc..4ee7de98c50 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -368,6 +368,10 @@ struct dwarf2_per_bfd is allocated on the dwarf2_per_bfd obstack. */ signatured_type_up allocate_signatured_type (ULONGEST signature); + /* Map all the DWARF section data needed when scanning + .debug_info. */ + void map_info_sections (struct objfile *objfile); + private: /* This function is mapped across the sections and remembers the offset and size of each of the debugging sections we are -- 2.34.1