From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway31.websitewelcome.com (gateway31.websitewelcome.com [192.185.143.43]) by sourceware.org (Postfix) with ESMTPS id 99F6C389906D for ; Sat, 28 Mar 2020 19:22:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 99F6C389906D 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 cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 3A38F4C84A for ; Sat, 28 Mar 2020 14:22:12 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id IH24jFBWb1s2xIH24jw0l9; Sat, 28 Mar 2020 14:22:12 -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=cX2+KwSRllxzuZimSmCVTurYFctQMM8d5lkBfN7NBec=; b=Oz+ZPL+Tqh8mkZkpHd3ZOtSFXB wwhmFkVWm0KGXeqTcHfS/BwFr5gHJmMEeeaZKMHQZ1BwyovA4w47dKhdg8p4U08ycLD7GgGzG8le9 rBYpRm42LaMWUxuShYBfbh34H; 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 1jIH23-003oZR-Uh; Sat, 28 Mar 2020 13:22:12 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 09/20] Remove DW_SND Date: Sat, 28 Mar 2020 13:21:57 -0600 Message-Id: <20200328192208.11324-10-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: 1jIH23-003oZR-Uh 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: 12 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:14 -0000 This removes DW_SND in favor of accessors on struct attribute. These accessors check that the form is appropriate. gdb/ChangeLog 2020-03-28 Tom Tromey * dwarf2/read.c (get_alignment, read_array_order) (read_attribute_value, dwarf2_const_value_attr) (dump_die_shallow, dwarf2_fetch_constant_bytes): Update. * dwarf2/attribute.h (struct attribute) : New methods. (DW_SND): Remove. --- gdb/ChangeLog | 9 +++++++++ gdb/dwarf2/attribute.h | 16 +++++++++++++++- gdb/dwarf2/read.c | 20 ++++++++++++-------- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index 8a7aab84eb2..a08c5a13e44 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -65,6 +65,14 @@ struct attribute return u.signature; } + /* Return the signed value. The attribute must have the appropriate + form. */ + LONGEST get_signed () const + { + gdb_assert (form == DW_FORM_sdata || form == DW_FORM_implicit_const); + return u.snd; + } + /* Return non-zero if ATTR's value is a section offset --- classes lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise. You may use DW_UNSND (attr) to retrieve such offsets. @@ -154,6 +162,13 @@ struct attribute u.signature = signature; } + /* Set this attribute to a signed integer. */ + void set_signed (LONGEST snd) + { + gdb_assert (form == DW_FORM_sdata || form == DW_FORM_implicit_const); + u.snd = snd; + } + ENUM_BITFIELD(dwarf_attribute) name : 16; ENUM_BITFIELD(dwarf_form) form : 15; @@ -178,7 +193,6 @@ struct attribute /* Get at parts of an attribute structure. */ #define DW_UNSND(attr) ((attr)->u.unsnd) -#define DW_SND(attr) ((attr)->u.snd) #define DW_ADDR(attr) ((attr)->u.addr) #endif /* GDB_DWARF2_ATTRIBUTE_H */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index cecdc41a0eb..6eecf051c84 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -14812,7 +14812,7 @@ get_alignment (struct dwarf2_cu *cu, struct die_info *die) ULONGEST align; if (attr->form == DW_FORM_sdata) { - LONGEST val = DW_SND (attr); + LONGEST val = attr->get_signed (); if (val < 0) { complaint (_("DW_AT_alignment value must not be negative" @@ -15764,7 +15764,11 @@ read_array_order (struct die_info *die, struct dwarf2_cu *cu) attr = dwarf2_attr (die, DW_AT_ordering, cu); if (attr != nullptr) - return (enum dwarf_array_dim_ordering) DW_SND (attr); + { + LONGEST val = attr->constant_value (-1); + if (val == DW_ORD_row_major || val == DW_ORD_col_major) + return (enum dwarf_array_dim_ordering) val; + } /* GNU F77 is a special case, as at 08/2004 array type info is the opposite order to the dwarf2 specification, but data is still @@ -18474,7 +18478,7 @@ read_attribute_value (const struct die_reader_specs *reader, DW_UNSND (attr) = 1; break; case DW_FORM_sdata: - DW_SND (attr) = read_signed_leb128 (abfd, info_ptr, &bytes_read); + attr->set_signed (read_signed_leb128 (abfd, info_ptr, &bytes_read)); info_ptr += bytes_read; break; case DW_FORM_udata: @@ -18523,7 +18527,7 @@ read_attribute_value (const struct die_reader_specs *reader, info_ptr, need_reprocess); break; case DW_FORM_implicit_const: - DW_SND (attr) = implicit_const; + attr->set_signed (implicit_const); break; case DW_FORM_addrx: case DW_FORM_GNU_addr_index: @@ -20508,7 +20512,7 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type, case DW_FORM_sdata: case DW_FORM_implicit_const: - *value = DW_SND (attr); + *value = attr->get_signed (); break; case DW_FORM_udata: @@ -21373,7 +21377,6 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die) case DW_FORM_data4: case DW_FORM_data8: case DW_FORM_udata: - case DW_FORM_sdata: fprintf_unfiltered (f, "constant: %s", pulongest (DW_UNSND (&die->attrs[i]))); break; @@ -21411,9 +21414,10 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die) fprintf_unfiltered (f, "unexpected attribute form: DW_FORM_indirect"); break; + case DW_FORM_sdata: case DW_FORM_implicit_const: fprintf_unfiltered (f, "constant: %s", - plongest (DW_SND (&die->attrs[i]))); + plongest (die->attrs[i].get_signed ())); break; default: fprintf_unfiltered (f, "unsupported attribute form: %d.", @@ -21839,7 +21843,7 @@ dwarf2_fetch_constant_bytes (sect_offset sect_off, case DW_FORM_implicit_const: type = die_type (die, cu); result = write_constant_as_bytes (obstack, byte_order, - type, DW_SND (attr), len); + type, attr->get_signed (), len); break; case DW_FORM_udata: -- 2.17.2