From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 6D7C6385B835 for ; Mon, 30 Mar 2020 16:00:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6D7C6385B835 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id F18511E581; Mon, 30 Mar 2020 12:00:29 -0400 (EDT) Subject: Re: [PATCH 16/20] Change is_valid_DW_AT_defaulted to a method on attribute To: Tom Tromey , gdb-patches@sourceware.org References: <20200328192208.11324-1-tom@tromey.com> <20200328192208.11324-17-tom@tromey.com> From: Simon Marchi Message-ID: Date: Mon, 30 Mar 2020 12:00:29 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200328192208.11324-17-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US-large Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-25.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, 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: Mon, 30 Mar 2020 16:00:31 -0000 On 2020-03-28 3:22 p.m., Tom Tromey wrote: > 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; I don't quite understand the logic here, we check form_is_constant after having called constant_value? If the form is not a constant, shouldn't we emit a warning to that effect (and return _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; > + > There's an extra empty line here, might as well remove it. Simon