This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug mi/13393] New: There is no way to access runtime type of C++variable via MI (using RTTI)
- From: "xgsa at yandex dot ru" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Tue, 08 Nov 2011 08:31:37 +0000
- Subject: [Bug mi/13393] New: There is no way to access runtime type of C++variable via MI (using RTTI)
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=13393
Bug #: 13393
Summary: There is no way to access runtime type of C++ variable
via MI (using RTTI)
Product: gdb
Version: 7.3
Status: NEW
Severity: normal
Priority: P2
Component: mi
AssignedTo: unassigned@sourceware.org
ReportedBy: xgsa@yandex.ru
Classification: Unclassified
The CLI "print" command shows user runtime type of C++ variable based on RTTI
if "set print object" is "on". So gdb can show "real" type name for the objects
that are stored by the interfaces and show their internals. Unfortunately, this
information is not available via MI, so a lot of GUI tools that use it (like
Eclipse CDT, Qt Creator, ...) cann't access it.
Here is an example that demonstrates the case described above:
struct Base {
Base() : a(1) {}
virtual ~Base() {} // Enforce type to have RTTI
int a;
};
struct Derived : public Base {
Derived() : b(2) {}
int b;
};
int main() {
Derived b;
Base* aPtr = &b;
return 0; // <= Set breakpoint here
}
Here is an example of CLI session:
(gdb) p b
$1 = (Derived) {<Base> = {_vptr.Base = 0x8048788, a = 1}, b = 2}
(gdb) p *aPtr
$2 = {_vptr.Base = 0x8048788, a = 1}
(gdb) set print object on
(gdb) p *aPtr
$3 = (Derived) {<Base> = {_vptr.Base = 0x8048788, a = 1}, b = 2}
Here is a fragment of MI session by Eclipse CDT ("set print object on" is done
in .gdbinit):
782,149 (gdb)
782,149 23-var-create --thread 1 --frame 0 - * b
782,150 24-var-create --thread 1 --frame 0 - * aPtr
782,150
23^done,name="var1",numchild="2",value="{...}",type="Derived",thread-id="1",has_more="0"
782,150 (gdb)
782,150 24^done,name="var2",numchild="1",value="0xbffff428",type="Base
*",thread-id="1",has_more="0"\
So can the "-var-create" command be extended to provide such information? Or
maybe another command that will do it? Or the value of "type" field of
"-var-create" command result will depend on "set print object"?
Maybe the next bugs are connected to this one:
Bug 9197 - Type printing uses different code from value access.
Bug 9257 - set print object on does not work
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.