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

            Bug ID: 94887
           Summary: -fdebug-types-section drops DW_TAG_formal_parameter
                    and DW_TAG_template_type_param
           Product: gcc
           Version: 10.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: ---

Consider this test-case, minimized from gdb testsuite test-case py-methods.cc:
...
$ cat py-xmethods.cc
template <typename T>
class G
{
public:
  template <typename T1>
  T mul(const T1 t1) { return t1 * 5; }
};

int
main(void)
{
  G<int> g;
  return g.mul (1.0);
}
...

Without -fdebug-types-section, we have:
...
$ g++ py-xmethods.cc -g
$ gdb -batch a.out -ex start  -ex "ptype g"  
Temporary breakpoint 1 at 0x4004cf: file py-xmethods.cc, line 13.

Temporary breakpoint 1, main () at py-xmethods.cc:13
13        return g.mul (1.0);
type = class G<int> [with T = int] {
  public:
    T mul<double>(double);
}
...

But with -fdebug-types-section, we have:
...
$ g++ py-xmethods.cc -g -fdebug-types-section
$ gdb -batch a.out -ex start  -ex "ptype g"
Temporary breakpoint 1 at 0x4004cf: file py-xmethods.cc, line 13.

Temporary breakpoint 1, main () at py-xmethods.cc:13
13        return g.mul (1.0);
type = class G<int> [with T = int] {
    <no data fields>
}
...

