From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway24.websitewelcome.com (gateway24.websitewelcome.com [192.185.50.91]) by sourceware.org (Postfix) with ESMTPS id 2924B385E024 for ; Sun, 22 Mar 2020 18:45:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2924B385E024 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 cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway24.websitewelcome.com (Postfix) with ESMTP id DA0A846241 for ; Sun, 22 Mar 2020 13:45:29 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id G5bFjJdRVXVkQG5bFjaDri; 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=MMBQIiCgH8nXBMl0Yf0azWXeenf7DKDzGMM1aonBhUk=; b=xOrU/dEx/omqqwwwJA4pElxn1w 9G3TgkjfiYfpLiom1qw7ictnpUybFedHMXVAR4Ko64z061FKbondyVRXuRWomPk6j0YDYJCirqsEt 7P8Rmgsb5oPDalETSVIgOKWPy; 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 1jG5bF-000LNS-MM; Sun, 22 Mar 2020 12:45:29 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 20/22] Rewrite new die_info methods Date: Sun, 22 Mar 2020 12:45:21 -0600 Message-Id: <20200322184523.28959-21-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: 1jG5bF-000LNS-MM 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: 21 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-22.9 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:33 -0000 This rewrites the two new die_info to iterate over attributes rather than to do two separate searches. gdb/ChangeLog 2020-03-22 Tom Tromey * dwarf2/die.h (struct die_info) : Rewrite. --- gdb/ChangeLog | 5 +++++ gdb/dwarf2/die.h | 30 ++++++++++++++++-------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/gdb/dwarf2/die.h b/gdb/dwarf2/die.h index 5673ae261ac..5522ebdf311 100644 --- a/gdb/dwarf2/die.h +++ b/gdb/dwarf2/die.h @@ -38,13 +38,14 @@ struct die_info DW_AT_addr_base. */ gdb::optional addr_base () { - struct attribute *attr; - attr = attr (DW_AT_addr_base); - if (attr == nullptr) - attr = attr (DW_AT_GNU_addr_base); - if (attr == nullptr) - return gdb::optional (); - return DW_UNSND (attr); + for (unsigned i = 0; i < num_attrs; ++i) + if (attrs[i].name == DW_AT_addr_base + || attrs[i].name == DW_AT_GNU_addr_base) + { + /* If both exist, just use the first one. */ + return DW_UNSND (&attrs[i]); + } + return gdb::optional (); } /* Return range lists base of the compile unit, which, if exists, is @@ -52,13 +53,14 @@ struct die_info DW_AT_GNU_ranges_base. */ ULONGEST ranges_base () { - struct attribute *attr; - attr = attr (DW_AT_rnglists_base); - if (attr == nullptr) - attr = attr (DW_AT_GNU_ranges_base); - if (attr == nullptr) - return 0; - return DW_UNSND (attr); + for (unsigned i = 0; i < num_attrs; ++i) + if (attrs[i].name == DW_AT_rnglists_base + || attrs[i].name == DW_AT_GNU_ranges_base) + { + /* If both exist, just use the first one. */ + return DW_UNSND (&attrs[i]); + } + return 0; } -- 2.17.2