I have an auto_ptr<IFoo>, where IFoo is an interface with just pure-virtual methods.
I now also have a core-file after a segmentation fault, where I'd really like to know what the concrete sub-class was behind this auto_ptr. As dynamic_cast works in the project, I think that RTTI must be available somehow, but I am unaware as how I would access this information via gdb?
The output I get is as follows:
(gdb) print this->obj._M_ptr
$22 = (class martin::IFoo *) 0x7418
What I'd really like to know, if the pointer belongs to an IBaror an IBaz.
Thanks for any help!
GDB should be able to tell you that. Use
(gdb) set print object on. Documentation here.Update:
That likely means that the pointer really is pointing to
IFoo(e.g. the object that was of typeIBarorIBazhas already been destructed).Yes,
dynamic_castcan't work without RTTI; if you are usingdynamic_cast,print object onshould just work.