From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway33.websitewelcome.com (gateway33.websitewelcome.com [192.185.146.78]) by sourceware.org (Postfix) with ESMTPS id 4B08D3899079 for ; Sat, 28 Mar 2020 19:22:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4B08D3899079 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 cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway33.websitewelcome.com (Postfix) with ESMTP id EED01A65A75 for ; Sat, 28 Mar 2020 14:22:13 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id IH25joCNs8vkBIH25jdfgC; 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=nMhwx95gJzW1WTPp0wy9qPn/WBN+/tpVqNBJ/5MuD7U=; b=KozOqfPzBCg8vsSe0I9KOkyXhq 45ZL4mZLRSl5f4U8UrthKvu1in9ihXRQUG4eY1ui4xSpv57yy6h2psek83WVCRGoNVxl0N9MYqBUa Dusdy4T5vWrmHfx/FT+fBefdE; 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-PA; Sat, 28 Mar 2020 13:22:13 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 18/20] Add attribute::virtuality method Date: Sat, 28 Mar 2020 13:22:06 -0600 Message-Id: <20200328192208.11324-19-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-PA 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: 21 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:16 -0000 This adds a new attribute::virtuality method and changes the DWARF reader to use it. This also ensures that the attibute's form will now be respected. 2020-03-28 Tom Tromey * dwarf2/read.c (dwarf2_add_field, dwarf2_add_member_fn): Update. * dwarf2/attribute.h (struct attribute) : New method. * dwarf2/attribute.c (attribute::virtuality): New method. --- gdb/ChangeLog | 6 ++++++ gdb/dwarf2/attribute.c | 21 +++++++++++++++++++++ gdb/dwarf2/attribute.h | 5 +++++ gdb/dwarf2/read.c | 4 ++-- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c index ee5e6321bde..7f428279757 100644 --- a/gdb/dwarf2/attribute.c +++ b/gdb/dwarf2/attribute.c @@ -240,3 +240,24 @@ attribute::defaulted () const plongest (value)); return DW_DEFAULTED_no; } + +/* See attribute.h. */ + +dwarf_virtuality_attribute +attribute::virtuality () const +{ + LONGEST value = constant_value (-1); + + switch (value) + { + case DW_VIRTUALITY_none: + case DW_VIRTUALITY_virtual: + case DW_VIRTUALITY_pure_virtual: + return (dwarf_virtuality_attribute) value; + } + + if (form_is_constant ()) + complaint (_("unrecognized DW_AT_virtuality value (%s)"), + plongest (value)); + return DW_VIRTUALITY_none; +} diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index dce93b154a8..7c0ce1615cf 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -237,6 +237,11 @@ struct attribute returned. */ dwarf_defaulted_attribute defaulted () const; + /* Return the attribute's value as a dwarf_virtuality_attribute + constant according to DWARF spec. An unrecognized value will + issue a complaint and return DW_VIRTUALITY_none. */ + dwarf_virtuality_attribute virtuality () const; + ENUM_BITFIELD(dwarf_attribute) name : 15; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index ec4e6e2e3b4..66a508c95ea 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -14107,7 +14107,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, attr = dwarf2_attr (die, DW_AT_virtuality, cu); if (attr != nullptr) - new_field->virtuality = DW_UNSND (attr); + new_field->virtuality = attr->virtuality (); else new_field->virtuality = DW_VIRTUALITY_none; @@ -14661,7 +14661,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, else { attr = dwarf2_attr (die, DW_AT_virtuality, cu); - if (attr && DW_UNSND (attr)) + if (attr != nullptr && attr->virtuality () != DW_VIRTUALITY_none) { /* GCC does this, as of 2008-08-25; PR debug/37237. */ complaint (_("Member function \"%s\" (offset %s) is virtual " -- 2.17.2