This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

getting subclass type from base class pointer


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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]