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 B17D1389906E for ; Sat, 28 Mar 2020 19:22:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B17D1389906E 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 cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 5BA9E288F2 for ; Sat, 28 Mar 2020 14:22:12 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id IH24jSoXREfyqIH24jQdBU; 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=9jdDVLb8/c8O1u4TxPGUpyA4AS3oRb0stvPStiL3Bgw=; b=guR7KSRKdTB0eCUiCjWsx2avYy D3qBPipCec3at9aZVp3XUIdi1oH/HZaB8RP3aU3SXU0CDUWcWviQytHg5s49rI4FvH9XluZnpY9j9 NhZdb9RHbiUA7J4BRuFfmfNp+; 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-51; Sat, 28 Mar 2020 13:22:12 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 10/20] Use setter for attribute's unsigned value Date: Sat, 28 Mar 2020 13:21:58 -0600 Message-Id: <20200328192208.11324-11-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-51 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: 13 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:15 -0000 This adds form_is_unsigned and an unsigned setter method to struct attribute, and updates the remaining code. Now DW_UNSND is no longer used as an lvalue. gdb/ChangeLog 2020-03-28 Tom Tromey * dwarf2/read.c (read_attribute_value): Update. * dwarf2/attribute.h (struct attribute) : New methods. * dwarf2/attribute.c (attribute::form_is_unsigned): New method. --- gdb/ChangeLog | 7 ++++++ gdb/dwarf2/attribute.c | 23 +++++++++++++++++++ gdb/dwarf2/attribute.h | 10 ++++++++ gdb/dwarf2/read.c | 52 +++++++++++++++++++++--------------------- 4 files changed, 66 insertions(+), 26 deletions(-) diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c index fdf202033e9..72ec13c11f9 100644 --- a/gdb/dwarf2/attribute.c +++ b/gdb/dwarf2/attribute.c @@ -183,3 +183,26 @@ attribute::constant_value (int default_value) const return default_value; } } + +/* See attribute.h. */ + +bool +attribute::form_is_unsigned () const +{ + return (form == DW_FORM_ref_addr + || form == DW_FORM_GNU_ref_alt + || form == DW_FORM_data2 + || form == DW_FORM_data4 + || form == DW_FORM_data8 + || form == DW_FORM_sec_offset + || form == DW_FORM_data1 + || form == DW_FORM_flag + || form == DW_FORM_flag_present + || form == DW_FORM_udata + || form == DW_FORM_rnglistx + || form == DW_FORM_ref1 + || form == DW_FORM_ref2 + || form == DW_FORM_ref4 + || form == DW_FORM_ref8 + || form == DW_FORM_ref_udata); +} diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index a08c5a13e44..0a4c8647f6e 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -115,6 +115,9 @@ struct attribute /* Check if the attribute's form is a string form. */ bool form_is_string () const; + /* Check if the attribute's form is an unsigned integer form. */ + bool form_is_unsigned () const; + /* Return DIE offset of this attribute. Return 0 with complaint if the attribute is not of the required kind. */ @@ -169,6 +172,13 @@ struct attribute u.snd = snd; } + /* Set this attribute to an unsigned integer. */ + void set_unsigned (ULONGEST unsnd) + { + gdb_assert (form_is_unsigned ()); + u.unsnd = unsnd; + } + ENUM_BITFIELD(dwarf_attribute) name : 16; ENUM_BITFIELD(dwarf_form) form : 15; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 6eecf051c84..75ac56efc02 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -18360,15 +18360,16 @@ read_attribute_value (const struct die_reader_specs *reader, { case DW_FORM_ref_addr: if (cu->header.version == 2) - DW_UNSND (attr) = cu->header.read_address (abfd, info_ptr, - &bytes_read); + attr->set_unsigned (cu->header.read_address (abfd, info_ptr, + &bytes_read)); else - DW_UNSND (attr) = cu->header.read_offset (abfd, info_ptr, - &bytes_read); + attr->set_unsigned (cu->header.read_offset (abfd, info_ptr, + &bytes_read)); info_ptr += bytes_read; break; case DW_FORM_GNU_ref_alt: - DW_UNSND (attr) = cu->header.read_offset (abfd, info_ptr, &bytes_read); + attr->set_unsigned (cu->header.read_offset (abfd, info_ptr, + &bytes_read)); info_ptr += bytes_read; break; case DW_FORM_addr: @@ -18393,15 +18394,15 @@ read_attribute_value (const struct die_reader_specs *reader, attr->set_block (blk); break; case DW_FORM_data2: - DW_UNSND (attr) = read_2_bytes (abfd, info_ptr); + attr->set_unsigned (read_2_bytes (abfd, info_ptr)); info_ptr += 2; break; case DW_FORM_data4: - DW_UNSND (attr) = read_4_bytes (abfd, info_ptr); + attr->set_unsigned (read_4_bytes (abfd, info_ptr)); info_ptr += 4; break; case DW_FORM_data8: - DW_UNSND (attr) = read_8_bytes (abfd, info_ptr); + attr->set_unsigned (read_8_bytes (abfd, info_ptr)); info_ptr += 8; break; case DW_FORM_data16: @@ -18412,7 +18413,8 @@ read_attribute_value (const struct die_reader_specs *reader, attr->set_block (blk); break; case DW_FORM_sec_offset: - DW_UNSND (attr) = cu->header.read_offset (abfd, info_ptr, &bytes_read); + attr->set_unsigned (cu->header.read_offset (abfd, info_ptr, + &bytes_read)); info_ptr += bytes_read; break; case DW_FORM_string: @@ -18467,15 +18469,12 @@ read_attribute_value (const struct die_reader_specs *reader, attr->set_block (blk); break; case DW_FORM_data1: - DW_UNSND (attr) = read_1_byte (abfd, info_ptr); - info_ptr += 1; - break; case DW_FORM_flag: - DW_UNSND (attr) = read_1_byte (abfd, info_ptr); + attr->set_unsigned (read_1_byte (abfd, info_ptr)); info_ptr += 1; break; case DW_FORM_flag_present: - DW_UNSND (attr) = 1; + attr->set_unsigned (1); break; case DW_FORM_sdata: attr->set_signed (read_signed_leb128 (abfd, info_ptr, &bytes_read)); @@ -18483,27 +18482,27 @@ read_attribute_value (const struct die_reader_specs *reader, break; case DW_FORM_udata: case DW_FORM_rnglistx: - DW_UNSND (attr) = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); + attr->set_unsigned (read_unsigned_leb128 (abfd, info_ptr, &bytes_read)); info_ptr += bytes_read; break; case DW_FORM_ref1: - DW_UNSND (attr) = (to_underlying (cu->header.sect_off) - + read_1_byte (abfd, info_ptr)); + attr->set_unsigned ((to_underlying (cu->header.sect_off) + + read_1_byte (abfd, info_ptr))); info_ptr += 1; break; case DW_FORM_ref2: - DW_UNSND (attr) = (to_underlying (cu->header.sect_off) - + read_2_bytes (abfd, info_ptr)); + attr->set_unsigned ((to_underlying (cu->header.sect_off) + + read_2_bytes (abfd, info_ptr))); info_ptr += 2; break; case DW_FORM_ref4: - DW_UNSND (attr) = (to_underlying (cu->header.sect_off) - + read_4_bytes (abfd, info_ptr)); + attr->set_unsigned ((to_underlying (cu->header.sect_off) + + read_4_bytes (abfd, info_ptr))); info_ptr += 4; break; case DW_FORM_ref8: - DW_UNSND (attr) = (to_underlying (cu->header.sect_off) - + read_8_bytes (abfd, info_ptr)); + attr->set_unsigned ((to_underlying (cu->header.sect_off) + + read_8_bytes (abfd, info_ptr))); info_ptr += 8; break; case DW_FORM_ref_sig8: @@ -18511,8 +18510,9 @@ read_attribute_value (const struct die_reader_specs *reader, info_ptr += 8; break; case DW_FORM_ref_udata: - DW_UNSND (attr) = (to_underlying (cu->header.sect_off) - + read_unsigned_leb128 (abfd, info_ptr, &bytes_read)); + attr->set_unsigned ((to_underlying (cu->header.sect_off) + + read_unsigned_leb128 (abfd, info_ptr, + &bytes_read))); info_ptr += bytes_read; break; case DW_FORM_indirect: @@ -18595,7 +18595,7 @@ read_attribute_value (const struct die_reader_specs *reader, complaint (_("Suspicious DW_AT_byte_size value treated as zero instead of %s"), hex_string (DW_UNSND (attr))); - DW_UNSND (attr) = 0; + attr->set_unsigned (0); } return info_ptr; -- 2.17.2