[Bug c++/80596] New: g++ generates incomplete DWARF debug information for array-typedefs
paul.kaletta at intel dot com
gcc-bugzilla@gcc.gnu.org
Tue May 2 14:29:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80596
Bug ID: 80596
Summary: g++ generates incomplete DWARF debug information for
array-typedefs
Product: gcc
Version: 6.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: paul.kaletta at intel dot com
Target Milestone: ---
The following observations apply to g++ 6.1.0 and earlier.
Consider the following program:
typedef int T_ACCESS_TECHNOLOGY;
typedef T_ACCESS_TECHNOLOGY T_AT;
typedef T_AT T_AT_ARRAY[5];
T_AT_ARRAY t_at_array;
When compiled with gcc 6.1.0 (gcc -g -c sample.c -o sample_gcc.o), the
generated DWARF looks as follows:
< 1><0x0000001d GOFF=0x0000001d> DW_TAG_typedef
DW_AT_name T_ACCESS_TECHNOLOGY
DW_AT_decl_file 0x00000001 /home/pkaletta/gcc_bug/sample.c
DW_AT_decl_line 0x00000001
DW_AT_type <0x00000028 GOFF=0x00000028>
< 1><0x00000028 GOFF=0x00000028> DW_TAG_base_type
DW_AT_byte_size 0x00000004
DW_AT_encoding DW_ATE_signed
DW_AT_name int
< 1><0x0000002f GOFF=0x0000002f> DW_TAG_typedef
DW_AT_name T_AT
DW_AT_decl_file 0x00000001 /home/pkaletta/gcc_bug/sample.c
DW_AT_decl_line 0x00000002
DW_AT_type <0x0000001d GOFF=0x0000001d>
< 1><0x0000003a GOFF=0x0000003a> DW_TAG_typedef
DW_AT_name T_AT_ARRAY
DW_AT_decl_file 0x00000001 /home/pkaletta/gcc_bug/sample.c
DW_AT_decl_line 0x00000003
DW_AT_type <0x00000045 GOFF=0x00000045>
< 1><0x00000045 GOFF=0x00000045> DW_TAG_array_type
DW_AT_type <0x0000002f GOFF=0x0000002f>
DW_AT_sibling <0x00000055 GOFF=0x00000055>
< 2><0x0000004e GOFF=0x0000004e> DW_TAG_subrange_type
DW_AT_type <0x00000055 GOFF=0x00000055>
DW_AT_upper_bound 4
< 1><0x00000055 GOFF=0x00000055> DW_TAG_base_type
DW_AT_byte_size 0x00000008
DW_AT_encoding DW_ATE_unsigned
DW_AT_name sizetype
< 1><0x0000005c GOFF=0x0000005c> DW_TAG_variable
DW_AT_name t_at_array
DW_AT_decl_file 0x00000001 /home/pkaletta/gcc_bug/sample.c
DW_AT_decl_line 0x00000004
DW_AT_type <0x0000003a GOFF=0x0000003a>
DW_AT_external yes(1)
DW_AT_location len 0x0009: 031000000000000000: DW_OP_addr
0x00000010
When compiled with g++ (g++ -g -c sample.c -o sample_g++.o):
< 1><0x0000001d GOFF=0x0000001d> DW_TAG_base_type
DW_AT_byte_size 0x00000004
DW_AT_encoding DW_ATE_signed
DW_AT_name int
< 1><0x00000024 GOFF=0x00000024> DW_TAG_typedef
DW_AT_name T_AT_ARRAY
DW_AT_decl_file 0x00000001 /home/pkaletta/gcc_bug/sample.c
DW_AT_decl_line 0x00000003
< 1><0x0000002b GOFF=0x0000002b> DW_TAG_base_type
DW_AT_byte_size 0x00000008
DW_AT_encoding DW_ATE_unsigned
DW_AT_name sizetype
< 1><0x00000032 GOFF=0x00000032> DW_TAG_variable
DW_AT_name t_at_array
DW_AT_decl_file 0x00000001 /home/pkaletta/gcc_bug/sample.c
DW_AT_decl_line 0x00000004
DW_AT_type <0x00000024 GOFF=0x00000024>
DW_AT_external yes(1)
DW_AT_location len 0x0009: 030000000000000000: DW_OP_addr
0x00000000
The debug info for C++ contains no trace of T_AT or
T_ACCESS_TECHNOLOGY. The typedef DIE generated for T_AT_ARRAY looks
bogus (typedef to void?). For earlier versions of g++ T_AT_ARRAY at
least shows up as an array of 5 ints, but that does not seem right
either.
In my opinion g++ (for C++) should behave just like gcc (for C) does,
and emit the entire chain of typedefs.
In my specific scenario, I would like to run some scripts on all
instances of T_ACCESS_TECHNOLOGY which is only possible if the type
information is preserved in the debug info.
Currently I can do this for C programs, but not for C++ programs.
-fno-eliminate-unused-debug-types doesn't help, as g++ will emit the
extra types, but fails to interconnect them.
More information about the Gcc-bugs
mailing list