mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-05 21:50:21 +08:00
2001-05-07 Daniel Berlin <dan@cgsoftware.com>
Changes by Jim Ingham: * values.c (value_change_enclosing_type): New function. If the new enclosing type is larger than the old one, we need to allocate more space. * value.h: Add value_change_enclosing_type prototype. * valops.c (value_cast): Use it. (value_assign): Use it. (value_addr): Use it. (value_ind): Use it. (value_full_object): Use it. 2001-05-07 Daniel Berlin <dan@cgsoftware.com> * values.c (value_static_field): Handle static fields that have a constant value.
This commit is contained in:
57
gdb/values.c
57
gdb/values.c
@ -762,14 +762,65 @@ value_static_field (struct type *type, int fieldno)
|
||||
}
|
||||
else
|
||||
{
|
||||
addr = SYMBOL_VALUE_ADDRESS (sym);
|
||||
sect = SYMBOL_BFD_SECTION (sym);
|
||||
}
|
||||
/* Anything static that isn't a constant, has an address */
|
||||
if (SYMBOL_CLASS (sym) != LOC_CONST)
|
||||
{
|
||||
addr = SYMBOL_VALUE_ADDRESS (sym);
|
||||
sect = SYMBOL_BFD_SECTION (sym);
|
||||
}
|
||||
/* However, static const's do not, the value is already known. */
|
||||
else
|
||||
{
|
||||
return value_from_longest (TYPE_FIELD_TYPE (type, fieldno), SYMBOL_VALUE (sym));
|
||||
}
|
||||
}
|
||||
SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno), addr);
|
||||
}
|
||||
return value_at (TYPE_FIELD_TYPE (type, fieldno), addr, sect);
|
||||
}
|
||||
|
||||
/* Change the enclosing type of a value object VAL to NEW_ENCL_TYPE.
|
||||
You have to be careful here, since the size of the data area for the value
|
||||
is set by the length of the enclosing type. So if NEW_ENCL_TYPE is bigger
|
||||
than the old enclosing type, you have to allocate more space for the data.
|
||||
The return value is a pointer to the new version of this value structure. */
|
||||
|
||||
value_ptr
|
||||
value_change_enclosing_type (value_ptr val, struct type *new_encl_type)
|
||||
{
|
||||
if (TYPE_LENGTH (new_encl_type) <= TYPE_LENGTH (VALUE_ENCLOSING_TYPE (val)))
|
||||
{
|
||||
VALUE_ENCLOSING_TYPE (val) = new_encl_type;
|
||||
return val;
|
||||
}
|
||||
else
|
||||
{
|
||||
value_ptr new_val;
|
||||
register value_ptr prev;
|
||||
|
||||
new_val = (value_ptr) xrealloc (val, sizeof (struct value) + TYPE_LENGTH (new_encl_type));
|
||||
|
||||
/* We have to make sure this ends up in the same place in the value
|
||||
chain as the original copy, so it's clean-up behavior is the same.
|
||||
If the value has been released, this is a waste of time, but there
|
||||
is no way to tell that in advance, so... */
|
||||
|
||||
if (val != all_values)
|
||||
{
|
||||
for (prev = all_values; prev != NULL; prev = prev->next)
|
||||
{
|
||||
if (prev->next == val)
|
||||
{
|
||||
prev->next = new_val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new_val;
|
||||
}
|
||||
}
|
||||
|
||||
/* Given a value ARG1 (offset by OFFSET bytes)
|
||||
of a struct or union type ARG_TYPE,
|
||||
extract and return the value of one of its (non-static) fields.
|
||||
|
Reference in New Issue
Block a user