首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用gdb检查boost shared_ptr

使用gdb检查boost shared_ptr
EN

Stack Overflow用户
提问于 2013-07-23 16:22:47
回答 3查看 12.1K关注 0票数 20

以下是我的源代码:

#include <iostream>
#include <boost/shared_ptr.hpp>

class MyClass
{
    public:
        MyClass()
        {
            i=10;
        }
    private:
        int i;
};


int main(int argc, const char *argv[])
{
    boost::shared_ptr <MyClass> obj(new MyClass());
    return 0;
}

我想在gdb中检查obj,并查看成员变量i的值。

这是我用普通打印得到的结果:

29          boost::shared_ptr <MyClass> obj(new MyClass());
(gdb) n
30          return 0;
(gdb) p obj
$1 = {px = 0x602010, pn = {pi_ = 0x602030}}

我尝试了this link中提到的提示,但不起作用。

(gdb) call (obj.get())->print()
Cannot evaluate function -- may be inlined

还有别的办法吗?gdb版本为7.0.1。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17804967

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档