Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* getting subclass type from base class pointer
@ 2015-10-29 19:41 Paul Marquess
  2015-10-29 23:38 ` Paul Marquess
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Marquess @ 2015-10-29 19:41 UTC (permalink / raw)
  To: gdb

I must be missing something obvious, so apologies upfront.

Consider this simple snippet of C++


class SuperClass 
{
};

class SubClass : public SuperClass 
{
};

int main()
{
    SuperClass* pTest = new SubClass;

    delete pTest; // << Break here in GDB
}

Using the python API I'm trying to determine the type of object that pTest points to. 


gdb) python x = gdb.parse_and_eval("pTest")
(gdb) python print x.type
SuperClass *
(gdb) python print x.dereference().type
SuperClass

How do I get at the SubClass object using the Python API?

cheers
Paul

PS running GDB 7.10

$ gdb -v
GNU gdb (GDB) 7.10




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-30 11:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-29 19:41 getting subclass type from base class pointer Paul Marquess
2015-10-29 23:38 ` Paul Marquess
2015-10-30  7:20   ` André Pönitz
2015-10-30 11:26     ` Paul Marquess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox