From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway22.websitewelcome.com (gateway22.websitewelcome.com [192.185.47.100]) by sourceware.org (Postfix) with ESMTPS id B5A923858C39 for ; Sat, 4 Dec 2021 20:38:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B5A923858C39 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 cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 4C920335E1 for ; Sat, 4 Dec 2021 14:38:47 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id tbnzmobEMlpqdtbnzmUx1b; Sat, 04 Dec 2021 14:38:47 -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=i9HnuGuPYBXtQm2SqSWJ83VPiK+3pY/roUkzWRT2cb4=; b=jcxCQh3GOwb5MEr4+7pQbXnHRH sMxtbwBGVoHUTeDfXxDowpViik8GLs+qFHlrdWucWIKVGnhoEw4KC1zQG0Q6BQnPE/8Ic0By3LEGF Tue3fJbdLQHJFnPF0bUY4VymR; Received: from 97-122-84-67.hlrn.qwest.net ([97.122.84.67]:51986 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 1mtbny-000epk-Qd; Sat, 04 Dec 2021 13:38:46 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v3 01/33] Split create_addrmap_from_aranges Date: Sat, 4 Dec 2021 13:38:12 -0700 Message-Id: <20211204203844.1188999-2-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211204203844.1188999-1-tom@tromey.com> References: <20211204203844.1188999-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.84.67 X-Source-L: No X-Exim-ID: 1mtbny-000epk-Qd X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-84-67.hlrn.qwest.net (localhost.localdomain) [97.122.84.67]:51986 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3031.3 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.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: Sat, 04 Dec 2021 20:38:49 -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 ff5758eb0a4..ce579b1ed75 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2579,12 +2579,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; @@ -2592,9 +2594,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> @@ -2615,7 +2614,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; } } @@ -2646,7 +2645,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. */ @@ -2658,7 +2657,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 @@ -2674,7 +2673,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; @@ -2685,7 +2684,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++; @@ -2697,7 +2696,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 @@ -2718,7 +2717,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); @@ -2742,8 +2741,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