diff options
author | Joel Brobecker <brobecker@adacore.com> | 2018-01-01 22:41:36 -0500 |
---|---|---|
committer | Joel Brobecker <brobecker@adacore.com> | 2018-01-01 22:41:36 -0500 |
commit | 74a2f8ffb83172de1af0da6751a65c08a722986f (patch) | |
tree | 7b5ada42366da6c6b022ca3f13be3e5df3c8c97d | |
parent | e2882c85786571175a0b0bfc3bcd2f14620b1ea3 (diff) | |
download | binutils-74a2f8ffb83172de1af0da6751a65c08a722986f.zip binutils-74a2f8ffb83172de1af0da6751a65c08a722986f.tar.gz binutils-74a2f8ffb83172de1af0da6751a65c08a722986f.tar.bz2 |
treat Ada DW_TAG_unspecified_type DIEs as stub types
Consider the gdb.ada/taft_type.exp testcase, which exercises
the situation where a variable is defined using a type which
is a pointer to an incomplete type, with the actual type
definition being provided by another unit. Up to now, the
strategy used by GNAT when generating the DWARF debugging info
was to produce a incomplete DW_TAG_enumeration_type DIE with
a DW_AT_declaration flag attached to it:
.uleb128 0x4 # (DIE (0x3e) DW_TAG_enumeration_type)
.long .LASF4 # DW_AT_name: "pck__empty"
# DW_AT_declaration
However, a more standard way for the compiler to describe
this kind of type is to use the DW_TAG_unspecified_type tag.
When the compiler is enhanced to do so, we'll need to treat
such types as stubs -- we only do so with types from Ada units,
however, as the meaning of this TAG is intentionally left
permissive and language-specific by the DWARF standard.
Without this patch, running the testcase above with an enhanced
compiler now yields:
(gdb) print w.e.all
Attempt to dereference a generic pointer.
FAIL: gdb.ada/taft_type.exp: print w.e.all
gdb/ChangeLog:
* dwarf2read.c (read_unspecified_type): Treat
DW_TAG_enumeration_type DIEs from Ada units as stubs.
Tested on x86_64-linux, fixes the FAIL in gdb.ada/taft_type.exp above.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9eaa15f..3199eaa 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-01-02 Joel Brobecker <brobecker@adacore.com> + + * dwarf2read.c (read_unspecified_type): Treat + DW_TAG_enumeration_type DIEs from Ada units as stubs. + 2018-01-01 Joel Brobecker <brobecker@adacore.com> Update copyright year range in all GDB files. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index b4f5cd1..4dbd5c3 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -17693,11 +17693,16 @@ read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu) { struct type *type; - /* For now, we only support the C meaning of an unspecified type: void. */ - type = init_type (cu->objfile, TYPE_CODE_VOID, 0, NULL); TYPE_NAME (type) = dwarf2_name (die, cu); + /* In Ada, an unspecified type is typically used when the description + of the type is defered to a different unit. When encountering + such a type, we treat it as a stub, and try to resolve it later on, + when needed. */ + if (cu->language == language_ada) + TYPE_STUB (type) = 1; + return set_die_type (die, type, cu); } |