diff options
author | Tom Tromey <tromey@redhat.com> | 2014-05-08 11:26:44 -0600 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2014-06-04 14:28:22 -0600 |
commit | 012370f6818657a816df1463ee71ca4e4ee40b33 (patch) | |
tree | 86113cdbeeca68560686b21b4c8af168d473dc3f /gdb/ada-lang.c | |
parent | 92e2a17f9b145d35b4a9a2273612d323ccdc9cac (diff) | |
download | gdb-012370f6818657a816df1463ee71ca4e4ee40b33.zip gdb-012370f6818657a816df1463ee71ca4e4ee40b33.tar.gz gdb-012370f6818657a816df1463ee71ca4e4ee40b33.tar.bz2 |
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.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 38972c6..c12fbb8 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -7385,7 +7385,11 @@ ada_which_variant_applies (struct type *var_type, struct type *outer_type, struct value *discrim; LONGEST discrim_val; - outer = value_from_contents_and_address (outer_type, outer_valaddr, 0); + /* Using plain value_from_contents_and_address here causes problems + because we will end up trying to resolve a type that is currently + being constructed. */ + outer = value_from_contents_and_address_unresolved (outer_type, + outer_valaddr, 0); discrim = ada_value_struct_elt (outer, discrim_name, 1); if (discrim == NULL) return -1; @@ -7925,7 +7929,13 @@ ada_template_to_fixed_record_type_1 (struct type *type, GDB may fail to allocate a value for it. So check the size first before creating the value. */ check_size (rtype); - dval = value_from_contents_and_address (rtype, valaddr, address); + /* Using plain value_from_contents_and_address here + causes problems because we will end up trying to + resolve a type that is currently being + constructed. */ + dval = value_from_contents_and_address_unresolved (rtype, + valaddr, + address); rtype = value_type (dval); } else @@ -8030,7 +8040,11 @@ ada_template_to_fixed_record_type_1 (struct type *type, if (dval0 == NULL) { - dval = value_from_contents_and_address (rtype, valaddr, address); + /* Using plain value_from_contents_and_address here causes + problems because we will end up trying to resolve a type + that is currently being constructed. */ + dval = value_from_contents_and_address_unresolved (rtype, valaddr, + address); rtype = value_type (dval); } else |