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

This turns value_contents_raw, value_contents_writeable, and
value_contents_all_raw into methods on value.  The remaining functions
will be changed later in the series; they were a bit trickier and so I
didn't include them in this patch.
---
 gdb/aarch64-linux-tdep.c |  2 +-
 gdb/aarch64-tdep.c       |  6 ++---
 gdb/ada-lang.c           | 26 +++++++++++-----------
 gdb/amd64-tdep.c         |  4 ++--
 gdb/amd64-windows-tdep.c |  2 +-
 gdb/arch-utils.c         |  2 +-
 gdb/arm-tdep.c           |  4 ++--
 gdb/c-lang.c             |  2 +-
 gdb/cp-valprint.c        |  2 +-
 gdb/dummy-frame.c        |  2 +-
 gdb/dwarf2/expr.c        |  6 ++---
 gdb/dwarf2/loc.c         |  4 ++--
 gdb/dwarf2/read.c        |  2 +-
 gdb/eval.c               | 10 ++++-----
 gdb/findvar.c            |  6 ++---
 gdb/frame-unwind.c       |  6 ++---
 gdb/frame.c              |  4 ++--
 gdb/i386-tdep.c          |  4 ++--
 gdb/infrun.c             |  4 ++--
 gdb/opencl-lang.c        | 12 +++++-----
 gdb/ppc-linux-tdep.c     |  2 +-
 gdb/regcache.c           |  4 ++--
 gdb/riscv-tdep.c         |  8 +++----
 gdb/sparc-tdep.c         |  2 +-
 gdb/std-regs.c           |  4 ++--
 gdb/tracepoint.c         |  2 +-
 gdb/valarith.c           | 20 ++++++++---------
 gdb/valops.c             | 32 +++++++++++++-------------
 gdb/valprint.c           |  2 +-
 gdb/value.c              | 58 ++++++++++++++++++++++++------------------------
 gdb/value.h              | 34 +++++++++++++---------------
 gdb/windows-tdep.c       |  2 +-
 32 files changed, 139 insertions(+), 141 deletions(-)

diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 20a041c599e..9d6ed358597 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -1668,7 +1668,7 @@ aarch64_linux_set_memtags (struct gdbarch *gdbarch, struct value *address,
 
       /* Update the value's content with the tag.  */
       enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-      gdb_byte *srcbuf = value_contents_raw (address).data ();
+      gdb_byte *srcbuf = address->contents_raw ().data ();
       store_unsigned_integer (srcbuf, sizeof (addr), byte_order, addr);
     }
   else
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 76c92fd99bd..1a6fdbebc76 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -2494,7 +2494,7 @@ aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value,
     {
       *read_value = value::allocate (valtype);
       aarch64_extract_return_value (valtype, regcache,
-				    value_contents_raw (*read_value).data ());
+				    (*read_value)->contents_raw ().data ());
     }
 
   aarch64_debug_printf ("return value in registers");
@@ -2769,7 +2769,7 @@ aarch64_pseudo_read_value_1 (struct gdbarch *gdbarch,
     mark_value_bytes_unavailable (result_value, 0,
 				  result_value->type ()->length ());
   else
-    memcpy (value_contents_raw (result_value).data (), reg_buf, regsize);
+    memcpy (result_value->contents_raw ().data (), reg_buf, regsize);
 
   return result_value;
  }
@@ -2803,7 +2803,7 @@ aarch64_pseudo_read_value (struct gdbarch *gdbarch, readable_regcache *regcache,
       if (regcache->raw_read_part (x_regnum, offset, 4, data) != REG_VALID)
 	mark_value_bytes_unavailable (result_value, 0, 4);
       else
-	memcpy (value_contents_raw (result_value).data (), data, 4);
+	memcpy (result_value->contents_raw ().data (), data, 4);
 
       return result_value;
     }
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 53265ca1a9c..274b5e3ce03 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2846,7 +2846,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
     }
   else
     v->set_bitsize (bit_size);
