diff options
author | Joel Brobecker <brobecker@adacore.com> | 2014-08-20 14:50:38 +0200 |
---|---|---|
committer | Joel Brobecker <brobecker@adacore.com> | 2014-08-20 15:34:19 +0200 |
commit | d36430db79dc8eccb9cb188e1234f7ff044f79b4 (patch) | |
tree | 68e68772d4683574eb6a07da98b4a64d190d30c1 /gdb/value.c | |
parent | 000339af7b74593f4dd3a679427b9fe34d1254f7 (diff) | |
download | gdb-d36430db79dc8eccb9cb188e1234f7ff044f79b4.zip gdb-d36430db79dc8eccb9cb188e1234f7ff044f79b4.tar.gz gdb-d36430db79dc8eccb9cb188e1234f7ff044f79b4.tar.bz2 |
Fix handling of typedefs to types having a data_location attribute.
Consider an array described in the debugging information as being
a typedef of an array type for which there is a DW_AT_data_location
attribute. Trying to print the value of that array currently yields
incorrect element values. For instance:
(gdb) print foo.three_tdef
$1 = (6293760, 0, 6293772)
The problem occurs because we check for the data_location attribute
only on the typedef type, whereas we should be checking for the
typedef's target type. As a result, GDB erroneously thinks that
there is no data_location, and therefore starts reading the array's
content from the address of the descriptor instead of the data_location
address.
gdb/ChangeLog:
* value.c (value_from_contents_and_address): Strip resolved_type's
typedef layers before checking its TYPE_DATA_LOCATION.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/data-loc.exp: Add additional tests exercising
the handling of variables declared as a typedef to an array
which a DW_AT_data_location attribute.
Diffstat (limited to 'gdb/value.c')
-rw-r--r-- | gdb/value.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gdb/value.c b/gdb/value.c index 09ee1ca..077d234 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -3475,15 +3475,16 @@ value_from_contents_and_address (struct type *type, CORE_ADDR address) { struct type *resolved_type = resolve_dynamic_type (type, address); + struct type *resolved_type_no_typedef = check_typedef (resolved_type); struct value *v; if (valaddr == NULL) v = allocate_value_lazy (resolved_type); else v = value_from_contents (resolved_type, valaddr); - if (TYPE_DATA_LOCATION (resolved_type) != NULL - && TYPE_DATA_LOCATION_KIND (resolved_type) == PROP_CONST) - address = TYPE_DATA_LOCATION_ADDR (resolved_type); + if (TYPE_DATA_LOCATION (resolved_type_no_typedef) != NULL + && TYPE_DATA_LOCATION_KIND (resolved_type_no_typedef) == PROP_CONST) + address = TYPE_DATA_LOCATION_ADDR (resolved_type_no_typedef); set_value_address (v, address); VALUE_LVAL (v) = lval_memory; return v; |