I've a class Impl
which inherites from Base
.
A simple code snippet I'm trying to debug:
{
Base* base = getObject(); // getObject() returns instance of Impl
base->something();
}
When I want to inspect base
I get:
p base
$1 = (Base *) 0x7fffc408edf0
p *base
$2 = {_vptr.Base = 0x7ffff74be100 <vtable for Impl+16>}
I'm compiling my program with gcc
and I use -O0 -g
. I've also tried -ggdb3
instead of -g
with no use.
What may be important here: my project is divided into 3 modules: executable and two static libraries. Code I'm debugging lies in one of those static libraries, and definitions of Impl
and Base
are in second one.
You want (gdb) set print object on
.
Documentation:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With