From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway34.websitewelcome.com (gateway34.websitewelcome.com [192.185.148.231]) by sourceware.org (Postfix) with ESMTPS id 57CAE385E02B for ; Sun, 22 Mar 2020 18:45:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 57CAE385E02B 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 gateway34.websitewelcome.com (Postfix) with ESMTP id 067A712CF545 for ; Sun, 22 Mar 2020 13:45:29 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id G5bEjQ10pVQh0G5bFjeUVj; Sun, 22 Mar 2020 13:45:29 -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=vPDCzDa7z7Ld9ZB34/LokzErSa4/4pVVIQ4GgGbQBSs=; b=dS/PWtxyMKKz3/S/UEkQZl/XlZ R1A4g1zDA0vWWQ15m9KH1bcWBX09AbRkEquzlGU6yFTLy+2oCbVhbp4MmR9pYUUJINtv+8yIRKYkA I2W078tZm0FrbV8EpCsawXFhM; Received: from 97-118-117-21.hlrn.qwest.net ([97.118.117.21]:48304 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jG5bE-000LNS-QU; Sun, 22 Mar 2020 12:45:28 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 16/22] Remove dwarf2_cu::base_known Date: Sun, 22 Mar 2020 12:45:17 -0600 Message-Id: <20200322184523.28959-17-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200322184523.28959-1-tom@tromey.com> References: <20200322184523.28959-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: 97.118.117.21 X-Source-L: No X-Exim-ID: 1jG5bE-000LNS-QU X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-117-21.hlrn.qwest.net (bapiya.Home) [97.118.117.21]:48304 X-Source-Auth: tom+tromey.com X-Email-Count: 17 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-23.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, URIBL_CSS, URIBL_CSS_A 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: Sun, 22 Mar 2020 18:45:31 -0000 This removes dwarf2_cu::base_known, changing base_address to be a gdb::optional. gdb/ChangeLog 2020-03-22 Tom Tromey * dwarf2/read.c (struct dwarf2_cu) : Remove. : Now an optional. (dwarf2_find_base_address, dwarf2_rnglists_process) (dwarf2_ranges_process, fill_in_loclist_baton) (dwarf2_symbol_mark_computed): Update. --- gdb/ChangeLog | 8 ++++++++ gdb/dwarf2/read.c | 47 +++++++++++++++++------------------------------ 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 8b9b6bc3ea0..3479cd55a2e 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -393,10 +393,7 @@ struct dwarf2_cu struct comp_unit_head header {}; /* Base address of this compilation unit. */ - CORE_ADDR base_address = 0; - - /* Non-zero if base_address has been set. */ - int base_known = 0; + gdb::optional base_address; /* The language we are debugging. */ enum language language = language_unknown; @@ -5783,23 +5780,16 @@ dwarf2_find_base_address (struct die_info *die, struct dwarf2_cu *cu) { struct attribute *attr; - cu->base_known = 0; - cu->base_address = 0; + cu->base_address.reset (); attr = dwarf2_attr (die, DW_AT_entry_pc, cu); if (attr != nullptr) - { - cu->base_address = attr->value_as_address (); - cu->base_known = 1; - } + cu->base_address = attr->value_as_address (); else { attr = dwarf2_attr (die, DW_AT_low_pc, cu); if (attr != nullptr) - { - cu->base_address = attr->value_as_address (); - cu->base_known = 1; - } + cu->base_address = attr->value_as_address (); } } @@ -13441,13 +13431,11 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, struct objfile *objfile = dwarf2_per_objfile->objfile; bfd *obfd = objfile->obfd; /* Base address selection entry. */ - CORE_ADDR base; - int found_base; + gdb::optional base; const gdb_byte *buffer; CORE_ADDR baseaddr; bool overflow = false; - found_base = cu->base_known; base = cu->base_address; dwarf2_per_objfile->rnglists.read (objfile); @@ -13486,7 +13474,6 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, break; } base = cu->header.read_address (obfd, buffer, &bytes_read); - found_base = 1; buffer += bytes_read; break; case DW_RLE_start_length: @@ -13544,7 +13531,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, if (rlet == DW_RLE_base_address) continue; - if (!found_base) + if (!base.has_value ()) { /* We have no valid base address for the ranges data. */ @@ -13563,8 +13550,8 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, if (range_beginning == range_end) continue; - range_beginning += base; - range_end += base; + range_beginning += *base; + range_end += *base; /* A not-uncommon case of bad debug info. Don't pollute the addrmap with bad data. */ @@ -13608,8 +13595,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, unsigned int addr_size = cu_header->addr_size; CORE_ADDR mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1)); /* Base address selection entry. */ - CORE_ADDR base; - int found_base; + gdb::optional base; unsigned int dummy; const gdb_byte *buffer; CORE_ADDR baseaddr; @@ -13617,7 +13603,6 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, if (cu_header->version >= 5) return dwarf2_rnglists_process (offset, cu, callback); - found_base = cu->base_known; base = cu->base_address; dwarf2_per_objfile->ranges.read (objfile); @@ -13654,11 +13639,10 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, /* If we found the largest possible address, then we already have the base address in range_end. */ base = range_end; - found_base = 1; continue; } - if (!found_base) + if (!base.has_value ()) { /* We have no valid base address for the ranges data. */ @@ -13677,8 +13661,8 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, if (range_beginning == range_end) continue; - range_beginning += base; - range_end += base; + range_beginning += *base; + range_end += *base; /* A not-uncommon case of bad debug info. Don't pollute the addrmap with bad data. */ @@ -22758,7 +22742,10 @@ fill_in_loclist_baton (struct dwarf2_cu *cu, don't run off the edge of the section. */ baton->size = section->size - DW_UNSND (attr); baton->data = section->buffer + DW_UNSND (attr); - baton->base_address = cu->base_address; + if (cu->base_address.has_value ()) + baton->base_address = *cu->base_address; + else + baton->base_address = 0; baton->from_dwo = cu->dwo_unit != NULL; } @@ -22783,7 +22770,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym, fill_in_loclist_baton (cu, baton, attr); - if (cu->base_known == 0) + if (!cu->base_address.has_value ()) complaint (_("Location list used without " "specifying the CU base address.")); -- 2.17.2