From 8ecb59f8567956c1520b491ea31396363efcb1ef Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 9 Apr 2019 07:46:39 -0600 Subject: 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 * 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 * gdb.ada/ptype_union.c: New file. * gdb.ada/ptype_union.exp: New file. --- gdb/cp-abi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gdb/cp-abi.c') diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c index d95b140..bbb74d4 100644 --- a/gdb/cp-abi.c +++ b/gdb/cp-abi.c @@ -109,7 +109,8 @@ value_rtti_type (struct value *v, int *full, { struct type *ret = NULL; - if ((current_cp_abi.rtti_type) == NULL) + if ((current_cp_abi.rtti_type) == NULL + || !HAVE_CPLUS_STRUCT (check_typedef (value_type (v)))) return NULL; try { -- cgit v1.1