This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug python/11792] New: Provide access to the dynamic type of an object
- From: "andre dot poenitz at nokia dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: 6 Jul 2010 16:00:18 -0000
- Subject: [Bug python/11792] New: Provide access to the dynamic type of an object
- Reply-to: sourceware-bugzilla at sourceware dot org
There seems to be no easy way to get access to the dynamic type of a C++ object.
The problem is visible in the following script:
=================== snip ======================
rm -rf s && mkdir s && cd s
echo -e "
class Base { public: virtual ~Base() {} };
class Derived : public Base {};
int main() {
Base *b = new Derived;
return (int)b;
}" | g++ -g -xc++ -
gdb -ex 'file a.out' \
-ex 'start' \
-ex 'next' \
-ex 'print b' \
-ex 'set print object on' \
-ex 'print b' \
-ex 'python import gdb' \
-ex 'python print "Python says: '%s'" % gdb.parse_and_eval("b").type' \
-ex 'set confirm off' \
-ex 'quit'
=================== snip ======================
The result is:
$1 = (Base *) 0x804b008
$2 = (Derived *) 0x804b008
Python says: Base *
It would be nice if there was a method accessible by Python that produces
"Derived *"
--
Summary: Provide access to the dynamic type of an object
Product: gdb
Version: 7.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: python
AssignedTo: unassigned at sourceware dot org
ReportedBy: andre dot poenitz at nokia dot com
CC: gdb-prs at sourceware dot org
GCC build triplet: i486-linux-gnu
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=11792
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.