[v2,47/48] Remove deprecated_lval_hack

Message ID 20230209-submit-value-fixups-2023-v2-47-b0b27fd97177@tromey.com
State New
Headers
Series Use methods for struct value |

Commit Message

Tom Tromey Feb. 10, 2023, 9:53 p.m. UTC
  This removes deprecated_lval_hack and the VALUE_LVAL macro, replacing
all uses with a call to value::lval.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
---
 gdb/ada-lang.c                      | 28 +++++++++++-----------
 gdb/breakpoint.c                    |  8 +++----
 gdb/c-lang.c                        |  6 ++---
 gdb/cli/cli-dump.c                  |  2 +-
 gdb/compile/compile-c-symbols.c     |  2 +-
 gdb/compile/compile-cplus-symbols.c |  2 +-
 gdb/compile/compile-loc2c.c         |  2 +-
 gdb/dwarf2/frame.c                  |  2 +-
 gdb/dwarf2/loc.c                    |  6 ++---
 gdb/eval.c                          | 12 +++++-----
 gdb/expop.h                         |  2 +-
 gdb/f-lang.c                        |  8 +++----
 gdb/findvar.c                       |  2 +-
 gdb/frame.c                         |  8 +++----
 gdb/gdbtypes.c                      |  2 +-
 gdb/infcall.c                       |  2 +-
 gdb/m2-lang.c                       |  2 +-
 gdb/opencl-lang.c                   |  6 ++---
 gdb/ppc-linux-nat.c                 |  8 +++----
 gdb/printcmd.c                      |  8 +++----
 gdb/python/py-unwind.c              |  2 +-
 gdb/rust-lang.c                     |  4 ++--
 gdb/stack.c                         |  6 ++---
 gdb/valarith.c                      | 14 +++++------
 gdb/valops.c                        | 34 +++++++++++++--------------
 gdb/value.c                         | 46 ++++++++++++++++++-------------------
 gdb/value.h                         | 10 --------
 gdb/varobj.c                        |  2 +-
 28 files changed, 113 insertions(+), 123 deletions(-)
  

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1fd424c60c2..ec85729042f 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -559,7 +559,7 @@  coerce_unspec_val_to_type (struct value *val, struct type *type)
 	result = value::allocate_optimized_out (type);
       else if (val->lazy ()
 	       /* Be careful not to make a lazy not_lval value.  */
-	       || (VALUE_LVAL (val) != not_lval
+	       || (val->lval () != not_lval
 		   && type->length () > val->type ()->length ()))
 	result = value::allocate_lazy (type);
       else
@@ -570,7 +570,7 @@  coerce_unspec_val_to_type (struct value *val, struct type *type)
       result->set_component_location (val);
       result->set_bitsize (val->bitsize ());
       result->set_bitpos (val->bitpos ());
-      if (VALUE_LVAL (result) == lval_memory)
+      if (result->lval () == lval_memory)
 	result->set_address (val->address ());
       return result;
     }
@@ -2810,7 +2810,7 @@  ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
       v = value::allocate (type);
       src = valaddr + offset;
     }
