[Bug debug/90232] New: gcc drops top-level dies with -fdebug-types-section

vries at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Apr 24 15:24:00 GMT 2019


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

            Bug ID: 90232
           Summary: gcc drops top-level dies with -fdebug-types-section
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

[ Spinoff bug from gdb PR
https://sourceware.org/bugzilla/show_bug.cgi?id=14148#c3 ]

Consider two-file test-case 36:
...
$ cat 36.c
struct s { int i; };
extern void f (void);
int main (void) {
  struct s a;
  f ();
  return 0;
}
$ cat 36b.c
struct s { int j; };
void f (void) {
  struct s b;
}
...

Compiled like this:
...
$ gcc -fdebug-types-section -o 36 36.c 36b.c -Wall -g
...

Without -fdebug-types-section, for 36.c we have the struct type s as top-level
die, and as type of main variable a:
...
 <0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <d8>   DW_AT_name        : (indirect string, offset: 0x1f8): 36.c
 <1><f4>: Abbrev Number: 2 (DW_TAG_structure_type)
    <f5>   DW_AT_name        : s
 <1><112>: Abbrev Number: 5 (DW_TAG_subprogram)
    <113>   DW_AT_name        : (indirect string, offset: 0x1fd): main
 <2><130>: Abbrev Number: 6 (DW_TAG_variable)
    <131>   DW_AT_name        : a
    <136>   DW_AT_type        : <0xf4>
...
with the same pattern for 36b.c:
...
 <0><14a>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <150>   DW_AT_name        : (indirect string, offset: 0x261): 36b.c
 <1><16c>: Abbrev Number: 2 (DW_TAG_structure_type)
    <16d>   DW_AT_name        : s
 <1><18a>: Abbrev Number: 5 (DW_TAG_subprogram)
    <18b>   DW_AT_name        : f
 <2><1a2>: Abbrev Number: 6 (DW_TAG_variable)
    <1a3>   DW_AT_name        : b
    <1a8>   DW_AT_type        : <0x16c>
...

With -fdebug-types-section, we have struct s in .debug_types with only a
reference from the variable for 36.c:
...
 <1><fb>: Abbrev Number: 6 (DW_TAG_subprogram)
    <fc>   DW_AT_name        : (indirect string, offset: 0x272): main
 <2><119>: Abbrev Number: 7 (DW_TAG_variable)
    <11a>   DW_AT_name        : a
    <11f>   DW_AT_type        : signature: 0xfd1462823bb6f7b7
Contents of the .debug_types section:
   Signature:     0xfd1462823bb6f7b7
 <1><1d>: Abbrev Number: 2 (DW_TAG_structure_type)
    <1e>   DW_AT_name        : s
...
and the same for 36b.c:
...
 <1><160>: Abbrev Number: 6 (DW_TAG_subprogram)
    <161>   DW_AT_name        : f
 <2><178>: Abbrev Number: 7 (DW_TAG_variable)
    <179>   DW_AT_name        : b
    <17e>   DW_AT_type        : signature: 0x534310fbefba324d
Contents of the .debug_types section:
   Signature:     0x534310fbefba324d
 <1><59>: Abbrev Number: 2 (DW_TAG_structure_type)
    <5a>   DW_AT_name        : s
...

So, AFAICT gcc drops the top-level struct s dies.


More information about the Gcc-bugs mailing list