]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix handling of DW_TAG_unspecified_type for Ada
authorTom Tromey <tromey@adacore.com>
Tue, 13 Jun 2023 15:36:35 +0000 (09:36 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 28 Jun 2023 15:49:22 +0000 (09:49 -0600)
Commit 80eaec735e ("[gdb/symtab] Handle named DW_TAG_unspecified_type
DIE") changed the handling of DW_TAG_unspecified_type.  Before this
change, such types were not entered into the symbol table.

It turns out that, when such a type is in the symtab, it can cause
failures in Ada.  In particular, a private type in another package may
be seen locally as "void".

Now, it would probably be better to fix this via check_typedef.
However, that is somewhat difficult given the state of the DWARF
reader -- in particular with gdb_index, this would require expanding
potentially many CUs to find the correct type.

Instead, this patch changes gdb to not enter a symbol for an
unspecified type -- but only for Ada.

gdb/dwarf2/read.c
gdb/testsuite/gdb.ada/py_taft.exp

index a9c2a7d59d545e349b234ead03135747024277b4..3508f2c29ee0db79c2d5f4aef142fe4a4b97ef4b 100644 (file)
@@ -19316,11 +19316,14 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
          sym->set_domain (VAR_DOMAIN);
          list_to_add = cu->list_in_scope;
          break;
+       case DW_TAG_unspecified_type:
+         if (cu->lang () == language_ada)
+           break;
+         /* FALLTHROUGH */
        case DW_TAG_array_type:
        case DW_TAG_base_type:
        case DW_TAG_subrange_type:
        case DW_TAG_generic_subrange:
-       case DW_TAG_unspecified_type:
          sym->set_aclass_index (LOC_TYPEDEF);
          sym->set_domain (VAR_DOMAIN);
          list_to_add = cu->list_in_scope;
index 0ce9df72005797779a3b83a8cccc463500fbc50f..1990e7e89ceb9835a9392d02b7b4703a41cdf457 100644 (file)
@@ -35,3 +35,8 @@ gdb_test "python print(v.dereference().type.code is gdb.TYPE_CODE_VOID)" \
     "False"
 gdb_test "python print(v.type.strip_typedefs().target().code is gdb.TYPE_CODE_VOID)" \
     "False"
+
+# This was a convenient spot to put a regression test.  GNAT will
+# create a DW_TAG_unspecified_type in the main.adb CU, and if gdb
+# isn't careful, this will result in this 'whatis' yielding 'void'.
+gdb_test "whatis pkg.value_record" "type = pkg.value_record"