This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug debug/81267] New: Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267

            Bug ID: 81267
           Summary: Missing DW_AT_type in DW_TAG_typedef of "typedef of
                    typedef of void"
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: palves at redhat dot com
  Target Milestone: ---

I'm writing a GDB testcase that exercises the "whatis" command.  If passed a
type name, that command strips one, and only one, level of typedef from the
type.  The test exposed missing target type info in the case of "typedef of
typedef of void".

I.e., with:

~~~
typedef void void_typedef1;
typedef void_typedef1 void_typedef2;

void_typedef1 *void_typedef1_ptr; // just to be sure the types are emitted.
void_typedef2 *void_typedef2_ptr; // ditto.
~~~

We get:

 <1><21>: Abbrev Number: 2 (DW_TAG_typedef)
    <22>   DW_AT_name        : (indirect string, offset: 0x1bf): void_typedef1
    <26>   DW_AT_decl_file   : 1
    <27>   DW_AT_decl_line   : 1
 <1><28>: Abbrev Number: 2 (DW_TAG_typedef)
    <29>   DW_AT_name        : (indirect string, offset: 0x1cd): void_typedef2
    <2d>   DW_AT_decl_file   : 1
    <2e>   DW_AT_decl_line   : 2

Notice that "void_typedef2" has no DW_AT_type pointing to "void_typedef1".
Seeing this, GDB assumes that "void_typedef2" is a direct typedef to "void":

 (gdb) whatis void_typedef1
 type = void
 (gdb) whatis void_typedef2
 type = void

The correct output in the second case above would have been:

 (gdb) whatis void_typedef2
 type = void_typedef1

... which is what I get if I compile the testcase with clang instead of gcc.  

clang (3.7) outputs:

 <1><44>: Abbrev Number: 4 (DW_TAG_typedef)
    <45>   DW_AT_name        : (indirect string, offset: 0x5e): void_typedef1
    <49>   DW_AT_decl_file   : 1
    <4a>   DW_AT_decl_line   : 1
...
 <1><65>: Abbrev Number: 5 (DW_TAG_typedef)
    <66>   DW_AT_type        : <0x44>
    <6a>   DW_AT_name        : (indirect string, offset: 0x7e): void_typedef2
    <6e>   DW_AT_decl_file   : 1
    <6f>   DW_AT_decl_line   : 2

I.e., it only "optimizes out" DW_AT_type when the typedef is a direct typedef
to void.

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