有没有运气调试lambdas与gdb?

pio*_*otr 6 lambda gdb c++11

尝试7.2为debian,但似乎不可能进入c ++ 0x lambdas.

n. *_* m. 4

我能够在一个非常简单的程序中进入 lambda(ubuntu 10.04、gdb-7.1、带-g标志的 gcc-4.6)。

#include <iostream>

void sayhello()
{
    std::cout << "Hello world" << std::endl;
}

int main ()
{
    std::cout << "=========" << std::endl;
    ([](void (*f)()) {
     std::cout << "---------" << std::endl;
     f();
     std::cout << "---------" << std::endl;
     })(sayhello);
}
Run Code Online (Sandbox Code Playgroud)

这是会议记录。

(gdb) br main
Breakpoint 1 at 0x804869e: file hello.C, line 10.
(gdb) r
Starting program: /tmp/hello 

Breakpoint 1, main () at hello.C:10
10          std::cout << "=========" << std::endl;
(gdb) n
=========
15           })(sayhello);
(gdb) s
operator() (this=0xbffff24f, f=0x8048614 <sayhello()>) at hello.C:12
12           std::cout << "---------" << std::endl;
(gdb) n
---------
13           f(); 
(gdb) s
sayhello () at hello.C:5
5           std::cout << "Hello world" << std::endl;
(gdb) n
Hello world
6       }
(gdb) s
operator() (this=0xbffff24f, f=0x8048614 <sayhello()>) at hello.C:14
14           std::cout << "---------" << std::endl;
(gdb) n
---------
15           })(sayhello);
(gdb) n
main () at hello.C:16
16      }
Run Code Online (Sandbox Code Playgroud)