|
|
e1d87d |
commit f236533e3c6a2693bea879b2a4d24d1229864ac9
|
|
|
e1d87d |
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
|
|
|
e1d87d |
Date: Tue Jun 13 15:20:31 2017 +0200
|
|
|
e1d87d |
|
|
|
e1d87d |
read/write_pieced_value: Remove unnecessary variable copies
|
|
|
e1d87d |
|
|
|
e1d87d |
In read_pieced_value's main loop, the variables `dest_offset_bits' and
|
|
|
e1d87d |
`source_offset_bits' are basically just copies of `offset' and
|
|
|
e1d87d |
`bits_to_skip', respectively. In write_pieced_value the copies are
|
|
|
e1d87d |
reversed. This is not very helpful when trying to keep the logic between
|
|
|
e1d87d |
these functions in sync. Since the copies are unnecessary, this patch
|
|
|
e1d87d |
just removes them.
|
|
|
e1d87d |
|
|
|
e1d87d |
gdb/ChangeLog:
|
|
|
e1d87d |
|
|
|
e1d87d |
* dwarf2loc.c (read_pieced_value): Remove unnecessary variables
|
|
|
e1d87d |
dest_offset_bits and source_offset_bits.
|
|
|
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): Remove unnecessary variables
|
|
|
e1d87d |
+ dest_offset_bits and source_offset_bits.
|
|
|
e1d87d |
+ (write_pieced_value): Likewise.
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+2017-06-13 Andreas Arnez <arnez@linux.vnet.ibm.com>
|
|
|
e1d87d |
+
|
|
|
e1d87d |
* dwarf2loc.c (read_pieced_value): Respect the piece offset, as
|
|
|
e1d87d |
given by DW_OP_bit_piece.
|
|
|
e1d87d |
(write_pieced_value): Likewise.
|
|
|
e1d87d |
--- a/gdb/dwarf2loc.c
|
|
|
e1d87d |
+++ b/gdb/dwarf2loc.c
|
|
|
e1d87d |
@@ -1790,25 +1790,16 @@ read_pieced_value (struct value *v)
|
|
|
e1d87d |
else
|
|
|
e1d87d |
max_offset = 8 * TYPE_LENGTH (value_type (v));
|
|
|
e1d87d |
|
|
|
e1d87d |
- for (i = 0; i < c->n_pieces && offset < max_offset; i++)
|
|
|
e1d87d |
+ /* Advance to the first non-skipped piece. */
|
|
|
e1d87d |
+ for (i = 0; i < c->n_pieces && bits_to_skip >= c->pieces[i].size; i++)
|
|
|
e1d87d |
+ bits_to_skip -= c->pieces[i].size;
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ for (; i < c->n_pieces && offset < max_offset; i++)
|
|
|
e1d87d |
{
|
|
|
e1d87d |
struct dwarf_expr_piece *p = &c->pieces[i];
|
|
|
e1d87d |
size_t this_size, this_size_bits;
|
|
|
e1d87d |
- long dest_offset_bits, source_offset_bits;
|
|
|
e1d87d |
-
|
|
|
e1d87d |
- /* Compute size, source, and destination offsets for copying, in
|
|
|
e1d87d |
- bits. */
|
|
|
e1d87d |
- this_size_bits = p->size;
|
|
|
e1d87d |
- if (bits_to_skip > 0 && bits_to_skip >= this_size_bits)
|
|
|
e1d87d |
- {
|
|
|
e1d87d |
- bits_to_skip -= this_size_bits;
|
|
|
e1d87d |
- continue;
|
|
|
e1d87d |
- }
|
|
|
e1d87d |
- source_offset_bits = bits_to_skip;
|
|
|
e1d87d |
- this_size_bits -= bits_to_skip;
|
|
|
e1d87d |
- bits_to_skip = 0;
|
|
|
e1d87d |
- dest_offset_bits = offset;
|
|
|
e1d87d |
|
|
|
e1d87d |
+ this_size_bits = p->size - bits_to_skip;
|
|
|
e1d87d |
if (this_size_bits > max_offset - offset)
|
|
|
e1d87d |
this_size_bits = max_offset - offset;
|
|
|
e1d87d |
|
|
|
e1d87d |
@@ -1827,16 +1818,16 @@ read_pieced_value (struct value *v)
|
|
|
e1d87d |
&& p->offset + p->size < reg_bits)
|
|
|
e1d87d |
{
|
|
|
e1d87d |
/* Big-endian, and we want less than full size. */
|
|
|
e1d87d |
- source_offset_bits += reg_bits - (p->offset + p->size);
|
|
|
e1d87d |
+ bits_to_skip += reg_bits - (p->offset + p->size);
|
|
|
e1d87d |
}
|
|
|
e1d87d |
else
|
|
|
e1d87d |
- source_offset_bits += p->offset;
|
|
|
e1d87d |
+ bits_to_skip += p->offset;
|
|
|
e1d87d |
|
|
|
e1d87d |
- this_size = bits_to_bytes (source_offset_bits, this_size_bits);
|
|
|
e1d87d |
+ this_size = bits_to_bytes (bits_to_skip, this_size_bits);
|
|
|
e1d87d |
buffer.reserve (this_size);
|
|
|
e1d87d |
|
|
|
e1d87d |
if (!get_frame_register_bytes (frame, gdb_regnum,
|
|
|
e1d87d |
- source_offset_bits / 8,
|
|
|
e1d87d |
+ bits_to_skip / 8,
|
|
|
e1d87d |
this_size, buffer.data (),
|
|
|
e1d87d |
&optim, &unavail))
|
|
|
e1d87d |
{
|
|
|
e1d87d |
@@ -1846,24 +1837,23 @@ read_pieced_value (struct value *v)
|
|
|
e1d87d |
mark_value_bits_unavailable (v, offset, this_size_bits);
|
|
|
e1d87d |
break;
|
|
|
e1d87d |
}
|
|
|
e1d87d |
-
|
|
|
e1d87d |
- copy_bitwise (contents, dest_offset_bits,
|
|
|
e1d87d |
- buffer.data (), source_offset_bits % 8,
|
|
|
e1d87d |
+ copy_bitwise (contents, offset,
|
|
|
e1d87d |
+ buffer.data (), bits_to_skip % 8,
|
|
|
e1d87d |
this_size_bits, bits_big_endian);
|
|
|
e1d87d |
}
|
|
|
e1d87d |
break;
|
|
|
e1d87d |
|
|
|
e1d87d |
case DWARF_VALUE_MEMORY:
|
|
|
e1d87d |
- source_offset_bits += p->offset;
|
|
|
e1d87d |
- this_size = bits_to_bytes (source_offset_bits, this_size_bits);
|
|
|
e1d87d |
+ bits_to_skip += p->offset;
|
|
|
e1d87d |
+ this_size = bits_to_bytes (bits_to_skip, this_size_bits);
|
|
|
e1d87d |
buffer.reserve (this_size);
|
|
|
e1d87d |
|
|
|
e1d87d |
read_value_memory (v, offset,
|
|
|
e1d87d |
p->v.mem.in_stack_memory,
|
|
|
e1d87d |
- p->v.mem.addr + source_offset_bits / 8,
|
|
|
e1d87d |
+ p->v.mem.addr + bits_to_skip / 8,
|
|
|
e1d87d |
buffer.data (), this_size);
|
|
|
e1d87d |
- copy_bitwise (contents, dest_offset_bits,
|
|
|
e1d87d |
- buffer.data (), source_offset_bits % 8,
|
|
|
e1d87d |
+ copy_bitwise (contents, offset,
|
|
|
e1d87d |
+ buffer.data (), bits_to_skip % 8,
|
|
|
e1d87d |
this_size_bits, bits_big_endian);
|
|
|
e1d87d |
break;
|
|
|
e1d87d |
|
|
|
e1d87d |
@@ -1880,14 +1870,13 @@ read_pieced_value (struct value *v)
|
|
|
e1d87d |
|
|
|
e1d87d |
/* Piece is anchored at least significant bit end. */
|
|
|
e1d87d |
if (gdbarch_byte_order (objfile_gdbarch) == BFD_ENDIAN_BIG)
|
|
|
e1d87d |
- source_offset_bits += (stack_value_size_bits
|
|
|
e1d87d |
- - p->offset - p->size);
|
|
|
e1d87d |
+ bits_to_skip += stack_value_size_bits - p->offset - p->size;
|
|
|
e1d87d |
else
|
|
|
e1d87d |
- source_offset_bits += p->offset;
|
|
|
e1d87d |
+ bits_to_skip += p->offset;
|
|
|
e1d87d |
|
|
|
e1d87d |
- copy_bitwise (contents, dest_offset_bits,
|
|
|
e1d87d |
+ copy_bitwise (contents, offset,
|
|
|
e1d87d |
value_contents_all (p->v.value),
|
|
|
e1d87d |
- source_offset_bits,
|
|
|
e1d87d |
+ bits_to_skip,
|
|
|
e1d87d |
this_size_bits, bits_big_endian);
|
|
|
e1d87d |
}
|
|
|
e1d87d |
break;
|
|
|
e1d87d |
@@ -1898,14 +1887,14 @@ read_pieced_value (struct value *v)
|
|
|
e1d87d |
size_t n = this_size_bits;
|
|
|
e1d87d |
|
|
|
e1d87d |
/* Cut off at the end of the implicit value. */
|
|
|
e1d87d |
- source_offset_bits += p->offset;
|
|
|
e1d87d |
- if (source_offset_bits >= literal_size_bits)
|
|
|
e1d87d |
+ bits_to_skip += p->offset;
|
|
|
e1d87d |
+ if (bits_to_skip >= literal_size_bits)
|
|
|
e1d87d |
break;
|
|
|
e1d87d |
- if (n > literal_size_bits - source_offset_bits)
|
|
|
e1d87d |
- n = literal_size_bits - source_offset_bits;
|
|
|
e1d87d |
+ if (n > literal_size_bits - bits_to_skip)
|
|
|
e1d87d |
+ n = literal_size_bits - bits_to_skip;
|
|
|
e1d87d |
|
|
|
e1d87d |
- copy_bitwise (contents, dest_offset_bits,
|
|
|
e1d87d |
- p->v.literal.data, source_offset_bits,
|
|
|
e1d87d |
+ copy_bitwise (contents, offset,
|
|
|
e1d87d |
+ p->v.literal.data, bits_to_skip,
|
|
|
e1d87d |
n, bits_big_endian);
|
|
|
e1d87d |
}
|
|
|
e1d87d |
break;
|
|
|
e1d87d |
@@ -1924,6 +1913,7 @@ read_pieced_value (struct value *v)
|
|
|
e1d87d |
}
|
|
|
e1d87d |
|
|
|
e1d87d |
offset += this_size_bits;
|
|
|
e1d87d |
+ bits_to_skip = 0;
|
|
|
e1d87d |
}
|
|
|
e1d87d |
}
|
|
|
e1d87d |
|
|
|
e1d87d |
@@ -1959,23 +1949,16 @@ write_pieced_value (struct value *to, struct value *from)
|
|
|
e1d87d |
else
|
|
|
e1d87d |
max_offset = 8 * TYPE_LENGTH (value_type (to));
|
|
|
e1d87d |
|
|
|
e1d87d |
- for (i = 0; i < c->n_pieces && offset < max_offset; i++)
|
|
|
e1d87d |
+ /* Advance to the first non-skipped piece. */
|
|
|
e1d87d |
+ for (i = 0; i < c->n_pieces && bits_to_skip >= c->pieces[i].size; i++)
|
|
|
e1d87d |
+ bits_to_skip -= c->pieces[i].size;
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ for (; i < c->n_pieces && offset < max_offset; i++)
|
|
|
e1d87d |
{
|
|
|
e1d87d |
struct dwarf_expr_piece *p = &c->pieces[i];
|
|
|
e1d87d |
size_t this_size_bits, this_size;
|
|
|
e1d87d |
- long dest_offset_bits, source_offset_bits;
|
|
|
e1d87d |
-
|
|
|
e1d87d |
- this_size_bits = p->size;
|
|
|
e1d87d |
- if (bits_to_skip > 0 && bits_to_skip >= this_size_bits)
|
|
|
e1d87d |
- {
|
|
|
e1d87d |
- bits_to_skip -= this_size_bits;
|
|
|
e1d87d |
- continue;
|
|
|
e1d87d |
- }
|
|
|
e1d87d |
- dest_offset_bits = bits_to_skip;
|
|
|
e1d87d |
- this_size_bits -= bits_to_skip;
|
|
|
e1d87d |
- bits_to_skip = 0;
|
|
|
e1d87d |
- source_offset_bits = offset;
|
|
|
e1d87d |
|
|
|
e1d87d |
+ this_size_bits = p->size - bits_to_skip;
|
|
|
e1d87d |
if (this_size_bits > max_offset - offset)
|
|
|
e1d87d |
this_size_bits = max_offset - offset;
|
|
|
e1d87d |
|
|
|
e1d87d |
@@ -1992,22 +1975,22 @@ write_pieced_value (struct value *to, struct value *from)
|
|
|
e1d87d |
&& p->offset + p->size < reg_bits)
|
|
|
e1d87d |
{
|
|
|
e1d87d |
/* Big-endian, and we want less than full size. */
|
|
|
e1d87d |
- dest_offset_bits += reg_bits - (p->offset + p->size);
|
|
|
e1d87d |
+ bits_to_skip += reg_bits - (p->offset + p->size);
|
|
|
e1d87d |
}
|
|
|
e1d87d |
else
|
|
|
e1d87d |
- dest_offset_bits += p->offset;
|
|
|
e1d87d |
+ bits_to_skip += p->offset;
|
|
|
e1d87d |
|
|
|
e1d87d |
- this_size = bits_to_bytes (dest_offset_bits, this_size_bits);
|
|
|
e1d87d |
+ this_size = bits_to_bytes (bits_to_skip, this_size_bits);
|
|
|
e1d87d |
buffer.reserve (this_size);
|
|
|
e1d87d |
|
|
|
e1d87d |
- if (dest_offset_bits % 8 != 0 || this_size_bits % 8 != 0)
|
|
|
e1d87d |
+ if (bits_to_skip % 8 != 0 || this_size_bits % 8 != 0)
|
|
|
e1d87d |
{
|
|
|
e1d87d |
/* Data is copied non-byte-aligned into the register.
|
|
|
e1d87d |
Need some bits from original register value. */
|
|
|
e1d87d |
int optim, unavail;
|
|
|
e1d87d |
|
|
|
e1d87d |
if (!get_frame_register_bytes (frame, gdb_regnum,
|
|
|
e1d87d |
- dest_offset_bits / 8,
|
|
|
e1d87d |
+ bits_to_skip / 8,
|
|
|
e1d87d |
this_size, buffer.data (),
|
|
|
e1d87d |
&optim, &unavail))
|
|
|
e1d87d |
{
|
|
|
e1d87d |
@@ -2024,34 +2007,34 @@ write_pieced_value (struct value *to, struct value *from)
|
|
|
e1d87d |
}
|
|
|
e1d87d |
}
|
|
|
e1d87d |
|
|
|
e1d87d |
- copy_bitwise (buffer.data (), dest_offset_bits % 8,
|
|
|
e1d87d |
- contents, source_offset_bits,
|
|
|
e1d87d |
+ copy_bitwise (buffer.data (), bits_to_skip % 8,
|
|
|
e1d87d |
+ contents, offset,
|
|
|
e1d87d |
this_size_bits, bits_big_endian);
|
|
|
e1d87d |
put_frame_register_bytes (frame, gdb_regnum,
|
|
|
e1d87d |
- dest_offset_bits / 8,
|
|
|
e1d87d |
+ bits_to_skip / 8,
|
|
|
e1d87d |
this_size, buffer.data ());
|
|
|
e1d87d |
}
|
|
|
e1d87d |
break;
|
|
|
e1d87d |
case DWARF_VALUE_MEMORY:
|
|
|
e1d87d |
{
|
|
|
e1d87d |
- dest_offset_bits += p->offset;
|
|
|
e1d87d |
+ bits_to_skip += p->offset;
|
|
|
e1d87d |
|
|
|
e1d87d |
- CORE_ADDR start_addr = p->v.mem.addr + dest_offset_bits / 8;
|
|
|
e1d87d |
+ CORE_ADDR start_addr = p->v.mem.addr + bits_to_skip / 8;
|
|
|
e1d87d |
|
|
|
e1d87d |
- if (dest_offset_bits % 8 == 0 && this_size_bits % 8 == 0
|
|
|
e1d87d |
- && source_offset_bits % 8 == 0)
|
|
|
e1d87d |
+ if (bits_to_skip % 8 == 0 && this_size_bits % 8 == 0
|
|
|
e1d87d |
+ && offset % 8 == 0)
|
|
|
e1d87d |
{
|
|
|
e1d87d |
/* Everything is byte-aligned; no buffer needed. */
|
|
|
e1d87d |
write_memory (start_addr,
|
|
|
e1d87d |
- contents + source_offset_bits / 8,
|
|
|
e1d87d |
+ contents + offset / 8,
|
|
|
e1d87d |
this_size_bits / 8);
|
|
|
e1d87d |
break;
|
|
|
e1d87d |
}
|
|
|
e1d87d |
|
|
|
e1d87d |
- this_size = bits_to_bytes (dest_offset_bits, this_size_bits);
|
|
|
e1d87d |
+ this_size = bits_to_bytes (bits_to_skip, this_size_bits);
|
|
|
e1d87d |
buffer.reserve (this_size);
|
|
|
e1d87d |
|
|
|
e1d87d |
- if (dest_offset_bits % 8 != 0 || this_size_bits % 8 != 0)
|
|
|
e1d87d |
+ if (bits_to_skip % 8 != 0 || this_size_bits % 8 != 0)
|
|
|
e1d87d |
{
|
|
|
e1d87d |
if (this_size <= 8)
|
|
|
e1d87d |
{
|
|
|
e1d87d |
@@ -2068,8 +2051,8 @@ write_pieced_value (struct value *to, struct value *from)
|
|
|
e1d87d |
}
|
|
|
e1d87d |
}
|
|
|
e1d87d |
|
|
|
e1d87d |
- copy_bitwise (buffer.data (), dest_offset_bits % 8,
|
|
|
e1d87d |
- contents, source_offset_bits,
|
|
|
e1d87d |
+ copy_bitwise (buffer.data (), bits_to_skip % 8,
|
|
|
e1d87d |
+ contents, offset,
|
|
|
e1d87d |
this_size_bits, bits_big_endian);
|
|
|
e1d87d |
write_memory (start_addr, buffer.data (), this_size);
|
|
|
e1d87d |
}
|
|
|
e1d87d |
@@ -2079,6 +2062,7 @@ write_pieced_value (struct value *to, struct value *from)
|
|
|
e1d87d |
break;
|
|
|
e1d87d |
}
|
|
|
e1d87d |
offset += this_size_bits;
|
|
|
e1d87d |
+ bits_to_skip = 0;
|
|
|
e1d87d |
}
|
|
|
e1d87d |
}
|
|
|
e1d87d |
|