-  unpacked = value_contents_writeable (v).data ();
+  unpacked = v->contents_writeable ().data ();
 
   if (bit_size == 0)
     {
@@ -2921,7 +2921,7 @@ ada_value_assign (struct value *toval, struct value *fromval)
       write_memory_with_notification (to_addr, buffer, len);
 
       val = value_copy (toval);
-      memcpy (value_contents_raw (val).data (),
+      memcpy (val->contents_raw ().data (),
 	      value_contents (fromval).data (),
 	      type->length ());
       val->deprecated_set_type (type);
@@ -2970,13 +2970,13 @@ value_assign_to_component (struct value *container, struct value *component,
 	  = component->type ()->length () * TARGET_CHAR_BIT - bits;
       else
 	src_offset = 0;
-      copy_bitwise ((value_contents_writeable (container).data ()
+      copy_bitwise ((container->contents_writeable ().data ()
 		     + offset_in_container),
 		    container->bitpos () + bit_offset_in_container,
 		    value_contents (val).data (), src_offset, bits, 1);
     }
   else
-    copy_bitwise ((value_contents_writeable (container).data ()
+    copy_bitwise ((container->contents_writeable ().data ()
 		   + offset_in_container),
 		  container->bitpos () + bit_offset_in_container,
 		  value_contents (val).data (), 0, bits, 0);
@@ -4529,7 +4529,7 @@ ada_convert_actual (struct value *actual, struct type *formal_type0)
 
 	      actual_type = ada_check_typedef (actual->type ());
 	      val = value::allocate (actual_type);
-	      copy (value_contents (actual), value_contents_raw (val));
+	      copy (value_contents (actual), val->contents_raw ());
 	      actual = ensure_lval (val);
 	    }
 	  result = value_addr (actual);
@@ -4592,12 +4592,12 @@ make_array_descriptor (struct type *type, struct value *arr)
        i > 0; i -= 1)
     {
       modify_field (bounds->type (),
-		    value_contents_writeable (bounds).data (),
+		    bounds->contents_writeable ().data (),
 		    ada_array_bound (arr, i, 0),
 		    desc_bound_bitpos (bounds_type, i, 0),
 		    desc_bound_bitsize (bounds_type, i, 0));
       modify_field (bounds->type (),
-		    value_contents_writeable (bounds).data (),
+		    bounds->contents_writeable ().data (),
 		    ada_array_bound (arr, i, 1),
 		    desc_bound_bitpos (bounds_type, i, 1),
 		    desc_bound_bitsize (bounds_type, i, 1));
@@ -4606,14 +4606,14 @@ make_array_descriptor (struct type *type, struct value *arr)
   bounds = ensure_lval (bounds);
 
   modify_field (descriptor->type (),
-		value_contents_writeable (descriptor).data (),
+		descriptor->contents_writeable ().data (),
 		value_pointer (ensure_lval (arr),
 			       desc_type->field (0).type ()),
 		fat_pntr_data_bitpos (desc_type),
 		fat_pntr_data_bitsize (desc_type));
 
   modify_field (descriptor->type (),
-		value_contents_writeable (descriptor).data (),
+		descriptor->contents_writeable ().data (),
 		value_pointer (bounds,
 			       desc_type->field (1).type ()),
 		fat_pntr_bounds_bitpos (desc_type),
@@ -9282,7 +9282,7 @@ ada_promote_array_of_integrals (struct type *type, struct value *val)
     error (_("unable to determine array bounds"));
 
   value *res = value::allocate (type);
-  gdb::array_view<gdb_byte> res_contents = value_contents_writeable (res);
+  gdb::array_view<gdb_byte> res_contents = res->contents_writeable ();
 
   /* Promote each array element.  */
   for (i = 0; i < hi - lo + 1; i++)
@@ -9404,7 +9404,7 @@ ada_value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
     }
 
   val = value::allocate (type1);
-  store_unsigned_integer (value_contents_raw (val).data (),
+  store_unsigned_integer (val->contents_raw ().data (),
 			  val->type ()->length (),
 			  type_byte_order (type1), v);
   return val;
@@ -10668,7 +10668,7 @@ ada_string_operation::evaluate (struct type *expect_type,
 	struct type *stringtype
 	  = lookup_array_range_type (char_type, 1, str.length ());
 	struct value *val = value::allocate (stringtype);
-	memcpy (value_contents_raw (val).data (), str.c_str (),
+	memcpy (val->contents_raw ().data (), str.c_str (),
 		str.length ());
 	return val;
       }
@@ -10703,7 +10703,7 @@ ada_string_operation::evaluate (struct type *expect_type,
 			       obstack_object_size (&converted)
 			       / char_type->length ());
   struct value *val = value::allocate (stringtype);
-  memcpy (value_contents_raw (val).data (),
+  memcpy (val->contents_raw ().data (),
 	  obstack_base (&converted),
 	  obstack_object_size (&converted));
   return val;
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 03e9ac951c8..085e5327a75 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -358,7 +358,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch,
   value *result_value = value::allocate (register_type (gdbarch, regnum));
   VALUE_LVAL (result_value) = lval_register;
   VALUE_REGNUM (result_value) = regnum;
-  gdb_byte *buf = value_contents_raw (result_value).data ();
+  gdb_byte *buf = result_value->contents_raw ().data ();
 
   if (i386_byte_regnum_p (gdbarch, regnum))
     {
@@ -832,7 +832,7 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function,
   if (read_value != nullptr)
     {
       *read_value = value::allocate (type);
-      readbuf = value_contents_raw (*read_value).data ();
+      readbuf = (*read_value)->contents_raw ().data ();
     }
 
   /* 8. If the class is COMPLEX_X87, the real part of the value is
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index aea8aaa6200..7a7fbbb9859 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -410,7 +410,7 @@ amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function,
 	{
 	  *read_value = value::allocate (type);
 	  regcache->raw_read_part (regnum, 0, len,
-				   value_contents_raw (*read_value).data ());
+				   (*read_value)->contents_raw ().data ());
 	}
       if (writebuf)
 	regcache->raw_write_part (regnum, 0, len, writebuf);
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 49c699fd124..e3af9ce2dbc 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -1179,7 +1179,7 @@ default_gdbarch_return_value
   if (read_value != nullptr)
     {
       *read_value = value::allocate (valtype);
-      readbuf = value_contents_raw (*read_value).data ();
+      readbuf = (*read_value)->contents_raw ().data ();
     }
 
   return gdbarch->return_value (gdbarch, function, valtype, regcache,
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index c4b92ea17d9..bf38880c247 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -9193,7 +9193,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function,
       if (read_value != nullptr)
 	{
 	  *read_value = value::allocate (valtype);
-	  readbuf = value_contents_raw (*read_value).data ();
+	  readbuf = (*read_value)->contents_raw ().data ();
 	}
 
       for (i = 0; i < vfp_base_count; i++)
@@ -9269,7 +9269,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function,
   if (read_value != nullptr)
     {
       *read_value = value::allocate (valtype);
-      gdb_byte *readbuf = value_contents_raw (*read_value).data ();
+      gdb_byte *readbuf = (*read_value)->contents_raw ().data ();
       arm_extract_return_value (valtype, regcache, readbuf);
     }
 
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 255901887d6..ec2e06027d2 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -674,7 +674,7 @@ c_string_operation::evaluate (struct type *expect_type,
 	    error (_("Too many array elements"));
 
 	  result = value::allocate (expect_type);
-	  memcpy (value_contents_raw (result).data (), obstack_base (&output),
+	  memcpy (result->contents_raw ().data (), obstack_base (&output),
 		  obstack_object_size (&output));
 	}
       else
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 268a414a37b..dd396825798 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -762,7 +762,7 @@ test_print_fields (gdbarch *arch)
     }
 
   value *val = value::allocate (the_struct);
-  gdb_byte *contents = value_contents_writeable (val).data ();
+  gdb_byte *contents = val->contents_writeable ().data ();
   store_unsigned_integer (contents, val->enclosing_type ()->length (),
 			  gdbarch_byte_order (arch), 0xe9);
 
diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c
index 6c3dfb1b24d..961b3ac7a25 100644
--- a/gdb/dummy-frame.c
+++ b/gdb/dummy-frame.c
@@ -354,7 +354,7 @@ dummy_frame_prev_register (frame_info_ptr this_frame,
      constructs either a raw or pseudo register from the raw
      register cache.  */
   cache->prev_regcache->cooked_read
-    (regnum, value_contents_writeable (reg_val).data ());
+    (regnum, reg_val->contents_writeable ().data ());
   return reg_val;
 }
 
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index bb77a969784..e08dca01a67 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -164,7 +164,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized)
       if (check_optimized)
 	v_contents = nullptr;
       else
-	v_contents = value_contents_raw (v).data ();
+	v_contents = v->contents_raw ().data ();
       from_contents = nullptr;
     }
 
@@ -1026,7 +1026,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
 	      subobj_offset += n - max;
 
 	    copy (value_contents_all (val).slice (subobj_offset, len),
-		  value_contents_raw (retval));
+		  retval->contents_raw ());
 	  }
 	  break;
 
@@ -1038,7 +1038,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
 	      invalid_synthetic_pointer ();
 
 	    retval = value::allocate (subobj_type);
-	    bfd_byte *contents = value_contents_raw (retval).data ();
+	    bfd_byte *contents = retval->contents_raw ().data ();
 	    memcpy (contents, this->m_data + subobj_offset, n);
 	  }
 	  break;
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 96686d9a110..0aa6aafe823 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1363,8 +1363,8 @@ value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame,
 				 release_value (target_val).release ());
 
   /* Copy the referencing pointer to the new computed value.  */
-  memcpy (value_contents_raw (val).data (),
-	  value_contents_raw (outer_val).data (),
+  memcpy (val->contents_raw ().data (),
+	  outer_val->contents_raw ().data (),
 	  checked_type->length ());
   val->set_lazy (0);
 
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 7da86798454..3faaf2ce883 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9026,7 +9026,7 @@ dwarf2_compute_name (const char *name,
 		      else if (bytes != NULL)
 			{
 			  v = value::allocate (type);
-			  memcpy (value_contents_writeable (v).data (), bytes,
+			  memcpy (v->contents_writeable ().data (), bytes,
 				  type->length ());
 			}
 		      else
diff --git a/gdb/eval.c b/gdb/eval.c
index 7dcad5b5d99..fbc72a5a34e 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2413,7 +2413,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val,
 
       bitsize = TYPE_FIELD_BITSIZE (struct_type, fieldno);
       bitpos = struct_type->field (fieldno).loc_bitpos ();
-      addr = value_contents_writeable (struct_val).data () + bitpos / 8;
+      addr = struct_val->contents_writeable ().data () + bitpos / 8;
       if (bitsize)
 	modify_field (struct_type, addr,
 		      value_as_long (val), bitpos % 8, bitsize);
@@ -2442,7 +2442,7 @@ array_operation::evaluate (struct type *expect_type,
     {
       struct value *rec = value::allocate (expect_type);
 
-      memset (value_contents_raw (rec).data (), '\0', type->length ());
+      memset (rec->contents_raw ().data (), '\0', type->length ());
       return evaluate_struct_tuple (rec, exp, noside, nargs);
     }
 
@@ -2461,7 +2461,7 @@ array_operation::evaluate (struct type *expect_type,
 	  high_bound = (type->length () / element_size) - 1;
 	}
       index = low_bound;
-      memset (value_contents_raw (array).data (), 0, expect_type->length ());
+      memset (array->contents_raw ().data (), 0, expect_type->length ());
       for (tem = nargs; --nargs >= 0;)
 	{
 	  struct value *element;
@@ -2473,7 +2473,7 @@ array_operation::evaluate (struct type *expect_type,
 	  if (index > high_bound)
 	    /* To avoid memory corruption.  */
 	    error (_("Too many array elements"));
-	  memcpy (value_contents_raw (array).data ()
+	  memcpy (array->contents_raw ().data ()
 		  + (index - low_bound) * element_size,
 		  value_contents (element).data (),
 		  element_size);
@@ -2486,7 +2486,7 @@ array_operation::evaluate (struct type *expect_type,
       && type->code () == TYPE_CODE_SET)
     {
       struct value *set = value::allocate (expect_type);
-      gdb_byte *valaddr = value_contents_raw (set).data ();
+      gdb_byte *valaddr = set->contents_raw ().data ();
       struct type *element_type = type->index_type ();
       struct type *check_type = element_type;
       LONGEST low_bound, high_bound;
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 048e439ac33..a64b35c2bcf 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -587,7 +587,7 @@ language_defn::read_var_value (struct symbol *var,
 	}
       /* Put the constant back in target format. */
       v = value::allocate (type);
-      store_signed_integer (value_contents_raw (v).data (), type->length (),
+      store_signed_integer (v->contents_raw ().data (), type->length (),
 			    type_byte_order (type), var->value_longest ());
       VALUE_LVAL (v) = not_lval;
       return v;
@@ -627,7 +627,7 @@ language_defn::read_var_value (struct symbol *var,
 	  type = resolve_dynamic_type (type, {}, /* Unused address.  */ 0);
 	}
       v = value::allocate (type);
-      memcpy (value_contents_raw (v).data (), var->value_bytes (),
+      memcpy (v->contents_raw ().data (), var->value_bytes (),
 	      type->length ());
       VALUE_LVAL (v) = not_lval;
       return v;
@@ -900,7 +900,7 @@ value_from_register (struct type *type, int regnum, frame_info_ptr frame)
       VALUE_NEXT_FRAME_ID (v) = get_frame_id (get_next_frame_sentinel_okay (frame));
       VALUE_REGNUM (v) = regnum;
       ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1,
-				      value_contents_raw (v).data (), &optim,
+				      v->contents_raw ().data (), &optim,
 				      &unavail);
 
       if (!ok)
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index 12f83d58755..279d86a5ffc 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -304,7 +304,7 @@ frame_unwind_got_constant (frame_info_ptr frame, int regnum,
   struct value *reg_val;
 
   reg_val = value::zero (register_type (gdbarch, regnum), not_lval);
-  store_unsigned_integer (value_contents_writeable (reg_val).data (),
+  store_unsigned_integer (reg_val->contents_writeable ().data (),
 			  register_size (gdbarch, regnum), byte_order, val);
   return reg_val;
 }
@@ -316,7 +316,7 @@ frame_unwind_got_bytes (frame_info_ptr frame, int regnum, const gdb_byte *buf)
   struct value *reg_val;
 
   reg_val = value::zero (register_type (gdbarch, regnum), not_lval);
-  memcpy (value_contents_raw (reg_val).data (), buf,
+  memcpy (reg_val->contents_raw ().data (), buf,
 	  register_size (gdbarch, regnum));
   return reg_val;
 }
@@ -333,7 +333,7 @@ frame_unwind_got_address (frame_info_ptr frame, int regnum,
   struct value *reg_val;
 
   reg_val = value::zero (register_type (gdbarch, regnum), not_lval);
-  pack_long (value_contents_writeable (reg_val).data (),
+  pack_long (reg_val->contents_writeable ().data (),
 	     register_type (gdbarch, regnum), addr);
   return reg_val;
 }
diff --git a/gdb/frame.c b/gdb/frame.c
index 935dea1e417..0fcf3f43492 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1598,10 +1598,10 @@ put_frame_register_bytes (frame_info_ptr frame, int regnum,
 					   regnum);
 	  gdb_assert (value != NULL);
 
-	  memcpy ((char *) value_contents_writeable (value).data () + offset,
+	  memcpy ((char *) value->contents_writeable ().data () + offset,
 		  myaddr, curr_len);
 	  put_frame_register (frame, regnum,
-			      value_contents_raw (value).data ());
+			      value->contents_raw ().data ());
 	  release_value (value);
 	}
 
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 5857e16ff36..c6078e726ab 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3095,7 +3095,7 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function,
     {
       *read_value = value::allocate (type);
       i386_extract_return_value (gdbarch, type, regcache,
-				 value_contents_raw (*read_value).data ());
+				 (*read_value)->contents_raw ().data ());
     }
   if (writebuf)
     i386_store_return_value (gdbarch, type, regcache, writebuf);
@@ -3379,7 +3379,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
 {
   gdb_byte raw_buf[I386_MAX_REGISTER_SIZE];
   enum register_status status;
-  gdb_byte *buf = value_contents_raw (result_value).data ();
+  gdb_byte *buf = result_value->contents_raw ().data ();
 
   if (i386_mmx_regnum_p (gdbarch, regnum))
     {
diff --git a/gdb/infrun.c b/gdb/infrun.c
index c45c6b5c802..c5718580162 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -9143,7 +9143,7 @@ siginfo_value_read (struct value *v)
     target_read (current_inferior ()->top_target (),
 		 TARGET_OBJECT_SIGNAL_INFO,
 		 nullptr,
-		 value_contents_all_raw (v).data (),
+		 v->contents_all_raw ().data (),
 		 v->offset (),
 		 v->type ()->length ());
 
@@ -9166,7 +9166,7 @@ siginfo_value_write (struct value *v, struct value *fromval)
   transferred = target_write (current_inferior ()->top_target (),
 			      TARGET_OBJECT_SIGNAL_INFO,
 			      nullptr,
-			      value_contents_all_raw (fromval).data (),
+			      fromval->contents_all_raw ().data (),
 			      v->offset (),
 			      fromval->type ()->length ());
 
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index dc34dee2995..8bc727cdfdf 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -139,7 +139,7 @@ lval_func_read (struct value *v)
   gdb_assert (n <= c->n);
 
   for (i = offset; i < n; i++)
-    memcpy (value_contents_raw (v).data () + j++ * elsize,
+    memcpy (v->contents_raw ().data () + j++ * elsize,
 	    value_contents (c->val).data () + c->indices[i] * elsize,
 	    elsize);
 }
@@ -180,7 +180,7 @@ lval_func_write (struct value *v, struct value *fromval)
       struct value *from_elm_val = value::allocate (eltype);
       struct value *to_elm_val = value_subscript (c->val, c->indices[i]);
 
-      memcpy (value_contents_writeable (from_elm_val).data (),
+      memcpy (from_elm_val->contents_writeable ().data (),
 	      value_contents (fromval).data () + j++ * elsize,
 	      elsize);
       value_assign (to_elm_val, from_elm_val);
@@ -314,7 +314,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside,
 
 	      /* Copy src val contents into the destination value.  */
 	      for (i = 0; i < n; i++)
-		memcpy (value_contents_writeable (ret).data ()
+		memcpy (ret->contents_writeable ().data ()
 			+ (i * elm_type->length ()),
 			value_contents (val).data ()
 			+ (indices[i] * elm_type->length ()),
@@ -472,7 +472,7 @@ opencl_logical_not (struct type *expect_type, struct expression *exp,
 	  value of its operand compares unequal to 0, and -1 (i.e. all bits
 	  set) if the value of its operand compares equal to 0.  */
 	  int tmp = value_logical_not (value_subscript (arg, i)) ? -1 : 0;
-	  memset ((value_contents_writeable (ret).data ()
+	  memset ((ret->contents_writeable ().data ()
 		   + i * eltype->length ()),
 		  tmp, eltype->length ());
 	}
@@ -573,7 +573,7 @@ vector_relop (struct expression *exp, struct value *val1, struct value *val2,
 	 if the specified relation is true.  */
       int tmp = scalar_relop (value_subscript (val1, i),
 			      value_subscript (val2, i), op) ? -1 : 0;
-      memset ((value_contents_writeable (ret).data ()
+      memset ((ret->contents_writeable ().data ()
 	       + i * eltype1->length ()),
 	      tmp, eltype1->length ());
      }
@@ -837,7 +837,7 @@ Cannot perform conditional operation on vectors with different sizes"));
 	{
 	  tmp = value_logical_not (value_subscript (arg1, i)) ?
 	    value_subscript (arg3, i) : value_subscript (arg2, i);
-	  memcpy (value_contents_writeable (ret).data () +
+	  memcpy (ret->contents_writeable ().data () +
 		  i * eltype2->length (), value_contents_all (tmp).data (),
 		  eltype2->length ());
 	}
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 2084e2b618f..fcddb2008a0 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -255,7 +255,7 @@ ppc_linux_return_value (struct gdbarch *gdbarch, struct value *function,
   if (read_value != nullptr)
     {
       *read_value = value::allocate (valtype);
-      readbuf = value_contents_raw (*read_value).data ();
+      readbuf = (*read_value)->contents_raw ().data ();
     }
 
   if ((valtype->code () == TYPE_CODE_STRUCT
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 4a31dd5e706..90989595acc 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -716,7 +716,7 @@ readable_regcache::cooked_read (int regnum, gdb_byte *buf)
       computed = gdbarch_pseudo_register_read_value (m_descr->gdbarch,
 						     this, regnum);
       if (value_entirely_available (computed))
-	memcpy (buf, value_contents_raw (computed).data (),
+	memcpy (buf, computed->contents_raw ().data (),
 		m_descr->sizeof_register[regnum]);
       else
 	{
@@ -751,7 +751,7 @@ readable_regcache::cooked_read_value (int regnum)
 	 direction than in the other one, even though the value-based
 	 API is preferred.  */
       if (cooked_read (regnum,
-		       value_contents_raw (result).data ()) == REG_UNAVAILABLE)
+		       result->contents_raw ().data ()) == REG_UNAVAILABLE)
 	mark_value_bytes_unavailable (result, 0,
 				      result->type ()->length ());
 
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 375ba4228a2..f8be46c9fb6 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -3278,7 +3278,7 @@ riscv_return_value (struct gdbarch  *gdbarch,
 			     type_byte_order (arg_type),
 			     arg_type->is_unsigned ());
 	      abi_val = value::allocate (info.type);
-	      unscaled.write (value_contents_raw (abi_val),
+	      unscaled.write (abi_val->contents_raw (),
 			      type_byte_order (info.type),
 			      info.type->is_unsigned ());
 	    }
@@ -3287,12 +3287,12 @@ riscv_return_value (struct gdbarch  *gdbarch,
 	      arg_val = value_from_contents (arg_type, writebuf);
 	      abi_val = value_cast (info.type, arg_val);
 	    }
-	  writebuf = value_contents_raw (abi_val).data ();
+	  writebuf = abi_val->contents_raw ().data ();
 	}
       else
 	{
 	  abi_val = value::allocate (info.type);
-	  readbuf = value_contents_raw (abi_val).data ();
+	  readbuf = abi_val->contents_raw ().data ();
 	}
       arg_len = info.type->length ();
 
@@ -3409,7 +3409,7 @@ riscv_return_value (struct gdbarch  *gdbarch,
 			     type_byte_order (info.type),
 			     info.type->is_unsigned ());
 	      *read_value = value::allocate (arg_type);
-	      unscaled.write (value_contents_raw (*read_value),
+	      unscaled.write ((*read_value)->contents_raw (),
 			      type_byte_order (arg_type),
 			      arg_type->is_unsigned ());
 	    }
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 44f16215bb2..5e582c7b77a 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -1531,7 +1531,7 @@ sparc32_return_value (struct gdbarch *gdbarch, struct value *function,
   if (read_value != nullptr)
     {
       *read_value = value::allocate (type);
-      gdb_byte *readbuf = value_contents_raw (*read_value).data ();
+      gdb_byte *readbuf = (*read_value)->contents_raw ().data ();
       sparc32_extract_return_value (type, regcache, readbuf);
     }
   if (writebuf)
diff --git a/gdb/std-regs.c b/gdb/std-regs.c
index 5520789ea95..54cf9018e42 100644
--- a/gdb/std-regs.c
+++ b/gdb/std-regs.c
@@ -44,7 +44,7 @@ value_of_builtin_frame_fp_reg (frame_info_ptr frame, const void *baton)
     {
       struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
       struct value *val = value::allocate (data_ptr_type);
-      gdb_byte *buf = value_contents_raw (val).data ();
+      gdb_byte *buf = val->contents_raw ().data ();
 
       gdbarch_address_to_pointer (gdbarch, data_ptr_type,
 				  buf, get_frame_base_address (frame));
@@ -63,7 +63,7 @@ value_of_builtin_frame_pc_reg (frame_info_ptr frame, const void *baton)
     {
       struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
       struct value *val = value::allocate (func_ptr_type);
-      gdb_byte *buf = value_contents_raw (val).data ();
+      gdb_byte *buf = val->contents_raw ().data ();
 
       gdbarch_address_to_pointer (gdbarch, func_ptr_type,
 				  buf, get_frame_pc (frame));
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index bd02cae05ee..1c1fea7d970 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -3778,7 +3778,7 @@ sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var,
       type = init_vector_type (builtin_type (gdbarch)->builtin_true_char,
 			       buf->size ());
       v = value::allocate (type);
-      memcpy (value_contents_raw (v).data (), buf->data (), buf->size ());
+      memcpy (v->contents_raw ().data (), buf->data (), buf->size ());
       return v;
     }
   else
diff --git a/gdb/valarith.c b/gdb/valarith.c
index a2fc1829cd3..adc7da76b65 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -702,7 +702,7 @@ value_concat (struct value *arg1, struct value *arg2)
 						lowbound + n_elts - 1);
 
   struct value *result = value::allocate (atype);
-  gdb::array_view<gdb_byte> contents = value_contents_raw (result);
+  gdb::array_view<gdb_byte> contents = result->contents_raw ();
   gdb::array_view<const gdb_byte> lhs_contents = value_contents (arg1);
   gdb::array_view<const gdb_byte> rhs_contents = value_contents (arg2);
   gdb::copy (lhs_contents, contents.slice (0, lhs_contents.size ()));
@@ -857,7 +857,7 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
       value *fp_val = value::allocate (type1);
 
       fp.write_fixed_point
-	(value_contents_raw (fp_val),
+      (fp_val->contents_raw (),
 	 type_byte_order (type1),
 	 type1->is_unsigned (),
 	 type1->fixed_point_scaling_factor ());
@@ -1176,7 +1176,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
 				  v2.data (), &eff_type_v2);
       target_float_binop (op, v1.data (), eff_type_v1,
 			      v2.data (), eff_type_v2,
-			      value_contents_raw (val).data (), result_type);
+			  val->contents_raw ().data (), result_type);
     }
   else if (type1->code () == TYPE_CODE_BOOL
 	   || type2->code () == TYPE_CODE_BOOL)
@@ -1215,7 +1215,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
       result_type = type1;
 
       val = value::allocate (result_type);
-      store_signed_integer (value_contents_raw (val).data (),
+      store_signed_integer (val->contents_raw ().data (),
 			    result_type->length (),
 			    type_byte_order (result_type),
 			    v);
@@ -1361,7 +1361,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
 	    }
 
 	  val = value::allocate (result_type);
-	  store_unsigned_integer (value_contents_raw (val).data (),
+	  store_unsigned_integer (val->contents_raw ().data (),
 				  val->type ()->length (),
 				  type_byte_order (result_type),
 				  v);
@@ -1522,7 +1522,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
 	    }
 
 	  val = value::allocate (result_type);
-	  store_signed_integer (value_contents_raw (val).data (),
+	  store_signed_integer (val->contents_raw ().data (),
 				val->type ()->length (),
 				type_byte_order (result_type),
 				v);
@@ -1567,7 +1567,7 @@ value_vector_widen (struct value *scalar_value, struct type *vector_type)
     error (_("conversion of scalar to vector involves truncation"));
 
   value *val = value::allocate (vector_type);
-  gdb::array_view<gdb_byte> val_contents = value_contents_writeable (val);
+  gdb::array_view<gdb_byte> val_contents = val->contents_writeable ();
   int elt_len = eltype->length ();
 
   for (i = 0; i < high_bound - low_bound + 1; i++)
@@ -1614,7 +1614,7 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op)
     error (_("Cannot perform operation on vectors with different types"));
 
   value *val = value::allocate (type1);
-  gdb::array_view<gdb_byte> val_contents = value_contents_writeable (val);
+  gdb::array_view<gdb_byte> val_contents = val->contents_writeable ();
   scoped_value_mark mark;
   for (i = 0; i < high_bound1 - low_bound1 + 1; i++)
     {
@@ -1909,7 +1909,7 @@ value_neg (struct value *arg1)
       if (!get_array_bounds (type, &low_bound, &high_bound))
 	error (_("Could not determine the vector bounds"));
 
-      gdb::array_view<gdb_byte> val_contents = value_contents_writeable (val);
+      gdb::array_view<gdb_byte> val_contents = val->contents_writeable ();
       int elt_len = eltype->length ();
 
       for (i = 0; i < high_bound - low_bound + 1; i++)
@@ -1954,7 +1954,7 @@ value_complement (struct value *arg1)
 	error (_("Could not determine the vector bounds"));
 
       val = value::allocate (type);
-      gdb::array_view<gdb_byte> val_contents = value_contents_writeable (val);
+      gdb::array_view<gdb_byte> val_contents = val->contents_writeable ();
       int elt_len = eltype->length ();
 
       for (i = 0; i < high_bound - low_bound + 1; i++)
diff --git a/gdb/valops.c b/gdb/valops.c
index a6357f0afca..738967cc88d 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -392,7 +392,7 @@ value_cast_to_fixed_point (struct type *to_type, struct value *from_val)
   /* Finally, create the result value, and pack the unscaled value
      in it.  */
   struct value *result = value::allocate (to_type);
-  unscaled.write (value_contents_raw (result),
+  unscaled.write (result->contents_raw (),
 		  type_byte_order (to_type),
 		  to_type->is_unsigned ());
 
@@ -545,7 +545,7 @@ value_cast (struct type *type, struct value *arg2)
 	{
 	  struct value *v = value::allocate (to_type);
 	  target_float_convert (value_contents (arg2).data (), type2,
-				value_contents_raw (v).data (), type);
+				v->contents_raw ().data (), type);
 	  return v;
 	}
       else if (is_fixed_point_type (type2))
@@ -558,7 +558,7 @@ value_cast (struct type *type, struct value *arg2)
 				   type2->fixed_point_scaling_factor ());
 
 	  struct value *v = value::allocate (to_type);
-	  target_float_from_host_double (value_contents_raw (v).data (),
+	  target_float_from_host_double (v->contents_raw ().data (),
 					 to_type, mpq_get_d (fp_val.val));
 	  return v;
 	}
@@ -621,7 +621,7 @@ value_cast (struct type *type, struct value *arg2)
       struct value *result = value::allocate (to_type);
 
       cplus_make_method_ptr (to_type,
-			     value_contents_writeable (result).data (), 0, 0);
+			     result->contents_writeable ().data (), 0, 0);
       return result;
     }
   else if (code1 == TYPE_CODE_MEMBERPTR && code2 == TYPE_CODE_INT
@@ -955,7 +955,7 @@ value_one (struct type *type)
 	error (_("Could not determine the vector bounds"));
 
       val = value::allocate (type);
-      gdb::array_view<gdb_byte> val_contents = value_contents_writeable (val);
+      gdb::array_view<gdb_byte> val_contents = val->contents_writeable ();
       int elt_len = eltype->length ();
 
       for (i = 0; i < high_bound - low_bound + 1; i++)
@@ -1344,7 +1344,7 @@ value_assign (struct value *toval, struct value *fromval)
      implies the returned value is not lazy, even if TOVAL was.  */
   val = value_copy (toval);
   val->set_lazy (0);
-  copy (value_contents (fromval), value_contents_raw (val));
+  copy (value_contents (fromval), val->contents_raw ());
 
   /* We copy over the enclosing type and pointed-to offset from FROMVAL
      in the case of pointer types.  For object types, the enclosing type
@@ -1377,7 +1377,7 @@ value_repeat (struct value *arg1, int count)
   val->set_address (arg1->address ());
 
   read_value_memory (val, 0, val->stack (), val->address (),
-		     value_contents_all_raw (val).data (),
+		     val->contents_all_raw ().data (),
 		     type_length_units (val->enclosing_type ()));
 
   return val;
@@ -1750,7 +1750,7 @@ value_cstring (const char *ptr, ssize_t len, struct type *char_type)
     = lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1);
 
   val = value::allocate (stringtype);
-  memcpy (value_contents_raw (val).data (), ptr, len);
+  memcpy (val->contents_raw ().data (), ptr, len);
   return val;
 }
 
@@ -1773,7 +1773,7 @@ value_string (const char *ptr, ssize_t len, struct type *char_type)
     = lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1);
 
   val = value::allocate (stringtype);
-  memcpy (value_contents_raw (val).data (), ptr, len);
+  memcpy (val->contents_raw ().data (), ptr, len);
   return val;
 }
 
@@ -2101,7 +2101,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset,
 	      base_addr = arg1->address () + boffset;
 	      v2 = value_at_lazy (basetype, base_addr);
 	      if (target_read_memory (base_addr, 
-				      value_contents_raw (v2).data (),
+				      v2->contents_raw ().data (),
 				      v2->type ()->length ()) != 0)
 		error (_("virtual baseclass botch"));
 	    }
@@ -3740,7 +3740,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
 		  result = value::allocate
 		    (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
 		  cplus_make_method_ptr (result->type (),
-					 value_contents_writeable (result).data (),
+					 result->contents_writeable ().data (),
 					 TYPE_FN_FIELD_VOFFSET (f, j), 1);
 		}
 	      else if (noside == EVAL_AVOID_SIDE_EFFECTS)
@@ -3765,7 +3765,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
 		{
 		  result = value::allocate (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
 		  cplus_make_method_ptr (result->type (),
-					 value_contents_writeable (result).data (),
+					 result->contents_writeable ().data (),
 					 v->address (), 0);
 		}
 	    }
@@ -4111,9 +4111,9 @@ value_literal_complex (struct value *arg1,
   int len = real_type->length ();
 
   copy (value_contents (arg1),
-	value_contents_raw (val).slice (0, len));
+	val->contents_raw ().slice (0, len));
   copy (value_contents (arg2),
-	value_contents_raw (val).slice (len, len));
+	val->contents_raw ().slice (len, len));
 
   return val;
 }
@@ -4158,9 +4158,9 @@ cast_into_complex (struct type *type, struct value *val)
       int len = val_real_type->length ();
 
       copy (value_contents (val).slice (0, len),
-	    value_contents_raw (re_val));
+	    re_val->contents_raw ());
       copy (value_contents (val).slice (len, len),
-	    value_contents_raw (im_val));
+	    im_val->contents_raw ());
 
       return value_literal_complex (re_val, im_val, type);
     }
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 4a2aa5f4878..8c6973ca1f1 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -3092,7 +3092,7 @@ test_print_flags (gdbarch *arch)
   append_flags_type_field (flags_type, 5, 3, field_type, "C");
 
   value *val = value::allocate (flags_type);
-  gdb_byte *contents = value_contents_writeable (val).data ();
+  gdb_byte *contents = val->contents_writeable ().data ();
   store_unsigned_integer (contents, 4, gdbarch_byte_order (arch), 0xaa);
 
   string_file out;
diff --git a/gdb/value.c b/gdb/value.c
index 550bcb4709f..c22c7670a6a 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -891,25 +891,25 @@ value::allocate_optimized_out (struct type *type)
 /* Accessor methods.  */
 
 gdb::array_view<gdb_byte>
-value_contents_raw (struct value *value)
+value::contents_raw ()
 {
-  struct gdbarch *arch = value->get_arch ();
+  struct gdbarch *arch = get_arch ();
   int unit_size = gdbarch_addressable_memory_unit_size (arch);
 
-  allocate_value_contents (value);
+  allocate_value_contents (this);
 
-  ULONGEST length = value->type ()->length ();
+  ULONGEST length = type ()->length ();
   return gdb::make_array_view
-    (value->m_contents.get () + value->m_embedded_offset * unit_size, length);
+    (m_contents.get () + m_embedded_offset * unit_size, length);
 }
 
 gdb::array_view<gdb_byte>
-value_contents_all_raw (struct value *value)
+value::contents_all_raw ()
 {
-  allocate_value_contents (value);
+  allocate_value_contents (this);
 
-  ULONGEST length = value->enclosing_type ()->length ();
-  return gdb::make_array_view (value->m_contents.get (), length);
+  ULONGEST length = enclosing_type ()->length ();
+  return gdb::make_array_view (m_contents.get (), length);
 }
 
 /* Look at value.h for description.  */
@@ -1083,10 +1083,10 @@ value_contents_copy_raw (struct value *dst, LONGEST dst_offset,
 
   /* Copy the data.  */
   gdb::array_view<gdb_byte> dst_contents
-    = value_contents_all_raw (dst).slice (dst_offset * unit_size,
+    = dst->contents_all_raw ().slice (dst_offset * unit_size,
 					  length * unit_size);
   gdb::array_view<const gdb_byte> src_contents
-    = value_contents_all_raw (src).slice (src_offset * unit_size,
+    = src->contents_all_raw ().slice (src_offset * unit_size,
 					  length * unit_size);
   copy (src_contents, dst_contents);
 
@@ -1124,8 +1124,8 @@ value_contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset,
 					     bit_length));
 
   /* Copy the data.  */
-  gdb::array_view<gdb_byte> dst_contents = value_contents_all_raw (dst);
-  gdb::array_view<const gdb_byte> src_contents = value_contents_all_raw (src);
+  gdb::array_view<gdb_byte> dst_contents = dst->contents_all_raw ();
+  gdb::array_view<const gdb_byte> src_contents = src->contents_all_raw ();
   copy_bitwise (dst_contents.data (), dst_bit_offset,
 		src_contents.data (), src_bit_offset,
 		bit_length,
@@ -1160,18 +1160,18 @@ value_contents_copy (struct value *dst, LONGEST dst_offset,
 gdb::array_view<const gdb_byte>
 value_contents (struct value *value)
 {
-  gdb::array_view<const gdb_byte> result = value_contents_writeable (value);
+  gdb::array_view<const gdb_byte> result = value->contents_writeable ();
   require_not_optimized_out (value);
   require_available (value);
   return result;
 }
 
 gdb::array_view<gdb_byte>
-value_contents_writeable (struct value *value)
+value::contents_writeable ()
 {
-  if (value->m_lazy)
-    value_fetch_lazy (value);
-  return value_contents_raw (value);
+  if (m_lazy)
+    value_fetch_lazy (this);
+  return contents_raw ();
 }
 
 int
@@ -1438,7 +1438,7 @@ value_copy (const value *arg)
       ULONGEST length = arg->enclosing_type ()->length ();
       const auto &arg_view
 	= gdb::make_array_view (arg->m_contents.get (), length);
-      copy (arg_view, value_contents_all_raw (val));
+      copy (arg_view, val->contents_all_raw ());
     }
 
   val->m_parent = arg->m_parent;
@@ -1481,7 +1481,7 @@ value_non_lval (struct value *arg)
       struct type *enc_type = arg->enclosing_type ();
       struct value *val = value::allocate (enc_type);
 
-      copy (value_contents_all (arg), value_contents_all_raw (val));
+      copy (value_contents_all (arg), val->contents_all_raw ());
       val->m_type = arg->m_type;
       val->set_embedded_offset (arg->embedded_offset ());
       val->set_pointed_to_offset (arg->pointed_to_offset ());
@@ -1497,7 +1497,7 @@ value_force_lval (struct value *v, CORE_ADDR addr)
 {
   gdb_assert (VALUE_LVAL (v) == not_lval);
 
-  write_memory (addr, value_contents_raw (v).data (), v->type ()->length ());
+  write_memory (addr, v->contents_raw ().data (), v->type ()->length ());
   v->m_lval = lval_memory;
   v->m_location.address = addr;
 }
@@ -2030,7 +2030,7 @@ set_internalvar_component (struct internalvar *var,
   switch (var->kind)
     {
     case INTERNALVAR_VALUE:
-      addr = value_contents_writeable (var->u.value).data ();
+      addr = var->u.value->contents_writeable ().data ();
       arch = var->u.value->get_arch ();
       unit_size = gdbarch_addressable_memory_unit_size (arch);
 
@@ -3065,7 +3065,7 @@ unpack_value_bitfield (struct value *dest_val,
 
       num = unpack_bits_as_long (field_type, valaddr + embedded_offset,
 				 bitpos, bitsize);
-      store_signed_integer (value_contents_raw (dest_val).data (),
+      store_signed_integer (dest_val->contents_raw ().data (),
 			    field_type->length (), byte_order, num);
     }
 
@@ -3271,7 +3271,7 @@ value_from_longest (struct type *type, LONGEST num)
 {
   struct value *val = value::allocate (type);
 
-  pack_long (value_contents_raw (val).data (), type, num);
+  pack_long (val->contents_raw ().data (), type, num);
   return val;
 }
 
@@ -3283,7 +3283,7 @@ value_from_ulongest (struct type *type, ULONGEST num)
 {
   struct value *val = value::allocate (type);
 
-  pack_unsigned_long (value_contents_raw (val).data (), type, num);
+  pack_unsigned_long (val->contents_raw ().data (), type, num);
 
   return val;
 }
@@ -3297,7 +3297,7 @@ value_from_pointer (struct type *type, CORE_ADDR addr)
 {
   struct value *val = value::allocate (type);
 
-  store_typed_address (value_contents_raw (val).data (),
+  store_typed_address (val->contents_raw ().data (),
 		       check_typedef (type), addr);
   return val;
 }
@@ -3311,7 +3311,7 @@ value_from_host_double (struct type *type, double d)
 {
   struct value *value = value::allocate (type);
   gdb_assert (type->code () == TYPE_CODE_FLT);
-  target_float_from_host_double (value_contents_raw (value).data (),
+  target_float_from_host_double (value->contents_raw ().data (),
 				 value->type (), d);
   return value;
 }
@@ -3377,7 +3377,7 @@ value_from_contents (struct type *type, const gdb_byte *contents)
   struct value *result;
 
   result = value::allocate (type);
-  memcpy (value_contents_raw (result).data (), contents, type->length ());
+  memcpy (result->contents_raw ().data (), contents, type->length ());
   return result;
 }
 
@@ -3657,7 +3657,7 @@ value_fetch_lazy_memory (struct value *val)
 
   if (type->length ())
     read_value_memory (val, 0, val->stack (),
-			 addr, value_contents_all_raw (val).data (),
+		       addr, val->contents_all_raw ().data (),
 			 type_length_units (type));
 }
 
diff --git a/gdb/value.h b/gdb/value.h
index e45ff9f8d9f..4f161a9ed4f 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -371,6 +371,22 @@ struct value
 
   int *deprecated_regnum_hack ();
 
+  /* contents() and contents_raw() both return the address of the gdb
+     buffer used to hold a copy of the contents of the lval.
+     contents() is used when the contents of the buffer are needed --
+     it uses fetch_lazy() to load the buffer from the process being
+     debugged if it hasn't already been loaded (contents_writeable()
+     is used when a writeable but fetched buffer is required)..
+     contents_raw() is used when data is being stored into the buffer,
+     or when it is certain that the contents of the buffer are valid.
+
+     Note: The contents pointer is adjusted by the offset required to
+     get to the real subobject, if the value happens to represent
+     something embedded in a larger run-time object.  */
+  gdb::array_view<gdb_byte> contents_raw ();
+  gdb::array_view<gdb_byte> contents_all_raw ();
+  gdb::array_view<gdb_byte> contents_writeable ();
+
 
   /* Type of value; either not an lval, or one of the various
      different possible kinds of lval.  */
@@ -620,22 +636,6 @@ struct lval_funcs
 
 extern void error_value_optimized_out (void);
 
-/* value_contents() and value_contents_raw() both return the address
-   of the gdb buffer used to hold a copy of the contents of the lval.
-   value_contents() is used when the contents of the buffer are needed
-   -- it uses value_fetch_lazy() to load the buffer from the process
-   being debugged if it hasn't already been loaded
-   (value_contents_writeable() is used when a writeable but fetched
-   buffer is required)..  value_contents_raw() is used when data is
-   being stored into the buffer, or when it is certain that the
-   contents of the buffer are valid.
-
-   Note: The contents pointer is adjusted by the offset required to
-   get to the real subobject, if the value happens to represent
-   something embedded in a larger run-time object.  */
-
-extern gdb::array_view<gdb_byte> value_contents_raw (struct value *);
-
 /* Actual contents of the value.  For use of this value; setting it
    uses the stuff above.  Not valid if lazy is nonzero.  Target
    byte-order.  We force it to be aligned properly for any possible
@@ -643,12 +643,10 @@ extern gdb::array_view<gdb_byte> value_contents_raw (struct value *);
    declared here.  */
 
 extern gdb::array_view<const gdb_byte> value_contents (struct value *);
-extern gdb::array_view<gdb_byte> value_contents_writeable (struct value *);
 
 /* The ALL variants of the above two macros do not adjust the returned
    pointer by the embedded_offset value.  */
 
-extern gdb::array_view<gdb_byte> value_contents_all_raw (struct value *);
 extern gdb::array_view<const gdb_byte> value_contents_all (struct value *);
 
 /* Like value_contents_all, but does not require that the returned
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index 893e34d9912..97199527c8b 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -404,7 +404,7 @@ tlb_value_read (struct value *val)
 
   if (!target_get_tib_address (inferior_ptid, &tlb))
     error (_("Unable to read tlb"));
-  store_typed_address (value_contents_raw (val).data (), type, tlb);
+  store_typed_address (val->contents_raw ().data (), type, tlb);
 }
 
 /* This function implements the lval_computed support for writing a

-- 
2.39.1


  parent reply	other threads:[~2023-02-09 21:38 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 ` [PATCH 14/47] Turn value_lazy and set_value_lazy functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 15/47] Turn value_stack and set_value_stack " 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 ` Tom Tromey [this message]
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-26-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).