From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway21.websitewelcome.com (gateway21.websitewelcome.com [192.185.45.140]) by sourceware.org (Postfix) with ESMTPS id 138353857C73 for ; Thu, 4 Nov 2021 18:09:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 138353857C73 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 cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 98C46400CC009 for ; Thu, 4 Nov 2021 13:09:09 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id ihAjmyQ7VOnCIihAjmbH9e; Thu, 04 Nov 2021 13:09:09 -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=FnrBEhTC+08P1dATqT+fQvTqd/j8c7tKfDqAeV3XEFk=; b=Z3yTltkSAxZqlJ0RKie/rIii9E ZbmfQglmIlz8D3bRZwtIrBPuyukmr32LztbGpY8UNgrCML++Q2b5HfFLPgOzWIwYs/r+yaKRVLYBP LP+PcW+32o+21HZ/vHjgSSXv1; Received: from 75-166-134-234.hlrn.qwest.net ([75.166.134.234]:51956 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 1mihAj-003Gss-8A; Thu, 04 Nov 2021 12:09:09 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 02/32] Split create_addrmap_from_aranges Date: Thu, 4 Nov 2021 12:08:37 -0600 Message-Id: <20211104180907.2360627-3-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211104180907.2360627-1-tom@tromey.com> References: <20211104180907.2360627-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: 75.166.134.234 X-Source-L: No X-Exim-ID: 1mihAj-003Gss-8A X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-134-234.hlrn.qwest.net (localhost.localdomain) [75.166.134.234]:51956 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3031.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: Thu, 04 Nov 2021 18:09:11 -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 48fb55c308c..ffa62b645aa 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2595,12 +2595,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; @@ -2608,9 +2610,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> @@ -2631,7 +2630,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; } } @@ -2662,7 +2661,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. */ @@ -2674,7 +2673,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 @@ -2690,7 +2689,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; @@ -2701,7 +2700,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++; @@ -2713,7 +2712,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 @@ -2734,7 +2733,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); @@ -2758,8 +2757,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