Input ===== ``` template<typename... T> void f(T&&...zzargs) {} int main() { f(0); } ``` g++-11 -Wall -ggdb3 x.cpp Observed output =============== ยป gdb a.out GNU gdb (GDB; openSUSE Tumbleweed) 11.1 ... (gdb) b main (gdb) r ... Breakpoint 1, main () at x.cpp:2 2 int main() { f(0); } Missing separate debuginfos, use: zypper install libgcc_s1-debuginfo-11.2.1+git1173-2.3.x86_64 libstdc++6-debuginfo-11.2.1+git1173-2.3.x86_64 (gdb) s f<int> () at x.cpp:1 1 template<typename... T> void f(T&&...zzargs) {} (gdb) info args No arguments. (gdb) p zzargs No symbol "zzargs" in current context. Expected output =============== (gdb) info args zzargs = {0} (gdb) p zzargs $1 = {0} or something of the sort.
Note that gcc currently doesn't write the name of the parameter pack in the debug information: <2><95>: Abbrev Number: 5 (DW_TAG_GNU_formal_parameter_pack) <96> DW_AT_decl_file : 1 <97> DW_AT_decl_line : 1 <98> DW_AT_decl_column : 35 <3><99>: Abbrev Number: 6 (DW_TAG_formal_parameter) <9a> DW_AT_type : <0xaa> <9e> DW_AT_location : 2 byte block: 91 0 (DW_OP_fbreg: 0) <3><a1>: Abbrev Number: 0 Apparently this has been reported already some time ago: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70536 So even if gdb would make use of DW_TAG_GNU_formal_parameter_pack, it couldn't show it as `zzargs` in the example.
+1 to this from a Clang developer. Clang does name the template parameter pack. ``` 0x0000039a: DW_TAG_structure_type DW_AT_name ("single_and_pack<int, int>") DW_AT_byte_size (1) DW_AT_decl_file ("/usr/local/google/home/blaikie/dev/scratch/test.cpp") DW_AT_decl_line (9) DW_AT_decl_column (8) DW_AT_sibling (0x000003b7) 0x000003a4: DW_TAG_template_type_parameter DW_AT_name ("T1") DW_AT_type (0x00000094 "int") 0x000003ac: DW_TAG_GNU_template_parameter_pack DW_AT_name ("Ts") 0x000003b0: DW_TAG_template_type_parameter DW_AT_type (0x00000094 "int") 0x000003b5: NULL 0x000003b6: NULL ``` And there's an extra bonus reason from Clang's side: I'm working on a mode for clang (called -gsimple-template-names) that will produce DW_AT_names for templates without template parameters in some cases (so in the above example "single_and_pack") and so working around this bug (missing structural/API access to template parameters) by using the string name won't be possible with debug info like this) (total aside, though this is probably for a conversation on a gdb mailing list - it does look like gdb does quite a bit of work that looks /a lot/ like it's intending to support debug info like I described above... anyone happen to have context on that?)
Is related to (or a duplicate of) PR17272.
(In reply to Hannes Domani from comment #3) > Is related to (or a duplicate of) PR17272. Yeah, dup seems fine
Dup. *** This bug has been marked as a duplicate of bug 17272 ***
Hi David, can you let me know whether clang would be able to make use of the fix in #17272 (see attached patch, linked PR, linked ML post, whatever works for you)? It would be useful to know whether someone would be able to make use of it, even if gcc aren't interested in supporting DW_TAG_GNU_template_parameter_pack.