From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway30.websitewelcome.com (gateway30.websitewelcome.com [192.185.149.4]) by sourceware.org (Postfix) with ESMTPS id 4F9323899083 for ; Sat, 28 Mar 2020 19:22:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4F9323899083 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 cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 957D52B37 for ; Sat, 28 Mar 2020 14:22:13 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id IH25jzbqQAGTXIH25jNzze; Sat, 28 Mar 2020 14:22:13 -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=RSfkSTvl0+r20P8I/MUcpcm1RV7DI8OdBJY5/fT/bnk=; b=ROEIzLeshNB7m5/TJHF9ERPnXH M4nMmzxhqJUNSCtltX4L1hp3XljfBZ8HKWC7bGsw5MhpEJcQt8FL6Yn8l1izUlcwelFGG123qEJRC KyqxbWuCUq1Mn3UC48SMhWvae; Received: from 97-118-117-21.hlrn.qwest.net ([97.118.117.21]:55190 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jIH25-003oZR-CE; Sat, 28 Mar 2020 13:22:13 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 16/20] Change is_valid_DW_AT_defaulted to a method on attribute Date: Sat, 28 Mar 2020 13:22:04 -0600 Message-Id: <20200328192208.11324-17-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200328192208.11324-1-tom@tromey.com> References: <20200328192208.11324-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: 1jIH25-003oZR-CE X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-117-21.hlrn.qwest.net (bapiya.Home) [97.118.117.21]:55190 X-Source-Auth: tom+tromey.com X-Email-Count: 19 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-21.3 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: Sat, 28 Mar 2020 19:22:17 -0000 This changes is_valid_DW_AT_defaulted to be a method on struct attribute. Now it correctly respects the form of the attribute. 2020-03-28 Tom Tromey * dwarf2/read.c (is_valid_DW_AT_defaulted): Move to attribute.c. (dwarf2_add_member_fn): Update. * dwarf2/attribute.h (struct attribute) : Declare. * dwarf2/attribute.c (attribute::defaulted): New method, from is_valid_DW_AT_defaulted. --- gdb/ChangeLog | 8 ++++++++ gdb/dwarf2/attribute.c | 21 +++++++++++++++++++++ gdb/dwarf2/attribute.h | 8 ++++++++ gdb/dwarf2/read.c | 23 ++--------------------- 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c index 94bedf6dbd3..ee5e6321bde 100644 --- a/gdb/dwarf2/attribute.c +++ b/gdb/dwarf2/attribute.c @@ -219,3 +219,24 @@ attribute::form_is_reprocessed () const || form == DW_FORM_addrx || form == DW_FORM_GNU_addr_index); } + +/* See attribute.h. */ + +dwarf_defaulted_attribute +attribute::defaulted () const +{ + LONGEST value = constant_value (-1); + + switch (value) + { + case DW_DEFAULTED_no: + case DW_DEFAULTED_in_class: + case DW_DEFAULTED_out_of_class: + return (dwarf_defaulted_attribute) value; + } + + if (form_is_constant ()) + complaint (_("unrecognized DW_AT_defaulted value (%s)"), + plongest (value)); + return DW_DEFAULTED_no; +} diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index 546156283b3..dce93b154a8 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -29,6 +29,7 @@ #include "dwarf2.h" #include "gdbtypes.h" +#include "gdbsupport/gdb_optional.h" /* Blocks are a bunch of untyped bytes. */ struct dwarf_block @@ -229,6 +230,13 @@ struct attribute return requires_reprocessing; } + /* Return the value as one of the recognized enum + dwarf_defaulted_attribute constants according to DWARF5 spec, + Table 7.24. If the value is incorrect, or if this attribute has + the wrong form, then a complaint is issued and DW_DEFAULTED_no is + returned. */ + dwarf_defaulted_attribute defaulted () const; + ENUM_BITFIELD(dwarf_attribute) name : 15; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index abeb0e1a4e9..ec4e6e2e3b4 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -14479,25 +14479,6 @@ dwarf2_is_constructor (struct die_info *die, struct dwarf2_cu *cu) && (type_name[len] == '\0' || type_name[len] == '<')); } -/* Check if the given VALUE is a recognized enum - dwarf_defaulted_attribute constant according to DWARF5 spec, - Table 7.24. */ - -static bool -is_valid_DW_AT_defaulted (ULONGEST value) -{ - switch (value) - { - case DW_DEFAULTED_no: - case DW_DEFAULTED_in_class: - case DW_DEFAULTED_out_of_class: - return true; - } - - complaint (_("unrecognized DW_AT_defaulted value (%s)"), pulongest (value)); - return false; -} - /* Add a member function to the proper fieldlist. */ static void @@ -14607,8 +14588,8 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, /* Check for defaulted methods. */ attr = dwarf2_attr (die, DW_AT_defaulted, cu); - if (attr != nullptr && is_valid_DW_AT_defaulted (DW_UNSND (attr))) - fnp->defaulted = (enum dwarf_defaulted_attribute) DW_UNSND (attr); + if (attr != nullptr) + fnp->defaulted = attr->defaulted (); /* Check for deleted methods. */ attr = dwarf2_attr (die, DW_AT_deleted, cu); -- 2.17.2