aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.dwarf2/var-access.exp
diff options
context:
space:
mode:
authorAndreas Arnez <arnez@linux.vnet.ibm.com>2017-06-13 15:20:30 +0200
committerAndreas Arnez <arnez@linux.vnet.ibm.com>2017-06-13 15:20:30 +0200
commit03c8af18d1a8f359fd023696848bda488119da60 (patch)
treef1fe1a485db241dfd1cf7dbe5c5268da065661c9 /gdb/testsuite/gdb.dwarf2/var-access.exp
parent840989c113433c069f54872d7e051e1572202326 (diff)
downloadgdb-03c8af18d1a8f359fd023696848bda488119da60.zip
gdb-03c8af18d1a8f359fd023696848bda488119da60.tar.gz
gdb-03c8af18d1a8f359fd023696848bda488119da60.tar.bz2
Fix handling of DWARF register pieces on big-endian targets
For big-endian targets the logic in read/write_pieced_value tries to take a register piece from the LSB end. This requires offsets and sizes to be adjusted accordingly, and that's where the current implementation has some issues: * The formulas for recalculating the bit- and byte-offsets into the register are wrong. They just happen to yield correct results if everything is byte-aligned and the piece's last byte belongs to the given value. * After recalculating the bit offset into the register, the number of bytes to be copied from the register is not recalculated. Of course this does not matter if everything (particularly the piece size) is byte-aligned. These issues are fixed. The size calculation is performed with a new helper function bits_to_bytes(). gdb/ChangeLog: * dwarf2loc.c (bits_to_bytes): New function. (read_pieced_value): Fix offset calculations for register pieces on big-endian targets. (write_pieced_value): Likewise. gdb/testsuite/ChangeLog: * gdb.dwarf2/var-access.exp: Add test for non-byte-aligned register pieces.
Diffstat (limited to 'gdb/testsuite/gdb.dwarf2/var-access.exp')
-rw-r--r--gdb/testsuite/gdb.dwarf2/var-access.exp25
1 files changed, 25 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.dwarf2/var-access.exp b/gdb/testsuite/gdb.dwarf2/var-access.exp
index 3ba2c08..c533b8d 100644
--- a/gdb/testsuite/gdb.dwarf2/var-access.exp
+++ b/gdb/testsuite/gdb.dwarf2/var-access.exp
@@ -215,6 +215,19 @@ Dwarf::assemble $asm_file {
piece 1
} SPECIAL_expr}
}
+ # Register pieces for bitfield access: 4 bytes optimized
+ # out, 3 bytes from r0, and 1 byte from r1.
+ DW_TAG_variable {
+ {name "t2"}
+ {type :$struct_t_label}
+ {location {
+ piece 4
+ regx [lindex $dwarf_regnum 0]
+ piece 3
+ regx [lindex $dwarf_regnum 1]
+ piece 1
+ } SPECIAL_expr}
+ }
}
}
}
@@ -279,3 +292,15 @@ switch $endian {
# val
gdb_test "print/x a" " = \\{0x0, ${val}, 0x0, 0x0\\}" \
"verify st1 through a"
+
+switch $endian { big {set val 0x7ffc} little {set val 0x3ffe00} }
+gdb_test_no_output "set var \$[lindex $regname 0] = $val" \
+ "init t2, first piece"
+gdb_test_no_output "set var \$[lindex $regname 1] = 0" \
+ "init t2, second piece"
+gdb_test "print/d t2" " = \\{u = <optimized out>, x = 0, y = -1, z = 0\\}" \
+ "initialized t2 from regs"
+gdb_test_no_output "set var t2.y = 2641"
+gdb_test_no_output "set var t2.z = -400"
+gdb_test_no_output "set var t2.x = 200"
+gdb_test "print t2.x + t2.y + t2.z" " = 2441"