任何运气调试lambdas与gdb? [英] Any luck debugging lambdas with gdb?

查看:186
本文介绍了任何运气调试lambdas与gdb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用7.2的debian,但似乎不可能进入c ++ 0x lambdas。

Tried with 7.2 for debian, but seems is not possible to step into c++0x lambdas.

推荐答案

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

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);
}

以下是会话记录。

(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      }

这篇关于任何运气调试lambdas与gdb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