From patchwork Tue Feb 14 20:23:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 65020 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C7D96385B51C for ; Tue, 14 Feb 2023 20:24:32 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id BBC2D3858C62 for ; Tue, 14 Feb 2023 20:23:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BBC2D3858C62 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id 36CB31004852F for ; Tue, 14 Feb 2023 20:23:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id S1q1pAYapaJXNS1q1pQePq; Tue, 14 Feb 2023 20:23:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=ZpQol/3G c=1 sm=1 tr=0 ts=63ebedcd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=m04uMKEZRckA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=Fg_Ay7aQO5oJo26YExYA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc: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=LpvzDYATo5mEsZbRNGG/g9WPYGwvsZLPGS9uINVGbTg=; b=cpBmWfWPkeokoMZ9ElYXDKRkMr qgPp7ZESOzDw5OMXOtSC78h0jAlEJFm5JvTIC01jfZyD4ZJ1/zQN9bKGbUUWxxlt/eThsWzX9aT8L 6Zyd6gutPbwHR8W4e4gfPLJpZ; Received: from 75-166-130-93.hlrn.qwest.net ([75.166.130.93]:49794 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pS1q1-002zny-11 for gdb-patches@sourceware.org; Tue, 14 Feb 2023 13:23:41 -0700 From: Tom Tromey Date: Tue, 14 Feb 2023 13:23:36 -0700 Subject: [PATCH 6/6] Return bool from more value methods MIME-Version: 1.0 Message-Id: <20230214-submit-more-value-stuff-v1-6-2fb85efbaa72@tromey.com> References: <20230214-submit-more-value-stuff-v1-0-2fb85efbaa72@tromey.com> In-Reply-To: <20230214-submit-more-value-stuff-v1-0-2fb85efbaa72@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.0 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: 75.166.130.93 X-Source-L: No X-Exim-ID: 1pS1q1-002zny-11 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-130-93.hlrn.qwest.net ([192.168.0.21]) [75.166.130.93]:49794 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" There are several more value methods that currently return 'int' but that should return 'bool'. This patch updates these. --- gdb/value.c | 30 +++++++++++++++--------------- gdb/value.h | 22 +++++++++++----------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index 9e561e28551..1943ef06321 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -69,7 +69,7 @@ struct internal_function /* Returns true if the ranges defined by [offset1, offset1+len1) and [offset2, offset2+len2) overlap. */ -static int +static bool ranges_overlap (LONGEST offset1, ULONGEST len1, LONGEST offset2, ULONGEST len2) { @@ -83,7 +83,7 @@ ranges_overlap (LONGEST offset1, ULONGEST len1, /* Returns true if RANGES contains any range that overlaps [OFFSET, OFFSET+LENGTH). */ -static int +static bool ranges_contain (const std::vector &ranges, LONGEST offset, ULONGEST length) { @@ -131,7 +131,7 @@ ranges_contain (const std::vector &ranges, LONGEST offset, const struct range &bef = *(i - 1); if (ranges_overlap (bef.offset, bef.length, offset, length)) - return 1; + return true; } if (i < ranges.end ()) @@ -139,10 +139,10 @@ ranges_contain (const std::vector &ranges, LONGEST offset, const struct range &r = *i; if (ranges_overlap (r.offset, r.length, offset, length)) - return 1; + return true; } - return 0; + return false; } static struct cmd_list_element *functionlist; @@ -168,7 +168,7 @@ value::arch () const return type ()->arch (); } -int +bool value::bits_available (LONGEST offset, ULONGEST length) const { gdb_assert (!m_lazy); @@ -182,7 +182,7 @@ value::bits_available (LONGEST offset, ULONGEST length) const || ranges_contain (m_unavailable, offset, length)); } -int +bool value::bytes_available (LONGEST offset, ULONGEST length) const { ULONGEST sign = (1ULL << (sizeof (ULONGEST) * 8 - 1)) / TARGET_CHAR_BIT; @@ -196,7 +196,7 @@ value::bytes_available (LONGEST offset, ULONGEST length) const return bits_available (offset * TARGET_CHAR_BIT, length * TARGET_CHAR_BIT); } -int +bool value::bits_any_optimized_out (int bit_offset, int bit_length) const { gdb_assert (!m_lazy); @@ -204,7 +204,7 @@ value::bits_any_optimized_out (int bit_offset, int bit_length) const return ranges_contain (m_optimized_out, bit_offset, bit_length); } -int +bool value::entirely_available () { /* We can only tell whether the whole value is available when we try @@ -213,13 +213,13 @@ value::entirely_available () fetch_lazy (); if (m_unavailable.empty ()) - return 1; - return 0; + return true; + return false; } /* See value.h. */ -int +bool value::entirely_covered_by_range_vector (const std::vector &ranges) { /* We can only tell whether the whole value is optimized out / @@ -233,10 +233,10 @@ value::entirely_covered_by_range_vector (const std::vector &ranges) if (t.offset == 0 && t.length == TARGET_CHAR_BIT * enclosing_type ()->length ()) - return 1; + return true; } - return 0; + return false; } /* Insert into the vector pointed to by VECTORP the bit range starting of @@ -1255,7 +1255,7 @@ value::contents_writeable () return contents_raw (); } -int +bool value::optimized_out () { if (m_lazy) diff --git a/gdb/value.h b/gdb/value.h index 5536e00332e..f2a4907ab81 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -487,23 +487,23 @@ struct value /* Given a value, determine whether the contents bytes starting at OFFSET and extending for LENGTH bytes are available. This returns - nonzero if all bytes in the given range are available, zero if any + true if all bytes in the given range are available, false if any byte is unavailable. */ - int bytes_available (LONGEST offset, ULONGEST length) const; + bool bytes_available (LONGEST offset, ULONGEST length) const; /* Given a value, determine whether the contents bits starting at OFFSET and extending for LENGTH bits are available. This returns - nonzero if all bits in the given range are available, zero if any + true if all bits in the given range are available, false if any bit is unavailable. */ - int bits_available (LONGEST offset, ULONGEST length) const; + bool bits_available (LONGEST offset, ULONGEST length) const; /* Like bytes_available, but return false if any byte in the whole object is unavailable. */ - int entirely_available (); + bool entirely_available (); /* Like entirely_available, but return false if any byte in the whole object is available. */ - int entirely_unavailable () + bool entirely_unavailable () { return entirely_covered_by_range_vector (m_unavailable); } /* Mark this value's content bytes starting at OFFSET and extending @@ -514,19 +514,19 @@ struct value for LENGTH bits as unavailable. */ void mark_bits_unavailable (LONGEST offset, ULONGEST length); - /* If nonzero, this is the value of a variable which does not actually + /* If true, this is the value of a variable which does not actually exist in the program, at least partially. If the value is lazy, this may fetch it now. */ - int optimized_out (); + bool optimized_out (); /* Given a value, return true if any of the contents bits starting at OFFSET and extending for LENGTH bits is optimized out, false otherwise. */ - int bits_any_optimized_out (int bit_offset, int bit_length) const; + bool bits_any_optimized_out (int bit_offset, int bit_length) const; /* Like optimized_out, but return true iff the whole value is optimized out. */ - int entirely_optimized_out () + bool entirely_optimized_out () { return entirely_covered_by_range_vector (m_optimized_out); } @@ -829,7 +829,7 @@ struct value /* Returns true if this value is entirely covered by RANGES. If the value is lazy, it'll be read now. Note that RANGE is a pointer to pointer because reading the value might change *RANGE. */ - int entirely_covered_by_range_vector (const std::vector &ranges); + bool entirely_covered_by_range_vector (const std::vector &ranges); /* Copy the ranges metadata from this value that overlaps [SRC_BIT_OFFSET, SRC_BIT_OFFSET+BIT_LENGTH) into DST,