diff options
author | Tom Tromey <tromey@adacore.com> | 2019-04-09 07:46:39 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2019-04-19 13:23:05 -0600 |
commit | 8ecb59f8567956c1520b491ea31396363efcb1ef (patch) | |
tree | f0e0de7b531df940914dadf2d8a9df74fd079498 /gdb/gdbtypes.h | |
parent | 62160ec9547cdd21ac7334d9a378ca2930aac61c (diff) | |
download | gdb-8ecb59f8567956c1520b491ea31396363efcb1ef.zip gdb-8ecb59f8567956c1520b491ea31396363efcb1ef.tar.gz gdb-8ecb59f8567956c1520b491ea31396363efcb1ef.tar.bz2 |
Print non-Ada unions without crashing
ada-lang.c is a bit too eager trying to decode unions in the Ada style
-- looking for discriminants and such. This causes crashes when
printing a non-Ada union in Ada mode, something that can easily happen
when printing a value from history or certain registers on AArch64.
This patch fixes the bug by changing ada-lang.c to only apply special
Ada treatment to types coming from an Ada CU. This in turn required a
couple of surprising changes.
First, some of the Ada code was already using HAVE_GNAT_AUX_INFO to
decide whether a type had already been fixed -- such types had
INIT_CPLUS_SPECIFIC called on them. This patch changes these spots to
use the "none" identifier instead.
This then required changing value_rtti_type to avoid changing the
language-specific object attached to an Ada type, which seems like a
good change regardless.
Tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-04-19 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_is_variant_part, ada_to_fixed_type_1):
Check ADA_TYPE_P.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part): Use INIT_NONE_SPECIFIC.
* cp-abi.c (value_rtti_type): Check HAVE_CPLUS_STRUCT.
* gdbtypes.h (INIT_NONE_SPECIFIC, ADA_TYPE_P): New
macros.
gdb/testsuite/ChangeLog
2019-04-19 Tom Tromey <tromey@adacore.com>
* gdb.ada/ptype_union.c: New file.
* gdb.ada/ptype_union.exp: New file.
Diffstat (limited to 'gdb/gdbtypes.h')
-rw-r--r-- | gdb/gdbtypes.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 2125ed9..a5f6afc 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1255,6 +1255,10 @@ extern void allocate_cplus_struct_type (struct type *); (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_CPLUS_STUFF \ && TYPE_RAW_CPLUS_SPECIFIC (type) != &cplus_struct_default) +#define INIT_NONE_SPECIFIC(type) \ + (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_NONE, \ + TYPE_MAIN_TYPE (type)->type_specific = {}) + extern const struct gnat_aux_type gnat_aux_default; extern void allocate_gnat_aux_type (struct type *); @@ -1268,6 +1272,12 @@ extern void allocate_gnat_aux_type (struct type *); #define HAVE_GNAT_AUX_INFO(type) \ (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF) +/* * True if TYPE is known to be an Ada type of some kind. */ +#define ADA_TYPE_P(type) \ + (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF \ + || (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE \ + && TYPE_FIXED_INSTANCE (type))) + #define INIT_FUNC_SPECIFIC(type) \ (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC, \ TYPE_MAIN_TYPE (type)->type_specific.func_stuff = (struct func_type *) \ |