diff options
author | Tom Tromey <tromey@adacore.com> | 2020-10-06 08:56:54 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-10-09 11:18:52 -0600 |
commit | 7c184d334adac03eb200b0f8b01edaf051bfc01b (patch) | |
tree | 38ff6a0265cb9dbbd3683aa7d726bb92bc47e324 /gdb/dwarf2 | |
parent | 5c4258f4c051a31d7209712ecd28830c55a92034 (diff) | |
download | gdb-7c184d334adac03eb200b0f8b01edaf051bfc01b.zip gdb-7c184d334adac03eb200b0f8b01edaf051bfc01b.tar.gz gdb-7c184d334adac03eb200b0f8b01edaf051bfc01b.tar.bz2 |
Fix bit offset regression
The type-safe attribute patch introduced a regression that can occur
when the DW_AT_bit_offset value is negative. This can happen with
some Ada programs.
This patch fixes the problem. It also fixes a minor oddity in the
existing scalar storage test -- this test was intended to assign a
smaller number of bits to the field.
2020-10-09 Tom Tromey <tromey@adacore.com>
* dwarf2/read.c (dwarf2_add_field): Handle signed offsets.
gdb/testsuite/ChangeLog
2020-10-09 Tom Tromey <tromey@adacore.com>
* gdb.ada/scalar_storage/storage.adb (Another_Range): New type.
(Rec): Add field. Fix range.
* gdb.ada/scalar_storage.exp: Update.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r-- | gdb/dwarf2/read.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index eedfea1..2ec3789 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -15050,7 +15050,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, /* Get bit offset of field. */ handle_data_member_location (die, cu, fp); attr = dwarf2_attr (die, DW_AT_bit_offset, cu); - if (attr != nullptr && attr->form_is_unsigned ()) + if (attr != nullptr && attr->form_is_constant ()) { if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) { @@ -15060,7 +15060,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, have to do anything special since we don't need to know the size of the anonymous object. */ SET_FIELD_BITPOS (*fp, (FIELD_BITPOS (*fp) - + attr->as_unsigned ())); + + attr->constant_value (0))); } else { @@ -15071,15 +15071,15 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, the field itself. The result is the bit offset of the LSB of the field. */ int anonymous_size; - int bit_offset = attr->as_unsigned (); + int bit_offset = attr->constant_value (0); attr = dwarf2_attr (die, DW_AT_byte_size, cu); - if (attr != nullptr && attr->form_is_unsigned ()) + if (attr != nullptr && attr->form_is_constant ()) { /* The size of the anonymous object containing the bit field is explicit, so use the indicated size (in bytes). */ - anonymous_size = attr->as_unsigned (); + anonymous_size = attr->constant_value (0); } else { |