Or with the tentative gdb patch from here (
https://sourceware.org/bugzilla/show_bug.cgi?id=25898#c3 ), we have:
...
$ gdb -batch a.out -ex start  -ex "ptype g"
Temporary breakpoint 1 at 0x4004cf: file py-xmethods.cc, line 13.

Temporary breakpoint 1, main () at py-xmethods.cc:13
13        return g.mul (1.0);
type = class G<int> [with T = int] {
  public:
    T mul<double>(void);
}
...
Note the 'void' instead of 'double'.

Without -fdebug-types-section, we have:
...
 <1><f0>: Abbrev Number: 2 (DW_TAG_class_type)
    <f1>   DW_AT_name        : (indirect string, offset: 0x225): G<int>
    <f5>   DW_AT_byte_size   : 1
    <f6>   DW_AT_decl_file   : 1
    <f7>   DW_AT_decl_line   : 2
    <f8>   DW_AT_sibling     : <0x12f>
 <2><fc>: Abbrev Number: 3 (DW_TAG_subprogram)
    <fd>   DW_AT_external    : 1
    <fd>   DW_AT_name        : mul<double>
    <101>   DW_AT_decl_file   : 1
    <102>   DW_AT_decl_line   : 6
    <103>   DW_AT_linkage_name: _ZN1GIiE3mulIdEEiT_
    <107>   DW_AT_type        : <0x12f>
    <10b>   DW_AT_accessibility: 1      (public)
    <10c>   DW_AT_declaration : 1
    <10c>   DW_AT_object_pointer: <0x11c>
    <110>   DW_AT_sibling     : <0x127>
 <3><114>: Abbrev Number: 4 (DW_TAG_template_type_param)
    <115>   DW_AT_name        : T1
    <118>   DW_AT_type        : <0x136>
 <3><11c>: Abbrev Number: 5 (DW_TAG_formal_parameter)
    <11d>   DW_AT_type        : <0x142>
    <121>   DW_AT_artificial  : 1
 <3><121>: Abbrev Number: 6 (DW_TAG_formal_parameter)
    <122>   DW_AT_type        : <0x136>
 <1><14d>: Abbrev Number: 11 (DW_TAG_subprogram)
    <14e>   DW_AT_specification: <0xfc>
    <152>   DW_AT_object_pointer: <0x178>
    <156>   DW_AT_low_pc      : 0x4004ee
    <15e>   DW_AT_high_pc     : 0x24
    <166>   DW_AT_frame_base  : 1 byte block: 9c        (DW_OP_call_frame_cfa)
    <168>   DW_AT_object_pointer: <0x178>
    <16c>   DW_AT_GNU_all_call_sites: 1
    <16c>   DW_AT_sibling     : <0x192>
 <2><170>: Abbrev Number: 4 (DW_TAG_template_type_param)
    <171>   DW_AT_name        : T1
    <174>   DW_AT_type        : <0x136>
 <2><178>: Abbrev Number: 12 (DW_TAG_formal_parameter)
    <179>   DW_AT_name        : this
    <17d>   DW_AT_type        : <0x148>
    <181>   DW_AT_artificial  : 1
    <181>   DW_AT_location    : 2 byte block: 91 68     (DW_OP_fbreg: -24)
 <2><184>: Abbrev Number: 13 (DW_TAG_formal_parameter)
    <185>   DW_AT_name        : t1
    <188>   DW_AT_decl_file   : 1
    <189>   DW_AT_decl_line   : 6
    <18a>   DW_AT_type        : <0x13d>
    <18e>   DW_AT_location    : 2 byte block: 91 60     (DW_OP_fbreg: -32)
...

But with -fdebug-types-section, we have:
...
 <1><10e>: Abbrev Number: 9 (DW_TAG_subprogram)
    <10f>   DW_AT_specification: <0x18e>
    <113>   DW_AT_object_pointer: <0x139>
    <117>   DW_AT_low_pc      : 0x4004ee
    <11f>   DW_AT_high_pc     : 0x24
    <127>   DW_AT_frame_base  : 1 byte block: 9c        (DW_OP_call_frame_cfa)
    <129>   DW_AT_object_pointer: <0x139>
    <12d>   DW_AT_GNU_all_call_sites: 1
    <12d>   DW_AT_sibling     : <0x153>
 <2><131>: Abbrev Number: 3 (DW_TAG_template_type_param)
    <132>   DW_AT_name        : T1
    <135>   DW_AT_type        : <0xf7>
 <2><139>: Abbrev Number: 10 (DW_TAG_formal_parameter)
    <13a>   DW_AT_name        : this
    <13e>   DW_AT_type        : <0x109>
    <142>   DW_AT_artificial  : 1
    <142>   DW_AT_location    : 2 byte block: 91 68     (DW_OP_fbreg: -24)
 <2><145>: Abbrev Number: 11 (DW_TAG_formal_parameter)
    <146>   DW_AT_name        : t1
    <149>   DW_AT_decl_file   : 1
    <14a>   DW_AT_decl_line   : 6
    <14b>   DW_AT_type        : <0xfe>
    <14f>   DW_AT_location    : 2 byte block: 91 60     (DW_OP_fbreg: -32)
 <1><181>: Abbrev Number: 14 (DW_TAG_class_type)
    <182>   DW_AT_name        : (indirect string, offset: 0x202): G<int>
    <186>   DW_AT_signature   : signature: 0x239eaf153e8777a
    <18e>   DW_AT_declaration : 1
 <2><18e>: Abbrev Number: 15 (DW_TAG_subprogram)
    <18f>   DW_AT_external    : 1
    <18f>   DW_AT_name        : mul<double>
    <193>   DW_AT_decl_file   : 1
    <194>   DW_AT_decl_line   : 6
    <195>   DW_AT_linkage_name: _ZN1GIiE3mulIdEEiT_
    <199>   DW_AT_type        : <0xf0>
    <19d>   DW_AT_accessibility: 1      (public)
    <19e>   DW_AT_declaration : 1
    <19e>   DW_AT_object_pointer: <0x1a2>
 <3><1a2>: Abbrev Number: 16 (DW_TAG_formal_parameter)
    <1a3>   DW_AT_type        : <0x103>
    <1a7>   DW_AT_artificial  : 1
...

So, the DIE at 0x18e is missing the DW_TAG_template_type_param and the
DW_TAG_formal_parameter for the double arg.

Reply via email to