I use C++ 11 features actively. I have program created in Visual Studio 2013 that relies on lambdas to run multiple threads (lambda represents task, and thread receives lambda i
I've seen them in stack traces before, so it does at least know about them. I've never tried setting a normal breakpoint in one. It's sort of a hack, but you can set a breakpoint in one (or anywhere) by using asm volatile("int $3");
on x86(-64).
Here's an example program:
int main(){
auto f = [](){
asm volatile("int $3");
};
f();
return 0;
}
Here's it's backtrace when it hits that breakpoint:
#0 0x0000000000400577 in main::{lambda()#1}::operator()() const ()
#1 0x000000000040058d in main ()
Step into Lamba's .run()
go next/step (jump initializations) until the following call:
std::forward<>(args)(...)
Step into this one. It will lead you to you lambda body code.
From my experience, gdb cannot step into lambdas -- it just skips over them. Not only that, stepping into a lambda definition seems to confuse gdb and it proceeds to the end of the current function. You can, however, place a breakpoint explicitly inside a lambda, and if you hit that point, you will stop. This is obviously far from ideal.