forked from Imagelibrary/binutils-gdb
handle VLA in a struct or union
It is valid in GNU C to have a VLA in a struct or union type, but gdb did not handle this. This patch adds support for these cases in the obvious way. Built and regtested on x86-64 Fedora 20. New tests included. 2014-06-04 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_template_to_fixed_record_type_1): Use value_from_contents_and_address_unresolved. (ada_template_to_fixed_record_type_1): Likewise. (ada_which_variant_applies): Likewise. * value.h (value_from_contents_and_address_unresolved): Declare. * value.c (value_from_contents_and_address_unresolved): New function. * gdbtypes.c (is_dynamic_type, resolve_dynamic_type) <TYPE_CODE_STRUCT, TYPE_CODE_UNION>: New cases. (resolve_dynamic_struct, resolve_dynamic_union): New functions. 2014-06-04 Tom Tromey <tromey@redhat.com> * gdb.base/vla-datatypes.exp: Add tests for VLA-in-structure and VLA-in-union. * gdb.base/vla-datatypes.c (vla_factory): Add vla_struct, inner_vla_struct, vla_union types. Initialize objects of those types and compute their sizes.
This commit is contained in:
23
gdb/value.c
23
gdb/value.c
@@ -3376,6 +3376,29 @@ value_from_pointer (struct type *type, CORE_ADDR addr)
|
||||
}
|
||||
|
||||
|
||||
/* Create a value of type TYPE whose contents come from VALADDR, if it
|
||||
is non-null, and whose memory address (in the inferior) is
|
||||
ADDRESS. The type of the created value may differ from the passed
|
||||
type TYPE. Make sure to retrieve values new type after this call.
|
||||
Note that TYPE is not passed through resolve_dynamic_type; this is
|
||||
a special API intended for use only by Ada. */
|
||||
|
||||
struct value *
|
||||
value_from_contents_and_address_unresolved (struct type *type,
|
||||
const gdb_byte *valaddr,
|
||||
CORE_ADDR address)
|
||||
{
|
||||
struct value *v;
|
||||
|
||||
if (valaddr == NULL)
|
||||
v = allocate_value_lazy (type);
|
||||
else
|
||||
v = value_from_contents (type, valaddr);
|
||||
set_value_address (v, address);
|
||||
VALUE_LVAL (v) = lval_memory;
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Create a value of type TYPE whose contents come from VALADDR, if it
|
||||
is non-null, and whose memory address (in the inferior) is
|
||||
ADDRESS. The type of the created value may differ from the passed
|
||||
|
||||
Reference in New Issue
Block a user