如何在GDB中访问std :: tr1 :: shared_ptr的目标 [英] How to access target of std::tr1::shared_ptr in GDB
本文介绍了如何在GDB中访问std :: tr1 :: shared_ptr的目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在GDB中访问std :: tr1 :: shared_ptr的目标。这不起作用:
(gdb)p sharedPtr-> variableOfTarget
如果我尝试使用指针对象本身( p sharedPtr
),我得到如下所示:
$ 1 = std :: tr1 :: shared_ptr(count 2)0x13c2060
使用普通指针我可以执行 p * ptr
并获取所有数据或 p ptr->变量
只有一个变量。
我在Centos 6.5,GCC 4.4.7-4.el6和
<$> p pre $(gdb)p(* sharedPtr.get())
该函数返回指向智能指针所拥有对象的指针。
How can I access target of a std::tr1::shared_ptr in GDB. This doesn't work:
(gdb) p sharedPtr->variableOfTarget
If I try with the pointer object itself (p sharedPtr
) I get something like this:
$1 = std::tr1::shared_ptr (count 2) 0x13c2060
With a normal pointer I can do p *ptr
and get all the data or p ptr->variable
for just one variable.
I'm on Centos 6.5, GCC 4.4.7-4.el6 and GDB 7.2-64.el6_5.2.
解决方案
Try with
(gdb) p (*sharedPtr.get())
that function returns the a pointer to the object owned by the smart pointer.
这篇关于如何在GDB中访问std :: tr1 :: shared_ptr的目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文