This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA/DWARF] Set TYPE_FLAG_STUB for enum DIEs that are declarations only

Long explaination but small patch :-).

For those who are not familiar with Ada, the declaration of types
whose implementation must be opaque is done as follow:

        type My_Opaque type is private;

And then the language expects that you provide the definition
of that type in the private section of your package spec, like so:

           type My_Opaque is (One, Two, Three);

But there has been a small amendment to that which allows a developer
to provide the actual definition not in the spec, but in the body.
This is an approach that is not used very often, but still legitimate.
These types are called "Taft Amendment Types" (TAT) because they were
introduced by Tucker Taft, I believe.

Unfortunately, we found out that this can cause trouble in the debugger.
When compiling a unit that uses a TAT, the compiler does not look
inside the package body, but only in the package spec. So it knows that
we have an object of that type, but it doesn't know what that type is.
As a result, it generates a bogus "stub" enumeration type and sets
its AT_declaration attribute. The debugger missed that part, and so
we ended up thinking that our object was a degenerated enum type,
and printed its value accordingly:

        (gdb) p w.e.all
        $1 = 0

The expected output is:

        (gdb) p w.e.all
        $1 = (month => 8, year => 1974)

The fix is to flag the type as a TYPE_FLAG_STUB, so that we will
know to lookup the complete definition.

2008-01-03  Joel Brobecker  <>

        * dwarf2read.c (read_enumeration_type): Flag type as stub if
        the given die is a declaration.

I also wrote a small testcase that reproduces the issue:

2008-01-03  Joel Brobecker  <>

        * gdb.ada/taft_type/, gdb.ada/taft_type/pck.adb,
        gdb.ada/taft_type/p.adb: New files.
        * gdb.ada/taft_type.exp: New testcase.

Tested on x86-linux. No regression.
OK to apply?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]