通过gdb观看stl向量的内容
我有一个在全局命名空间中定义的自定义类对象的 stl 向量(是的,邪恶的,我知道)。 现在我想在 gdb 中设置一个观察点来监视该向量的某个元素的(公共)成员变量中可能发生的变化。类似于:
watch custom_namespace::vec[123].aVariable
如果我这样做,那么 gdb(Ubuntu Lucid 上的版本 7.1)会出现段错误。 有没有替代方法。这有可能吗?
I've got a stl vector of custom class objects defined in a global namespace (yeah, evil, I know).
Now I would like to set a watchpoint in gdb to monitor possible changes in a (public) member variable for a certain element of this vector. Something like:
watch custom_namespace::vec[123].aVariable
If I do this, then gdb (Version 7.1 on Ubuntu Lucid) segfaults.
Are there alternative ways. Is this possible at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这是否适用于您的情况(来自 gdb 手册) :
尝试将地址转换为
(int*)
。仍然存在段错误吗?另外,如果 STL
vector
需要扩展内部缓冲区,它也会移动其内容,因此您的对象可能只是从观察点下“被盗”。See if this applies to your case (from gdb manual):
Try casting the address to
(int*)
. Does it still segfault?Also STL
vector
will move its content if it needs to extend the internal buffer, so your object might just be "stolen" from under the watchpoint.