GDB 不显示对象的成员

Mic*_*iak 3 c++ gcc gdb static-libraries

我有一个Impl继承自Base.

我正在尝试调试的一个简单代码片段:

{
    Base* base = getObject();     // getObject() returns instance of Impl
    base->something();
}
Run Code Online (Sandbox Code Playgroud)

当我想检查时,base我得到:

p base
$1 = (Base *) 0x7fffc408edf0

p *base
$2 = {_vptr.Base = 0x7ffff74be100 <vtable for Impl+16>}
Run Code Online (Sandbox Code Playgroud)

我正在编译我的程序,gcc我使用-O0 -g. 我也试过,-ggdb3而不是-g没有用。

这里可能很重要:我的项目分为 3 个模块:可执行文件和两个静态库。代码我在那些静态库的一个调试的谎言,以及定义ImplBase是第二个。

Emp*_*ian 5

你要(gdb) set print object on

文件

set print object on
  When displaying a pointer to an object, identify the actual (derived) type
  of the object rather than the declared type, using the virtual function table.
Run Code Online (Sandbox Code Playgroud)