This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
RE: getting subclass type from base class pointer
- From: Paul Marquess <Paul dot Marquess at owmobility dot com>
- To: André Pönitz <apoenitz at t-online dot de>
- Cc: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Fri, 30 Oct 2015 11:26:14 +0000
- Subject: RE: getting subclass type from base class pointer
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp dot mailfrom=Paul dot Marquess at owmobility dot com;
- References: <CY1PR0501MB1178C26EDF7B171D6BDAE33E95200 at CY1PR0501MB1178 dot namprd05 dot prod dot outlook dot com> <CY1PR0501MB11786B043D21E72D27B73A8D95200 at CY1PR0501MB1178 dot namprd05 dot prod dot outlook dot com> <20151030072010 dot GA12621 at klara dot mpi dot htwm dot de>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
From: André Pönitz [mailto:apoenitz@t-online.de]
> On Thu, Oct 29, 2015 at 11:38:27PM +0000, Paul Marquess wrote:
> > > gdb) python x = gdb.parse_and_eval("pTest")
> > > (gdb) python print x.type
> > > SuperClass *
>
> (gdb) python print(x.type)
> SuperClass *
> (gdb) python print(x.dynamic_type)
> SubClass *
Bingo! That did it.
Hmm, could have sworn that I tried that myself (but obviously I'm deluding myself).
Thanks for the help
Paul