Tried with 7.2 for debian, but seems is not possible to step into c++0x lambdas.
-
cutting edge, probably better off asking on g++ or gdb mailing listMK.– MK.2011-06-20 21:58:59 +00:00Commented Jun 20, 2011 at 21:58
-
Can you elaborate on exactly what went wrong?templatetypedef– templatetypedef2011-06-20 22:00:22 +00:00Commented Jun 20, 2011 at 22:00
-
@templatetypedef I couldn't do step by step into the lambda function.piotr– piotr2011-06-20 22:26:20 +00:00Commented Jun 20, 2011 at 22:26
-
did you try putting break point inside lambda?Gene Bushuyev– Gene Bushuyev2011-06-21 00:43:11 +00:00Commented Jun 21, 2011 at 0:43
-
Possible duplicate of Can GDB debug lambda?Ciro Santilli OurBigBook.com– Ciro Santilli OurBigBook.com2018-08-28 17:39:16 +00:00Commented Aug 28, 2018 at 17:39
Add a comment
|
1 Answer
I was able to step into a lambda in a very simple program (ubuntu 10.04, gdb-7.1, gcc-4.6 with -g flag).
#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);
}
And here's a session transcript.
(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 }
1 Comment
piotr
I have to use this inside the lambda to access captures btw. Using the same captured symbol yields garbage.