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 14/47] Turn value_lazy and set_value_lazy functions into methods
Date: Thu, 09 Feb 2023 14:38:35 -0700	[thread overview]
Message-ID: <20230209-submit-value-fixups-2023-v1-14-55dc2794dbb9@tromey.com> (raw)
In-Reply-To: <20230209-submit-value-fixups-2023-v1-0-55dc2794dbb9@tromey.com>

This changes the value_lazy and set_value_lazy functions to be methods
of value.  Much of this patch was written by script.
---
 gdb/ada-lang.c               |  8 +++----
 gdb/ada-valprint.c           |  2 +-
 gdb/breakpoint.c             |  4 ++--
 gdb/c-varobj.c               |  4 ++--
 gdb/dwarf2/loc.c             |  2 +-
 gdb/eval.c                   |  6 ++---
 gdb/f-lang.c                 |  8 +++----
 gdb/frame.c                  |  2 +-
 gdb/gnu-v2-abi.c             |  4 ++--
 gdb/guile/scm-pretty-print.c |  2 +-
 gdb/guile/scm-value.c        |  4 ++--
 gdb/ppc-linux-nat.c          |  2 +-
 gdb/printcmd.c               |  2 +-
 gdb/python/py-prettyprint.c  |  2 +-
 gdb/python/py-value.c        |  4 ++--
 gdb/stack.c                  | 10 ++++----
 gdb/valops.c                 |  6 ++---
 gdb/valprint.c               |  2 +-
 gdb/value.c                  | 54 +++++++++++++++++---------------------------
 gdb/value.h                  | 39 +++++++++++++++++---------------
 gdb/varobj.c                 | 16 ++++++-------
 21 files changed, 87 insertions(+), 96 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index baffea75657..05f8c3fd0da 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -557,7 +557,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type)
 
       if (value_optimized_out (val))
 	result = allocate_optimized_out_value (type);
-      else if (value_lazy (val)
+      else if (val->lazy ()
 	       /* Be careful not to make a lazy not_lval value.  */
 	       || (VALUE_LVAL (val) != not_lval
 		   && type->length () > val->type ()->length ()))
@@ -2810,7 +2810,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
       v = allocate_value (type);
       src = valaddr + offset;
     }
