From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway22.websitewelcome.com (gateway22.websitewelcome.com [192.185.47.163]) by sourceware.org (Postfix) with ESMTPS id 36F513943541 for ; Sun, 21 Feb 2021 03:16:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 36F513943541 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 cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 7E583BFD9 for ; Sat, 20 Feb 2021 21:16:50 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id DfEolnrkCsvw9DfEolmoET; Sat, 20 Feb 2021 21:16:50 -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: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=8flLvYh8KTtk/jw6gLooc/tiWDSKjQyrwt82jeHEw4E=; b=ovLCoQ3dkQmHruA4Jf86gzdsgh EgvXr2Ogf+DneRrokrmxLssecRaZNzg8W57FowPhzzuk60uOhWq7keWc+60/VkwrTvYfdXgOwJa6P Cbm41XFa/tKLQ127b9R7/3kZT; Received: from 97-122-70-152.hlrn.qwest.net ([97.122.70.152]:56692 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 1lDfEo-001OUW-8X; Sat, 20 Feb 2021 20:16:50 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/5] Change section_is_p to a method on dwarf2_section_names Date: Sat, 20 Feb 2021 20:16:44 -0700 Message-Id: <20210221031647.949270-3-tom@tromey.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210221031647.949270-1-tom@tromey.com> References: <20210221031647.949270-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: 1lDfEo-001OUW-8X X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-70-152.hlrn.qwest.net (localhost.localdomain) [97.122.70.152]:56692 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3034.6 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, 21 Feb 2021 03:17:01 -0000 This replaces section_is_p with a method on dwarf2_section_names. gdb/ChangeLog 2021-02-20 Tom Tromey * dwarf2/sect-names.h (struct dwarf2_section_names) : New method. * dwarf2/read.c (section_is_p): Remove. (dwarf2_per_bfd::locate_sections) (dwarf2_per_bfd::locate_sections, locate_dwz_sections) (locate_v1_virtual_dwo_sections, dwarf2_locate_dwo_sections) (dwarf2_locate_common_dwp_sections) (dwarf2_locate_v2_dwp_sections, dwarf2_locate_v5_dwp_sections): Update. --- gdb/ChangeLog | 12 ++++ gdb/dwarf2/read.c | 142 ++++++++++++++++++---------------------- gdb/dwarf2/sect-names.h | 7 ++ 3 files changed, 82 insertions(+), 79 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d747286f2e3..0347f91947e 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1977,22 +1977,6 @@ dwarf2_has_info (struct objfile *objfile, && per_objfile->per_bfd->abbrev.s.section != NULL); } -/* When loading sections, we look either for uncompressed section or for - compressed section names. */ - -static int -section_is_p (const char *section_name, - const struct dwarf2_section_names *names) -{ - if (names->normal != NULL - && strcmp (section_name, names->normal) == 0) - return 1; - if (names->compressed != NULL - && strcmp (section_name, names->compressed) == 0) - return 1; - return 0; -} - /* See declaration. */ void @@ -2013,82 +1997,82 @@ dwarf2_per_bfd::locate_sections (bfd *abfd, asection *sectp, bfd_section_name (sectp), phex_nz (size, sizeof (size)), bfd_get_filename (abfd)); } - else if (section_is_p (sectp->name, &names.info)) + else if (names.info.matches (sectp->name)) { this->info.s.section = sectp; this->info.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.abbrev)) + else if (names.abbrev.matches (sectp->name)) { this->abbrev.s.section = sectp; this->abbrev.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.line)) + else if (names.line.matches (sectp->name)) { this->line.s.section = sectp; this->line.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.loc)) + else if (names.loc.matches (sectp->name)) { this->loc.s.section = sectp; this->loc.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.loclists)) + else if (names.loclists.matches (sectp->name)) { this->loclists.s.section = sectp; this->loclists.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.macinfo)) + else if (names.macinfo.matches (sectp->name)) { this->macinfo.s.section = sectp; this->macinfo.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.macro)) + else if (names.macro.matches (sectp->name)) { this->macro.s.section = sectp; this->macro.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.str)) + else if (names.str.matches (sectp->name)) { this->str.s.section = sectp; this->str.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.str_offsets)) + else if (names.str_offsets.matches (sectp->name)) { this->str_offsets.s.section = sectp; this->str_offsets.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.line_str)) + else if (names.line_str.matches (sectp->name)) { this->line_str.s.section = sectp; this->line_str.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.addr)) + else if (names.addr.matches (sectp->name)) { this->addr.s.section = sectp; this->addr.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.frame)) + else if (names.frame.matches (sectp->name)) { this->frame.s.section = sectp; this->frame.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.eh_frame)) + else if (names.eh_frame.matches (sectp->name)) { this->eh_frame.s.section = sectp; this->eh_frame.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.ranges)) + else if (names.ranges.matches (sectp->name)) { this->ranges.s.section = sectp; this->ranges.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.rnglists)) + else if (names.rnglists.matches (sectp->name)) { this->rnglists.s.section = sectp; this->rnglists.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.types)) + else if (names.types.matches (sectp->name)) { struct dwarf2_section_info type_section; @@ -2098,17 +2082,17 @@ dwarf2_per_bfd::locate_sections (bfd *abfd, asection *sectp, this->types.push_back (type_section); } - else if (section_is_p (sectp->name, &names.gdb_index)) + else if (names.gdb_index.matches (sectp->name)) { this->gdb_index.s.section = sectp; this->gdb_index.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.debug_names)) + else if (names.debug_names.matches (sectp->name)) { this->debug_names.s.section = sectp; this->debug_names.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names.debug_aranges)) + else if (names.debug_aranges.matches (sectp->name)) { this->debug_aranges.s.section = sectp; this->debug_aranges.size = bfd_section_size (sectp); @@ -2166,37 +2150,37 @@ locate_dwz_sections (bfd *abfd, asection *sectp, dwz_file *dwz_file) { /* Note that we only support the standard ELF names, because .dwz is ELF-only (at the time of writing). */ - if (section_is_p (sectp->name, &dwarf2_elf_names.abbrev)) + if (dwarf2_elf_names.abbrev.matches (sectp->name)) { dwz_file->abbrev.s.section = sectp; dwz_file->abbrev.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &dwarf2_elf_names.info)) + else if (dwarf2_elf_names.info.matches (sectp->name)) { dwz_file->info.s.section = sectp; dwz_file->info.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &dwarf2_elf_names.str)) + else if (dwarf2_elf_names.str.matches (sectp->name)) { dwz_file->str.s.section = sectp; dwz_file->str.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &dwarf2_elf_names.line)) + else if (dwarf2_elf_names.line.matches (sectp->name)) { dwz_file->line.s.section = sectp; dwz_file->line.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &dwarf2_elf_names.macro)) + else if (dwarf2_elf_names.macro.matches (sectp->name)) { dwz_file->macro.s.section = sectp; dwz_file->macro.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &dwarf2_elf_names.gdb_index)) + else if (dwarf2_elf_names.gdb_index.matches (sectp->name)) { dwz_file->gdb_index.s.section = sectp; dwz_file->gdb_index.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &dwarf2_elf_names.debug_names)) + else if (dwarf2_elf_names.debug_names.matches (sectp->name)) { dwz_file->debug_names.s.section = sectp; dwz_file->debug_names.size = bfd_section_size (sectp); @@ -12069,7 +12053,7 @@ locate_v1_virtual_dwo_sections (asection *sectp, { const struct dwop_section_names *names = &dwop_section_names; - if (section_is_p (sectp->name, &names->abbrev_dwo)) + if (names->abbrev_dwo.matches (sectp->name)) { /* There can be only one. */ if (sections->abbrev.s.section != NULL) @@ -12077,8 +12061,8 @@ locate_v1_virtual_dwo_sections (asection *sectp, sections->abbrev.s.section = sectp; sections->abbrev.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->info_dwo) - || section_is_p (sectp->name, &names->types_dwo)) + else if (names->info_dwo.matches (sectp->name) + || names->types_dwo.matches (sectp->name)) { /* There can be only one. */ if (sections->info_or_types.s.section != NULL) @@ -12086,7 +12070,7 @@ locate_v1_virtual_dwo_sections (asection *sectp, sections->info_or_types.s.section = sectp; sections->info_or_types.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->line_dwo)) + else if (names->line_dwo.matches (sectp->name)) { /* There can be only one. */ if (sections->line.s.section != NULL) @@ -12094,7 +12078,7 @@ locate_v1_virtual_dwo_sections (asection *sectp, sections->line.s.section = sectp; sections->line.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->loc_dwo)) + else if (names->loc_dwo.matches (sectp->name)) { /* There can be only one. */ if (sections->loc.s.section != NULL) @@ -12102,7 +12086,7 @@ locate_v1_virtual_dwo_sections (asection *sectp, sections->loc.s.section = sectp; sections->loc.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->macinfo_dwo)) + else if (names->macinfo_dwo.matches (sectp->name)) { /* There can be only one. */ if (sections->macinfo.s.section != NULL) @@ -12110,7 +12094,7 @@ locate_v1_virtual_dwo_sections (asection *sectp, sections->macinfo.s.section = sectp; sections->macinfo.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->macro_dwo)) + else if (names->macro_dwo.matches (sectp->name)) { /* There can be only one. */ if (sections->macro.s.section != NULL) @@ -12118,7 +12102,7 @@ locate_v1_virtual_dwo_sections (asection *sectp, sections->macro.s.section = sectp; sections->macro.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->str_offsets_dwo)) + else if (names->str_offsets_dwo.matches (sectp->name)) { /* There can be only one. */ if (sections->str_offsets.s.section != NULL) @@ -12853,57 +12837,57 @@ dwarf2_locate_dwo_sections (bfd *abfd, asection *sectp, { const struct dwop_section_names *names = &dwop_section_names; - if (section_is_p (sectp->name, &names->abbrev_dwo)) + if (names->abbrev_dwo.matches (sectp->name)) { dwo_sections->abbrev.s.section = sectp; dwo_sections->abbrev.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->info_dwo)) + else if (names->info_dwo.matches (sectp->name)) { dwo_sections->info.s.section = sectp; dwo_sections->info.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->line_dwo)) + else if (names->line_dwo.matches (sectp->name)) { dwo_sections->line.s.section = sectp; dwo_sections->line.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->loc_dwo)) + else if (names->loc_dwo.matches (sectp->name)) { dwo_sections->loc.s.section = sectp; dwo_sections->loc.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->loclists_dwo)) + else if (names->loclists_dwo.matches (sectp->name)) { dwo_sections->loclists.s.section = sectp; dwo_sections->loclists.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->macinfo_dwo)) + else if (names->macinfo_dwo.matches (sectp->name)) { dwo_sections->macinfo.s.section = sectp; dwo_sections->macinfo.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->macro_dwo)) + else if (names->macro_dwo.matches (sectp->name)) { dwo_sections->macro.s.section = sectp; dwo_sections->macro.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->rnglists_dwo)) + else if (names->rnglists_dwo.matches (sectp->name)) { dwo_sections->rnglists.s.section = sectp; dwo_sections->rnglists.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->str_dwo)) + else if (names->str_dwo.matches (sectp->name)) { dwo_sections->str.s.section = sectp; dwo_sections->str.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->str_offsets_dwo)) + 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); } - else if (section_is_p (sectp->name, &names->types_dwo)) + else if (names->types_dwo.matches (sectp->name)) { struct dwarf2_section_info type_section; @@ -12978,17 +12962,17 @@ dwarf2_locate_common_dwp_sections (bfd *abfd, asection *sectp, dwp_file->elf_sections[elf_section_nr] = sectp; /* Look for specific sections that we need. */ - if (section_is_p (sectp->name, &names->str_dwo)) + if (names->str_dwo.matches (sectp->name)) { dwp_file->sections.str.s.section = sectp; dwp_file->sections.str.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->cu_index)) + 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); } - else if (section_is_p (sectp->name, &names->tu_index)) + else if (names->tu_index.matches (sectp->name)) { dwp_file->sections.tu_index.s.section = sectp; dwp_file->sections.tu_index.size = bfd_section_size (sectp); @@ -13013,42 +12997,42 @@ 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. */ - if (section_is_p (sectp->name, &names->abbrev_dwo)) + if (names->abbrev_dwo.matches (sectp->name)) { dwp_file->sections.abbrev.s.section = sectp; dwp_file->sections.abbrev.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->info_dwo)) + else if (names->info_dwo.matches (sectp->name)) { dwp_file->sections.info.s.section = sectp; dwp_file->sections.info.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->line_dwo)) + else if (names->line_dwo.matches (sectp->name)) { dwp_file->sections.line.s.section = sectp; dwp_file->sections.line.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->loc_dwo)) + else if (names->loc_dwo.matches (sectp->name)) { dwp_file->sections.loc.s.section = sectp; dwp_file->sections.loc.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->macinfo_dwo)) + else if (names->macinfo_dwo.matches (sectp->name)) { dwp_file->sections.macinfo.s.section = sectp; dwp_file->sections.macinfo.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->macro_dwo)) + else if (names->macro_dwo.matches (sectp->name)) { dwp_file->sections.macro.s.section = sectp; dwp_file->sections.macro.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->str_offsets_dwo)) + 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); } - else if (section_is_p (sectp->name, &names->types_dwo)) + else if (names->types_dwo.matches (sectp->name)) { dwp_file->sections.types.s.section = sectp; dwp_file->sections.types.size = bfd_section_size (sectp); @@ -13073,37 +13057,37 @@ 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. */ - if (section_is_p (sectp->name, &names->abbrev_dwo)) + if (names->abbrev_dwo.matches (sectp->name)) { dwp_file->sections.abbrev.s.section = sectp; dwp_file->sections.abbrev.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->info_dwo)) + else if (names->info_dwo.matches (sectp->name)) { dwp_file->sections.info.s.section = sectp; dwp_file->sections.info.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->line_dwo)) + else if (names->line_dwo.matches (sectp->name)) { dwp_file->sections.line.s.section = sectp; dwp_file->sections.line.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->loclists_dwo)) + else if (names->loclists_dwo.matches (sectp->name)) { dwp_file->sections.loclists.s.section = sectp; dwp_file->sections.loclists.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->macro_dwo)) + else if (names->macro_dwo.matches (sectp->name)) { dwp_file->sections.macro.s.section = sectp; dwp_file->sections.macro.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->rnglists_dwo)) + else if (names->rnglists_dwo.matches (sectp->name)) { dwp_file->sections.rnglists.s.section = sectp; dwp_file->sections.rnglists.size = bfd_section_size (sectp); } - else if (section_is_p (sectp->name, &names->str_offsets_dwo)) + 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); diff --git a/gdb/dwarf2/sect-names.h b/gdb/dwarf2/sect-names.h index 63cf2cafef7..b75328358c2 100644 --- a/gdb/dwarf2/sect-names.h +++ b/gdb/dwarf2/sect-names.h @@ -31,6 +31,13 @@ struct dwarf2_section_names { const char *normal; const char *compressed; + + /* Return true if NAME matches either of this section's names. */ + bool matches (const char *name) const + { + return ((normal != nullptr && strcmp (name, normal) == 0) + || (compressed != nullptr && strcmp (name, compressed) == 0)); + } }; /* List of names for dward2 debugging sections. Also most object file formats -- 2.26.2