From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway23.websitewelcome.com (gateway23.websitewelcome.com [192.185.50.107]) by sourceware.org (Postfix) with ESMTPS id E607A3948495 for ; Fri, 28 Aug 2020 16:23:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E607A3948495 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 cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 88F47C4E6 for ; Fri, 28 Aug 2020 11:23:54 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id BhAQk8jcTXp2ABhAQkMgAC; Fri, 28 Aug 2020 11:23:54 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=JO3iQE8FLZkhe2Ytmdv6BETFH+igRTx3Ayca07daj50=; b=MIRiX8v2f3JQl4pN2f06bwJI8m cd5aiWxtTJEUwHZCRujCFEiAS1ovVUYqu1j4352c9VnejjAPnk5kIQK8sePOTE9Yc8gtanaNeXw6p AL/PFdJYGQioskNlBCm6HxsKA; Received: from 71-218-12-75.hlrn.qwest.net ([71.218.12.75]:33904 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kBhAQ-002WJo-9F; Fri, 28 Aug 2020 10:23:54 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 07/13] Use gdb_bfd_sections in dwarf2/read.c Date: Fri, 28 Aug 2020 10:23:43 -0600 Message-Id: <20200828162349.987-8-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200828162349.987-1-tom@tromey.com> References: <20200828162349.987-1-tom@tromey.com> 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.218.12.75 X-Source-L: No X-Exim-ID: 1kBhAQ-002WJo-9F X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-218-12-75.hlrn.qwest.net (bapiya.Home) [71.218.12.75]:33904 X-Source-Auth: tom+tromey.com X-Email-Count: 8 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3035.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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: Fri, 28 Aug 2020 16:23:56 -0000 This changes some functions in dwarf2/read.c to avoid bfd_map_over_sections, in favor of iteration. gdb/ChangeLog 2020-08-28 Tom Tromey * dwarf2/read.c (locate_dwz_sections): Change parameters. (dwarf2_get_dwz_file): Use foreach. (dwarf2_locate_dwo_sections): Change parameters. (open_and_init_dwo_file): Use foreach. (dwarf2_locate_common_dwp_sections): Change parameters. (open_and_init_dwp_file): Use foreach. --- gdb/ChangeLog | 9 +++++++++ gdb/dwarf2/read.c | 50 +++++++++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 0ac8533263a..1da71c48084 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2120,10 +2120,8 @@ dwarf2_get_section_info (struct objfile *objfile, /* A helper function to find the sections for a .dwz file. */ static void -locate_dwz_sections (bfd *abfd, asection *sectp, void *arg) +locate_dwz_sections (bfd *abfd, asection *sectp, dwz_file *dwz_file) { - struct dwz_file *dwz_file = (struct dwz_file *) arg; - /* 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)) @@ -2246,8 +2244,8 @@ dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd) std::unique_ptr result (new struct dwz_file (std::move (dwz_bfd))); - bfd_map_over_sections (result->dwz_bfd.get (), locate_dwz_sections, - result.get ()); + for (asection *sec : gdb_bfd_sections (result->dwz_bfd)) + locate_dwz_sections (result->dwz_bfd.get (), sec, result.get ()); gdb_bfd_record_inclusion (per_bfd->obfd, result->dwz_bfd.get ()); per_bfd->dwz_file = std::move (result); @@ -11923,9 +11921,9 @@ create_dwp_hash_table (dwarf2_per_objfile *per_objfile, /* Update SECTIONS with the data from SECTP. - This function is like the other "locate" section routines that are - passed to bfd_map_over_sections, but in this context the sections to - read comes from the DWP V1 hash table, not the full ELF section table. + This function is like the other "locate" section routines, but in + this context the sections to read comes from the DWP V1 hash table, + not the full ELF section table. The result is non-zero for success, or zero if an error was found. */ @@ -12738,9 +12736,9 @@ 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, void *dwo_sections_ptr) +dwarf2_locate_dwo_sections (bfd *abfd, asection *sectp, + dwo_sections *dwo_sections) { - struct dwo_sections *dwo_sections = (struct dwo_sections *) dwo_sections_ptr; const struct dwop_section_names *names = &dwop_section_names; if (section_is_p (sectp->name, &names->abbrev_dwo)) @@ -12827,8 +12825,9 @@ open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name, dwo_file->comp_dir = comp_dir; dwo_file->dbfd = std::move (dbfd); - bfd_map_over_sections (dwo_file->dbfd.get (), dwarf2_locate_dwo_sections, - &dwo_file->sections); + for (asection *sec : gdb_bfd_sections (dwo_file->dbfd)) + dwarf2_locate_dwo_sections (dwo_file->dbfd.get (), sec, + &dwo_file->sections); create_cus_hash_table (per_objfile, cu, *dwo_file, dwo_file->sections.info, dwo_file->cus); @@ -12857,9 +12856,8 @@ open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name, static void dwarf2_locate_common_dwp_sections (bfd *abfd, asection *sectp, - void *dwp_file_ptr) + dwp_file *dwp_file) { - struct dwp_file *dwp_file = (struct dwp_file *) dwp_file_ptr; const struct dwop_section_names *names = &dwop_section_names; unsigned int elf_section_nr = elf_section_data (sectp)->this_idx; @@ -13123,9 +13121,9 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile) OBSTACK_CALLOC (&per_objfile->per_bfd->obstack, dwp_file->num_sections, asection *); - bfd_map_over_sections (dwp_file->dbfd.get (), - dwarf2_locate_common_dwp_sections, - dwp_file.get ()); + for (asection *sec : gdb_bfd_sections (dwp_file->dbfd)) + dwarf2_locate_common_dwp_sections (dwp_file->dbfd.get (), sec, + dwp_file.get ()); dwp_file->cus = create_dwp_hash_table (per_objfile, dwp_file.get (), 0); @@ -13151,15 +13149,15 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile) else dwp_file->version = 2; - if (dwp_file->version == 2) - bfd_map_over_sections (dwp_file->dbfd.get (), - dwarf2_locate_v2_dwp_sections, - dwp_file.get ()); - else if (dwp_file->version == 5) - bfd_map_over_sections (dwp_file->dbfd.get (), - dwarf2_locate_v5_dwp_sections, - dwp_file.get ()); - + for (asection *sec : gdb_bfd_sections (dwp_file->dbfd)) + { + if (dwp_file->version == 2) + dwarf2_locate_v2_dwp_sections (dwp_file->dbfd.get (), sec, + dwp_file.get ()); + else + dwarf2_locate_v5_dwp_sections (dwp_file->dbfd.get (), sec, + dwp_file.get ()); + } dwp_file->loaded_cus = allocate_dwp_loaded_cutus_table (); dwp_file->loaded_tus = allocate_dwp_loaded_cutus_table (); -- 2.17.2