Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的类是在头文件中定义的,我需要在 GDB 中观察它的私有非静态成员,如下所示:
class foo { int bar; };
您可以在内存地址上设置观察点。
您应该在foo构造函数执行后的某处停止代码并打印bar变量地址。然后你可以像这样在地址上设置观察点:
foo
bar
(gdb) p &bar $1 = (int *) 0x10793ad0 (gdb) watch *0x10793ad0