public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/6] Change value::m_modifiable to bool
Date: Tue, 14 Feb 2023 13:23:31 -0700	[thread overview]
Message-ID: <20230214-submit-more-value-stuff-v1-1-2fb85efbaa72@tromey.com> (raw)
In-Reply-To: <20230214-submit-more-value-stuff-v1-0-2fb85efbaa72@tromey.com>

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<value_ref_ptr> &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<value_ref_ptr>
       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,

-- 
2.39.1


  reply	other threads:[~2023-02-14 20:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14 20:23 [PATCH 0/6] Use bool in value Tom Tromey
2023-02-14 20:23 ` Tom Tromey [this message]
2023-02-21 14:36   ` [PATCH 1/6] Change value::m_modifiable to bool Alexandra Petlanova Hajkova
2023-02-14 20:23 ` [PATCH 2/6] Change value::m_lazy " Tom Tromey
2023-02-15 11:53   ` Bruno Larsen
2023-02-15 21:52     ` Tom Tromey
2023-02-14 20:23 ` [PATCH 3/6] Change value::m_initialized " Tom Tromey
2023-02-21 15:10   ` Alexandra Petlanova Hajkova
2023-02-14 20:23 ` [PATCH 4/6] Change value::m_stack " Tom Tromey
2023-02-21 15:30   ` Alexandra Petlanova Hajkova
2023-02-14 20:23 ` [PATCH 5/6] Have value::bits_synthetic_pointer return bool Tom Tromey
2023-02-14 20:23 ` [PATCH 6/6] Return bool from more value methods Tom Tromey
2023-02-15 12:22 ` [PATCH 0/6] Use bool in value Bruno Larsen
2023-02-15 21:54   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230214-submit-more-value-stuff-v1-1-2fb85efbaa72@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).