to an INT (or some size). After all, it is only an offset. */
LONGEST
-unpack_long (struct type *type, char *valaddr)
+unpack_long (struct type *type, const char *valaddr)
{
register enum type_code code = TYPE_CODE (type);
register int len = TYPE_LENGTH (type);
format, result is in host format. */
DOUBLEST
-unpack_double (struct type *type, char *valaddr, int *invp)
+unpack_double (struct type *type, const char *valaddr, int *invp)
{
enum type_code code;
int len;
to an INT (or some size). After all, it is only an offset. */
CORE_ADDR
-unpack_pointer (struct type *type, char *valaddr)
+unpack_pointer (struct type *type, const char *valaddr)
{
/* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure
whether we want this to be true eventually. */
}
\f
-/* Get the value of the FIELDN'th field (which must be static) of TYPE. */
+/* Get the value of the FIELDN'th field (which must be static) of
+ TYPE. Return NULL if the field doesn't exist or has been
+ optimized out. */
struct value *
value_static_field (struct type *type, int fieldno)
{
- CORE_ADDR addr;
- asection *sect;
+ struct value *retval;
+
if (TYPE_FIELD_STATIC_HAS_ADDR (type, fieldno))
{
- addr = TYPE_FIELD_STATIC_PHYSADDR (type, fieldno);
- sect = NULL;
+ retval = value_at (TYPE_FIELD_TYPE (type, fieldno),
+ TYPE_FIELD_STATIC_PHYSADDR (type, fieldno),
+ NULL);
}
else
{
return NULL;
else
{
- addr = SYMBOL_VALUE_ADDRESS (msym);
- sect = SYMBOL_BFD_SECTION (msym);
+ retval = value_at (TYPE_FIELD_TYPE (type, fieldno),
+ SYMBOL_VALUE_ADDRESS (msym),
+ SYMBOL_BFD_SECTION (msym));
}
}
else
{
- /* 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));
- }
+ /* SYM should never have a SYMBOL_CLASS which will require
+ read_var_value to use the FRAME parameter. */
+ if (symbol_read_needs_frame (sym))
+ warning ("static field's value depends on the current "
+ "frame - bad debug info?");
+ retval = read_var_value (sym, NULL);
}
- SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno), addr);
+ if (retval && VALUE_LVAL (retval) == lval_memory)
+ SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno),
+ VALUE_ADDRESS (retval));
}
- return value_at (TYPE_FIELD_TYPE (type, fieldno), addr, sect);
+ return retval;
}
/* Change the enclosing type of a value object VAL to NEW_ENCL_TYPE.
struct value *prev;
new_val = (struct value *) xrealloc (val, sizeof (struct value) + TYPE_LENGTH (new_encl_type));
-
+
+ VALUE_ENCLOSING_TYPE (new_val) = 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
If the field is signed, we also do sign extension. */
LONGEST
-unpack_field_as_long (struct type *type, char *valaddr, int fieldno)
+unpack_field_as_long (struct type *type, const char *valaddr, int fieldno)
{
ULONGEST val;
ULONGEST valmask;
|| code == TYPE_CODE_UNION) /* FIXME, implement struct return. */
error ("GDB does not support specifying a struct or union return value.");
- STORE_RETURN_VALUE (type, VALUE_CONTENTS (val));
+ STORE_RETURN_VALUE (type, current_regcache, VALUE_CONTENTS (val));
}
\f
void