From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway24.websitewelcome.com (gateway24.websitewelcome.com [192.185.51.196]) by sourceware.org (Postfix) with ESMTPS id 73A08385E013 for ; Sat, 28 Mar 2020 19:22:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 73A08385E013 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 gateway24.websitewelcome.com (Postfix) with ESMTP id 2C187404E for ; Sat, 28 Mar 2020 14:22:13 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id IH25joCNX8vkBIH25jdffo; 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=HX7+fQVzGRqXDWPEbZuUJxKLEVdgWLJk7DO0+dysT+k=; b=QEUkfEWPyd/1I9CMijuoChW8Oy 81iieNQZ1sr4Q6knZFeutq5z6skN15UozvumYkATbGaAbS3K1iOHWerrF6U1HQBx5aYYzxbE89OoL oB1ZeMnvb35vS9Yn+btij+pN4; 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 1jIH24-003oZR-VJ; Sat, 28 Mar 2020 13:22:13 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 14/20] Change how accessibility is handled in dwarf2/read.c Date: Sat, 28 Mar 2020 13:22:02 -0600 Message-Id: <20200328192208.11324-15-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: 1jIH24-003oZR-VJ 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: 17 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-21.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: Sat, 28 Mar 2020 19:22:16 -0000 dwarf2/read.c uses dwarf2_default_access_attribute to check for the default access attribute. This patch simplifies the code by moving more of the access processing into this function, changing its name to reflect the difference. This also ensures that the attribute's form is respected, by changing to code to use the constant_value method. gdb/ChangeLog 2020-03-28 Tom Tromey * dwarf2/read.c (dwarf2_access_attribute): Rename from dwarf2_default_access_attribute. Look up attribute. (dwarf2_add_field, dwarf2_add_type_defn, dwarf2_add_member_fn): Update. --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2/read.c | 38 +++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d3897ac2198..efa59fcab4d 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -14001,12 +14001,24 @@ producer_is_codewarrior (struct dwarf2_cu *cu) return cu->producer_is_codewarrior; } -/* Return the default accessibility type if it is not overridden by +/* Return the accessibility type if it is not overridden by DW_AT_accessibility. */ static enum dwarf_access_attribute -dwarf2_default_access_attribute (struct die_info *die, struct dwarf2_cu *cu) +dwarf2_access_attribute (struct die_info *die, struct dwarf2_cu *cu) { + attribute *attr = dwarf2_attr (die, DW_AT_accessibility, cu); + if (attr != nullptr) + { + LONGEST value = attr->constant_value (-1); + if (value == DW_ACCESS_public + || value == DW_ACCESS_protected + || value == DW_ACCESS_private) + return (dwarf_access_attribute) value; + complaint (_("Unhandled DW_AT_accessibility value (%s)"), + plongest (value)); + } + if (cu->header.version < 3 || producer_is_gxx_lt_4_6 (cu)) { /* The default DWARF 2 accessibility for members is public, the default @@ -14089,11 +14101,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, new_field = &fip->fields.back (); } - attr = dwarf2_attr (die, DW_AT_accessibility, cu); - if (attr != nullptr) - new_field->accessibility = DW_UNSND (attr); - else - new_field->accessibility = dwarf2_default_access_attribute (die, cu); + new_field->accessibility = dwarf2_access_attribute (die, cu); if (new_field->accessibility != DW_ACCESS_public) fip->non_public_fields = 1; @@ -14315,12 +14323,7 @@ dwarf2_add_type_defn (struct field_info *fip, struct die_info *die, fp.type = read_type_die (die, cu); /* Save accessibility. */ - enum dwarf_access_attribute accessibility; - struct attribute *attr = dwarf2_attr (die, DW_AT_accessibility, cu); - if (attr != NULL) - accessibility = (enum dwarf_access_attribute) DW_UNSND (attr); - else - accessibility = dwarf2_default_access_attribute (die, cu); + dwarf_access_attribute accessibility = dwarf2_access_attribute (die, cu); switch (accessibility) { case DW_ACCESS_public: @@ -14332,8 +14335,6 @@ dwarf2_add_type_defn (struct field_info *fip, struct die_info *die, case DW_ACCESS_protected: fp.is_protected = 1; break; - default: - complaint (_("Unhandled DW_AT_accessibility value (%x)"), accessibility); } if (die->tag == DW_TAG_typedef) @@ -14510,7 +14511,6 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, struct fn_field *fnp; const char *fieldname; struct type *this_type; - enum dwarf_access_attribute accessibility; if (cu->language == language_ada) error (_("unexpected member function in Ada type")); @@ -14589,11 +14589,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, is_volatile is irrelevant, as it is needed by gdb_mangle_name only. */ /* Get accessibility. */ - attr = dwarf2_attr (die, DW_AT_accessibility, cu); - if (attr != nullptr) - accessibility = (enum dwarf_access_attribute) DW_UNSND (attr); - else - accessibility = dwarf2_default_access_attribute (die, cu); + dwarf_access_attribute accessibility = dwarf2_access_attribute (die, cu); switch (accessibility) { case DW_ACCESS_private: -- 2.17.2