Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Paul Marquess <Paul.Marquess@owmobility.com>
To: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: getting subclass type from base class pointer
Date: Thu, 29 Oct 2015 19:41:00 -0000	[thread overview]
Message-ID: <CY1PR0501MB1178C26EDF7B171D6BDAE33E95200@CY1PR0501MB1178.namprd05.prod.outlook.com> (raw)

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




             reply	other threads:[~2015-10-29 19:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-29 19:41 Paul Marquess [this message]
2015-10-29 23:38 ` Paul Marquess
2015-10-30  7:20   ` André Pönitz
2015-10-30 11:26     ` Paul Marquess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CY1PR0501MB1178C26EDF7B171D6BDAE33E95200@CY1PR0501MB1178.namprd05.prod.outlook.com \
    --to=paul.marquess@owmobility.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox