خرید بک لینک

Vote count: 0

I'm trying to debug the following simple program:

#include <iostream>

template <class... Args>
void printAll(Args&&... args) {
    using swallow = int[];
    swallow{0,
        (std::cout << args, 0)...
    };  
}

int main() {
    printAll(1, "23", 4); 
}

Compiled with gcc 4.9.2 using:

g++ -std=c++11 -g -O0 foo.cxx

And then debugging with gdb 7.9 using:

gdb a.out

(gdb) break foo.cxx:5
Breakpoint 1 at 0x400884: file foo.cxx, line 5.
(gdb) run
Starting program: /..[snip]../a.out 

Breakpoint 1, printAll<int, char const (&) [3], int>(int&&, char const (&) [3], int&&) () at foo.cxx:6
6       swallow{0,
(gdb) bt
#0  printAll<int, char const (&) [3], int>(int&&, char const (&) [3], int&&) () at foo.cxx:6
#1  0x0000000000400813 in main () at foo.cxx:12

I'm in the right function, but I have no way to inspect the parameter pack:

(gdb) info args
No arguments.
(gdb) print args
No symbol "args" in current context.
(gdb) inspect args
No symbol "args" in current context.

How do I actually examine the arguments?

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 16 فروردين 1395 ساعت: 23:37

صفحه بندی