-  else if (VALUE_LVAL (obj) == lval_memory && value_lazy (obj))
+  else if (VALUE_LVAL (obj) == lval_memory && obj->lazy ())
     {
       int src_len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8;
       gdb_byte *buf;
@@ -10852,7 +10852,7 @@ ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type,
      an address of the result of a cast (view conversion in Ada).  */
   if (VALUE_LVAL (val) == lval_memory)
     {
-      if (value_lazy (val))
+      if (val->lazy ())
 	value_fetch_lazy (val);
       VALUE_LVAL (val) = not_lval;
     }
@@ -10874,7 +10874,7 @@ ada_var_value_operation::evaluate_for_cast (struct type *expect_type,
      an address of the result of a cast (view conversion in Ada).  */
   if (VALUE_LVAL (val) == lval_memory)
     {
-      if (value_lazy (val))
+      if (val->lazy ())
 	value_fetch_lazy (val);
       VALUE_LVAL (val) = not_lval;
     }
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index c1004b5f33c..64d7ac18b8c 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -982,7 +982,7 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr,
   if (ada_is_tagged_type (deref_val->type (), 1))
     deref_val = ada_tag_value_at_base_address (deref_val);
 
-  if (value_lazy (deref_val))
+  if (deref_val->lazy ())
     value_fetch_lazy (deref_val);
 
   common_val_print (deref_val, stream, recurse + 1,
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 492b0ef7941..aa3045cd37f 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2068,7 +2068,7 @@ update_watchpoint (struct watchpoint *b, bool reparse)
 	     still lazy, that means an error occurred reading it;
 	     watch it anyway in case it becomes readable.  */
 	  if (VALUE_LVAL (v) == lval_memory
-	      && (v == val_chain[0] || ! value_lazy (v)))
+	      && (v == val_chain[0] || ! v->lazy ()))
 	    {
 	      struct type *vtype = check_typedef (v->type ());
 
@@ -10384,7 +10384,7 @@ can_use_hardware_watchpoint (const std::vector<value_ref_ptr> &vals)
 
       if (VALUE_LVAL (v) == lval_memory)
 	{
-	  if (v != head && value_lazy (v))
+	  if (v != head && v->lazy ())
 	    /* A lazy memory lvalue in the chain is one that GDB never
 	       needed to fetch; we either just used its address (e.g.,
 	       `a' in `a.b') or we never needed it at all (e.g., `a'
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index d517c798a6a..00094244ff1 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -506,14 +506,14 @@ c_value_of_variable (const struct varobj *var,
 	  }
 	else
 	  {
-	    if (var->not_fetched && value_lazy (var->value.get ()))
+	    if (var->not_fetched && var->value.get ()->lazy ())
 	      /* Frozen variable and no value yet.  We don't
 		 implicitly fetch the value.  MI response will
 		 use empty string for the value, which is OK.  */
 	      return std::string ();
 
 	    gdb_assert (varobj_value_is_changeable_p (var));
-	    gdb_assert (!value_lazy (var->value.get ()));
+	    gdb_assert (!var->value.get ()->lazy ());
 	    
 	    /* If the specified format is the current one,
 	       we can reuse print_value.  */
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 4af4dfde090..e5b35b8aadb 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 (value_contents_raw (val).data (),
 	  value_contents_raw (outer_val).data (),
 	  checked_type->length ());
-  set_value_lazy (val, 0);
+  val->set_lazy (0);
 
   return val;
 }
diff --git a/gdb/eval.c b/gdb/eval.c
index 87147593ed9..934ca4c7ea2 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -205,7 +205,7 @@ fetch_subexp_value (struct expression *exp,
      have a non-lazy previous value to compare with.  */
   if (result != NULL)
     {
-      if (!value_lazy (result))
+      if (!result->lazy ())
 	*valp = result;
       else
 	{
@@ -2877,7 +2877,7 @@ var_msym_value_operation::evaluate_for_cast (struct type *to_type,
   /* Don't allow e.g. '&(int)var_with_no_debug_info'.  */
   if (VALUE_LVAL (val) == lval_memory)
     {
-      if (value_lazy (val))
+      if (val->lazy ())
 	value_fetch_lazy (val);
       VALUE_LVAL (val) = not_lval;
     }
@@ -2898,7 +2898,7 @@ var_value_operation::evaluate_for_cast (struct type *to_type,
   /* Don't allow e.g. '&(int)var_with_no_debug_info'.  */
   if (VALUE_LVAL (val) == lval_memory)
     {
-      if (value_lazy (val))
+      if (val->lazy ())
 	value_fetch_lazy (val);
       VALUE_LVAL (val) = not_lval;
     }
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index bf2471a1e2c..d88e81c4a11 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -356,7 +356,7 @@ class fortran_array_repacker_impl
       m_base_offset (base_offset),
       m_val (val)
   {
-    gdb_assert (!value_lazy (val));
+    gdb_assert (!val->lazy ());
   }
 
   /* Extract an element of ELT_TYPE at offset (M_BASE_OFFSET + ELT_OFF)
@@ -1441,7 +1441,7 @@ fortran_undetermined::value_subarray (value *array,
       /* Now copy the elements from the original ARRAY into the packed
 	 array value DEST.  */
       struct value *dest = allocate_value (repacked_array_type);
-      if (value_lazy (array)
+      if (array->lazy ()
 	  || (total_offset + array_slice_type->length ()
 	      > check_typedef (array->type ())->length ()))
 	{
@@ -1466,7 +1466,7 @@ fortran_undetermined::value_subarray (value *array,
 	     the requested slice is outside the values content range then
 	     just create a new lazy value pointing at the memory where the
 	     contents we're looking for exist.  */
-	  if (value_lazy (array)
+	  if (array->lazy ()
 	      || (total_offset + array_slice_type->length ()
 		  > check_typedef (array->type ())->length ()))
 	    array = value_at_lazy (array_slice_type,
@@ -1476,7 +1476,7 @@ fortran_undetermined::value_subarray (value *array,
 	      (array_slice_type, value_contents (array).data () + total_offset,
 	       value_address (array) + total_offset);
 	}
-      else if (!value_lazy (array))
+      else if (!array->lazy ())
 	array = value_from_component (array, array_slice_type, total_offset);
       else
 	error (_("cannot subscript arrays that are not in memory"));
diff --git a/gdb/frame.c b/gdb/frame.c
index f845f8caf78..8bb2385d9e7 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1306,7 +1306,7 @@ frame_unwind_register_value (frame_info_ptr next_frame, int regnum)
 	  else
 	    gdb_printf (&debug_file, " computed");
 
-	  if (value_lazy (value))
+	  if (value->lazy ())
 	    gdb_printf (&debug_file, " lazy");
 	  else
 	    {
diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c
index 632b46f92de..76dc719719f 100644
--- a/gdb/gnu-v2-abi.c
+++ b/gdb/gnu-v2-abi.c
@@ -161,9 +161,9 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j,
       arg1->set_offset (arg1->offset ()
 			+ value_as_long (value_field (entry, 0)));
 
-      if (!value_lazy (arg1))
+      if (!arg1->lazy ())
 	{
-	  set_value_lazy (arg1, 1);
+	  arg1->set_lazy (1);
 	  value_fetch_lazy (arg1);
 	}
 
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index 3e93f3523be..7a680c052d3 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -965,7 +965,7 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang,
   enum ext_lang_rc result = EXT_LANG_RC_NOP;
   enum guile_string_repr_result print_result;
 
-  if (value_lazy (value))
+  if (value->lazy ())
     value_fetch_lazy (value);
 
   /* No pretty-printer support for unavailable values.  */
diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c
index 0d9e15a7404..5b9a4cfb181 100644
--- a/gdb/guile/scm-value.c
+++ b/gdb/guile/scm-value.c
@@ -1233,7 +1233,7 @@ gdbscm_value_lazy_p (SCM self)
     = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   struct value *value = v_smob->value;
 
-  return scm_from_bool (value_lazy (value));
+  return scm_from_bool (value->lazy ());
 }
 
 /* (value-fetch-lazy! <gdb:value>) -> unspecified */
@@ -1247,7 +1247,7 @@ gdbscm_value_fetch_lazy_x (SCM self)
 
   return gdbscm_wrap ([=]
     {
-      if (value_lazy (value))
+      if (value->lazy ())
 	value_fetch_lazy (value);
       return SCM_UNSPECIFIED;
     });
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index a796364b413..d6d1d0fe1a2 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -2462,7 +2462,7 @@ ppc_linux_nat_target::num_memory_accesses (const std::vector<value_ref_ptr>
 	  /* A lazy memory lvalue is one that GDB never needed to fetch;
 	     we either just used its address (e.g., `a' in `a.b') or
 	     we never needed it at all (e.g., `a' in `a,b').  */
-	  if (!value_lazy (v))
+	  if (!v->lazy ())
 	    found_memory_cnt++;
 	}
       /* Other kinds of values are not fine.  */
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 2962c7111e4..539285477db 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1927,7 +1927,7 @@ x_command (const char *exp, int from_tty)
 	 as $__.  If the last value has not been fetched from memory
 	 then don't fetch it now; instead mark it by voiding the $__
 	 variable.  */
-      if (value_lazy (last_examine_value.get ()))
+      if (last_examine_value.get ()->lazy ())
 	clear_internalvar (lookup_internalvar ("__"));
       else
 	set_internalvar (lookup_internalvar ("__"), last_examine_value.get ());
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 346395e564e..0bd54dab5c6 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -578,7 +578,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
   struct gdbarch *gdbarch = type->arch ();
   enum gdbpy_string_repr_result print_result;
 
-  if (value_lazy (value))
+  if (value->lazy ())
     value_fetch_lazy (value);
 
   /* No pretty-printer support for unavailable values.  */
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index c748a87cfc9..0e3bc699819 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -1219,7 +1219,7 @@ valpy_get_is_lazy (PyObject *self, void *closure)
 
   try
     {
-      opt = value_lazy (value);
+      opt = value->lazy ();
     }
   catch (const gdb_exception &except)
     {
@@ -1240,7 +1240,7 @@ valpy_fetch_lazy (PyObject *self, PyObject *args)
 
   try
     {
-      if (value_lazy (value))
+      if (value->lazy ())
 	value_fetch_lazy (value);
     }
   catch (const gdb_exception &except)
diff --git a/gdb/stack.c b/gdb/stack.c
index 9e239ed4f67..5efe024c88e 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -580,9 +580,9 @@ read_frame_arg (const frame_print_options &fp_opts,
 	    {
 	      struct type *type = val->type ();
 
-	      if (value_lazy (val))
+	      if (val->lazy ())
 		value_fetch_lazy (val);
-	      if (value_lazy (entryval))
+	      if (entryval->lazy ())
 		value_fetch_lazy (entryval);
 
 	      if (value_contents_eq (val, 0, entryval, 0, type->length ()))
@@ -599,12 +599,12 @@ read_frame_arg (const frame_print_options &fp_opts,
 		      struct type *type_deref;
 
 		      val_deref = coerce_ref (val);
-		      if (value_lazy (val_deref))
+		      if (val_deref->lazy ())
 			value_fetch_lazy (val_deref);
 		      type_deref = val_deref->type ();
 
 		      entryval_deref = coerce_ref (entryval);
-		      if (value_lazy (entryval_deref))
+		      if (entryval_deref->lazy ())
 			value_fetch_lazy (entryval_deref);
 
 		      /* If the reference addresses match but dereferenced
@@ -2749,7 +2749,7 @@ return_command (const char *retval_exp, int from_tty)
 
       /* Make sure the value is fully evaluated.  It may live in the
 	 stack frame we're about to pop.  */
-      if (value_lazy (return_value))
+      if (return_value->lazy ())
 	value_fetch_lazy (return_value);
 
       if (thisfun != NULL)
diff --git a/gdb/valops.c b/gdb/valops.c
index e4e8ff8d876..cfa21631850 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 = value_copy (toval);
-  set_value_lazy (val, 0);
+  val->set_lazy (0);
   copy (value_contents (fromval), value_contents_raw (val));
 
   /* We copy over the enclosing type and pointed-to offset from FROMVAL
@@ -1406,7 +1406,7 @@ address_of_variable (struct symbol *var, const struct block *b)
   val = value_of_variable (var, b);
   type = val->type ();
 
-  if ((VALUE_LVAL (val) == lval_memory && value_lazy (val))
+  if ((VALUE_LVAL (val) == lval_memory && val->lazy ())
       || type->code () == TYPE_CODE_FUNC)
     {
       CORE_ADDR addr = value_address (val);
@@ -4078,7 +4078,7 @@ value_slice (struct value *array, int lowbound, int length)
 				    slice_range_type);
     slice_type->set_code (array_type->code ());
 
-    if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
+    if (VALUE_LVAL (array) == lval_memory && array->lazy ())
       slice = allocate_value_lazy (slice_type);
     else
       {
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 3899d915981..6aef98e37c1 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1043,7 +1043,7 @@ common_val_print (struct value *value, struct ui_file *stream, int recurse,
        get a fixed representation of our value.  */
     value = ada_to_fixed_value (value);
 
-  if (value_lazy (value))
+  if (value->lazy ())
     value_fetch_lazy (value);
 
   struct value_print_options local_opts = *options;
diff --git a/gdb/value.c b/gdb/value.c
index f5400402638..46aeeec49b2 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -888,7 +888,7 @@ allocate_optimized_out_value (struct type *type)
   struct value *retval = allocate_value_lazy (type);
 
   mark_value_bytes_optimized_out (retval, 0, type->length ());
-  set_value_lazy (retval, 0);
+  retval->set_lazy (0);
   return retval;
 }
 
@@ -1161,18 +1161,6 @@ value_contents_copy (struct value *dst, LONGEST dst_offset,
   value_contents_copy_raw (dst, dst_offset, src, src_offset, length);
 }
 
-int
-value_lazy (const struct value *value)
-{
-  return value->m_lazy;
-}
-
-void
-set_value_lazy (struct value *value, int val)
-{
-  value->m_lazy = val;
-}
-
 int
 value_stack (const struct value *value)
 {
@@ -1458,7 +1446,7 @@ value_copy (const value *arg)
   struct type *encl_type = arg->enclosing_type ();
   struct value *val;
 
-  if (value_lazy (arg))
+  if (arg->lazy ())
     val = allocate_value_lazy (encl_type);
   else
     val = allocate_value (encl_type);
@@ -1478,7 +1466,7 @@ value_copy (const value *arg)
   val->m_unavailable = arg->m_unavailable;
   val->m_optimized_out = arg->m_optimized_out;
 
-  if (!value_lazy (val) && !value_entirely_optimized_out (val))
+  if (!val->lazy () && !value_entirely_optimized_out (val))
     {
       gdb_assert (arg->m_contents != nullptr);
       ULONGEST length = arg->enclosing_type ()->length ();
@@ -1602,7 +1590,7 @@ set_value_component_location (struct value *component,
          change to how values work in GDB.  */
       if (VALUE_LVAL (component) == lval_internalvar_component)
 	{
-	  gdb_assert (value_lazy (component));
+	  gdb_assert (component->lazy ());
 	  VALUE_LVAL (component) = lval_memory;
 	}
       else
@@ -1623,7 +1611,7 @@ record_latest_value (struct value *val)
      In particular, "set $1 = 50" should not affect the variable from which
      the value was taken, and fast watchpoints should be able to assume that
      a value on the value history never changes.  */
-  if (value_lazy (val))
+  if (val->lazy ())
     value_fetch_lazy (val);
   /* 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
@@ -1986,7 +1974,7 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var)
 
     case INTERNALVAR_VALUE:
       val = value_copy (var->u.value);
-      if (value_lazy (val))
+      if (val->lazy ())
 	value_fetch_lazy (val);
       break;
 
@@ -2126,7 +2114,7 @@ set_internalvar (struct internalvar *var, struct value *val)
       /* 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
 	 has changed.  */
-      if (value_lazy (copy))
+      if (copy->lazy ())
 	value_fetch_lazy (copy);
 
       /* Release the value from the value chain to prevent it from being
@@ -2839,7 +2827,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
 		   + offset
 		   + (bitpos - v->m_bitpos) / 8);
       v->set_parent (arg1);
-      if (!value_lazy (arg1))
+      if (!arg1->lazy ())
 	value_fetch_lazy (v);
     }
   else if (fieldno < TYPE_N_BASECLASSES (arg_type))
@@ -2850,7 +2838,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
       LONGEST boffset;
 
       /* Lazy register values with offsets are not supported.  */
-      if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1))
+      if (VALUE_LVAL (arg1) == lval_register && arg1->lazy ())
 	value_fetch_lazy (arg1);
 
       /* We special case virtual inheritance here because this
@@ -2865,7 +2853,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
       else
 	boffset = arg_type->field (fieldno).loc_bitpos () / 8;
 
-      if (value_lazy (arg1))
+      if (arg1->lazy ())
 	v = allocate_value_lazy (arg1->enclosing_type ());
       else
 	{
@@ -2895,10 +2883,10 @@ value_primitive_field (struct value *arg1, LONGEST offset,
 		 / (HOST_CHAR_BIT * unit_size));
 
       /* Lazy register values with offsets are not supported.  */
-      if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1))
+      if (VALUE_LVAL (arg1) == lval_register && arg1->lazy ())
 	value_fetch_lazy (arg1);
 
-      if (value_lazy (arg1))
+      if (arg1->lazy ())
 	v = allocate_value_lazy (type);
       else
 	{
@@ -3500,7 +3488,7 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset)
 {
   struct value *v;
 
-  if (VALUE_LVAL (whole) == lval_memory && value_lazy (whole))
+  if (VALUE_LVAL (whole) == lval_memory && whole->lazy ())
     v = allocate_value_lazy (type);
   else
     {
@@ -3521,7 +3509,7 @@ struct value *
 value_from_component_bitsize (struct value *whole, struct type *type,
 			      LONGEST bit_offset, LONGEST bit_length)
 {
-  gdb_assert (!value_lazy (whole));
+  gdb_assert (!whole->lazy ());
 
   /* Preserve lvalue-ness if possible.  This is needed to avoid
      array-printing failures (including crashes) when printing Ada
@@ -3701,7 +3689,7 @@ value_fetch_lazy_bitfield (struct value *val)
      value have been fetched.  */
   struct value *parent = val->parent ();
 
-  if (value_lazy (parent))
+  if (parent->lazy ())
     value_fetch_lazy (parent);
 
   unpack_value_bitfield (val, val->bitpos (), val->bitsize (),
@@ -3739,7 +3727,7 @@ value_fetch_lazy_register (struct value *val)
      refer to the entire register.  */
   gdb_assert (val->offset () == 0);
 
-  while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
+  while (VALUE_LVAL (new_val) == lval_register && new_val->lazy ())
     {
       struct frame_id next_frame_id = VALUE_NEXT_FRAME_ID (new_val);
 
@@ -3775,19 +3763,19 @@ value_fetch_lazy_register (struct value *val)
 	 any case, it should always be an internal error to end up
 	 in this situation.  */
       if (VALUE_LVAL (new_val) == lval_register
-	  && value_lazy (new_val)
+	  && new_val->lazy ()
 	  && VALUE_NEXT_FRAME_ID (new_val) == next_frame_id)
 	internal_error (_("infinite loop while fetching a register"));
     }
 
   /* If it's still lazy (for instance, a saved register on the
      stack), fetch it.  */
-  if (value_lazy (new_val))
+  if (new_val->lazy ())
     value_fetch_lazy (new_val);
 
   /* Copy the contents and the unavailability/optimized-out
      meta-data from NEW_VAL to VAL.  */
-  set_value_lazy (val, 0);
+  val->set_lazy (0);
   value_contents_copy (val, val->embedded_offset (),
 		       new_val, new_val->embedded_offset (),
 		       type_length_units (type));
@@ -3854,7 +3842,7 @@ value_fetch_lazy_register (struct value *val)
 void
 value_fetch_lazy (struct value *val)
 {
-  gdb_assert (value_lazy (val));
+  gdb_assert (val->lazy ());
   allocate_value_contents (val);
   /* A value is either lazy, or fully fetched.  The
      availability/validity is only established as we try to fetch a
@@ -3877,7 +3865,7 @@ value_fetch_lazy (struct value *val)
   else
     internal_error (_("Unexpected lazy value type."));
 
-  set_value_lazy (val, 0);
+  val->set_lazy (0);
 }
 
 /* Implementation of the convenience function $_isvoid.  */
diff --git a/gdb/value.h b/gdb/value.h
index 5f1bb1cfca7..a41bd2f4fd2 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -228,6 +228,27 @@ 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,
+     the contents are in inferior memory at location.address plus offset.
+     The lval field may also be lval_register.
+
+     WARNING: This field is used by the code which handles watchpoints
+     (see breakpoint.c) to decide whether a particular value can be
+     watched by hardware watchpoints.  If the lazy flag is set for some
+     member of a value chain, it is assumed that this member of the
+     chain doesn't need to be watched as part of watching the value
+     itself.  This is how GDB avoids watching the entire struct 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!  */
+
+  int lazy () const
+  { return m_lazy; }
+
+  void set_lazy (int val)
+  { m_lazy = val; }
+
 
   /* If a value represents a C++ object, then the `type' field gives the
      object's compile-time type.  If the object actually belongs to some
@@ -537,24 +558,6 @@ extern const struct lval_funcs *value_computed_funcs (const struct value *);
 
 extern void *value_computed_closure (const struct value *value);
 
-/* If zero, contents of this value are in the contents field.  If
-   nonzero, 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.
-
-   WARNING: This field is used by the code which handles watchpoints
-   (see breakpoint.c) to decide whether a particular value can be
-   watched by hardware watchpoints.  If the lazy flag is set for some
-   member of a value chain, it is assumed that this member of the
-   chain doesn't need to be watched as part of watching the value
-   itself.  This is how GDB avoids watching the entire struct 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!  */
-
-extern int value_lazy (const struct value *);
-extern void set_value_lazy (struct value *value, int val);
-
 extern int value_stack (const struct value *);
 extern void set_value_stack (struct value *value, int val);
 
diff --git a/gdb/varobj.c b/gdb/varobj.c
index fb846fd65c7..0e023c09cf8 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -504,7 +504,7 @@ varobj_set_display_format (struct varobj *var,
     }
 
   if (varobj_value_is_changeable_p (var) 
-      && var->value != nullptr && !value_lazy (var->value.get ()))
+      && var->value != nullptr && !var->value.get ()->lazy ())
     {
       var->print_value = varobj_value_get_print_value (var->value.get (),
 						       var->format, var);
@@ -1007,7 +1007,7 @@ varobj_set_value (struct varobj *var, const char *expression)
   gdb_assert (varobj_value_is_changeable_p (var));
 
   /* The value of a changeable variable object must not be lazy.  */
-  gdb_assert (!value_lazy (var->value.get ()));
+  gdb_assert (!var->value.get ()->lazy ());
 
   /* Need to coerce the input.  We want to check if the
      value of the variable object will be different
@@ -1247,7 +1247,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial)
      that is we'll be comparing values of this type, fetch the
      value now.  Otherwise, on the next update the old value
      will be lazy, which means we've lost that old value.  */
-  if (need_to_fetch && value && value_lazy (value))
+  if (need_to_fetch && value && value->lazy ())
     {
       const struct varobj *parent = var->parent;
       bool frozen = var->frozen;
@@ -1292,7 +1292,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial)
      lazy -- if it is, the code above has decided that the value
      should not be fetched.  */
   std::string print_value;
-  if (value != NULL && !value_lazy (value)
+  if (value != NULL && !value->lazy ()
       && var->dynamic->pretty_printer == NULL)
     print_value = varobj_value_get_print_value (value, var->format, var);
 
@@ -1312,7 +1312,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial)
 	{
 	  /* Try to compare the values.  That requires that both
 	     values are non-lazy.  */
-	  if (var->not_fetched && value_lazy (var->value.get ()))
+	  if (var->not_fetched && var->value.get ()->lazy ())
 	    {
 	      /* This is a frozen varobj and the value was never read.
 		 Presumably, UI shows some "never read" indicator.
@@ -1330,8 +1330,8 @@ install_new_value (struct varobj *var, struct value *value, bool initial)
 	    }
 	  else
 	    {
-	      gdb_assert (!value_lazy (var->value.get ()));
-	      gdb_assert (!value_lazy (value));
+	      gdb_assert (!var->value.get ()->lazy ());
+	      gdb_assert (!value->lazy ());
 
 	      gdb_assert (!var->print_value.empty () && !print_value.empty ());
 	      if (var->print_value != print_value)
@@ -1351,7 +1351,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial)
 
   /* We must always keep the new value, since children depend on it.  */
   var->value = value_holder;
-  if (value && value_lazy (value) && intentionally_not_fetched)
+  if (value && value->lazy () && intentionally_not_fetched)
     var->not_fetched = true;
   else
     var->not_fetched = false;

-- 
2.39.1


  parent reply	other threads:[~2023-02-09 21:39 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09 21:38 [PATCH 00/47] Use methods for struct value Tom Tromey
2023-02-09 21:38 ` [PATCH 01/47] Rename all fields of " Tom Tromey
2023-02-10 21:05   ` Tom Tromey
2023-02-09 21:38 ` [PATCH 02/47] Move ~value body out-of-line Tom Tromey
2023-02-09 21:38 ` [PATCH 03/47] Move struct value to value.h Tom Tromey
2023-02-09 21:38 ` [PATCH 04/47] Turn value_type into method Tom Tromey
2023-02-09 21:38 ` [PATCH 05/47] Turn deprecated_set_value_type into a method Tom Tromey
2023-02-09 21:38 ` [PATCH 06/47] Turn value_arch into method Tom Tromey
2023-02-10  2:08   ` Simon Marchi
2023-02-10 16:36     ` Tom Tromey
2023-02-09 21:38 ` [PATCH 07/47] Turn value_bitsize " Tom Tromey
2023-02-09 21:38 ` [PATCH 08/47] Turn value_bitpos " Tom Tromey
2023-02-09 21:38 ` [PATCH 09/47] Turn value_parent " Tom Tromey
2023-02-09 21:38 ` [PATCH 10/47] Turn value_offset " Tom Tromey
2023-02-09 21:38 ` [PATCH 11/47] Turn deprecated_value_modifiable " Tom Tromey
2023-02-09 21:38 ` [PATCH 12/47] Turn value_enclosing_type " Tom Tromey
2023-02-09 21:38 ` [PATCH 13/47] Turn some value offset functions " Tom Tromey
2023-02-09 21:38 ` Tom Tromey [this message]
2023-02-09 21:38 ` [PATCH 15/47] Turn value_stack and set_value_stack functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 16/47] Turn value_computed_closure and value_computed_funcs " Tom Tromey
2023-02-09 21:38 ` [PATCH 17/47] Convert value_lval_const and deprecated_lval_hack to methods Tom Tromey
2023-02-09 21:38 ` [PATCH 18/47] Turn value_initialized and set_value_initialized functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 19/47] Turn value_address and set_value_address " Tom Tromey
2023-02-09 21:38 ` [PATCH 20/47] Turn more deprecated_* " Tom Tromey
2023-02-09 21:38 ` [PATCH 21/47] Turn allocate_value_lazy into a static "constructor" Tom Tromey
2023-02-09 21:38 ` [PATCH 22/47] Turn allocate_value " Tom Tromey
2023-02-09 21:38 ` [PATCH 23/47] Turn allocate_computed_value into " Tom Tromey
2023-02-09 21:38 ` [PATCH 24/47] Turn allocate_optimized_out_value " Tom Tromey
2023-02-09 21:38 ` [PATCH 25/47] Turn value_zero " Tom Tromey
2023-02-09 21:38 ` [PATCH 26/47] Turn some value_contents functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 27/47] Turn value_fetch_lazy into a method Tom Tromey
2023-02-09 21:38 ` [PATCH 28/47] Turn allocate_value_contents " Tom Tromey
2023-02-09 21:38 ` [PATCH 29/47] Turn value_contents_eq " Tom Tromey
2023-02-10  2:18   ` Simon Marchi
2023-02-10 17:46     ` Tom Tromey
2023-02-09 21:38 ` [PATCH 30/47] Turn value_bits_synthetic_pointer " Tom Tromey
2023-02-09 21:38 ` [PATCH 31/47] Move value_ref_policy methods out-of-line Tom Tromey
2023-02-09 21:38 ` [PATCH 32/47] Turn value_incref and value_decref into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 33/47] Turn remaining value_contents functions " Tom Tromey
2023-02-10  2:24   ` Simon Marchi
2023-02-10 17:46     ` Tom Tromey
2023-02-09 21:38 ` [PATCH 34/47] Fully qualify calls to copy in value.c Tom Tromey
2023-02-09 21:38 ` [PATCH 35/47] Turn value_copy into a method Tom Tromey
2023-02-10  2:42   ` Simon Marchi
2023-02-10 18:03     ` Tom Tromey
2023-02-09 21:38 ` [PATCH 36/47] Turn many optimized-out value functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 37/47] Turn value_non_lval and value_force_lval " Tom Tromey
2023-02-09 21:38 ` [PATCH 38/47] Turn set_value_component_location into method Tom Tromey
2023-02-09 21:39 ` [PATCH 39/47] Change some code to use value methods Tom Tromey
2023-02-09 21:39 ` [PATCH 40/47] Turn some xmethod functions into methods Tom Tromey
2023-02-09 21:39 ` [PATCH 41/47] Turn preserve_one_value into method Tom Tromey
2023-02-09 21:39 ` [PATCH 42/47] Turn various value copying-related functions into methods Tom Tromey
2023-02-10 20:20   ` Tom Tromey
2023-02-09 21:39 ` [PATCH 43/47] Add value::set_modifiable Tom Tromey
2023-02-09 21:39 ` [PATCH 44/47] Make struct value data members private Tom Tromey
2023-02-09 21:39 ` [PATCH 45/47] Make ~value private Tom Tromey
2023-02-09 21:39 ` [PATCH 46/47] Introduce set_lval method on value Tom Tromey
2023-02-09 21:39 ` [PATCH 47/47] Remove deprecated_lval_hack Tom Tromey
2023-02-10  2:54 ` [PATCH 00/47] Use methods for struct value Simon Marchi
2023-02-10 18:08   ` 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=20230209-submit-value-fixups-2023-v1-14-55dc2794dbb9@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).