Debugging C++ Applications Using HP WDB (766162-001, March 2014)

Example 27 (page 39) shows a sample program for debugging template functions:
Example 27 Sample program for debugging template functions
1 template<class ...T> void fun(int x, T ...args)
2 {
3 int a[] = {0, args..., 5};
4 int y;
5 y = x;
6 }
7
8 int main(int argc, char** argv)
9 {
10 fun(1, 2, 3, 4);
11 fun(30,40);
12
13 return 0;
14 }
The following is the WDB output snippet for this program:
(gdb) b fun
[0] cancel
[1] all
[2] fun<<int,int,int> >(int,<int,int,int>...) at my_variadic.cc:3
[3] fun<<int> >(int,<int>...) at my_variadic.cc:3
> 1
Breakpoint 1 at 0x4000b40:0: file my_variadic.cc, line 3 from /user/usr1/my_variadic.
Breakpoint 2 at 0x4000be0:1: file my_variadic.cc, line 3 from /user/usr1/my_variadic.
Multiple breakpoints were set.
Use the "delete" command to delete unwanted breakpoints.
(gdb) r
Starting program: /user/usr1/my_variadic
Breakpoint 1, void fun<<int,int,int> > (x=1, args=2, args=3, args=4)
at my_variadic.cc:3
3 int a[] = {0, args..., 5};
(gdb) bt
#0 void fun<<int,int,int> > (x=1, args=2, args=3, args=4) at my_variadic.cc:3
#1 0x4000a70:0 in main (argc=1, argv=0x200000007ffff268) at my_variadic.cc:10
(gdb) info args
x = 1
args = 2
args = 3
args = 4
(gdb) c
Continuing.
Breakpoint 2, void fun<<int> > (x=30, args=40) at my_variadic.cc:3
3 int a[] = {0, args..., 5};
(gdb) bt
#0 void fun<<int> > (x=30, args=40) at my_variadic.cc:3
#1 0x4000a80:0 in main (argc=1, argv=0x200000007ffff268) at my_variadic.cc:11
(gdb) info args
x = 30
args = 40
(gdb) fini
Run till exit from #0 void fun<<int> > (x=30, args=40) at my_variadic.cc:3
main (argc=1, argv=0x200000007ffff268) at my_variadic.cc:13
13 return 0;
(gdb) pt fun
type = void (int, int, int, int)
type = void (int, int)
(gdb) list fun
[0] cancel
[1] all
Debugging C++11 specific features 39