diff options
author | Andreas Arnez <arnez@linux.vnet.ibm.com> | 2017-06-13 15:20:26 +0200 |
---|---|---|
committer | Andreas Arnez <arnez@linux.vnet.ibm.com> | 2017-06-13 15:20:26 +0200 |
commit | e93523245b704bc126705620969b4736b00350c5 (patch) | |
tree | 3dd486229466121329888fa591dfd0f45feb22d8 /gdb/testsuite/gdb.dwarf2 | |
parent | d5d1163eff2415a01895f1cff8bbee32b3f0ab66 (diff) | |
download | gdb-e93523245b704bc126705620969b4736b00350c5.zip gdb-e93523245b704bc126705620969b4736b00350c5.tar.gz gdb-e93523245b704bc126705620969b4736b00350c5.tar.bz2 |
PR gdb/21226: Take DWARF stack value pieces from LSB end
When taking a DW_OP_piece or DW_OP_bit_piece from a DW_OP_stack_value, the
existing logic always takes the piece from the lowest-addressed end, which
is wrong on big-endian targets. The DWARF standard states that the
"DW_OP_bit_piece operation describes a sequence of bits using the least
significant bits of that value", and this also matches the current logic
in GCC. For instance, the GCC guality test case pr54970.c fails on s390x
because of this.
This fix adjusts the piece accordingly on big-endian targets. It is
assumed that:
* DW_OP_piece shall take the piece from the LSB end as well;
* pieces reaching outside the stack value bits are considered undefined,
and a zero value can be used instead.
gdb/ChangeLog:
PR gdb/21226
* dwarf2loc.c (read_pieced_value): Anchor stack value pieces at
the LSB end, independent of endianness.
gdb/testsuite/ChangeLog:
PR gdb/21226
* gdb.dwarf2/nonvar-access.exp: Add checks for verifying that
stack value pieces are taken from the LSB end.
Diffstat (limited to 'gdb/testsuite/gdb.dwarf2')
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/nonvar-access.exp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/gdb/testsuite/gdb.dwarf2/nonvar-access.exp b/gdb/testsuite/gdb.dwarf2/nonvar-access.exp index 99f63cc..5406029 100644 --- a/gdb/testsuite/gdb.dwarf2/nonvar-access.exp +++ b/gdb/testsuite/gdb.dwarf2/nonvar-access.exp @@ -128,14 +128,26 @@ Dwarf::assemble $asm_file { {name def_t} {type :$struct_t_label} {location { - const1u 0 + const2s -184 stack_value bit_piece 9 0 - const1s -1 + const4u 1752286 stack_value bit_piece 23 0 } SPECIAL_expr} } + # Composite location with some empty pieces. + DW_TAG_variable { + {name part_def_a} + {type :$array_a9_label} + {location { + piece 3 + const4u 0xf1927314 + stack_value + piece 4 + piece 2 + } SPECIAL_expr} + } # Implicit location: immediate value. DW_TAG_variable { {name def_implicit_s} @@ -221,9 +233,12 @@ gdb_test "print/x *implicit_b_ptr" " = $val" # Byte-aligned fields, pieced together from DWARF stack values. gdb_test "print def_s" " = \\{a = 0, b = -1\\}" +switch $endian { big {set val 0x92} little {set val 0x73} } +gdb_test "print/x part_def_a\[4\]" " = $val" +gdb_test "print/x part_def_a\[8\]" " = <optimized out>" # Non-byte-aligned fields, pieced together from DWARF stack values. -gdb_test "print def_t" " = \\{a = 0, b = -1\\}" +gdb_test "print def_t" " = \\{a = -184, b = 1752286\\}" # Simple variable without location. gdb_test "print undef_int" " = <optimized out>" |