|
|
e1d87d |
commit af547a9614969e1d1ea6fcec6b59cd77a606380f
|
|
|
e1d87d |
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
|
|
|
e1d87d |
Date: Tue Jun 13 15:20:27 2017 +0200
|
|
|
e1d87d |
|
|
|
e1d87d |
read/write_pieced_value: Respect value parent's offset
|
|
|
e1d87d |
|
|
|
e1d87d |
In the case of targeting a bit-field, read_pieced_value and
|
|
|
e1d87d |
write_pieced_value calculate the number of bits preceding the bit-field
|
|
|
e1d87d |
without considering the relative offset of the value's parent. This is
|
|
|
e1d87d |
relevant for a structure variable like this:
|
|
|
e1d87d |
|
|
|
e1d87d |
struct s {
|
|
|
e1d87d |
uint64_t foo;
|
|
|
e1d87d |
struct {
|
|
|
e1d87d |
uint32_t bar;
|
|
|
e1d87d |
uint32_t bf : 10; /* <-- target bit-field */
|
|
|
e1d87d |
} baz;
|
|
|
e1d87d |
} s;
|
|
|
e1d87d |
|
|
|
e1d87d |
In this scenario, if 'val' is a GDB value representing s.baz.bf,
|
|
|
e1d87d |
val->parent represents the whole s.baz structure, and the following holds:
|
|
|
e1d87d |
|
|
|
e1d87d |
- value_offset (val) == sizeof s.baz.bar == 4
|
|
|
e1d87d |
- value_offset (val->parent) == sizeof s.foo == 8
|
|
|
e1d87d |
|
|
|
e1d87d |
The current logic would only use value_offset(val), resulting in the wrong
|
|
|
e1d87d |
offset into the target value. This is fixed.
|
|
|
e1d87d |
|
|
|
e1d87d |
gdb/ChangeLog:
|
|
|
e1d87d |
|
|
|
e1d87d |
* dwarf2loc.c (read_pieced_value): Respect parent value's offset
|
|
|
e1d87d |
when targeting a bit-field.
|
|
|
e1d87d |
(write_pieced_value): Likewise.
|
|
|
e1d87d |
|
|
|
e1d87d |
### a/gdb/ChangeLog
|
|
|
e1d87d |
### b/gdb/ChangeLog
|
|
|
e1d87d |
## -1,5 +1,11 @@
|
|
|
e1d87d |
2017-06-13 Andreas Arnez <arnez@linux.vnet.ibm.com>
|
|
|
e1d87d |
|
|
|
e1d87d |
+ * dwarf2loc.c (read_pieced_value): Respect parent value's offset
|
|
|
e1d87d |
+ when targeting a bit-field.
|
|
|
e1d87d |
+ (write_pieced_value): Likewise.
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+2017-06-13 Andreas Arnez <arnez@linux.vnet.ibm.com>
|
|
|
e1d87d |
+
|
|
|
e1d87d |
* dwarf2loc.c (struct piece_closure) <addr_size>: Remove field.
|
|
|
e1d87d |
(allocate_piece_closure): Drop addr_size parameter.
|
|
|
e1d87d |
(dwarf2_evaluate_loc_desc_full): Adjust call to
|
|
|
e1d87d |
--- a/gdb/dwarf2loc.c
|
|
|
e1d87d |
+++ b/gdb/dwarf2loc.c
|
|
|
e1d87d |
@@ -1776,7 +1776,8 @@ read_pieced_value (struct value *v)
|
|
|
e1d87d |
bits_to_skip = 8 * value_offset (v);
|
|
|
e1d87d |
if (value_bitsize (v))
|
|
|
e1d87d |
{
|
|
|
e1d87d |
- bits_to_skip += value_bitpos (v);
|
|
|
e1d87d |
+ bits_to_skip += (8 * value_offset (value_parent (v))
|
|
|
e1d87d |
+ + value_bitpos (v));
|
|
|
e1d87d |
type_len = value_bitsize (v);
|
|
|
e1d87d |
}
|
|
|
e1d87d |
else
|
|
|
e1d87d |
@@ -1946,7 +1947,8 @@ write_pieced_value (struct value *to, struct value *from)
|
|
|
e1d87d |
bits_to_skip = 8 * value_offset (to);
|
|
|
e1d87d |
if (value_bitsize (to))
|
|
|
e1d87d |
{
|
|
|
e1d87d |
- bits_to_skip += value_bitpos (to);
|
|
|
e1d87d |
+ bits_to_skip += (8 * value_offset (value_parent (to))
|
|
|
e1d87d |
+ + value_bitpos (to));
|
|
|
e1d87d |
type_len = value_bitsize (to);
|
|
|
e1d87d |
}
|
|
|
e1d87d |
else
|