From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id 9B5383858C53 for ; Mon, 4 Apr 2022 19:53:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9B5383858C53 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 06A0610048285 for ; Mon, 4 Apr 2022 19:53:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bSlfnVkjDY8ycbSlfn7Ziv; Mon, 04 Apr 2022 19:53:39 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=e+XD9Yl/ c=1 sm=1 tr=0 ts=624b4cc3 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=pH4bBhm7orczRVDYSjEA:9 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=D7q+IsFgjWxfCRNvdDOfROgOQmwGb/louCCRYRH+xbw=; b=SfiHL7xy1NdccJZjQMrtKptDIS D9RwTzaaEZQgt0YJUmZUwgWC8WbOns294AdHPldydnL8zuk1xDlcM4dx+kdcfduLBW+DKbXbj3syb WN1+xApgpaXuH8zvHNzmojANL; Received: from 71-211-176-135.hlrn.qwest.net ([71.211.176.135]:34798 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 1nbSlf-003u7z-3Z; Mon, 04 Apr 2022 13:53:39 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v4 02/34] Split create_addrmap_from_aranges Date: Mon, 4 Apr 2022 13:53:03 -0600 Message-Id: <20220404195335.2111906-3-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: 1nbSlf-003u7z-3Z X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-176-135.hlrn.qwest.net (prentzel.Home) [71.211.176.135]:34798 X-Source-Auth: tom+tromey.com X-Email-Count: 10 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, 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:42 -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 cb33171b1a9..fe6978af656 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.34.1