From patchwork Tue Feb 14 20:23:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 65015 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 B7896384F030 for ; Tue, 14 Feb 2023 20:23:59 +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 27B4A3858D33 for ; Tue, 14 Feb 2023 20:23:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27B4A3858D33 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 cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id 8C3B110048525 for ; Tue, 14 Feb 2023 20:23:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id S1q0pOO7NA1zNS1q0pAuVi; Tue, 14 Feb 2023 20:23:40 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=CqN6zl0D c=1 sm=1 tr=0 ts=63ebedcc 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=z-40141oyrumv8niXycA: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=TmoRWcfB8h6EAt+dUMENhwFliD+0nOQdWi5sDGdP3IE=; b=CL9hjaNdhHvmpvkUzz+LH76abc z1m3/1HErWQay8FDfFESzm4YloxkiUEQtd/oOrr9pol6V7qqWRMmwDRA++QXV2twiUU2FVA/4gOQ5 7H2gD2fcH4anhKLtQsR2vd/63; 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 1pS1q0-002zny-Cp for gdb-patches@sourceware.org; Tue, 14 Feb 2023 13:23:40 -0700 From: Tom Tromey Date: Tue, 14 Feb 2023 13:23:31 -0700 Subject: [PATCH 1/6] Change value::m_modifiable to bool MIME-Version: 1.0 Message-Id: <20230214-submit-more-value-stuff-v1-1-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: 1pS1q0-002zny-Cp 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: 2 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" This changes value::m_modifiable to be a bool and updates the various uses. --- gdb/breakpoint.c | 3 +-- gdb/ppc-linux-nat.c | 2 +- gdb/value.c | 6 +++--- gdb/value.h | 8 ++++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 3b9aebc5605..b1922fc1e98 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -10450,8 +10450,7 @@ can_use_hardware_watchpoint (const std::vector &vals) } } } - else if (v->lval () != not_lval - && v->deprecated_modifiable () == 0) + else if (v->lval () != not_lval && !v->deprecated_modifiable ()) return 0; /* These are values from the history (e.g., $1). */ else if (v->lval () == lval_register) return 0; /* Cannot watch a register with a HW watchpoint. */ diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index 32c0177228a..494e9bf6119 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -2455,7 +2455,7 @@ ppc_linux_nat_target::num_memory_accesses (const std::vector struct value *v = iter.get (); /* Constants and values from the history are fine. */ - if (v->lval () == not_lval || v->deprecated_modifiable () == 0) + if (v->lval () == not_lval || !v->deprecated_modifiable ()) continue; else if (v->lval () == lval_memory) { diff --git a/gdb/value.c b/gdb/value.c index 7873aeb9558..b027b63ee48 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1676,7 +1676,7 @@ value::record_latest () /* We preserve VALUE_LVAL so that the user can find out where it was fetched from. This is a bit dubious, because then *&$1 does not just return $1 but the current contents of that location. c'est la vie... */ - set_modifiable (0); + set_modifiable (false); value_history.push_back (release_value (this)); @@ -2169,7 +2169,7 @@ set_internalvar (struct internalvar *var, struct value *val) default: new_kind = INTERNALVAR_VALUE; struct value *copy = val->copy (); - copy->set_modifiable (1); + copy->set_modifiable (true); /* Force the value to be fetched from the target now, to avoid problems later when this internalvar is referenced and the target is gone or @@ -2492,7 +2492,7 @@ value::from_xmethod (xmethod_worker_up &&worker) v = value::allocate (builtin_type (target_gdbarch ())->xmethod); v->m_lval = lval_xcallable; v->m_location.xm_worker = worker.release (); - v->m_modifiable = 0; + v->m_modifiable = false; return v; } diff --git a/gdb/value.h b/gdb/value.h index 8b45f7fdee8..92247185cd0 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -132,7 +132,7 @@ struct value /* Values can only be created via "static constructors". */ explicit value (struct type *type_) - : m_modifiable (1), + : m_modifiable (true), m_lazy (1), m_initialized (1), m_stack (0), @@ -228,11 +228,11 @@ struct value /* The comment from "struct value" reads: ``Is it modifiable? Only relevant if lval != not_lval.''. Shouldn't the value instead be not_lval and be done with it? */ - int deprecated_modifiable () const + bool deprecated_modifiable () const { return m_modifiable; } /* Set or clear the modifiable flag. */ - void set_modifiable (int val) + void set_modifiable (bool val) { m_modifiable = val; } LONGEST pointed_to_offset () const @@ -619,7 +619,7 @@ struct value enum lval_type m_lval = not_lval; /* Is it modifiable? Only relevant if lval != not_lval. */ - unsigned int m_modifiable : 1; + bool m_modifiable : 1; /* If zero, contents of this value are in the contents field. If nonzero, contents are in inferior. If the lval field is lval_memory, From patchwork Tue Feb 14 20:23:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 65016 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 74A4538654A3 for ; Tue, 14 Feb 2023 20:24:01 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 309863858D35 for ; Tue, 14 Feb 2023 20:23:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 309863858D35 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 cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id A42A5100389E9 for ; Tue, 14 Feb 2023 20:23:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id S1q0pOO7RA1zNS1q0pAuVm; Tue, 14 Feb 2023 20:23:40 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=CqN6zl0D c=1 sm=1 tr=0 ts=63ebedcc 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=5HGvlBD7qXdGYqwDoaAA: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=pyLNtscVrT+fgtFoIyYXzoXcTyP8rFdOpJNS5QxFhAQ=; b=DOCjLiKqttVD1wuqxBKVIuQ9Si qKCVFTfppzTd9lXHYL3lhGeEwoWbSpWjVkY/TdCEMfrs2Vu/f370hRssCdBZMGSuMk/7Dao2WRZmX t0KjFlFZvlpxAIDuxNmi3YFqw; 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 1pS1q0-002zny-Gq for gdb-patches@sourceware.org; Tue, 14 Feb 2023 13:23:40 -0700 From: Tom Tromey Date: Tue, 14 Feb 2023 13:23:32 -0700 Subject: [PATCH 2/6] Change value::m_lazy to bool MIME-Version: 1.0 Message-Id: <20230214-submit-more-value-stuff-v1-2-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: 1pS1q0-002zny-Gq 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: 3 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" This changes value::m_lazy to be a bool and updates the various uses. --- gdb/dwarf2/loc.c | 2 +- gdb/gnu-v2-abi.c | 2 +- gdb/valops.c | 2 +- gdb/value.c | 6 +++--- gdb/value.h | 16 ++++++++-------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 27c4b7ce31a..0ab54abea9a 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1366,7 +1366,7 @@ value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame, memcpy (val->contents_raw ().data (), outer_val->contents_raw ().data (), checked_type->length ()); - val->set_lazy (0); + val->set_lazy (false); return val; } diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index fa46d474914..6afa1795ebd 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -163,7 +163,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, if (!arg1->lazy ()) { - arg1->set_lazy (1); + arg1->set_lazy (true); arg1->fetch_lazy (); } diff --git a/gdb/valops.c b/gdb/valops.c index 3901053c7d5..90f7b8c5532 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1343,7 +1343,7 @@ value_assign (struct value *toval, struct value *fromval) information, but its contents are updated from FROMVAL. This implies the returned value is not lazy, even if TOVAL was. */ val = toval->copy (); - val->set_lazy (0); + val->set_lazy (false); copy (fromval->contents (), val->contents_raw ()); /* We copy over the enclosing type and pointed-to offset from FROMVAL diff --git a/gdb/value.c b/gdb/value.c index b027b63ee48..855354f542f 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -990,7 +990,7 @@ value::allocate_optimized_out (struct type *type) struct value *retval = value::allocate_lazy (type); retval->mark_bytes_optimized_out (0, type->length ()); - retval->set_lazy (0); + retval->set_lazy (false); return retval; } @@ -3809,7 +3809,7 @@ value::fetch_lazy_register () /* Copy the contents and the unavailability/optimized-out meta-data from NEW_VAL to VAL. */ - set_lazy (0); + set_lazy (false); new_val->contents_copy (this, embedded_offset (), new_val->embedded_offset (), type_length_units (type)); @@ -3893,7 +3893,7 @@ value::fetch_lazy () else internal_error (_("Unexpected lazy value type.")); - set_lazy (0); + set_lazy (false); } /* Implementation of the convenience function $_isvoid. */ diff --git a/gdb/value.h b/gdb/value.h index 92247185cd0..233f42d32a0 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -133,7 +133,7 @@ struct value /* Values can only be created via "static constructors". */ explicit value (struct type *type_) : m_modifiable (true), - m_lazy (1), + m_lazy (true), m_initialized (1), m_stack (0), m_is_zero (false), @@ -247,8 +247,8 @@ struct value void set_embedded_offset (LONGEST val) { m_embedded_offset = val; } - /* If zero, contents of this value are in the contents field. If - nonzero, contents are in inferior. If the lval field is lval_memory, + /* If false, contents of this value are in the contents field. If + true, contents are in inferior. If the lval field is lval_memory, the contents are in inferior memory at location.address plus offset. The lval field may also be lval_register. @@ -262,10 +262,10 @@ struct value element. If you ever change the way lazy flag is set and reset, be sure to consider this use as well! */ - int lazy () const + bool lazy () const { return m_lazy; } - void set_lazy (int val) + void set_lazy (bool val) { m_lazy = val; } /* If a value represents a C++ object, then the `type' field gives the @@ -621,8 +621,8 @@ struct value /* Is it modifiable? Only relevant if lval != not_lval. */ bool m_modifiable : 1; - /* If zero, contents of this value are in the contents field. If - nonzero, contents are in inferior. If the lval field is lval_memory, + /* If false, contents of this value are in the contents field. If + true, contents are in inferior. If the lval field is lval_memory, the contents are in inferior memory at location.address plus offset. The lval field may also be lval_register. @@ -635,7 +635,7 @@ struct value or array when the user wants to watch a single struct member or array element. If you ever change the way lazy flag is set and reset, be sure to consider this use as well! */ - unsigned int m_lazy : 1; + bool m_lazy : 1; /* If value is a variable, is it initialized or not. */ unsigned int m_initialized : 1; From patchwork Tue Feb 14 20:23:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 65019 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 C327D3858C36 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 gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id D56F13858C66 for ; Tue, 14 Feb 2023 20:23:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D56F13858C66 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 cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id E249C10047A45 for ; Tue, 14 Feb 2023 20:23:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id S1q0p6oz0Fh3zS1q0pWfHw; Tue, 14 Feb 2023 20:23:40 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=QpabYX+d c=1 sm=1 tr=0 ts=63ebedcc 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=2Hwf15CJv0IExURGYekA: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=MdPpSvPEoSdA/qf/eGYQNvd90RSPu/s7ON6weXCYyIc=; b=hmdJM0SRadGSYzxt4FEHr2OuU1 mVuK6lrmf/XUb3OK4ZyNw+sZkZcjtVv4IuljiSrUSU5F/DCxJEHEwNRgStdPAVTDh1cSKjrDxQpzj fyC6HF1EtJEXz5j3jf/QSoeFY; 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 1pS1q0-002zny-Kv for gdb-patches@sourceware.org; Tue, 14 Feb 2023 13:23:40 -0700 From: Tom Tromey Date: Tue, 14 Feb 2023 13:23:33 -0700 Subject: [PATCH 3/6] Change value::m_initialized to bool MIME-Version: 1.0 Message-Id: <20230214-submit-more-value-stuff-v1-3-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: 1pS1q0-002zny-Kv 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: 4 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" This changes value::m_initialized to be a bool and updates the various uses. --- gdb/dwarf2/expr.c | 4 ++-- gdb/dwarf2/expr.h | 6 +++--- gdb/value.h | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 60d9bf5f1f9..760c5c4b0d0 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -1496,7 +1496,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, type *address_type = this->address_type (); this->m_location = DWARF_VALUE_MEMORY; - this->m_initialized = 1; /* Default is initialized. */ + this->m_initialized = true; /* Default is initialized. */ if (this->m_recursion_depth > this->m_max_recursion_depth) error (_("DWARF-2 expression error: Loop detected (%d)."), @@ -2192,7 +2192,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, error (_("DWARF-2 expression error: DW_OP_GNU_uninit must always " "be the very last op.")); - this->m_initialized = 0; + this->m_initialized = false; goto no_push; case DW_OP_call2: diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h index 44fc645116a..7a64316160e 100644 --- a/gdb/dwarf2/expr.h +++ b/gdb/dwarf2/expr.h @@ -164,9 +164,9 @@ struct dwarf_expr_context ULONGEST m_len = 0; const gdb_byte *m_data = nullptr; - /* Initialization status of variable: Non-zero if variable has been - initialized; zero otherwise. */ - int m_initialized = 0; + /* Initialization status of variable: True if variable has been + initialized; false otherwise. */ + bool m_initialized = false; /* A vector of pieces. diff --git a/gdb/value.h b/gdb/value.h index 233f42d32a0..41327ebe3b8 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -134,7 +134,7 @@ struct value explicit value (struct type *type_) : m_modifiable (true), m_lazy (true), - m_initialized (1), + m_initialized (true), m_stack (0), m_is_zero (false), m_in_history (false), @@ -338,11 +338,11 @@ struct value /* Set or return field indicating whether a variable is initialized or not, based on debugging information supplied by the compiler. - 1 = initialized; 0 = uninitialized. */ - int initialized () const + true = initialized; false = uninitialized. */ + bool initialized () const { return m_initialized; } - void set_initialized (int value) + void set_initialized (bool value) { m_initialized = value; } /* If lval == lval_memory, return the address in the inferior. If @@ -638,7 +638,7 @@ struct value bool m_lazy : 1; /* If value is a variable, is it initialized or not. */ - unsigned int m_initialized : 1; + bool m_initialized : 1; /* If value is from the stack. If this is set, read_stack will be used instead of read_memory to enable extra caching. */ From patchwork Tue Feb 14 20:23:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 65018 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 A9FE0384F036 for ; Tue, 14 Feb 2023 20:24:17 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id 7BE963858CDB for ; Tue, 14 Feb 2023 20:23:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7BE963858CDB 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id E7510100406DD for ; Tue, 14 Feb 2023 20:23:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id S1q0pQQ6qNX2aS1q0pAqmy; Tue, 14 Feb 2023 20:23:40 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63ebedcc 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=Lz-IZ8fpgrDb48-hSZIA: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=7kex1QjUr2FNt3E1R7Hk2Rad3Ev3xQ/F/ClxnL0MCVc=; b=pmcrS5i6heNIey2ZoAUvTMiQmL AnOx89GidGG0af9U51WKRaO17FTXNYMUSYQi8wvCvECCtMoE9rPgslD3x09iiNUH3K/QrXYvQvopD csd9kmHcCo8/l/RUND91UHZa+; 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 1pS1q0-002zny-Ou for gdb-patches@sourceware.org; Tue, 14 Feb 2023 13:23:40 -0700 From: Tom Tromey Date: Tue, 14 Feb 2023 13:23:34 -0700 Subject: [PATCH 4/6] Change value::m_stack to bool MIME-Version: 1.0 Message-Id: <20230214-submit-more-value-stuff-v1-4-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: 1pS1q0-002zny-Ou 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: 5 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" This changes value::m_stack to be a bool and updates the various uses. --- gdb/dwarf2/expr.c | 2 +- gdb/frame-unwind.c | 2 +- gdb/valops.c | 2 +- gdb/value.c | 2 +- gdb/value.h | 10 +++++----- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 760c5c4b0d0..3f040e7b2d3 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -1005,7 +1005,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, retval = value_at_lazy (subobj_type, address + subobj_offset); if (in_stack_memory) - retval->set_stack (1); + retval->set_stack (true); } break; diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index e5f8dc639e3..a3673dde77a 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -289,7 +289,7 @@ frame_unwind_got_memory (frame_info_ptr frame, int regnum, CORE_ADDR addr) struct gdbarch *gdbarch = frame_unwind_arch (frame); struct value *v = value_at_lazy (register_type (gdbarch, regnum), addr); - v->set_stack (1); + v->set_stack (true); return v; } diff --git a/gdb/valops.c b/gdb/valops.c index 90f7b8c5532..3a1b14c3d44 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1041,7 +1041,7 @@ value_at_lazy (struct type *type, CORE_ADDR addr) void read_value_memory (struct value *val, LONGEST bit_offset, - int stack, CORE_ADDR memaddr, + bool stack, CORE_ADDR memaddr, gdb_byte *buffer, size_t length) { ULONGEST xfered_total = 0; diff --git a/gdb/value.c b/gdb/value.c index 855354f542f..6a8c12823c4 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -3743,7 +3743,7 @@ value::fetch_lazy_memory () gdb_assert (len >= 0); if (len > 0) - read_value_memory (this, 0, stack (), addr, + read_value_memory (this, false, stack (), addr, contents_all_raw ().data (), len); } diff --git a/gdb/value.h b/gdb/value.h index 41327ebe3b8..4cb6fac4104 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -135,7 +135,7 @@ struct value : m_modifiable (true), m_lazy (true), m_initialized (true), - m_stack (0), + m_stack (false), m_is_zero (false), m_in_history (false), m_type (type_), @@ -314,10 +314,10 @@ struct value void set_enclosing_type (struct type *new_type); - int stack () const + bool stack () const { return m_stack; } - void set_stack (int val) + void set_stack (bool val) { m_stack = val; } /* If this value is lval_computed, return its lval_funcs @@ -642,7 +642,7 @@ struct value /* If value is from the stack. If this is set, read_stack will be used instead of read_memory to enable extra caching. */ - unsigned int m_stack : 1; + bool m_stack : 1; /* True if this is a zero value, created by 'value::zero'; false otherwise. */ @@ -1000,7 +1000,7 @@ extern struct value *coerce_array (struct value *value); whether the memory is known to be stack memory. */ extern void read_value_memory (struct value *val, LONGEST bit_offset, - int stack, CORE_ADDR memaddr, + bool stack, CORE_ADDR memaddr, gdb_byte *buffer, size_t length); /* Cast SCALAR_VALUE to the element type of VECTOR_TYPE, then replicate From patchwork Tue Feb 14 20:23:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 65017 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 1249B385B52C for ; Tue, 14 Feb 2023 20:24:15 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 968813858C53 for ; Tue, 14 Feb 2023 20:23:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 968813858C53 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 cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 12C1310038A07 for ; Tue, 14 Feb 2023 20:23:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id S1q1p6ozDFh3zS1q1pWfIA; Tue, 14 Feb 2023 20:23:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=QpabYX+d 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=lomSTQFzVKiumFt1d-8A: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=kAeKSmRzOs6OQLY3r26DyosFMMXBGpLJjfvqtxOhcAE=; b=Z4lmn8gcLxsmhZFBxtKyncwaeg ZAImSsb7atXOAZWuA/dOHuMNqwtlp8sgL03NJF876ZS8QFmMHexjg9jt4O5SJNLEk4ub9alJTKnzu JGmFcIXF1/6JD4xFta8D2gEdf; 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 1pS1q0-002zny-TB for gdb-patches@sourceware.org; Tue, 14 Feb 2023 13:23:40 -0700 From: Tom Tromey Date: Tue, 14 Feb 2023 13:23:35 -0700 Subject: [PATCH 5/6] Have value::bits_synthetic_pointer return bool MIME-Version: 1.0 Message-Id: <20230214-submit-more-value-stuff-v1-5-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: 1pS1q0-002zny-TB 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: 6 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" This changes value::bits_synthetic_pointer to return bool and fixes up some fallout from this. --- gdb/dwarf2/expr.c | 6 +++--- gdb/opencl-lang.c | 10 +++++----- gdb/valprint.c | 2 +- gdb/value.c | 4 ++-- gdb/value.h | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 3f040e7b2d3..b48bab0b410 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -459,7 +459,7 @@ is_optimized_out_pieced_value (value *v) /* An implementation of an lval_funcs method to see whether a value is a synthetic pointer. */ -static int +static bool check_pieced_synthetic_pointer (const value *value, LONGEST bit_offset, int bit_length) { @@ -490,10 +490,10 @@ check_pieced_synthetic_pointer (const value *value, LONGEST bit_offset, bit_length -= this_size_bits; if (p->location != DWARF_VALUE_IMPLICIT_POINTER) - return 0; + return false; } - return 1; + return true; } /* An implementation of an lval_funcs method to indirect through a diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 3e4a9c360b2..ae1a6d4446d 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -187,10 +187,10 @@ lval_func_write (struct value *v, struct value *fromval) } } -/* Return nonzero if bits in V from OFFSET and LENGTH represent a +/* Return true if bits in V from OFFSET and LENGTH represent a synthetic pointer. */ -static int +static bool lval_func_check_synthetic_pointer (const struct value *v, LONGEST offset, int length) { @@ -208,7 +208,7 @@ lval_func_check_synthetic_pointer (const struct value *v, end++; if (end > c->n) - return 0; + return false; for (i = start; i < end; i++) { @@ -217,10 +217,10 @@ lval_func_check_synthetic_pointer (const struct value *v, if (!c->val->bits_synthetic_pointer (c->indices[i] * elsize + comp_offset, comp_length)) - return 0; + return false; } - return 1; + return true; } static void * diff --git a/gdb/valprint.c b/gdb/valprint.c index 8c067693492..357db3815b0 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -566,7 +566,7 @@ generic_val_print_ref (struct type *type, { struct type *elttype = check_typedef (type->target_type ()); struct value *deref_val = NULL; - const int value_is_synthetic + const bool value_is_synthetic = original_value->bits_synthetic_pointer (TARGET_CHAR_BIT * embedded_offset, TARGET_CHAR_BIT * type->length ()); const int must_coerce_ref = ((options->addressprint && value_is_synthetic) diff --git a/gdb/value.c b/gdb/value.c index 6a8c12823c4..9e561e28551 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1315,12 +1315,12 @@ value::mark_bits_optimized_out (LONGEST offset, LONGEST length) insert_into_bit_range_vector (&m_optimized_out, offset, length); } -int +bool value::bits_synthetic_pointer (LONGEST offset, LONGEST length) const { if (m_lval != lval_computed || !m_location.computed.funcs->check_synthetic_pointer) - return 0; + return false; return m_location.computed.funcs->check_synthetic_pointer (this, offset, length); } diff --git a/gdb/value.h b/gdb/value.h index 4cb6fac4104..5536e00332e 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -475,7 +475,7 @@ struct value /* Given a value, determine whether the bits starting at OFFSET and extending for LENGTH bits are a synthetic pointer. */ - int bits_synthetic_pointer (LONGEST offset, LONGEST length) const; + bool bits_synthetic_pointer (LONGEST offset, LONGEST length) const; /* Increase this value's reference count. */ void incref () @@ -924,8 +924,8 @@ struct lval_funcs /* If non-NULL, this is used to determine whether the indicated bits of VALUE are a synthetic pointer. */ - int (*check_synthetic_pointer) (const struct value *value, - LONGEST offset, int length); + bool (*check_synthetic_pointer) (const struct value *value, + LONGEST offset, int length); /* Return a duplicate of VALUE's closure, for use in a new value. This may simply return the same closure, if VALUE's is 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,