diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-03-01 11:06:23 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-07-12 12:09:55 +0100 |
commit | 0d4e84ed37c404eb7e691ee9d68ae2ec758d8f66 (patch) | |
tree | 8ac7687c3d05c9b0fcbfbcee2b87617ee21eb42f /gdb/dwarf2loc.c | |
parent | 9a49df9d4bfc7ff03fed751e12b1bc32fbee4fb2 (diff) | |
download | gdb-0d4e84ed37c404eb7e691ee9d68ae2ec758d8f66.zip gdb-0d4e84ed37c404eb7e691ee9d68ae2ec758d8f66.tar.gz gdb-0d4e84ed37c404eb7e691ee9d68ae2ec758d8f66.tar.bz2 |
gdb: Better support for dynamic properties with negative values
When the type of a property is smaller than the CORE_ADDR in which the
property value has been placed, and if the property is signed, then
sign extend the property value from its actual type up to the size of
CORE_ADDR.
gdb/ChangeLog:
* dwarf2loc.c (dwarf2_evaluate_property): Sign extend property
value if its desired type is smaller than a CORE_ADDR and signed.
gdb/testsuite/ChangeLog:
* gdb.fortran/vla-ptype.exp: Print array with negative bounds.
* gdb.fortran/vla-sizeof.exp: Print the size of an array with
negative bounds.
* gdb.fortran/vla-value.exp: Print elements of an array with
negative bounds.
* gdb.fortran/vla.f90: Setup an array with negative bounds for
testing.
Diffstat (limited to 'gdb/dwarf2loc.c')
-rw-r--r-- | gdb/dwarf2loc.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 00f3d76..63643cb 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -2454,6 +2454,29 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, struct value *val = value_at (baton->property_type, *value); *value = value_as_address (val); } + else + { + gdb_assert (baton->property_type != NULL); + + struct type *type = check_typedef (baton->property_type); + if (TYPE_LENGTH (type) < sizeof (CORE_ADDR) + && !TYPE_UNSIGNED (type)) + { + /* If we have a valid return candidate and it's value + is signed, we have to sign-extend the value because + CORE_ADDR on 64bit machine has 8 bytes but address + size of an 32bit application is bytes. */ + const int addr_size + = (dwarf2_per_cu_addr_size (baton->locexpr.per_cu) + * TARGET_CHAR_BIT); + const CORE_ADDR neg_mask + = (~((CORE_ADDR) 0) << (addr_size - 1)); + + /* Check if signed bit is set and sign-extend values. */ + if (*value & neg_mask) + *value |= neg_mask; + } + } return true; } } |