mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-09 04:21:49 +08:00
Turn value_enclosing_type into method
This changes value_enclosing_type to be a method of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
parent
4b53ca8883
commit
463b870d01
@ -3060,7 +3060,7 @@ ada_value_ptr_subscript (struct value *arr, int arity, struct value **ind)
|
||||
int k;
|
||||
struct value *array_ind = ada_value_ind (arr);
|
||||
struct type *type
|
||||
= check_typedef (value_enclosing_type (array_ind));
|
||||
= check_typedef (array_ind->enclosing_type ());
|
||||
|
||||
if (type->code () == TYPE_CODE_ARRAY
|
||||
&& TYPE_FIELD_BITSIZE (type, 0) > 0)
|
||||
@ -3334,7 +3334,7 @@ ada_array_bound (struct value *arr, int n, int which)
|
||||
|
||||
if (check_typedef (arr->type ())->code () == TYPE_CODE_PTR)
|
||||
arr = value_ind (arr);
|
||||
arr_type = value_enclosing_type (arr);
|
||||
arr_type = arr->enclosing_type ();
|
||||
|
||||
if (ada_is_constrained_packed_array_type (arr_type))
|
||||
return ada_array_bound (decode_constrained_packed_array (arr), n, which);
|
||||
@ -3358,7 +3358,7 @@ ada_array_length (struct value *arr, int n)
|
||||
|
||||
if (check_typedef (arr->type ())->code () == TYPE_CODE_PTR)
|
||||
arr = value_ind (arr);
|
||||
arr_type = value_enclosing_type (arr);
|
||||
arr_type = arr->enclosing_type ();
|
||||
|
||||
if (ada_is_constrained_packed_array_type (arr_type))
|
||||
return ada_array_length (decode_constrained_packed_array (arr), n);
|
||||
|
@ -509,7 +509,7 @@ bfin_push_dummy_call (struct gdbarch *gdbarch,
|
||||
|
||||
for (i = nargs - 1; i >= 0; i--)
|
||||
{
|
||||
struct type *value_type = value_enclosing_type (args[i]);
|
||||
struct type *value_type = args[i]->enclosing_type ();
|
||||
|
||||
total_len += align_up (value_type->length (), 4);
|
||||
}
|
||||
@ -525,7 +525,7 @@ bfin_push_dummy_call (struct gdbarch *gdbarch,
|
||||
|
||||
for (i = nargs - 1; i >= 0; i--)
|
||||
{
|
||||
struct type *value_type = value_enclosing_type (args[i]);
|
||||
struct type *value_type = args[i]->enclosing_type ();
|
||||
struct type *arg_type = check_typedef (value_type);
|
||||
int container_len = align_up (arg_type->length (), 4);
|
||||
|
||||
|
@ -571,18 +571,18 @@ c_value_print (struct value *val, struct ui_file *stream,
|
||||
better to leave the object as-is. */
|
||||
if (!(full
|
||||
&& (real_type->length ()
|
||||
< value_enclosing_type (val)->length ())))
|
||||
< val->enclosing_type ()->length ())))
|
||||
val = value_cast (real_type, val);
|
||||
gdb_printf (stream, "(%s%s) ",
|
||||
real_type->name (),
|
||||
full ? "" : _(" [incomplete object]"));
|
||||
}
|
||||
else if (type != check_typedef (value_enclosing_type (val)))
|
||||
else if (type != check_typedef (val->enclosing_type ()))
|
||||
{
|
||||
/* No RTTI information, so let's do our best. */
|
||||
gdb_printf (stream, "(%s ?) ",
|
||||
value_enclosing_type (val)->name ());
|
||||
val = value_cast (value_enclosing_type (val), val);
|
||||
val->enclosing_type ()->name ());
|
||||
val = value_cast (val->enclosing_type (), val);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -763,7 +763,7 @@ test_print_fields (gdbarch *arch)
|
||||
|
||||
value *val = allocate_value (the_struct);
|
||||
gdb_byte *contents = value_contents_writeable (val).data ();
|
||||
store_unsigned_integer (contents, value_enclosing_type (val)->length (),
|
||||
store_unsigned_integer (contents, val->enclosing_type ()->length (),
|
||||
gdbarch_byte_order (arch), 0xe9);
|
||||
|
||||
string_file out;
|
||||
|
@ -372,7 +372,7 @@ gnuv3_rtti_type (struct value *value,
|
||||
|
||||
if (full_p)
|
||||
*full_p = (- offset_to_top == value_embedded_offset (value)
|
||||
&& (value_enclosing_type (value)->length ()
|
||||
&& (value->enclosing_type ()->length ()
|
||||
>= run_time_type->length ()));
|
||||
if (top_p)
|
||||
*top_p = - offset_to_top;
|
||||
|
@ -183,7 +183,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
|
||||
|
||||
for (i = 0; i < nargs; i++)
|
||||
{
|
||||
struct type *arg_type = value_enclosing_type (args[i]);
|
||||
struct type *arg_type = args[i]->enclosing_type ();
|
||||
|
||||
if (i386_m128_p (arg_type) && num_m128 < 4)
|
||||
{
|
||||
|
@ -2725,11 +2725,11 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
|
||||
|
||||
for (i = thiscall ? 1 : 0; i < nargs; i++)
|
||||
{
|
||||
int len = value_enclosing_type (args[i])->length ();
|
||||
int len = args[i]->enclosing_type ()->length ();
|
||||
|
||||
if (write_pass)
|
||||
{
|
||||
if (i386_16_byte_align_p (value_enclosing_type (args[i])))
|
||||
if (i386_16_byte_align_p (args[i]->enclosing_type ()))
|
||||
args_space_used = align_up (args_space_used, 16);
|
||||
|
||||
write_memory (sp + args_space_used,
|
||||
@ -2745,7 +2745,7 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i386_16_byte_align_p (value_enclosing_type (args[i])))
|
||||
if (i386_16_byte_align_p (args[i]->enclosing_type ()))
|
||||
args_space = align_up (args_space, 16);
|
||||
args_space += align_up (len, 4);
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
|
||||
/* Push arguments in reverse order. */
|
||||
for (i = nargs - 1; i >= 0; i--)
|
||||
{
|
||||
struct type *value_type = value_enclosing_type (args[i]);
|
||||
struct type *value_type = args[i]->enclosing_type ();
|
||||
int len = value_type->length ();
|
||||
int container_len = (len + 3) & ~3;
|
||||
int offset;
|
||||
|
@ -1340,7 +1340,7 @@ rl78_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
|
||||
/* Push arguments in reverse order. */
|
||||
for (i = nargs - 1; i >= 0; i--)
|
||||
{
|
||||
struct type *value_type = value_enclosing_type (args[i]);
|
||||
struct type *value_type = args[i]->enclosing_type ();
|
||||
int len = value_type->length ();
|
||||
int container_len = (len + 1) & ~1;
|
||||
|
||||
|
@ -298,7 +298,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch,
|
||||
for (i = 0; i < nargs && argreg <= TILEGX_R9_REGNUM; i++)
|
||||
{
|
||||
const gdb_byte *val;
|
||||
typelen = value_enclosing_type (args[i])->length ();
|
||||
typelen = args[i]->enclosing_type ()->length ();
|
||||
|
||||
if (typelen > (TILEGX_R9_REGNUM - argreg + 1) * tilegx_reg_size)
|
||||
break;
|
||||
@ -325,7 +325,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch,
|
||||
{
|
||||
const gdb_byte *contents = value_contents (args[j]).data ();
|
||||
|
||||
typelen = value_enclosing_type (args[j])->length ();
|
||||
typelen = args[j]->enclosing_type ()->length ();
|
||||
slacklen = align_up (typelen, 8) - typelen;
|
||||
gdb::byte_vector val (typelen + slacklen);
|
||||
memcpy (val.data (), contents, typelen);
|
||||
|
33
gdb/valops.c
33
gdb/valops.c
@ -327,7 +327,7 @@ value_cast_pointers (struct type *type, struct value *arg2,
|
||||
/* No superclass found, just change the pointer type. */
|
||||
arg2 = value_copy (arg2);
|
||||
arg2->deprecated_set_type (type);
|
||||
set_value_enclosing_type (arg2, type);
|
||||
arg2->set_enclosing_type (type);
|
||||
set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */
|
||||
return arg2;
|
||||
}
|
||||
@ -649,7 +649,7 @@ value_cast (struct type *type, struct value *arg2)
|
||||
|
||||
arg2 = value_copy (arg2);
|
||||
arg2->deprecated_set_type (to_type);
|
||||
set_value_enclosing_type (arg2, to_type);
|
||||
arg2->set_enclosing_type (to_type);
|
||||
set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */
|
||||
return arg2;
|
||||
}
|
||||
@ -1352,7 +1352,7 @@ value_assign (struct value *toval, struct value *fromval)
|
||||
to by TOVAL retains its original dynamic type after assignment. */
|
||||
if (type->code () == TYPE_CODE_PTR)
|
||||
{
|
||||
set_value_enclosing_type (val, value_enclosing_type (fromval));
|
||||
val->set_enclosing_type (fromval->enclosing_type ());
|
||||
set_value_pointed_to_offset (val, value_pointed_to_offset (fromval));
|
||||
}
|
||||
|
||||
@ -1371,14 +1371,14 @@ value_repeat (struct value *arg1, int count)
|
||||
if (count < 1)
|
||||
error (_("Invalid number %d of repetitions."), count);
|
||||
|
||||
val = allocate_repeat_value (value_enclosing_type (arg1), count);
|
||||
val = allocate_repeat_value (arg1->enclosing_type (), count);
|
||||
|
||||
VALUE_LVAL (val) = lval_memory;
|
||||
set_value_address (val, value_address (arg1));
|
||||
|
||||
read_value_memory (val, 0, value_stack (val), value_address (val),
|
||||
value_contents_all_raw (val).data (),
|
||||
type_length_units (value_enclosing_type (val)));
|
||||
type_length_units (val->enclosing_type ()));
|
||||
|
||||
return val;
|
||||
}
|
||||
@ -1568,13 +1568,13 @@ value_addr (struct value *arg1)
|
||||
struct type *type_ptr
|
||||
= lookup_pointer_type (type->target_type ());
|
||||
struct type *enclosing_type
|
||||
= check_typedef (value_enclosing_type (arg1));
|
||||
= check_typedef (arg1->enclosing_type ());
|
||||
struct type *enclosing_type_ptr
|
||||
= lookup_pointer_type (enclosing_type->target_type ());
|
||||
|
||||
arg2 = value_copy (arg1);
|
||||
arg2->deprecated_set_type (type_ptr);
|
||||
set_value_enclosing_type (arg2, enclosing_type_ptr);
|
||||
arg2->set_enclosing_type (enclosing_type_ptr);
|
||||
|
||||
return arg2;
|
||||
}
|
||||
@ -1596,8 +1596,7 @@ value_addr (struct value *arg1)
|
||||
|
||||
/* This may be a pointer to a base subobject; so remember the
|
||||
full derived object's type ... */
|
||||
set_value_enclosing_type (arg2,
|
||||
lookup_pointer_type (value_enclosing_type (arg1)));
|
||||
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));
|
||||
@ -1657,7 +1656,7 @@ value_ind (struct value *arg1)
|
||||
|
||||
/* We may be pointing to something embedded in a larger object.
|
||||
Get the real type of the enclosing object. */
|
||||
enc_type = check_typedef (value_enclosing_type (arg1));
|
||||
enc_type = check_typedef (arg1->enclosing_type ());
|
||||
enc_type = enc_type->target_type ();
|
||||
|
||||
CORE_ADDR base_addr;
|
||||
@ -1710,17 +1709,17 @@ value_array (int lowbound, int highbound, struct value **elemvec)
|
||||
{
|
||||
error (_("bad array bounds (%d, %d)"), lowbound, highbound);
|
||||
}
|
||||
typelength = type_length_units (value_enclosing_type (elemvec[0]));
|
||||
typelength = type_length_units (elemvec[0]->enclosing_type ());
|
||||
for (idx = 1; idx < nelem; idx++)
|
||||
{
|
||||
if (type_length_units (value_enclosing_type (elemvec[idx]))
|
||||
if (type_length_units (elemvec[idx]->enclosing_type ())
|
||||
!= typelength)
|
||||
{
|
||||
error (_("array elements must all be the same size"));
|
||||
}
|
||||
}
|
||||
|
||||
arraytype = lookup_array_range_type (value_enclosing_type (elemvec[0]),
|
||||
arraytype = lookup_array_range_type (elemvec[0]->enclosing_type (),
|
||||
lowbound, highbound);
|
||||
|
||||
if (!current_language->c_style_arrays_p ())
|
||||
@ -2095,7 +2094,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset,
|
||||
|
||||
boffset += value_embedded_offset (arg1) + offset;
|
||||
if (boffset < 0
|
||||
|| boffset >= value_enclosing_type (arg1)->length ())
|
||||
|| boffset >= arg1->enclosing_type ()->length ())
|
||||
{
|
||||
CORE_ADDR base_addr;
|
||||
|
||||
@ -3944,14 +3943,14 @@ value_full_object (struct value *argp,
|
||||
real_type = value_rtti_type (argp, &full, &top, &using_enc);
|
||||
|
||||
/* If no RTTI data, or if object is already complete, do nothing. */
|
||||
if (!real_type || real_type == value_enclosing_type (argp))
|
||||
if (!real_type || real_type == argp->enclosing_type ())
|
||||
return argp;
|
||||
|
||||
/* In a destructor we might see a real type that is a superclass of
|
||||
the object's type. In this case it is better to leave the object
|
||||
as-is. */
|
||||
if (full
|
||||
&& real_type->length () < value_enclosing_type (argp)->length ())
|
||||
&& real_type->length () < argp->enclosing_type ()->length ())
|
||||
return argp;
|
||||
|
||||
/* If we have the full object, but for some reason the enclosing
|
||||
@ -3960,7 +3959,7 @@ value_full_object (struct value *argp,
|
||||
if (full)
|
||||
{
|
||||
argp = value_copy (argp);
|
||||
set_value_enclosing_type (argp, real_type);
|
||||
argp->set_enclosing_type (real_type);
|
||||
return argp;
|
||||
}
|
||||
|
||||
|
60
gdb/value.c
60
gdb/value.c
@ -177,7 +177,7 @@ value_bits_available (const struct value *value,
|
||||
/* Don't pretend we have anything available there in the history beyond
|
||||
the boundaries of the value recorded. It's not like inferior memory
|
||||
where there is actual stuff underneath. */
|
||||
ULONGEST val_len = TARGET_CHAR_BIT * value_enclosing_type (value)->length ();
|
||||
ULONGEST val_len = TARGET_CHAR_BIT * value->enclosing_type ()->length ();
|
||||
return !((value->m_in_history
|
||||
&& (offset < 0 || offset + length > val_len))
|
||||
|| ranges_contain (value->m_unavailable, offset, length));
|
||||
@ -240,7 +240,7 @@ value_entirely_covered_by_range_vector (struct value *value,
|
||||
|
||||
if (t.offset == 0
|
||||
&& t.length == (TARGET_CHAR_BIT
|
||||
* value_enclosing_type (value)->length ()))
|
||||
* value->enclosing_type ()->length ()))
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -725,8 +725,8 @@ value_contents_eq (const struct value *val1, LONGEST offset1,
|
||||
bool
|
||||
value_contents_eq (const struct value *val1, const struct value *val2)
|
||||
{
|
||||
ULONGEST len1 = check_typedef (value_enclosing_type (val1))->length ();
|
||||
ULONGEST len2 = check_typedef (value_enclosing_type (val2))->length ();
|
||||
ULONGEST len1 = check_typedef (val1->enclosing_type ())->length ();
|
||||
ULONGEST len2 = check_typedef (val2->enclosing_type ())->length ();
|
||||
if (len1 != len2)
|
||||
return false;
|
||||
return value_contents_eq (val1, 0, val2, 0, len1);
|
||||
@ -934,7 +934,7 @@ allocate_value_contents (struct value *val, bool check_size)
|
||||
{
|
||||
if (!val->m_contents)
|
||||
{
|
||||
struct type *enclosing_type = value_enclosing_type (val);
|
||||
struct type *enclosing_type = val->enclosing_type ();
|
||||
ULONGEST len = enclosing_type->length ();
|
||||
|
||||
if (check_size)
|
||||
@ -1042,16 +1042,10 @@ value_contents_all_raw (struct value *value)
|
||||
{
|
||||
allocate_value_contents (value, true);
|
||||
|
||||
ULONGEST length = value_enclosing_type (value)->length ();
|
||||
ULONGEST length = value->enclosing_type ()->length ();
|
||||
return gdb::make_array_view (value->m_contents.get (), length);
|
||||
}
|
||||
|
||||
struct type *
|
||||
value_enclosing_type (const struct value *value)
|
||||
{
|
||||
return value->m_enclosing_type;
|
||||
}
|
||||
|
||||
/* Look at value.h for description. */
|
||||
|
||||
struct type *
|
||||
@ -1089,7 +1083,7 @@ value_actual_type (struct value *value, int resolve_simple_types,
|
||||
{
|
||||
if (real_type_found)
|
||||
*real_type_found = 1;
|
||||
result = value_enclosing_type (value);
|
||||
result = value->enclosing_type ();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1128,7 +1122,7 @@ value_contents_for_printing (struct value *value)
|
||||
if (value->m_lazy)
|
||||
value_fetch_lazy (value);
|
||||
|
||||
ULONGEST length = value_enclosing_type (value)->length ();
|
||||
ULONGEST length = value->enclosing_type ()->length ();
|
||||
return gdb::make_array_view (value->m_contents.get (), length);
|
||||
}
|
||||
|
||||
@ -1137,7 +1131,7 @@ value_contents_for_printing_const (const struct value *value)
|
||||
{
|
||||
gdb_assert (!value->m_lazy);
|
||||
|
||||
ULONGEST length = value_enclosing_type (value)->length ();
|
||||
ULONGEST length = value->enclosing_type ()->length ();
|
||||
return gdb::make_array_view (value->m_contents.get (), length);
|
||||
}
|
||||
|
||||
@ -1614,7 +1608,7 @@ value_release_to_mark (const struct value *mark)
|
||||
struct value *
|
||||
value_copy (const value *arg)
|
||||
{
|
||||
struct type *encl_type = value_enclosing_type (arg);
|
||||
struct type *encl_type = arg->enclosing_type ();
|
||||
struct value *val;
|
||||
|
||||
val = allocate_value_lazy (encl_type);
|
||||
@ -1643,7 +1637,7 @@ value_copy (const value *arg)
|
||||
{
|
||||
ULONGEST length = val->m_limited_length;
|
||||
if (length == 0)
|
||||
length = value_enclosing_type (val)->length ();
|
||||
length = val->enclosing_type ()->length ();
|
||||
|
||||
gdb_assert (arg->m_contents != nullptr);
|
||||
const auto &arg_view
|
||||
@ -1676,12 +1670,11 @@ struct value *
|
||||
make_cv_value (int cnst, int voltl, struct value *v)
|
||||
{
|
||||
struct type *val_type = v->type ();
|
||||
struct type *m_enclosing_type = value_enclosing_type (v);
|
||||
struct type *m_enclosing_type = v->enclosing_type ();
|
||||
struct value *cv_val = value_copy (v);
|
||||
|
||||
cv_val->deprecated_set_type (make_cv_type (cnst, voltl, val_type, NULL));
|
||||
set_value_enclosing_type (cv_val,
|
||||
make_cv_type (cnst, voltl, m_enclosing_type, NULL));
|
||||
cv_val->set_enclosing_type (make_cv_type (cnst, voltl, m_enclosing_type, NULL));
|
||||
|
||||
return cv_val;
|
||||
}
|
||||
@ -1693,7 +1686,7 @@ value_non_lval (struct value *arg)
|
||||
{
|
||||
if (VALUE_LVAL (arg) != not_lval)
|
||||
{
|
||||
struct type *enc_type = value_enclosing_type (arg);
|
||||
struct type *enc_type = arg->enclosing_type ();
|
||||
struct value *val = allocate_value (enc_type);
|
||||
|
||||
copy (value_contents_all (arg), value_contents_all_raw (val));
|
||||
@ -1788,7 +1781,7 @@ set_value_component_location (struct value *component,
|
||||
int
|
||||
record_latest_value (struct value *val)
|
||||
{
|
||||
struct type *enclosing_type = value_enclosing_type (val);
|
||||
struct type *enclosing_type = val->enclosing_type ();
|
||||
struct type *type = val->type ();
|
||||
|
||||
/* We don't want this value to have anything to do with the inferior anymore.
|
||||
@ -2972,17 +2965,16 @@ value_static_field (struct type *type, int fieldno)
|
||||
data. */
|
||||
|
||||
void
|
||||
set_value_enclosing_type (struct value *val, struct type *new_encl_type)
|
||||
value::set_enclosing_type (struct type *new_encl_type)
|
||||
{
|
||||
if (new_encl_type->length () > value_enclosing_type (val)->length ())
|
||||
if (new_encl_type->length () > enclosing_type ()->length ())
|
||||
{
|
||||
check_type_length_before_alloc (new_encl_type);
|
||||
val->m_contents
|
||||
.reset ((gdb_byte *) xrealloc (val->m_contents.release (),
|
||||
new_encl_type->length ()));
|
||||
m_contents.reset ((gdb_byte *) xrealloc (m_contents.release (),
|
||||
new_encl_type->length ()));
|
||||
}
|
||||
|
||||
val->m_enclosing_type = new_encl_type;
|
||||
m_enclosing_type = new_encl_type;
|
||||
}
|
||||
|
||||
/* Given a value ARG1 (offset by OFFSET bytes)
|
||||
@ -3062,12 +3054,12 @@ value_primitive_field (struct value *arg1, LONGEST offset,
|
||||
boffset = arg_type->field (fieldno).loc_bitpos () / 8;
|
||||
|
||||
if (value_lazy (arg1))
|
||||
v = allocate_value_lazy (value_enclosing_type (arg1));
|
||||
v = allocate_value_lazy (arg1->enclosing_type ());
|
||||
else
|
||||
{
|
||||
v = allocate_value (value_enclosing_type (arg1));
|
||||
v = allocate_value (arg1->enclosing_type ());
|
||||
value_contents_copy_raw (v, 0, arg1, 0,
|
||||
value_enclosing_type (arg1)->length ());
|
||||
arg1->enclosing_type ()->length ());
|
||||
}
|
||||
v->m_type = type;
|
||||
v->m_offset = arg1->offset ();
|
||||
@ -3780,7 +3772,7 @@ readjust_indirect_value_type (struct value *value, struct type *enc_type,
|
||||
value->deprecated_set_type (resolved_original_target_type);
|
||||
|
||||
/* Add embedding info. */
|
||||
set_value_enclosing_type (value, enc_type);
|
||||
value->set_enclosing_type (enc_type);
|
||||
set_value_embedded_offset (value, value_pointed_to_offset (original_value));
|
||||
|
||||
/* We may be pointing to an object of some derived type. */
|
||||
@ -3801,7 +3793,7 @@ coerce_ref (struct value *arg)
|
||||
if (!TYPE_IS_REFERENCE (value_type_arg_tmp))
|
||||
return arg;
|
||||
|
||||
enc_type = check_typedef (value_enclosing_type (arg));
|
||||
enc_type = check_typedef (arg->enclosing_type ());
|
||||
enc_type = enc_type->target_type ();
|
||||
|
||||
CORE_ADDR addr = unpack_pointer (arg->type (), value_contents (arg).data ());
|
||||
@ -3913,7 +3905,7 @@ value_fetch_lazy_memory (struct value *val)
|
||||
gdb_assert (VALUE_LVAL (val) == lval_memory);
|
||||
|
||||
CORE_ADDR addr = value_address (val);
|
||||
struct type *type = check_typedef (value_enclosing_type (val));
|
||||
struct type *type = check_typedef (val->enclosing_type ());
|
||||
|
||||
/* Figure out how much we should copy from memory. Usually, this is just
|
||||
the size of the type, but, for arrays, we might only be loading a
|
||||
|
93
gdb/value.h
93
gdb/value.h
@ -215,6 +215,52 @@ struct value
|
||||
int deprecated_modifiable () const
|
||||
{ return m_modifiable; }
|
||||
|
||||
/* 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
|
||||
additional members, then `type' is just a subobject of the real
|
||||
thing, and the full object is probably larger than `type' would
|
||||
suggest.
|
||||
|
||||
If `type' is a dynamic class (i.e. one with a vtable), then GDB can
|
||||
actually determine the object's run-time type by looking at the
|
||||
run-time type information in the vtable. When this information is
|
||||
available, we may elect to read in the entire object, for several
|
||||
reasons:
|
||||
|
||||
- When printing the value, the user would probably rather see the
|
||||
full object, not just the limited portion apparent from the
|
||||
compile-time type.
|
||||
|
||||
- If `type' has virtual base classes, then even printing `type'
|
||||
alone may require reaching outside the `type' portion of the
|
||||
object to wherever the virtual base class has been stored.
|
||||
|
||||
When we store the entire object, `enclosing_type' is the run-time
|
||||
type -- the complete object -- and `embedded_offset' is the offset
|
||||
of `type' within that larger type, in bytes. The value_contents()
|
||||
macro takes `embedded_offset' into account, so most GDB code
|
||||
continues to see the `type' portion of the value, just as the
|
||||
inferior would.
|
||||
|
||||
If `type' is a pointer to an object, then `enclosing_type' is a
|
||||
pointer to the object's run-time type, and `pointed_to_offset' is
|
||||
the offset in bytes from the full object to the pointed-to object
|
||||
-- that is, the value `embedded_offset' would have if we followed
|
||||
the pointer and fetched the complete object. (I don't really see
|
||||
the point. Why not just determine the run-time type when you
|
||||
indirect, and avoid the special case? The contents don't matter
|
||||
until you indirect anyway.)
|
||||
|
||||
If we're not doing anything fancy, `enclosing_type' is equal to
|
||||
`type', and `embedded_offset' is zero, so everything works
|
||||
normally. */
|
||||
|
||||
struct type *enclosing_type () const
|
||||
{ return m_enclosing_type; }
|
||||
|
||||
void set_enclosing_type (struct type *new_type);
|
||||
|
||||
|
||||
/* Type of value; either not an lval, or one of the various
|
||||
different possible kinds of lval. */
|
||||
@ -393,51 +439,6 @@ struct value
|
||||
ULONGEST m_limited_length = 0;
|
||||
};
|
||||
|
||||
/* 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
|
||||
additional members, then `type' is just a subobject of the real
|
||||
thing, and the full object is probably larger than `type' would
|
||||
suggest.
|
||||
|
||||
If `type' is a dynamic class (i.e. one with a vtable), then GDB can
|
||||
actually determine the object's run-time type by looking at the
|
||||
run-time type information in the vtable. When this information is
|
||||
available, we may elect to read in the entire object, for several
|
||||
reasons:
|
||||
|
||||
- When printing the value, the user would probably rather see the
|
||||
full object, not just the limited portion apparent from the
|
||||
compile-time type.
|
||||
|
||||
- If `type' has virtual base classes, then even printing `type'
|
||||
alone may require reaching outside the `type' portion of the
|
||||
object to wherever the virtual base class has been stored.
|
||||
|
||||
When we store the entire object, `enclosing_type' is the run-time
|
||||
type -- the complete object -- and `embedded_offset' is the offset
|
||||
of `type' within that larger type, in bytes. The value_contents()
|
||||
macro takes `embedded_offset' into account, so most GDB code
|
||||
continues to see the `type' portion of the value, just as the
|
||||
inferior would.
|
||||
|
||||
If `type' is a pointer to an object, then `enclosing_type' is a
|
||||
pointer to the object's run-time type, and `pointed_to_offset' is
|
||||
the offset in bytes from the full object to the pointed-to object
|
||||
-- that is, the value `embedded_offset' would have if we followed
|
||||
the pointer and fetched the complete object. (I don't really see
|
||||
the point. Why not just determine the run-time type when you
|
||||
indirect, and avoid the special case? The contents don't matter
|
||||
until you indirect anyway.)
|
||||
|
||||
If we're not doing anything fancy, `enclosing_type' is equal to
|
||||
`type', and `embedded_offset' is zero, so everything works
|
||||
normally. */
|
||||
|
||||
extern struct type *value_enclosing_type (const struct value *);
|
||||
extern void set_value_enclosing_type (struct value *val,
|
||||
struct type *new_type);
|
||||
|
||||
/* Returns value_type or value_enclosing_type depending on
|
||||
value_print_options.objectprint.
|
||||
|
||||
@ -768,7 +769,7 @@ extern void mark_value_bits_unavailable (struct value *value,
|
||||
example, to compare a complete object value with itself, including
|
||||
its enclosing type chunk, you'd do:
|
||||
|
||||
int len = check_typedef (value_enclosing_type (val))->length ();
|
||||
int len = check_typedef (val->enclosing_type ())->length ();
|
||||
value_contents_eq (val, 0, val, 0, len);
|
||||
|
||||
Returns true iff the set of available/valid contents match.
|
||||
|
@ -117,7 +117,7 @@ vax_store_arguments (struct regcache *regcache, int nargs,
|
||||
/* Push arguments in reverse order. */
|
||||
for (i = nargs - 1; i >= 0; i--)
|
||||
{
|
||||
int len = value_enclosing_type (args[i])->length ();
|
||||
int len = args[i]->enclosing_type ()->length ();
|
||||
|
||||
sp -= (len + 3) & ~3;
|
||||
count += (len + 3) / 4;
|
||||
|
@ -247,7 +247,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
|
||||
would fit in the remaining unused registers. */
|
||||
for (i = 0; i < nargs && argreg <= E_LST_ARG_REGNUM; i++)
|
||||
{
|
||||
typelen = value_enclosing_type (args[i])->length ();
|
||||
typelen = args[i]->enclosing_type ()->length ();
|
||||
if (typelen > E_MAX_RETTYPE_SIZE (argreg))
|
||||
break;
|
||||
|
||||
@ -272,7 +272,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
|
||||
{
|
||||
const gdb_byte *bytes = value_contents (args[j]).data ();
|
||||
|
||||
typelen = value_enclosing_type (args[j])->length ();
|
||||
typelen = args[j]->enclosing_type ()->length ();
|
||||
slacklen = typelen & 1;
|
||||
gdb::byte_vector val (typelen + slacklen);
|
||||
memcpy (val.data (), bytes, typelen);
|
||||
|
Loading…
Reference in New Issue
Block a user