data_type = lookup_pointer_type (data_type);
if (type->code () == TYPE_CODE_PTR)
- return value_cast (data_type, value_copy (val));
+ return value_cast (data_type, val->copy ());
else
return value_from_longest (data_type, val->address ());
}
if (arrType == NULL)
return NULL;
- return value_cast (arrType, value_copy (desc_data (arr)));
+ return value_cast (arrType, desc_data (arr)->copy ());
}
else if (ada_is_constrained_packed_array_type (arr->type ()))
return decode_constrained_packed_array (arr);
bits, is_big_endian);
write_memory_with_notification (to_addr, buffer, len);
- val = value_copy (toval);
+ val = toval->copy ();
memcpy (val->contents_raw ().data (),
fromval->contents ().data (),
type->length ());
if (type->code () != TYPE_CODE_ARRAY)
error (_("too many subscripts (%d expected)"), k);
arr = value_cast (lookup_pointer_type (type->target_type ()),
- value_copy (arr));
+ arr->copy ());
get_discrete_bounds (type->index_type (), &lwb, &upb);
arr = value_ptradd (arr, pos_atr (ind[k]) - lwb);
type = type->target_type ();
type = ada_check_typedef (resolve_dynamic_type (type, view, address));
if (type != saved_type)
{
- val = value_copy (val);
+ val = val->copy ();
val->deprecated_set_type (type);
}
print_it (other.print_it)
{
if (other.old_val != NULL)
- old_val = release_value (value_copy (other.old_val.get ()));
+ old_val = release_value (other.old_val.get ()->copy ());
}
/* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
value_ref_ptr value_holder = value_ref_ptr::new_reference (retval);
free_values.free_to_mark ();
- return value_copy (retval);
+ return retval->copy ();
}
/* The exported interface to dwarf2_evaluate_loc_desc_full; it always
value = NULL;
}
else
- value = value_copy (vlscm_scm_to_value (obj));
+ value = vlscm_scm_to_value (obj)->copy ();
}
else if (gdbscm_is_true (scm_bytevector_p (obj)))
{
{
try
{
- value = value_copy (value);
+ value = value->copy ();
}
catch (const gdb_exception &except)
{
builtin_type_pychar);
}
else if (PyObject_TypeCheck (obj, &value_object_type))
- value = value_copy (((value_object *) obj)->value);
+ value = ((value_object *) obj)->value->copy ();
else if (gdbpy_is_lazy_string (obj))
{
PyObject *result;
result = PyObject_CallMethodObjArgs (obj, gdbpy_value_cst, NULL);
- value = value_copy (((value_object *) result)->value);
+ value = ((value_object *) result)->value->copy ();
}
else
PyErr_Format (PyExc_TypeError,
}
/* No superclass found, just change the pointer type. */
- arg2 = value_copy (arg2);
+ arg2 = arg2->copy ();
arg2->deprecated_set_type (type);
arg2->set_enclosing_type (type);
arg2->set_pointed_to_offset (0); /* pai: chk_val */
value completely. */
if (arg2->type () != type)
{
- arg2 = value_copy (arg2);
+ arg2 = arg2->copy ();
arg2->deprecated_set_type (type);
}
return arg2;
if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR)
return value_cast_pointers (to_type, arg2, 0);
- arg2 = value_copy (arg2);
+ arg2 = arg2->copy ();
arg2->deprecated_set_type (to_type);
arg2->set_enclosing_type (to_type);
arg2->set_pointed_to_offset (0); /* pai: chk_val */
/* The return value is a copy of TOVAL so it shares its location
information, but its contents are updated from FROMVAL. This
implies the returned value is not lazy, even if TOVAL was. */
- val = value_copy (toval);
+ val = toval->copy ();
val->set_lazy (0);
copy (fromval->contents (), val->contents_raw ());
struct type *enclosing_type_ptr
= lookup_pointer_type (enclosing_type->target_type ());
- arg2 = value_copy (arg1);
+ arg2 = arg1->copy ();
arg2->deprecated_set_type (type_ptr);
arg2->set_enclosing_type (enclosing_type_ptr);
}
else
{
- v2 = value_copy (arg1);
+ v2 = arg1->copy ();
v2->deprecated_set_type (basetype);
v2->set_embedded_offset (boffset);
}
/* pai: FIXME -- sounds iffy */
if (full)
{
- argp = value_copy (argp);
+ argp = argp->copy ();
argp->set_enclosing_type (real_type);
return argp;
}
return result;
}
-/* Return a copy of the value ARG. It contains the same contents,
- for the same memory address, but it's a different block of storage. */
+/* See value.h. */
struct value *
-value_copy (const value *arg)
+value::copy () const
{
- struct type *encl_type = arg->enclosing_type ();
+ struct type *encl_type = enclosing_type ();
struct value *val;
val = value::allocate_lazy (encl_type);
- val->m_type = arg->m_type;
- VALUE_LVAL (val) = arg->m_lval;
- val->m_location = arg->m_location;
- val->m_offset = arg->m_offset;
- val->m_bitpos = arg->m_bitpos;
- val->m_bitsize = arg->m_bitsize;
- val->m_lazy = arg->m_lazy;
- val->m_embedded_offset = arg->embedded_offset ();
- val->m_pointed_to_offset = arg->m_pointed_to_offset;
- val->m_modifiable = arg->m_modifiable;
- val->m_stack = arg->m_stack;
- val->m_is_zero = arg->m_is_zero;
- val->m_in_history = arg->m_in_history;
- val->m_initialized = arg->m_initialized;
- val->m_unavailable = arg->m_unavailable;
- val->m_optimized_out = arg->m_optimized_out;
- val->m_parent = arg->m_parent;
- val->m_limited_length = arg->m_limited_length;
+ val->m_type = m_type;
+ VALUE_LVAL (val) = m_lval;
+ val->m_location = m_location;
+ val->m_offset = m_offset;
+ val->m_bitpos = m_bitpos;
+ val->m_bitsize = m_bitsize;
+ val->m_lazy = m_lazy;
+ val->m_embedded_offset = embedded_offset ();
+ val->m_pointed_to_offset = m_pointed_to_offset;
+ val->m_modifiable = m_modifiable;
+ val->m_stack = m_stack;
+ val->m_is_zero = m_is_zero;
+ val->m_in_history = m_in_history;
+ val->m_initialized = m_initialized;
+ val->m_unavailable = m_unavailable;
+ val->m_optimized_out = m_optimized_out;
+ val->m_parent = m_parent;
+ val->m_limited_length = m_limited_length;
if (!val->lazy ()
&& !(value_entirely_optimized_out (val)
if (length == 0)
length = val->enclosing_type ()->length ();
- gdb_assert (arg->m_contents != nullptr);
+ gdb_assert (m_contents != nullptr);
const auto &arg_view
- = gdb::make_array_view (arg->m_contents.get (), length);
+ = gdb::make_array_view (m_contents.get (), length);
val->allocate_contents (false);
gdb::array_view<gdb_byte> val_contents
{
struct type *val_type = v->type ();
struct type *m_enclosing_type = v->enclosing_type ();
- struct value *cv_val = value_copy (v);
+ struct value *cv_val = v->copy ();
cv_val->deprecated_set_type (make_cv_type (cnst, voltl, val_type, NULL));
cv_val->set_enclosing_type (make_cv_type (cnst, voltl, m_enclosing_type, NULL));
absnum--;
- return value_copy (value_history[absnum].get ());
+ return value_history[absnum].get ()->copy ();
}
/* See value.h. */
break;
case INTERNALVAR_VALUE:
- val = value_copy (var->u.value);
+ val = var->u.value->copy ();
if (val->lazy ())
val->fetch_lazy ();
break;
default:
new_kind = INTERNALVAR_VALUE;
- struct value *copy = value_copy (val);
+ struct value *copy = val->copy ();
copy->m_modifiable = 1;
/* Force the value to be fetched from the target now, to avoid problems
/* Verify that we can copy an entirely optimized out value, that may not have
its contents allocated. */
value_ref_ptr val = release_value (value::allocate_optimized_out (type));
- value_ref_ptr copy = release_value (value_copy (val.get ()));
+ value_ref_ptr copy = release_value (val.get ()->copy ());
SELF_CHECK (value_entirely_optimized_out (val.get ()));
SELF_CHECK (value_entirely_optimized_out (copy.get ()));
/* Create a value of type TYPE that is zero, and return it. */
static struct value *zero (struct type *type, enum lval_type lv);
+ /* Return a copy of the value. It contains the same contents, for
+ the same memory address, but it's a different block of
+ storage. */
+ struct value *copy () const;
+
~value ();
DISABLE_COPY_AND_ASSIGN (value);
/* From values.c */
-extern struct value *value_copy (const value *);
-
extern struct value *value_non_lval (struct value *);
extern void value_force_lval (struct value *, CORE_ADDR);