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 718D33858400 for ; Thu, 26 Aug 2021 02:19:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 718D33858400 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tromey.com Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 124CDDF51 for ; Wed, 25 Aug 2021 21:19:40 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id J4zTm2XUjLjoRJ4zUm3uW9; Wed, 25 Aug 2021 21:19:40 -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=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=htLs/+FfkVzcVTm6Os0YnQoMx4Jh7Fjlp2RxujbRNmU=; b=ZA2FteK/CMFfWMM//LUKcg2MxU ONHfiTSAXKGHt7jiU0YkTXP2uuSon07KRBFniHRhxUVA1MH2eEEfU10s/AaJdAC77V045MWuzg+kU QrPV70Pca81GE6WnpM/rmnTNo; Received: from 97-122-86-84.hlrn.qwest.net ([97.122.86.84]:46876 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mJ4zT-003LSg-PL; Wed, 25 Aug 2021 20:19:39 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 02/30] Split create_addrmap_from_aranges Date: Wed, 25 Aug 2021 20:19:09 -0600 Message-Id: <20210826021937.1490292-3-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210826021937.1490292-1-tom@tromey.com> References: <20210826021937.1490292-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.86.84 X-Source-L: No X-Exim-ID: 1mJ4zT-003LSg-PL X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-86-84.hlrn.qwest.net (localhost.localdomain) [97.122.86.84]:46876 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3030.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, URIBL_CSS_A 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: Thu, 26 Aug 2021 02:19:50 -0000 This patch splits create_addrmap_from_aranges into a wrapper function and a worker function. The worker function is then used in a later patch. --- gdb/dwarf2/read.c | 49 +++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 5385a3aff53..e418307ee99 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2581,12 +2581,14 @@ create_addrmap_from_index (dwarf2_per_objfile *per_objfile, &per_bfd->obstack); } -/* Read the address map data from DWARF-5 .debug_aranges, and use it to - populate the psymtabs_addrmap. */ +/* Read the address map data from DWARF-5 .debug_aranges, and use it + to populate given addrmap. Returns true on success, false on + failure. */ -static void -create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, - struct dwarf2_section_info *section) +static bool +read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, + struct dwarf2_section_info *section, + addrmap *mutable_map) { struct objfile *objfile = per_objfile->objfile; bfd *abfd = objfile->obfd; @@ -2594,9 +2596,6 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, 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); - std::unordered_map> @@ -2617,7 +2616,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, warning (_("Section .debug_aranges in %s has duplicate " "debug_info_offset %s, ignoring .debug_aranges."), objfile_name (objfile), sect_offset_str (per_cu->sect_off)); - return; + return false; } } @@ -2648,7 +2647,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, plongest (entry_addr - section->buffer), plongest (bytes_read + entry_length), pulongest (section->size)); - return; + return false; } /* The version number. */ @@ -2660,7 +2659,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, "has unsupported version %d, ignoring .debug_aranges."), objfile_name (objfile), plongest (entry_addr - section->buffer), version); - return; + return false; } const uint64_t debug_info_offset @@ -2676,7 +2675,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, objfile_name (objfile), plongest (entry_addr - section->buffer), pulongest (debug_info_offset)); - return; + return false; } dwarf2_per_cu_data *const per_cu = per_cu_it->second; @@ -2687,7 +2686,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, "address_size %u is invalid, ignoring .debug_aranges."), objfile_name (objfile), plongest (entry_addr - section->buffer), address_size); - return; + return false; } const uint8_t segment_selector_size = *addr++; @@ -2699,7 +2698,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, objfile_name (objfile), plongest (entry_addr - section->buffer), segment_selector_size); - return; + return false; } /* Must pad to an alignment boundary that is twice the address @@ -2720,7 +2719,7 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, "ignoring .debug_aranges."), objfile_name (objfile), plongest (entry_addr - section->buffer)); - return; + return false; } ULONGEST start = extract_unsigned_integer (addr, address_size, dwarf5_byte_order); @@ -2744,8 +2743,24 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, } } - per_bfd->index_addrmap = addrmap_create_fixed (mutable_map, - &per_bfd->obstack); + return true; +} + +/* Read the address map data from DWARF-5 .debug_aranges, and use it to + populate the psymtabs_addrmap. */ + +static void +create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, + struct dwarf2_section_info *section) +{ + dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; + + auto_obstack temp_obstack; + addrmap *mutable_map = addrmap_create_mutable (&temp_obstack); + + if (read_addrmap_from_aranges (per_objfile, section, mutable_map)) + per_bfd->index_addrmap = addrmap_create_fixed (mutable_map, + &per_bfd->obstack); } /* A helper function that reads the .gdb_index from BUFFER and fills -- 2.31.1