This changes various offset-related functions to be methods of value.
Much of this patch was written by script.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
if (check_typedef (v0->type ())->length ()
!= check_typedef (v1->type ())->length ())
break;
- if (!value_contents_eq (v0, value_embedded_offset (v0),
- v1, value_embedded_offset (v1),
+ if (!value_contents_eq (v0, v0->embedded_offset (),
+ v1, v1->embedded_offset (),
check_typedef (v0->type ())->length ()))
break;
}
of the complete object to the start of the embedded subobject
VALUE represents. In other words, the enclosing object starts
at VALUE_ADDR (VALUE) + VALUE->offset () +
- value_embedded_offset (VALUE) + *TOP
+ VALUE->embedded_offset () + *TOP
- If *USING_ENC is non-zero, then *TOP is the offset from the
address of the complete object to the enclosing object stored
in VALUE. In other words, the enclosing object starts at
opts->deref_ref = false;
v = value_field_bitfield (type, i, valaddr,
- value_embedded_offset (val), val);
+ val->embedded_offset (), val);
common_val_print (v, stream, recurse + 1,
opts, current_language);
{
CORE_ADDR addr;
- i_offset += value_embedded_offset (val);
+ i_offset += val->embedded_offset ();
addr = extract_typed_address (valaddr + i_offset, i_type);
print_function_pointer_address (opts,
type->arch (),
try
{
boffset = baseclass_offset (type, i, valaddr,
- value_embedded_offset (val),
+ val->embedded_offset (),
address, val);
}
catch (const gdb_exception_error &ex)
switch (type->code ())
{
case TYPE_CODE_STRUCT:
- ret = dynamic_array_type (type, value_embedded_offset (val),
+ ret = dynamic_array_type (type, val->embedded_offset (),
value_address (val),
stream, recurse, val, options);
if (ret == 0)
{
struct type *type = check_typedef (value->type ());
- if (value_bits_synthetic_pointer (value, value_embedded_offset (value),
+ if (value_bits_synthetic_pointer (value, value->embedded_offset (),
TARGET_CHAR_BIT * type->length ()))
{
const piece_closure *closure
``this'' changes. */
vals[0] = value_from_longest (lookup_pointer_type (temp->type ()),
value_address (temp)
- + value_embedded_offset (temp));
+ + temp->embedded_offset ());
}
/* Take out `this' if needed. */
return is_unique_ancestor_worker (base, val->type (), &offset,
value_contents_for_printing (val).data (),
- value_embedded_offset (val),
+ val->embedded_offset (),
value_address (val), val) == 1;
}
/* Find the linker symbol for this vtable. */
vtable_symbol
= lookup_minimal_symbol_by_pc (value_address (vtable)
- + value_embedded_offset (vtable)).minsym;
+ + vtable->embedded_offset ()).minsym;
if (! vtable_symbol)
return NULL;
= value_as_long (value_field (vtable, vtable_field_offset_to_top));
if (full_p)
- *full_p = (- offset_to_top == value_embedded_offset (value)
+ *full_p = (- offset_to_top == value->embedded_offset ()
&& (value->enclosing_type ()->length ()
>= run_time_type->length ()));
if (top_p)
{
const struct value_and_voffset *o = (const struct value_and_voffset *) p;
- return value_address (o->value) + value_embedded_offset (o->value);
+ return value_address (o->value) + o->value->embedded_offset ();
}
/* Equality function for value_and_voffset. */
const struct value_and_voffset *ova = (const struct value_and_voffset *) a;
const struct value_and_voffset *ovb = (const struct value_and_voffset *) b;
- return (value_address (ova->value) + value_embedded_offset (ova->value)
- == value_address (ovb->value) + value_embedded_offset (ovb->value));
+ return (value_address (ova->value) + ova->value->embedded_offset ()
+ == value_address (ovb->value) + ovb->value->embedded_offset ());
}
/* Comparison function for value_and_voffset. */
const struct value_and_voffset *vb)
{
CORE_ADDR addra = (value_address (va->value)
- + value_embedded_offset (va->value));
+ + va->value->embedded_offset ());
CORE_ADDR addrb = (value_address (vb->value)
- + value_embedded_offset (vb->value));
+ + vb->value->embedded_offset ());
return addra < addrb;
}
vtable = gnuv3_get_vtable (gdbarch, type,
value_address (value)
- + value_embedded_offset (value));
+ + value->embedded_offset ());
vt_addr = value_address (value_field (vtable,
vtable_field_virtual_functions));
TYPE_SAFE_NAME (type),
paddress (gdbarch, vt_addr),
paddress (gdbarch, (value_address (value)
- + value_embedded_offset (value))));
+ + value->embedded_offset ())));
for (i = 0; i <= max_voffset; ++i)
{
&& gnuv3_dynamic_class (type))
{
struct value *vtable, *typeinfo_value;
- CORE_ADDR address = value_address (value) + value_embedded_offset (value);
+ CORE_ADDR address = value_address (value) + value->embedded_offset ();
vtable = gnuv3_get_vtable (gdbarch, type, address);
if (vtable == NULL)
case GO_TYPE_STRING:
if (! options->raw)
{
- print_go_string (type, value_embedded_offset (val),
+ print_go_string (type, val->embedded_offset (),
value_address (val),
stream, recurse, val, options);
return;
to its representation. */
|| (val_print_scalar_type_p (arg->val->type ())
&& !value_bytes_available (arg->val,
- value_embedded_offset (arg->val),
+ arg->val->embedded_offset (),
arg->val->type ()->length ()))))
return;
if (v)
{
/* Downcasting is possible (t1 is superclass of v2). */
- CORE_ADDR addr2 = value_address (v2) + value_embedded_offset (v2);
+ CORE_ADDR addr2 = value_address (v2) + v2->embedded_offset ();
- addr2 -= value_address (v) + value_embedded_offset (v);
+ addr2 -= value_address (v) + v->embedded_offset ();
return value_at (type, addr2);
}
}
arg2 = value_copy (arg2);
arg2->deprecated_set_type (type);
arg2->set_enclosing_type (type);
- set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */
+ arg2->set_pointed_to_offset (0); /* pai: chk_val */
return arg2;
}
arg2 = value_copy (arg2);
arg2->deprecated_set_type (to_type);
arg2->set_enclosing_type (to_type);
- set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */
+ arg2->set_pointed_to_offset (0); /* pai: chk_val */
return arg2;
}
else if (VALUE_LVAL (arg2) == lval_memory)
else if (using_enc)
addr += top;
else
- addr += top + value_embedded_offset (arg);
+ addr += top + arg->embedded_offset ();
/* dynamic_cast<void *> means to return a pointer to the
most-derived object. */
result = NULL;
if (dynamic_cast_check_1 (resolved_type->target_type (),
value_contents_for_printing (tem).data (),
- value_embedded_offset (tem),
+ tem->embedded_offset (),
value_address (tem), tem,
rtti_type, addr,
arg_type,
if (is_public_ancestor (arg_type, rtti_type)
&& dynamic_cast_check_2 (resolved_type->target_type (),
value_contents_for_printing (tem).data (),
- value_embedded_offset (tem),
+ tem->embedded_offset (),
value_address (tem), tem,
rtti_type, &result) == 1)
return value_cast (type,
if (type->code () == TYPE_CODE_PTR)
{
val->set_enclosing_type (fromval->enclosing_type ());
- set_value_pointed_to_offset (val, value_pointed_to_offset (fromval));
+ val->set_pointed_to_offset (fromval->pointed_to_offset ());
}
return val;
if (TYPE_IS_REFERENCE (type))
{
- if (value_bits_synthetic_pointer (arg1, value_embedded_offset (arg1),
+ if (value_bits_synthetic_pointer (arg1, arg1->embedded_offset (),
TARGET_CHAR_BIT * type->length ()))
arg1 = coerce_ref (arg1);
else
/* Get target memory address. */
arg2 = value_from_pointer (lookup_pointer_type (arg1->type ()),
(value_address (arg1)
- + value_embedded_offset (arg1)));
+ + arg1->embedded_offset ()));
/* This may be a pointer to a base subobject; so remember the
full derived object's type ... */
arg2->set_enclosing_type (lookup_pointer_type (arg1->enclosing_type ()));
/* ... and also the relative position of the subobject in the full
object. */
- set_value_pointed_to_offset (arg2, value_embedded_offset (arg1));
+ arg2->set_pointed_to_offset (arg1->embedded_offset ());
return arg2;
}
{
/* Retrieve the enclosing object pointed to. */
base_addr = (value_as_address (arg1)
- - value_pointed_to_offset (arg1));
+ - arg1->pointed_to_offset ());
}
arg2 = value_at_lazy (enc_type, base_addr);
enc_type = arg2->type ();
int found_baseclass = (m_looking_for_baseclass
&& TYPE_BASECLASS_NAME (type, i) != NULL
&& (strcmp_iw (m_name, basetype->name ()) == 0));
- LONGEST boffset = value_embedded_offset (arg1) + offset;
+ LONGEST boffset = arg1->embedded_offset () + offset;
if (BASETYPE_VIA_VIRTUAL (type, i))
{
boffset = baseclass_offset (type, i,
value_contents_for_printing (arg1).data (),
- value_embedded_offset (arg1) + offset,
+ arg1->embedded_offset () + offset,
value_address (arg1),
arg1);
by the user program. Make sure that it still points to a
valid memory location. */
- boffset += value_embedded_offset (arg1) + offset;
+ boffset += arg1->embedded_offset () + offset;
if (boffset < 0
|| boffset >= arg1->enclosing_type ()->length ())
{
{
v2 = value_copy (arg1);
v2->deprecated_set_type (basetype);
- set_value_embedded_offset (v2, boffset);
+ v2->set_embedded_offset (boffset);
}
if (found_baseclass)
object, adjusting for the embedded offset of argp if that's what
value_rtti_type used for its computation. */
new_val = value_at_lazy (real_type, value_address (argp) - top +
- (using_enc ? 0 : value_embedded_offset (argp)));
+ (using_enc ? 0 : argp->embedded_offset ()));
new_val->deprecated_set_type (argp->type ());
- set_value_embedded_offset (new_val, (using_enc
- ? top + value_embedded_offset (argp)
- : top));
+ new_val->set_embedded_offset ((using_enc
+ ? top + argp->embedded_offset ()
+ : top));
return new_val;
}
length);
}
-LONGEST
-value_embedded_offset (const struct value *value)
-{
- return value->m_embedded_offset;
-}
-
-void
-set_value_embedded_offset (struct value *value, LONGEST val)
-{
- value->m_embedded_offset = val;
-}
-
-LONGEST
-value_pointed_to_offset (const struct value *value)
-{
- return value->m_pointed_to_offset;
-}
-
-void
-set_value_pointed_to_offset (struct value *value, LONGEST val)
-{
- value->m_pointed_to_offset = val;
-}
-
const struct lval_funcs *
value_computed_funcs (const struct value *v)
{
val->m_bitpos = arg->m_bitpos;
val->m_bitsize = arg->m_bitsize;
val->m_lazy = arg->m_lazy;
- val->m_embedded_offset = value_embedded_offset (arg);
+ 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;
copy (value_contents_all (arg), value_contents_all_raw (val));
val->m_type = arg->m_type;
- set_value_embedded_offset (val, value_embedded_offset (arg));
- set_value_pointed_to_offset (val, value_pointed_to_offset (arg));
+ val->set_embedded_offset (arg->embedded_offset ());
+ val->set_pointed_to_offset (arg->pointed_to_offset ());
return val;
}
return arg;
v->m_bitpos = bitpos % container_bitsize;
else
v->m_bitpos = bitpos % 8;
- v->m_offset = (value_embedded_offset (arg1)
+ v->m_offset = (arg1->embedded_offset ()
+ offset
+ (bitpos - v->m_bitpos) / 8);
v->set_parent (arg1);
if (BASETYPE_VIA_VIRTUAL (arg_type, fieldno))
boffset = baseclass_offset (arg_type, fieldno,
value_contents (arg1).data (),
- value_embedded_offset (arg1),
+ arg1->embedded_offset (),
value_address (arg1),
arg1);
else
}
v->m_type = type;
v->m_offset = arg1->offset ();
- v->m_embedded_offset = offset + value_embedded_offset (arg1) + boffset;
+ v->m_embedded_offset = offset + arg1->embedded_offset () + boffset;
}
else if (NULL != TYPE_DATA_LOCATION (type))
{
else
{
v = allocate_value (type);
- value_contents_copy_raw (v, value_embedded_offset (v),
- arg1, value_embedded_offset (arg1) + offset,
+ value_contents_copy_raw (v, v->embedded_offset (),
+ arg1, arg1->embedded_offset () + offset,
type_length_units (type));
}
v->m_offset = (arg1->offset () + offset
- + value_embedded_offset (arg1));
+ + arg1->embedded_offset ());
}
set_value_component_location (v, arg1);
return v;
else
{
v = allocate_value (type);
- value_contents_copy (v, value_embedded_offset (v),
- whole, value_embedded_offset (whole) + offset,
+ value_contents_copy (v, v->embedded_offset (),
+ whole, whole->embedded_offset () + offset,
type_length_units (type));
}
- v->m_offset = whole->offset () + offset + value_embedded_offset (whole);
+ v->m_offset = whole->offset () + offset + whole->embedded_offset ();
set_value_component_location (v, whole);
return v;
struct value *v = allocate_value (type);
- LONGEST dst_offset = TARGET_CHAR_BIT * value_embedded_offset (v);
+ LONGEST dst_offset = TARGET_CHAR_BIT * v->embedded_offset ();
if (is_scalar_type (type) && type_byte_order (type) == BFD_ENDIAN_BIG)
dst_offset += TARGET_CHAR_BIT * type->length () - bit_length;
value_contents_copy_raw_bitwise (v, dst_offset,
whole,
TARGET_CHAR_BIT
- * value_embedded_offset (whole)
+ * whole->embedded_offset ()
+ bit_offset,
bit_length);
return v;
/* Add embedding info. */
value->set_enclosing_type (enc_type);
- set_value_embedded_offset (value, value_pointed_to_offset (original_value));
+ value->set_embedded_offset (original_value->pointed_to_offset ());
/* We may be pointing to an object of some derived type. */
return value_full_object (value, NULL, 0, 0, 0);
/* Copy the contents and the unavailability/optimized-out
meta-data from NEW_VAL to VAL. */
set_value_lazy (val, 0);
- value_contents_copy (val, value_embedded_offset (val),
- new_val, value_embedded_offset (new_val),
+ value_contents_copy (val, val->embedded_offset (),
+ new_val, new_val->embedded_offset (),
type_length_units (type));
if (frame_debug)
int deprecated_modifiable () const
{ return m_modifiable; }
+ LONGEST pointed_to_offset () const
+ { return m_pointed_to_offset; }
+
+ void set_pointed_to_offset (LONGEST val)
+ { m_pointed_to_offset = val; }
+
+ LONGEST embedded_offset () const
+ { return m_embedded_offset; }
+
+ void set_embedded_offset (LONGEST val)
+ { m_embedded_offset = val; }
+
+
/* If a value represents a C++ object, then the `type' field gives the
object's compile-time type. If the object actually belongs to some
class derived from `type', perhaps with other base classes and
int resolve_simple_types,
int *real_type_found);
-extern LONGEST value_pointed_to_offset (const struct value *value);
-extern void set_value_pointed_to_offset (struct value *value, LONGEST val);
-extern LONGEST value_embedded_offset (const struct value *value);
-extern void set_value_embedded_offset (struct value *value, LONGEST val);
-
/* For lval_computed values, this structure holds functions used to
retrieve and set the value (or portions of the value).