summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.dwarf2
diff options
context:
space:
mode:
authorAndreas Arnez <arnez@linux.vnet.ibm.com>2017-03-16 19:50:24 +0100
committerAndreas Arnez <arnez@linux.vnet.ibm.com>2017-03-16 19:50:24 +0100
commit7942e96e435d1cf4d4dbf58c47bb28d9f628c9e6 (patch)
treef09fed51fefa8ee276a87a786374ba95f4e2ece6 /gdb/testsuite/gdb.dwarf2
parent6ebac3fbacebaebd9e2c9393da3b612342d953a9 (diff)
Big-endian targets: Don't ignore offset into DW_OP_stack_value
Recently I fixed a bug that caused a DW_OP_implicit_pointer with non-zero offset into a DW_OP_implicit_value to be handled incorrectly on big-endian targets. GDB ignored the offset and copied the wrong bytes: https://sourceware.org/ml/gdb-patches/2017-01/msg00251.html But there is still a similar issue when a DW_OP_implicit_pointer points into a DW_OP_stack_value instead; and again, the offset is ignored. There is an important difference, though: While implicit values are treated like blocks of data and anchored at the lowest-addressed byte, stack values traditionally contain integer numbers and are anchored at the *least significant* byte. Also, stack values do not come in varying sizes, but are cut down appropriately when used. Thus, on big-endian targets the scenario looks like this (higher addresses shown right): |<- - - - - Stack value - - - - - - ->| | | |<- original object ->| | | offset ->|####| ^^^^ de-referenced implicit pointer (Note how the original object's size influences the position of the de-referenced implicit pointer within the stack value. This is not the case for little-endian targets, where the original object starts at offset zero within the stack value.) This patch implements the logic indicated in the above diagram and adds an appropriate test case. A new function dwarf2_fetch_die_type_sect_off is added; it is used for retrieving the original object's type, so its size can be determined. That type is passed to dwarf2_evaluate_loc_desc_full via a new parameter. gdb/ChangeLog: * dwarf2loc.c (indirect_synthetic_pointer): Get data type of pointed-to DIE and pass it to dwarf2_evaluate_loc_desc_full. (dwarf2_evaluate_loc_desc_full): New parameter subobj_type; rename byte_offset to subobj_byte_offset. Fix the handling of DWARF_VALUE_STACK on big-endian targets when coming via an implicit pointer. (dwarf2_evaluate_loc_desc): Adjust call to dwarf2_evaluate_loc_desc_full. * dwarf2loc.h (dwarf2_fetch_die_type_sect_off): New declaration. * dwarf2read.c (dwarf2_fetch_die_type_sect_off): New function. gdb/testsuite/ChangeLog: * lib/dwarf.exp: Add support for DW_OP_implicit_pointer. * gdb.dwarf2/nonvar-access.exp: Add test for stack value location and implicit pointer into such a location.
Diffstat (limited to 'gdb/testsuite/gdb.dwarf2')
-rw-r--r--gdb/testsuite/gdb.dwarf2/nonvar-access.exp28
1 files changed, 26 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.dwarf2/nonvar-access.exp b/gdb/testsuite/gdb.dwarf2/nonvar-access.exp
index 3cb5c493bc..99f63cca0f 100644
--- a/gdb/testsuite/gdb.dwarf2/nonvar-access.exp
+++ b/gdb/testsuite/gdb.dwarf2/nonvar-access.exp
@@ -33,7 +33,7 @@ Dwarf::assemble $asm_file {
} {
declare_labels int_type_label char_type_label \
struct_s_label struct_t_label array_a9_label \
- char_ptr_label implicit_a_label
+ char_ptr_label implicit_a_label stack_b_label
int_type_label: base_type {
{name "int"}
@@ -159,7 +159,24 @@ Dwarf::assemble $asm_file {
{name implicit_a_ptr}
{type :$char_ptr_label}
{location {
- GNU_implicit_pointer $implicit_a_label 5
+ implicit_pointer $implicit_a_label 5
+ } SPECIAL_expr}
+ }
+ # Stack-value location.
+ stack_b_label: DW_TAG_variable {
+ {name def_stack_b}
+ {type :$struct_t_label}
+ {location {
+ const4u 0x1a2b3c4d
+ stack_value
+ } SPECIAL_expr}
+ }
+ # Implicit pointer into stack value.
+ DW_TAG_variable {
+ {name implicit_b_ptr}
+ {type :$char_ptr_label}
+ {location {
+ implicit_pointer $stack_b_label 1
} SPECIAL_expr}
}
}
@@ -194,6 +211,13 @@ gdb_test "print/x def_implicit_a" \
gdb_test "print/x def_implicit_a\[5\]" " = 0x56"
gdb_test "print/x *(char (*)\[5\]) implicit_a_ptr" \
" = \\{0x56, 0x67, 0x78, 0x89, 0x9a\\}"
+switch $endian {
+ big {set val "a = 52, b = 2833485"}
+ little {set val "a = 77, b = 857502"}
+}
+gdb_test "print def_stack_b" " = \\{$val\\}"
+switch $endian {big {set val 0x2b} little {set val 0x3c}}
+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\\}"