forked from Imagelibrary/binutils-gdb
Fix bug in dynamic type resolution
A customer-reported problem led us to a bug in dynamic type resolution. resolve_dynamic_struct will recursively call resolve_dynamic_type_internal, passing it the sub-object for the particular field being resolved. While it offsets the address here, it does not also offset the "valaddr" -- the array of bytes describing the memory. This patch fixes the bug, by offsetting both. A test case is included that can be used to reproduce the bug.
This commit is contained in:
@@ -2615,10 +2615,11 @@ resolve_dynamic_struct (struct type *type,
|
||||
" (invalid location kind)"));
|
||||
|
||||
pinfo.type = check_typedef (resolved_type->field (i).type ());
|
||||
size_t offset = TYPE_FIELD_BITPOS (resolved_type, i) / TARGET_CHAR_BIT;
|
||||
pinfo.valaddr = addr_stack->valaddr;
|
||||
pinfo.addr
|
||||
= (addr_stack->addr
|
||||
+ (TYPE_FIELD_BITPOS (resolved_type, i) / TARGET_CHAR_BIT));
|
||||
if (!pinfo.valaddr.empty ())
|
||||
pinfo.valaddr = pinfo.valaddr.slice (offset);
|
||||
pinfo.addr = addr_stack->addr + offset;
|
||||
pinfo.next = addr_stack;
|
||||
|
||||
resolved_type->field (i).set_type
|
||||
|
||||
Reference in New Issue
Block a user