How can one see the values of a parameter pack in a variadic function in gdb?
Sample code (VariadicDebug.cpp):
template <typename... Ts> int Do(int a, Ts... ts)
{
// Add breakpoint here. a can be seen using 'print a' but how to show ts???
return a;
}
int main(int argc, char **argv)
{
return Do(0, "Hello world!", 88.9);
}
Compile with
g++ --std=c++11 -O0 -g VariadicDebug.cpp
And run gdb:
$ gdb ./a.exe
GNU gdb (GDB) 7.9
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://ift.tt/KpOJT7;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-msys".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://ift.tt/xLrliR;.
Find the GDB manual and other documentation resources online at:
<http://ift.tt/1gENejF;.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.exe...done.
(gdb) break VariadicDebug.cpp:4
Breakpoint 1 at 0x100401760: file VariadicDebug.cpp, line 4.
(gdb) run
Starting program: /c/Data/tests/a.exe
[New Thread 8008.0x1dd0]
[New Thread 8008.0x2898]
[New Thread 8008.0x26f0]
[New Thread 8008.0x1498]
Breakpoint 1, Do<char const*, double> (a=0) at VariadicDebug.cpp:4
4 return a;
(gdb) info args
a = 0
As you can see: It only gives the value for a not for ts.
Aucun commentaire:
Enregistrer un commentaire