|
|
e1d87d |
commit d5d1163eff2415a01895f1cff8bbee32b3f0ab66
|
|
|
e1d87d |
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
|
|
|
e1d87d |
Date: Tue Jun 13 15:20:26 2017 +0200
|
|
|
e1d87d |
|
|
|
e1d87d |
write_pieced_value: Fix size capping logic
|
|
|
e1d87d |
|
|
|
e1d87d |
A field f in a structure composed of DWARF pieces may be located in
|
|
|
e1d87d |
multiple pieces, where the first and last of those may contain bits from
|
|
|
e1d87d |
other fields as well. So when writing to f, the beginning of the first
|
|
|
e1d87d |
and the end of the last of those pieces may have to be skipped. But the
|
|
|
e1d87d |
logic in write_pieced_value for handling one of those pieces is flawed
|
|
|
e1d87d |
when the first and last piece are the same, i.e., f is contained in a
|
|
|
e1d87d |
single piece:
|
|
|
e1d87d |
|
|
|
e1d87d |
< - - - - - - - - - piece_size - - - - - - - - - ->
|
|
|
e1d87d |
+-------------------------------------------------+
|
|
|
e1d87d |
| skipped_bits | f_bits | / / / / / / / / / / |
|
|
|
e1d87d |
+-------------------------------------------------+
|
|
|
e1d87d |
|
|
|
e1d87d |
The current logic determines the size of the sub-piece to operate on by
|
|
|
e1d87d |
limiting the piece size to the bit size of f and then subtracting the
|
|
|
e1d87d |
skipped bits:
|
|
|
e1d87d |
|
|
|
e1d87d |
min (piece_size, f_bits) - skipped_bits
|
|
|
e1d87d |
|
|
|
e1d87d |
Instead of:
|
|
|
e1d87d |
|
|
|
e1d87d |
min (piece_size - skipped_bits, f_bits)
|
|
|
e1d87d |
|
|
|
e1d87d |
So the resulting sub-piece size is corrupted, leading to wrong handling of
|
|
|
e1d87d |
this piece in write_pieced_value.
|
|
|
e1d87d |
|
|
|
e1d87d |
Note that the same bug was already found in read_pieced_value and fixed
|
|
|
e1d87d |
there (but not in write_pieced_value), see PR 15391.
|
|
|
e1d87d |
|
|
|
e1d87d |
This patch swaps the calculations, bringing them into the same (correct)
|
|
|
e1d87d |
order as in read_pieced_value.
|
|
|
e1d87d |
|
|
|
e1d87d |
gdb/ChangeLog:
|
|
|
e1d87d |
|
|
|
e1d87d |
* dwarf2loc.c (write_pieced_value): Fix order of calculations for
|
|
|
e1d87d |
size capping.
|
|
|
e1d87d |
|
|
|
e1d87d |
gdb/testsuite/ChangeLog:
|
|
|
e1d87d |
|
|
|
e1d87d |
* gdb.dwarf2/var-pieces.exp: Add test case for modifying a
|
|
|
e1d87d |
variable at nonzero offset.
|
|
|
e1d87d |
|
|
|
e1d87d |
### a/gdb/ChangeLog
|
|
|
e1d87d |
### b/gdb/ChangeLog
|
|
|
e1d87d |
## -1,3 +1,8 @@
|
|
|
e1d87d |
+2017-06-13 Andreas Arnez <arnez@linux.vnet.ibm.com>
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ * dwarf2loc.c (write_pieced_value): Fix order of calculations for
|
|
|
e1d87d |
+ size capping.
|
|
|
e1d87d |
+
|
|
|
e1d87d |
2017-06-13 Yao Qi <yao.qi@linaro.org>
|
|
|
e1d87d |
|
|
|
e1d87d |
* mips-linux-nat.c: Move include features/mips*-linux.c to
|
|
|
e1d87d |
--- a/gdb/dwarf2loc.c
|
|
|
e1d87d |
+++ b/gdb/dwarf2loc.c
|
|
|
e1d87d |
@@ -1964,8 +1964,6 @@ write_pieced_value (struct value *to, struct value *from)
|
|
|
e1d87d |
bits_to_skip -= this_size_bits;
|
|
|
e1d87d |
continue;
|
|
|
e1d87d |
}
|
|
|
e1d87d |
- if (this_size_bits > type_len - offset)
|
|
|
e1d87d |
- this_size_bits = type_len - offset;
|
|
|
e1d87d |
if (bits_to_skip > 0)
|
|
|
e1d87d |
{
|
|
|
e1d87d |
dest_offset_bits = bits_to_skip;
|
|
|
e1d87d |
@@ -1978,6 +1976,8 @@ write_pieced_value (struct value *to, struct value *from)
|
|
|
e1d87d |
dest_offset_bits = 0;
|
|
|
e1d87d |
source_offset_bits = offset;
|
|
|
e1d87d |
}
|
|
|
e1d87d |
+ if (this_size_bits > type_len - offset)
|
|
|
e1d87d |
+ this_size_bits = type_len - offset;
|
|
|
e1d87d |
|
|
|
e1d87d |
this_size = (this_size_bits + source_offset_bits % 8 + 7) / 8;
|
|
|
e1d87d |
source_offset = source_offset_bits / 8;
|
|
|
e1d87d |
### a/gdb/testsuite/ChangeLog
|
|
|
e1d87d |
### b/gdb/testsuite/ChangeLog
|
|
|
e1d87d |
## -1,5 +1,10 @@
|
|
|
e1d87d |
2017-06-13 Andreas Arnez <arnez@linux.vnet.ibm.com>
|
|
|
e1d87d |
|
|
|
e1d87d |
+ * gdb.dwarf2/var-pieces.exp: Add test case for modifying a
|
|
|
e1d87d |
+ variable at nonzero offset.
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+2017-06-13 Andreas Arnez <arnez@linux.vnet.ibm.com>
|
|
|
e1d87d |
+
|
|
|
e1d87d |
* gdb.dwarf2/var-access.c: New file.
|
|
|
e1d87d |
* gdb.dwarf2/var-access.exp: New test.
|
|
|
e1d87d |
* lib/gdb-utils.exp (string_to_regexp): Quote braces as well.
|
|
|
e1d87d |
--- a/gdb/testsuite/gdb.dwarf2/var-access.exp
|
|
|
e1d87d |
+++ b/gdb/testsuite/gdb.dwarf2/var-access.exp
|
|
|
e1d87d |
@@ -178,6 +178,11 @@ gdb_test "print/d s1" " = \\{a = 63, b = 3, c = 0, d = 1\\}" \
|
|
|
e1d87d |
"verify s1.a"
|
|
|
e1d87d |
gdb_test "print/d a" " = \\{0, 1, 63, 3, 4, 5, 6, 7\\}" \
|
|
|
e1d87d |
"verify s1.a through a"
|
|
|
e1d87d |
+gdb_test_no_output "set var s1.b = 42"
|
|
|
e1d87d |
+gdb_test "print/d s1" " = \\{a = 63, b = 42, c = 0, d = 1\\}" \
|
|
|
e1d87d |
+ "verify s1.b"
|
|
|
e1d87d |
+gdb_test "print/d a" " = \\{0, 1, 63, 42, 4, 5, 6, 7\\}" \
|
|
|
e1d87d |
+ "verify s1.b through a"
|
|
|
e1d87d |
|
|
|
e1d87d |
# Byte-aligned register- and memory pieces.
|
|
|
e1d87d |
gdb_test_no_output "set var \$[lindex $regname 0] = 81" \
|