summaryrefslogtreecommitdiff
path: root/gdb/values.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <dan@debian.org>2002-09-18 15:43:47 +0000
committerDaniel Jacobowitz <dan@debian.org>2002-09-18 15:43:47 +0000
commit2d11909797764ca10f0e5c1a95116081d3626a36 (patch)
tree5bd07502e02b568e07d533d5fd3c8e2a50298726 /gdb/values.c
parent301a18620e43dfe8e5116907094da7db9f7f7395 (diff)
downloadgdb-2d11909797764ca10f0e5c1a95116081d3626a36.tar.gz
Fix PR gdb/709
* values.c (value_static_field): Call read_var_value.
Diffstat (limited to 'gdb/values.c')
-rw-r--r--gdb/values.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/gdb/values.c b/gdb/values.c
index a0c9794bced..c943f28fa46 100644
--- a/gdb/values.c
+++ b/gdb/values.c
@@ -800,25 +800,19 @@ unpack_pointer (struct type *type, char *valaddr)
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
{
char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno);
struct symbol *sym = lookup_symbol (phys_name, 0, VAR_NAMESPACE, 0, NULL);
- /* In some cases (involving uninitalized, unreferenced static
- const integral members), g++ -gdwarf-2 can emit debugging
- information giving rise to symbols whose SYMBOL_CLASS is
- LOC_UNRESOLVED. In that case, do a minimal symbol lookup.
- If it returns a useful value, then the symbol was defined
- elsewhere, so we use that information. Otherwise, return
- NULL. */
- if (sym == NULL || SYMBOL_CLASS (sym) == LOC_UNRESOLVED)
+ if (sym == NULL)
{
/* With some compilers, e.g. HP aCC, static data members are reported
as non-debuggable symbols */
@@ -827,27 +821,25 @@ value_static_field (struct type *type, int fieldno)
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.