-  else if (VALUE_LVAL (obj) == lval_memory && obj->lazy ())
+  else if (obj->lval () == lval_memory && obj->lazy ())
     {
       int src_len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8;
       gdb_byte *buf;
@@ -2891,7 +2891,7 @@  ada_value_assign (struct value *toval, struct value *fromval)
   if (!toval->deprecated_modifiable ())
     error (_("Left operand of assignment is not a modifiable lvalue."));
 
-  if (VALUE_LVAL (toval) == lval_memory
+  if (toval->lval () == lval_memory
       && bits > 0
       && (type->code () == TYPE_CODE_FLT
 	  || type->code () == TYPE_CODE_STRUCT))
@@ -4349,8 +4349,8 @@  ada_read_renaming_var_value (struct symbol *renaming_sym,
 static struct value *
 ensure_lval (struct value *val)
 {
-  if (VALUE_LVAL (val) == not_lval
-      || VALUE_LVAL (val) == lval_internalvar)
+  if (val->lval () == not_lval
+      || val->lval () == lval_internalvar)
     {
       int len = ada_check_typedef (val->type ())->length ();
       const CORE_ADDR addr =
@@ -4523,7 +4523,7 @@  ada_convert_actual (struct value *actual, struct type *formal_type0)
 	result = desc_data (actual);
       else if (formal_type->code () != TYPE_CODE_PTR)
 	{
-	  if (VALUE_LVAL (actual) != lval_memory)
+	  if (actual->lval () != lval_memory)
 	    {
 	      struct value *val;
 
@@ -8841,7 +8841,7 @@  ada_to_fixed_value_create (struct type *type0, CORE_ADDR address,
   if (type == type0 && val0 != NULL)
     return val0;
 
-  if (VALUE_LVAL (val0) != lval_memory)
+  if (val0->lval () != lval_memory)
     {
       /* Our value does not live in memory; it could be a convenience
 	 variable, for instance.  Create a not_lval value using val0's
@@ -9771,12 +9771,12 @@  ada_assign_operation::evaluate (struct type *expect_type,
      In the case of assigning to a convenience variable, the lhs
      should be exactly the result of the evaluation of the rhs.  */
   struct type *type = arg1->type ();
-  if (VALUE_LVAL (arg1) == lval_internalvar)
+  if (arg1->lval () == lval_internalvar)
     type = NULL;
   value *arg2 = std::get<1> (m_storage)->evaluate (type, exp, noside);
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
     return arg1;
-  if (VALUE_LVAL (arg1) == lval_internalvar)
+  if (arg1->lval () == lval_internalvar)
     {
       /* Nothing.  */
     }
@@ -10279,7 +10279,7 @@  ada_ternop_slice (struct expression *exp,
      convert to a pointer.  */
   if (array->type ()->code () == TYPE_CODE_REF
       || (array->type ()->code () == TYPE_CODE_ARRAY
-	  && VALUE_LVAL (array) == lval_memory))
+	  && array->lval () == lval_memory))
     array = value_addr (array);
 
   if (noside == EVAL_AVOID_SIDE_EFFECTS
@@ -10850,7 +10850,7 @@  ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type,
 
   /* Follow the Ada language semantics that do not allow taking
      an address of the result of a cast (view conversion in Ada).  */
-  if (VALUE_LVAL (val) == lval_memory)
+  if (val->lval () == lval_memory)
     {
       if (val->lazy ())
 	val->fetch_lazy ();
@@ -10872,7 +10872,7 @@  ada_var_value_operation::evaluate_for_cast (struct type *expect_type,
 
   /* Follow the Ada language semantics that do not allow taking
      an address of the result of a cast (view conversion in Ada).  */
-  if (VALUE_LVAL (val) == lval_memory)
+  if (val->lval () == lval_memory)
     {
       if (val->lazy ())
 	val->fetch_lazy ();
@@ -11169,7 +11169,7 @@  ada_funcall_operation::evaluate (struct type *expect_type,
       callee = ada_to_fixed_value (coerce_ref (callee));
     }
   else if (callee->type ()->code () == TYPE_CODE_ARRAY
-	   && VALUE_LVAL (callee) == lval_memory)
+	   && callee->lval () == lval_memory)
     callee = value_addr (callee);
 
   struct type *type = ada_check_typedef (callee->type ());
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 2ccc7c97b4c..239926ffd4a 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2066,7 +2066,7 @@  update_watchpoint (struct watchpoint *b, bool reparse)
 	     must watch it.  If the first value returned is
 	     still lazy, that means an error occurred reading it;
 	     watch it anyway in case it becomes readable.  */
-	  if (VALUE_LVAL (v) == lval_memory
+	  if (v->lval () == lval_memory
 	      && (v == val_chain[0] || ! v->lazy ()))
 	    {
 	      struct type *vtype = check_typedef (v->type ());
@@ -10381,7 +10381,7 @@  can_use_hardware_watchpoint (const std::vector<value_ref_ptr> &vals)
     {
       struct value *v = iter.get ();
 
-      if (VALUE_LVAL (v) == lval_memory)
+      if (v->lval () == lval_memory)
 	{
 	  if (v != head && v->lazy ())
 	    /* A lazy memory lvalue in the chain is one that GDB never
@@ -10419,10 +10419,10 @@  can_use_hardware_watchpoint (const std::vector<value_ref_ptr> &vals)
 		}
 	    }
 	}
-      else if (VALUE_LVAL (v) != not_lval
+      else if (v->lval () != not_lval
 	       && v->deprecated_modifiable () == 0)
 	return 0;	/* These are values from the history (e.g., $1).  */
-      else if (VALUE_LVAL (v) == lval_register)
+      else if (v->lval () == lval_register)
 	return 0;	/* Cannot watch a register with a HW watchpoint.  */
     }
 
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index e4027d8ee96..6535ab93498 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -294,8 +294,8 @@  c_get_string (struct value *value, gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
      C struct hack.  So, only do this if either no length was
      specified, or the length is within the existing bounds.  This
      avoids running off the end of the value's contents.  */
-  if ((VALUE_LVAL (value) == not_lval
-       || VALUE_LVAL (value) == lval_internalvar
+  if ((value->lval () == not_lval
+       || value->lval () == lval_internalvar
        || type->code () == TYPE_CODE_ARRAY)
       && fetchlimit != UINT_MAX
       && (*length < 0 || *length <= fetchlimit))
@@ -328,7 +328,7 @@  c_get_string (struct value *value, gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
       CORE_ADDR addr;
       if (type->code () == TYPE_CODE_ARRAY)
 	{
-	  if (VALUE_LVAL (value) != lval_memory)
+	  if (value->lval () != lval_memory)
 	    error (_("Attempt to take address of value "
 		     "not located in memory."));
 	  addr = value->address ();
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 769f6a589b6..08984f6fdf3 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -230,7 +230,7 @@  dump_value_to_file (const char *cmd, const char *mode, const char *file_format)
     {
       CORE_ADDR vaddr;
 
-      if (VALUE_LVAL (val))
+      if (val->lval ())
 	{
 	  vaddr = val->address ();
 	}
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 5b53ab3263f..6faff0eee06 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -156,7 +156,7 @@  convert_one_symbol (compile_c_instance *context,
 	      }
 
 	    val = read_var_value (sym.symbol, sym.block, frame);
-	    if (VALUE_LVAL (val) != lval_memory)
+	    if (val->lval () != lval_memory)
 	      error (_("Symbol \"%s\" cannot be used for compilation "
 		       "evaluation as its address has not been found."),
 		     sym.symbol->print_name ());
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index 28447776d4f..039aee34ab7 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -150,7 +150,7 @@  convert_one_symbol (compile_cplus_instance *instance,
 	      }
 
 	    val = read_var_value (sym.symbol, sym.block, frame);
-	    if (VALUE_LVAL (val) != lval_memory)
+	    if (val->lval () != lval_memory)
 	      error (_("Symbol \"%s\" cannot be used for compilation "
 		       "evaluation as its address has not been found."),
 		     sym.symbol->print_name ());
diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c
index ae30dd69dec..558460a7c57 100644
--- a/gdb/compile/compile-loc2c.c
+++ b/gdb/compile/compile-loc2c.c
@@ -642,7 +642,7 @@  do_compile_dwarf_expr_to_c (int indent, string_file *stream,
 	       sym->print_name ());
 
       val = read_var_value (sym, NULL, frame);
-      if (VALUE_LVAL (val) != lval_memory)
+      if (val->lval () != lval_memory)
 	error (_("Symbol \"%s\" cannot be used for compilation evaluation "
 		 "as its address has not been found."),
 	       sym->print_name ());
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index a83df2192c3..a561aaf3100 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -235,7 +235,7 @@  execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size,
   ctx.push_address (initial, initial_in_stack_memory);
   value *result_val = ctx.evaluate (exp, len, true, nullptr, this_frame);
 
-  if (VALUE_LVAL (result_val) == lval_memory)
+  if (result_val->lval () == lval_memory)
     return result_val->address ();
   else
     return value_as_address (result_val);
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 616db13488b..27c4b7ce31a 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -684,7 +684,7 @@  call_site_target::iterate_over_addresses
 					dwarf_block->per_cu,
 					dwarf_block->per_objfile);
 	/* DW_AT_call_target is a DWARF expression, not a DWARF location.  */
-	if (VALUE_LVAL (val) == lval_memory)
+	if (val->lval () == lval_memory)
 	  callback (val->address ());
 	else
 	  callback (value_as_address (val));
@@ -1612,11 +1612,11 @@  dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
   if (result->optimized_out ())
     return 0;
 
-  if (VALUE_LVAL (result) == lval_memory)
+  if (result->lval () == lval_memory)
     *valp = result->address ();
   else
     {
-      if (VALUE_LVAL (result) == not_lval)
+      if (result->lval () == not_lval)
 	*is_reference = false;
 
       *valp = value_as_address (result);
diff --git a/gdb/eval.c b/gdb/eval.c
index e043991c254..f8bbb9ef766 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1224,7 +1224,7 @@  eval_op_structop_struct (struct type *expect_type, struct expression *exp,
   struct value *arg3 = value_struct_elt (&arg1, {}, string,
 					 NULL, "structure");
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
-    arg3 = value::zero (arg3->type (), VALUE_LVAL (arg3));
+    arg3 = value::zero (arg3->type (), arg3->lval ());
   return arg3;
 }
 
@@ -1280,7 +1280,7 @@  eval_op_structop_ptr (struct type *expect_type, struct expression *exp,
   struct value *arg3 = value_struct_elt (&arg1, {}, string,
 					 NULL, "structure pointer");
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
-    arg3 = value::zero (arg3->type (), VALUE_LVAL (arg3));
+    arg3 = value::zero (arg3->type (), arg3->lval ());
   return arg3;
 }
 
@@ -1447,7 +1447,7 @@  eval_op_subscript (struct type *expect_type, struct expression *exp,
 	}
 
       if (noside == EVAL_AVOID_SIDE_EFFECTS)
-	return value::zero (type->target_type (), VALUE_LVAL (arg1));
+	return value::zero (type->target_type (), arg1->lval ());
       else
 	return value_subscript (arg1, value_as_long (arg2));
     }
@@ -2590,7 +2590,7 @@  evaluate_subexp_for_address_base (struct expression *exp, enum noside noside,
       if (TYPE_IS_REFERENCE (type))
 	return value::zero (lookup_pointer_type (type->target_type ()),
 			   not_lval);
-      else if (VALUE_LVAL (x) == lval_memory || value_must_coerce_to_target (x))
+      else if (x->lval () == lval_memory || value_must_coerce_to_target (x))
 	return value::zero (lookup_pointer_type (x->type ()),
 			   not_lval);
       else
@@ -2875,7 +2875,7 @@  var_msym_value_operation::evaluate_for_cast (struct type *to_type,
   val = value_cast (to_type, val);
 
   /* Don't allow e.g. '&(int)var_with_no_debug_info'.  */
-  if (VALUE_LVAL (val) == lval_memory)
+  if (val->lval () == lval_memory)
     {
       if (val->lazy ())
 	val->fetch_lazy ();
@@ -2896,7 +2896,7 @@  var_value_operation::evaluate_for_cast (struct type *to_type,
   val = value_cast (to_type, val);
 
   /* Don't allow e.g. '&(int)var_with_no_debug_info'.  */
-  if (VALUE_LVAL (val) == lval_memory)
+  if (val->lval () == lval_memory)
     {
       if (val->lazy ())
 	val->fetch_lazy ();
diff --git a/gdb/expop.h b/gdb/expop.h
index e53474711fe..d973d2314bb 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -1889,7 +1889,7 @@  class assign_operation
        expected type.  This avoids a weird case where re-assigning a
        string or array to an internal variable could error with "Too
        many array elements".  */
-    struct type *xtype = (VALUE_LVAL (lhs) == lval_internalvar
+    struct type *xtype = (lhs->lval () == lval_internalvar
 			  ? nullptr
 			  : lhs->type ());
     value *rhs = std::get<1> (m_storage)->evaluate (xtype, exp, noside);
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index d935f59088f..0d7863e4fd1 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -1363,7 +1363,7 @@  fortran_undetermined::value_subarray (value *array,
 	  if (index < lb
 	      || (dim_type->index_type ()->bounds ()->high.kind () != PROP_UNDEFINED
 		  && index > ub)
-	      || (VALUE_LVAL (array) != lval_memory
+	      || (array->lval () != lval_memory
 		  && dim_type->index_type ()->bounds ()->high.kind () == PROP_UNDEFINED))
 	    {
 	      if (type_not_associated (dim_type))
@@ -1460,7 +1460,7 @@  fortran_undetermined::value_subarray (value *array,
     }
   else
     {
-      if (VALUE_LVAL (array) == lval_memory)
+      if (array->lval () == lval_memory)
 	{
 	  /* If the value we're taking a slice from is not yet loaded, or
 	     the requested slice is outside the values content range then
@@ -1637,7 +1637,7 @@  fortran_structop_operation::evaluate (struct type *expect_type,
 	    = gdb::make_array_view (valaddr, elt_type->length ());
 	  elt_type = resolve_dynamic_type (elt_type, view, address);
 	}
-      elt = value::zero (elt_type, VALUE_LVAL (elt));
+      elt = value::zero (elt_type, elt->lval ());
     }
 
   return elt;
@@ -1872,7 +1872,7 @@  fortran_argument_convert (struct value *value, bool is_artificial)
     {
       /* If the value is not in the inferior e.g. registers values,
 	 convenience variables and user input.  */
-      if (VALUE_LVAL (value) != lval_memory)
+      if (value->lval () != lval_memory)
 	{
 	  struct type *type = value->type ();
 	  const int length = type->length ();
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 37ae518d6c4..7006500574c 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -846,7 +846,7 @@  read_frame_register_value (struct value *value, frame_info_ptr frame)
   int regnum = VALUE_REGNUM (value);
   int len = type_length_units (check_typedef (value->type ()));
 
-  gdb_assert (VALUE_LVAL (value) == lval_register);
+  gdb_assert (value->lval () == lval_register);
 
   /* Skip registers wholly inside of REG_OFFSET.  */
   while (reg_offset >= register_size (gdbarch, regnum))
diff --git a/gdb/frame.c b/gdb/frame.c
index bf9b055878a..be4c58e4642 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -930,7 +930,7 @@  frame_find_by_id (struct frame_id id)
      and get_prev_frame performs a series of checks that are relatively
      expensive).  This optimization is particularly useful when this function
      is called from another function (such as value_fetch_lazy, case
-     VALUE_LVAL (val) == lval_register) which already loops over all frames,
+     val->lval () == lval_register) which already loops over all frames,
      making the overall behavior O(n^2).  */
   frame = frame_stash_find (id);
   if (frame)
@@ -1191,7 +1191,7 @@  frame_register_unwind (frame_info_ptr next_frame, int regnum,
 
   *optimizedp = value->optimized_out ();
   *unavailablep = !value->entirely_available ();
-  *lvalp = VALUE_LVAL (value);
+  *lvalp = value->lval ();
   *addrp = value->address ();
   if (*lvalp == lval_register)
     *realnump = VALUE_REGNUM (value);
@@ -1296,10 +1296,10 @@  frame_unwind_register_value (frame_info_ptr next_frame, int regnum)
 	}
       else
 	{
-	  if (VALUE_LVAL (value) == lval_register)
+	  if (value->lval () == lval_register)
 	    gdb_printf (&debug_file, " register=%d",
 			VALUE_REGNUM (value));
-	  else if (VALUE_LVAL (value) == lval_memory)
+	  else if (value->lval () == lval_memory)
 	    gdb_printf (&debug_file, " address=%s",
 			paddress (gdbarch,
 				  value->address ()));
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 73ccd1cf3f8..f22ba44a538 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4908,7 +4908,7 @@  rank_one_type (struct type *parm, struct type *arg, struct value *value)
 
   if (TYPE_IS_REFERENCE (parm) && value != NULL)
     {
-      if (VALUE_LVAL (value) == not_lval)
+      if (value->lval () == not_lval)
 	{
 	  /* Rvalues should preferably bind to rvalue references or const
 	     lvalue references.  */
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 81a073d2123..9ed17bf4f8b 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -343,7 +343,7 @@  find_function_addr (struct value *function,
 	  int found_descriptor = 0;
 
 	  funaddr = 0;	/* pacify "gcc -Werror" */
-	  if (VALUE_LVAL (function) == lval_memory)
+	  if (function->lval () == lval_memory)
 	    {
 	      CORE_ADDR nfunaddr;
 
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index ffa2faa44a9..72d0b58d675 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -104,7 +104,7 @@  eval_op_m2_subscript (struct type *expect_type, struct expression *exp,
       }
 
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
-    return value::zero (type->target_type (), VALUE_LVAL (arg1));
+    return value::zero (type->target_type (), arg1->lval ());
   else
     return value_subscript (arg1, value_as_long (arg2));
 }
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index b3e82f4a6ae..3e4a9c360b2 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -300,7 +300,7 @@  create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside,
       else
 	{
 	  /* Check whether to create a lvalue or not.  */
-	  if (VALUE_LVAL (val) != not_lval && !array_has_dups (indices, n))
+	  if (val->lval () != not_lval && !array_has_dups (indices, n))
 	    {
 	      struct lval_closure *c = allocate_lval_closure (indices, n, val);
 	      ret = value::allocate_computed (dst_type, &opencl_value_funcs, c);
@@ -687,7 +687,7 @@  eval_opencl_assign (struct type *expect_type, struct expression *exp,
 
   struct type *type1 = arg1->type ();
   if (arg1->deprecated_modifiable ()
-      && VALUE_LVAL (arg1) != lval_internalvar)
+      && arg1->lval () != lval_internalvar)
     arg2 = opencl_value_cast (type1, arg2);
 
   return value_assign (arg1, arg2);
@@ -714,7 +714,7 @@  opencl_structop_operation::evaluate (struct type *expect_type,
 					  NULL, "structure");
 
       if (noside == EVAL_AVOID_SIDE_EFFECTS)
-	v = value::zero (v->type (), VALUE_LVAL (v));
+	v = value::zero (v->type (), v->lval ());
       return v;
     }
 }
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 6d4bf2cc618..e4fcce694cf 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -2455,9 +2455,9 @@  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 (VALUE_LVAL (v) == not_lval || v->->deprecated_modifiable () == 0)
+      if (v->lval () == not_lval || v->->deprecated_modifiable () == 0)
 	continue;
-      else if (VALUE_LVAL (v) == lval_memory)
+      else if (v->lval () == lval_memory)
 	{
 	  /* 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
@@ -2509,7 +2509,7 @@  ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr,
     return 0;
 
   if (num_accesses_left == 1 && num_accesses_right == 0
-      && VALUE_LVAL (left_val) == lval_memory
+      && left_val->lval () == lval_memory
       && left_val->address () == watch_addr)
     {
       *data_value = value_as_long (right_val);
@@ -2519,7 +2519,7 @@  ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr,
       *len = check_typedef (left_val->type ())->length ();
     }
   else if (num_accesses_left == 0 && num_accesses_right == 1
-	   && VALUE_LVAL (right_val) == lval_memory
+	   && right_val->lval () == lval_memory
 	   && right_val->address () == watch_addr)
     {
       *data_value = value_as_long (left_val);
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 514261e7ea7..c6b55e97f40 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -297,7 +297,7 @@  print_formatted (struct value *val, int size,
   struct type *type = check_typedef (val->type ());
   int len = type->length ();
 
-  if (VALUE_LVAL (val) == lval_memory)
+  if (val->lval () == lval_memory)
     next_address = val->address () + len;
 
   if (size)
@@ -1888,7 +1888,7 @@  x_command (const char *exp, int from_tty)
       /* In rvalue contexts, such as this, functions are coerced into
 	 pointers to functions.  This makes "x/i main" work.  */
       if (val->type ()->code () == TYPE_CODE_FUNC
-	   && VALUE_LVAL (val) == lval_memory)
+	  && val->lval () == lval_memory)
 	next_address = val->address ();
       else
 	next_address = value_as_address (val);
@@ -2430,7 +2430,7 @@  printf_c_string (struct ui_file *stream, const char *format,
   const gdb_byte *str;
 
   if (value->type ()->code () != TYPE_CODE_PTR
-      && VALUE_LVAL (value) == lval_internalvar
+      && value->lval () == lval_internalvar
       && c_is_string_type_p (value->type ()))
     {
       size_t len = value->type ()->length ();
@@ -2502,7 +2502,7 @@  printf_wide_c_string (struct ui_file *stream, const char *format,
 					 "wchar_t", NULL, 0);
   int wcwidth = wctype->length ();
 
-  if (VALUE_LVAL (value) == lval_internalvar
+  if (value->lval () == lval_internalvar
       && c_is_string_type_p (value->type ()))
     {
       str = value->contents ().data ();
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index 97b472f25b1..5b512c95dc7 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -272,7 +272,7 @@  unwind_infopy_add_saved_register (PyObject *self, PyObject *args)
     {
       struct value *user_reg_value
 	= value_of_user_reg (regnum, pending_frame->frame_info);
-      if (VALUE_LVAL (user_reg_value) == lval_register)
+      if (user_reg_value->lval () == lval_register)
 	regnum = VALUE_REGNUM (user_reg_value);
       if (regnum >= gdbarch_num_cooked_regs (pending_frame->gdbarch))
 	{
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 27b5928298f..fb9db9fe31b 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1204,7 +1204,7 @@  rust_subscript (struct type *expect_type, struct expression *exp,
       else
 	new_type = base_type;
 
-      return value::zero (new_type, VALUE_LVAL (lhs));
+      return value::zero (new_type, lhs->lval ());
     }
   else
     {
@@ -1470,7 +1470,7 @@  rust_structop::evaluate (struct type *expect_type,
   else
     result = value_struct_elt (&lhs, {}, field_name, NULL, "structure");
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
-    result = value::zero (result->type (), VALUE_LVAL (result));
+    result = value::zero (result->type (), result->lval ());
   return result;
 }
 
diff --git a/gdb/stack.c b/gdb/stack.c
index 934220e7c33..a26f65af1c4 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1710,7 +1710,7 @@  info_frame_command_core (frame_info_ptr fi, bool selected_frame_p)
 
 	if (!value->optimized_out () && value->entirely_available ())
 	  {
-	    if (VALUE_LVAL (value) == not_lval)
+	    if (value->lval () == not_lval)
 	      {
 		CORE_ADDR sp;
 		enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -1723,13 +1723,13 @@  info_frame_command_core (frame_info_ptr fi, bool selected_frame_p)
 		gdb_puts (paddress (gdbarch, sp));
 		gdb_printf ("\n");
 	      }
-	    else if (VALUE_LVAL (value) == lval_memory)
+	    else if (value->lval () == lval_memory)
 	      {
 		gdb_printf (" Previous frame's sp at ");
 		gdb_puts (paddress (gdbarch, value->address ()));
 		gdb_printf ("\n");
 	      }
-	    else if (VALUE_LVAL (value) == lval_register)
+	    else if (value->lval () == lval_register)
 	      {
 		gdb_printf (" Previous frame's sp in %s\n",
 			    gdbarch_register_name (gdbarch,
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 117662fda95..51965e4cf57 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -93,7 +93,7 @@  value_ptradd (struct value *arg1, LONGEST arg2)
 
   result = value_from_pointer (valptrtype,
 			       value_as_address (arg1) + sz * arg2);
-  if (VALUE_LVAL (result) != lval_internalvar)
+  if (result->lval () != lval_internalvar)
     result->set_component_location (arg1);
   return result;
 }
@@ -159,7 +159,7 @@  value_subscript (struct value *array, LONGEST index)
       if (!lowerbound.has_value ())
 	lowerbound = 0;
 
-      if (VALUE_LVAL (array) != lval_memory)
+      if (array->lval () != lval_memory)
 	return value_subscripted_rvalue (array, index, *lowerbound);
 
       gdb::optional<LONGEST> upperbound
@@ -220,7 +220,7 @@  value_subscripted_rvalue (struct value *array, LONGEST index,
   if (index < lowerbound
       || (!array_upper_bound_undefined
 	  && elt_offs >= type_length_units (array_type))
-      || (VALUE_LVAL (array) != lval_memory && array_upper_bound_undefined))
+      || (array->lval () != lval_memory && array_upper_bound_undefined))
     {
       if (type_not_associated (array_type))
 	error (_("no such vector element (vector not associated)"));
@@ -517,7 +517,7 @@  value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op,
 
 	      if (return_type == NULL)
 		error (_("Xmethod is missing return type."));
-	      return value::zero (return_type, VALUE_LVAL (arg1));
+	      return value::zero (return_type, arg1->lval ());
 	    }
 	  return argvec[0]->call_xmethod (argvec.slice (1));
 	}
@@ -526,7 +526,7 @@  value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op,
 	  struct type *return_type;
 
 	  return_type = check_typedef (argvec[0]->type ())->target_type ();
-	  return value::zero (return_type, VALUE_LVAL (arg1));
+	  return value::zero (return_type, arg1->lval ());
 	}
       return call_function_by_hand (argvec[0], NULL,
 				    argvec.slice (1, 2 - static_memfuncp));
@@ -630,7 +630,7 @@  value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
 
 	      if (return_type == NULL)
 		error (_("Xmethod is missing return type."));
-	      return value::zero (return_type, VALUE_LVAL (arg1));
+	      return value::zero (return_type, arg1->lval ());
 	    }
 	  return argvec[0]->call_xmethod (argvec[1]);
 	}
@@ -639,7 +639,7 @@  value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
 	  struct type *return_type;
 
 	  return_type = check_typedef (argvec[0]->type ())->target_type ();
-	  return value::zero (return_type, VALUE_LVAL (arg1));
+	  return value::zero (return_type, arg1->lval ());
 	}
       return call_function_by_hand (argvec[0], NULL,
 				    argvec.slice (1, nargs));
diff --git a/gdb/valops.c b/gdb/valops.c
index a90bcbe7f29..3901053c7d5 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -653,7 +653,7 @@  value_cast (struct type *type, struct value *arg2)
       arg2->set_pointed_to_offset (0);	/* pai: chk_val */
       return arg2;
     }
-  else if (VALUE_LVAL (arg2) == lval_memory)
+  else if (arg2->lval () == lval_memory)
     return value_at_lazy (to_type, arg2->address ());
   else
     {
@@ -971,7 +971,7 @@  value_one (struct type *type)
     }
 
   /* value_one result is never used for assignments to.  */
-  gdb_assert (VALUE_LVAL (val) == not_lval);
+  gdb_assert (val->lval () == not_lval);
 
   return val;
 }
@@ -1095,7 +1095,7 @@  value_assign (struct value *toval, struct value *fromval)
   toval = coerce_ref (toval);
 
   type = toval->type ();
-  if (VALUE_LVAL (toval) != lval_internalvar)
+  if (toval->lval () != lval_internalvar)
     fromval = value_cast (type, fromval);
   else
     {
@@ -1112,7 +1112,7 @@  value_assign (struct value *toval, struct value *fromval)
      and then restore the new frame afterwards.  */
   old_frame = get_frame_id (deprecated_safe_get_selected_frame ());
 
-  switch (VALUE_LVAL (toval))
+  switch (toval->lval ())
     {
     case lval_internalvar:
       set_internalvar (VALUE_INTERNALVAR (toval), fromval);
@@ -1292,7 +1292,7 @@  value_assign (struct value *toval, struct value *fromval)
      cause the frame cache and regcache to be out of date.  Assigning to memory
      also can.  We just do this on all assignments to registers or
      memory, for simplicity's sake; I doubt the slowdown matters.  */
-  switch (VALUE_LVAL (toval))
+  switch (toval->lval ())
     {
     case lval_memory:
     case lval_register:
@@ -1366,7 +1366,7 @@  value_repeat (struct value *arg1, int count)
 {
   struct value *val;
 
-  if (VALUE_LVAL (arg1) != lval_memory)
+  if (arg1->lval () != lval_memory)
     error (_("Only values in memory can be extended with '@'."));
   if (count < 1)
     error (_("Invalid number %d of repetitions."), count);
@@ -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 && val->lazy ())
+  if ((val->lval () == lval_memory && val->lazy ())
       || type->code () == TYPE_CODE_FUNC)
     {
       CORE_ADDR addr = val->address ();
@@ -1415,7 +1415,7 @@  address_of_variable (struct symbol *var, const struct block *b)
     }
 
   /* Not a memory address; check what the problem was.  */
-  switch (VALUE_LVAL (val))
+  switch (val->lval ())
     {
     case lval_register:
       {
@@ -1452,9 +1452,9 @@  value_must_coerce_to_target (struct value *val)
   struct type *valtype;
 
   /* The only lval kinds which do not live in target memory.  */
-  if (VALUE_LVAL (val) != not_lval
-      && VALUE_LVAL (val) != lval_internalvar
-      && VALUE_LVAL (val) != lval_xcallable)
+  if (val->lval () != not_lval
+      && val->lval () != lval_internalvar
+      && val->lval () != lval_xcallable)
     return false;
 
   valtype = check_typedef (val->type ());
@@ -1522,7 +1522,7 @@  value_coerce_array (struct value *arg1)
      be a good time to do so.  */
   arg1 = value_coerce_to_target (arg1);
 
-  if (VALUE_LVAL (arg1) != lval_memory)
+  if (arg1->lval () != lval_memory)
     error (_("Attempt to take address of value not located in memory."));
 
   return value_from_pointer (lookup_pointer_type (type->target_type ()),
@@ -1537,7 +1537,7 @@  value_coerce_function (struct value *arg1)
 {
   struct value *retval;
 
-  if (VALUE_LVAL (arg1) != lval_memory)
+  if (arg1->lval () != lval_memory)
     error (_("Attempt to take address of value not located in memory."));
 
   retval = value_from_pointer (lookup_pointer_type (arg1->type ()),
@@ -1586,7 +1586,7 @@  value_addr (struct value *arg1)
      then this would be a good time to force it to memory.  */
   arg1 = value_coerce_to_target (arg1);
 
-  if (VALUE_LVAL (arg1) != lval_memory)
+  if (arg1->lval () != lval_memory)
     error (_("Attempt to take address of value not located in memory."));
 
   /* Get target memory address.  */
@@ -1637,7 +1637,7 @@  value_ind (struct value *arg1)
 
   base_type = check_typedef (arg1->type ());
 
-  if (VALUE_LVAL (arg1) == lval_computed)
+  if (arg1->lval () == lval_computed)
     {
       const struct lval_funcs *funcs = arg1->computed_funcs ();
 
@@ -3963,7 +3963,7 @@  value_full_object (struct value *argp,
     }
 
   /* Check if object is in memory.  */
-  if (VALUE_LVAL (argp) != lval_memory)
+  if (argp->lval () != lval_memory)
     {
       warning (_("Couldn't retrieve complete object of RTTI "
 		 "type %s; object may be in register(s)."), 
@@ -4077,7 +4077,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 && array->lazy ())
+    if (array->lval () == lval_memory && array->lazy ())
       slice = value::allocate_lazy (slice_type);
     else
       {
diff --git a/gdb/value.c b/gdb/value.c
index fc08ba2244f..23a0e4abd0f 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -149,14 +149,14 @@  static struct cmd_list_element *functionlist;
 
 value::~value ()
 {
-  if (VALUE_LVAL (this) == lval_computed)
+  if (this->lval () == lval_computed)
     {
       const struct lval_funcs *funcs = m_location.computed.funcs;
 
       if (funcs->free_closure)
 	funcs->free_closure (this);
     }
-  else if (VALUE_LVAL (this) == lval_xcallable)
+  else if (this->lval () == lval_xcallable)
     delete m_location.xm_worker;
 }
 
@@ -1133,9 +1133,9 @@  value::optimized_out ()
     {
       /* See if we can compute the result without fetching the
 	 value.  */
-      if (VALUE_LVAL (this) == lval_memory)
+      if (this->lval () == lval_memory)
 	return false;
-      else if (VALUE_LVAL (this) == lval_computed)
+      else if (this->lval () == lval_computed)
 	{
 	  const struct lval_funcs *funcs = m_location.computed.funcs;
 
@@ -1377,7 +1377,7 @@  value::copy () const
     }
 
   val->m_parent = m_parent;
-  if (VALUE_LVAL (val) == lval_computed)
+  if (val->lval () == lval_computed)
     {
       const struct lval_funcs *funcs = val->m_location.computed.funcs;
 
@@ -1411,7 +1411,7 @@  make_cv_value (int cnst, int voltl, struct value *v)
 struct value *
 value::non_lval ()
 {
-  if (VALUE_LVAL (this) != not_lval)
+  if (this->lval () != not_lval)
     {
       struct type *enc_type = enclosing_type ();
       struct value *val = value::allocate (enc_type);
@@ -1430,7 +1430,7 @@  value::non_lval ()
 void
 value::force_lval (CORE_ADDR addr)
 {
-  gdb_assert (VALUE_LVAL (this) == not_lval);
+  gdb_assert (this->lval () == not_lval);
 
   write_memory (addr, contents_raw ().data (), type ()->length ());
   m_lval = lval_memory;
@@ -1488,13 +1488,13 @@  value::set_component_location (const struct value *whole)
          carry around both the parent value contents, and the contents of
          any dynamic fields within the parent.  This is a substantial
          change to how values work in GDB.  */
-      if (VALUE_LVAL (this) == lval_internalvar_component)
+      if (this->lval () == lval_internalvar_component)
 	{
 	  gdb_assert (lazy ());
 	  m_lval = lval_memory;
 	}
       else
-	gdb_assert (VALUE_LVAL (this) == lval_memory);
+	gdb_assert (this->lval () == lval_memory);
       set_address (TYPE_DATA_LOCATION_ADDR (type));
     }
 }
@@ -1999,7 +1999,7 @@  set_internalvar (struct internalvar *var, struct value *val)
       break;
 
     case TYPE_CODE_INTERNAL_FUNCTION:
-      gdb_assert (VALUE_LVAL (val) == lval_internalvar);
+      gdb_assert (val->lval () == lval_internalvar);
       new_kind = INTERNALVAR_FUNCTION;
       get_internalvar_function (VALUE_INTERNALVAR (val),
 				&new_data.fn.function);
@@ -2122,7 +2122,7 @@  value_internal_function_name (struct value *val)
   struct internal_function *ifn;
   int result;
 
-  gdb_assert (VALUE_LVAL (val) == lval_internalvar);
+  gdb_assert (val->lval () == lval_internalvar);
   result = get_internalvar_function (VALUE_INTERNALVAR (val), &ifn);
   gdb_assert (result);
 
@@ -2137,7 +2137,7 @@  call_internal_function (struct gdbarch *gdbarch,
   struct internal_function *ifn;
   int result;
 
-  gdb_assert (VALUE_LVAL (func) == lval_internalvar);
+  gdb_assert (func->lval () == lval_internalvar);
   result = get_internalvar_function (VALUE_INTERNALVAR (func), &ifn);
   gdb_assert (result);
 
@@ -2728,7 +2728,7 @@  value::primitive_field (LONGEST offset, int fieldno, struct type *arg_type)
       LONGEST boffset;
 
       /* Lazy register values with offsets are not supported.  */
-      if (VALUE_LVAL (this) == lval_register && lazy ())
+      if (this->lval () == lval_register && lazy ())
 	fetch_lazy ();
 
       /* We special case virtual inheritance here because this
@@ -2772,7 +2772,7 @@  value::primitive_field (LONGEST offset, int fieldno, struct type *arg_type)
 		 / (HOST_CHAR_BIT * unit_size));
 
       /* Lazy register values with offsets are not supported.  */
-      if (VALUE_LVAL (this) == lval_register && lazy ())
+      if (this->lval () == lval_register && lazy ())
 	fetch_lazy ();
 
       if (lazy ())
@@ -3366,7 +3366,7 @@  value_from_component (struct value *whole, struct type *type, LONGEST offset)
 {
   struct value *v;
 
-  if (VALUE_LVAL (whole) == lval_memory && whole->lazy ())
+  if (whole->lval () == lval_memory && whole->lazy ())
     v = value::allocate_lazy (type);
   else
     {
@@ -3563,7 +3563,7 @@  value_fetch_lazy_bitfield (struct value *val)
 static void
 value_fetch_lazy_memory (struct value *val)
 {
-  gdb_assert (VALUE_LVAL (val) == lval_memory);
+  gdb_assert (val->lval () == lval_memory);
 
   CORE_ADDR addr = val->address ();
   struct type *type = check_typedef (val->enclosing_type ());
@@ -3588,7 +3588,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 && new_val->lazy ())
+  while (new_val->lval () == lval_register && new_val->lazy ())
     {
       struct frame_id next_frame_id = VALUE_NEXT_FRAME_ID (new_val);
 
@@ -3623,7 +3623,7 @@  value_fetch_lazy_register (struct value *val)
 	 sniffer trying to unwind), bypassing its validations.  In
 	 any case, it should always be an internal error to end up
 	 in this situation.  */
-      if (VALUE_LVAL (new_val) == lval_register
+      if (new_val->lval () == lval_register
 	  && new_val->lazy ()
 	  && VALUE_NEXT_FRAME_ID (new_val) == next_frame_id)
 	internal_error (_("infinite loop while fetching a register"));
@@ -3667,10 +3667,10 @@  value_fetch_lazy_register (struct value *val)
 	  int i;
 	  gdb::array_view<const gdb_byte> buf = new_val->contents ();
 
-	  if (VALUE_LVAL (new_val) == lval_register)
+	  if (new_val->lval () == lval_register)
 	    gdb_printf (&debug_file, " register=%d",
 			VALUE_REGNUM (new_val));
-	  else if (VALUE_LVAL (new_val) == lval_memory)
+	  else if (new_val->lval () == lval_memory)
 	    gdb_printf (&debug_file, " address=%s",
 			paddress (gdbarch,
 				  new_val->address ()));
@@ -3710,11 +3710,11 @@  value::fetch_lazy ()
     }
   else if (bitsize ())
     value_fetch_lazy_bitfield (this);
-  else if (VALUE_LVAL (this) == lval_memory)
+  else if (this->lval () == lval_memory)
     value_fetch_lazy_memory (this);
-  else if (VALUE_LVAL (this) == lval_register)
+  else if (this->lval () == lval_register)
     value_fetch_lazy_register (this);
-  else if (VALUE_LVAL (this) == lval_computed
+  else if (this->lval () == lval_computed
 	   && computed_funcs ()->read != NULL)
     computed_funcs ()->read (this);
   else
diff --git a/gdb/value.h b/gdb/value.h
index dff4cb5e7b7..975c30a40b8 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -328,9 +328,6 @@  struct value
      uses.  */
   void *computed_closure () const;
 
-  enum lval_type *deprecated_lval_hack ()
-  { return &m_lval; }
-
   enum lval_type lval () const
   { return m_lval; }
 
@@ -916,13 +913,6 @@  struct lval_funcs
 
 extern void error_value_optimized_out (void);
 
-/* While the following fields are per- VALUE .CONTENT .PIECE (i.e., a
-   single value might have multiple LVALs), this hacked interface is
-   limited to just the first PIECE.  Expect further change.  */
-/* Type of value; either not an lval, or one of the various different
-   possible kinds of lval.  */
-#define VALUE_LVAL(val) (*((val)->deprecated_lval_hack ()))
-
 /* Pointer to internal variable.  */
 #define VALUE_INTERNALVAR(val) (*((val)->deprecated_internalvar_hack ()))
 
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 72d5e7f2a25..37b64a0c4bd 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2270,7 +2270,7 @@  varobj_editable_p (const struct varobj *var)
   struct type *type;
 
   if (!(var->root->is_valid && var->value != nullptr
-	&& VALUE_LVAL (var->value.get ())))
+	&& var->value.get ()->lval ()))
     return false;
 
   type = varobj_get_value_type (var);