@@ -1868,22 +1868,19 @@ read_pieced_value (struct value *v)
case DWARF_VALUE_STACK:
{
- size_t n = this_size;
+ ULONGEST obj_size = 8 * TYPE_LENGTH (value_type (p->v.value));
- if (n > c->addr_size - source_offset)
- n = (c->addr_size >= source_offset
- ? c->addr_size - source_offset
- : 0);
- if (n == 0)
- {
- /* Nothing. */
- }
- else
- {
- const gdb_byte *val_bytes = value_contents_all (p->v.value);
+ /* Use zeroes if piece reaches beyond stack value. */
+ if (p->offset + p->size > obj_size)
+ goto skip_copy;
- intermediate_buffer = val_bytes + source_offset;
- }
+ /* Piece offset is from least significant bit end. */
+ if (bits_big_endian)
+ source_offset_bits += obj_size - (p->offset + p->size);
+ else
+ source_offset_bits += p->offset;
+ intermediate_buffer = value_contents_all (p->v.value);
+ intermediate_buffer += source_offset_bits / 8;
}
break;
@@ -1903,22 +1900,21 @@ read_pieced_value (struct value *v)
/* These bits show up as zeros -- but do not cause the value
to be considered optimized-out. */
case DWARF_VALUE_IMPLICIT_POINTER:
- break;
+ goto skip_copy;
case DWARF_VALUE_OPTIMIZED_OUT:
mark_value_bits_optimized_out (v, offset, this_size_bits);
- break;
+ goto skip_copy;
default:
internal_error (__FILE__, __LINE__, _("invalid location type"));
}
- if (p->location != DWARF_VALUE_OPTIMIZED_OUT
- && p->location != DWARF_VALUE_IMPLICIT_POINTER)
- copy_bitwise (contents, dest_offset_bits,
- intermediate_buffer, source_offset_bits % 8,
- this_size_bits, bits_big_endian);
+ copy_bitwise (contents, dest_offset_bits,
+ intermediate_buffer, source_offset_bits % 8,
+ this_size_bits, bits_big_endian);
+ skip_copy:
offset += this_size_bits;
}
}
@@ -128,14 +128,26 @@ Dwarf::assemble $asm_file {
{name def_t}
{type :$struct_t_label}
{location {
- const1u 0
+ const2s -184
stack_value
bit_piece 9 0
- const1s -1
+ const4u 1752286
stack_value
bit_piece 23 0
} SPECIAL_expr}
}
+ # Composite location with some empty pieces.
+ DW_TAG_variable {
+ {name part_def_a}
+ {type :$array_a9_label}
+ {location {
+ piece 3
+ const4u 0xf1927314
+ stack_value
+ piece 4
+ piece 2
+ } SPECIAL_expr}
+ }
# Implicit location: immediate value.
DW_TAG_variable {
{name def_implicit_s}
@@ -197,9 +209,12 @@ gdb_test "print/x *(char (*)\[5\]) implicit_a_ptr" \
# Byte-aligned fields, pieced together from DWARF stack values.
gdb_test "print def_s" " = \\{a = 0, b = -1\\}"
+switch $endian { big {set val 0x92} little {set val 0x73} }
+gdb_test "print/x part_def_a\[4\]" " = $val"
+gdb_test "print/x part_def_a\[8\]" " = <optimized out>"
# Non-byte-aligned fields, pieced together from DWARF stack values.
-gdb_test "print def_t" " = \\{a = 0, b = -1\\}"
+gdb_test "print def_t" " = \\{a = -184, b = 1752286\\}"
# Simple variable without location.
gdb_test "print undef_int" " = <optimized out>"