public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug mi/13393] New: There is no way to access runtime type of C++ variable via MI (using RTTI)
@ 2011-11-08  8:31 xgsa at yandex dot ru
  2011-11-08 11:46 ` [Bug mi/13393] " xgsa at yandex dot ru
                   ` (23 more replies)
  0 siblings, 24 replies; 25+ messages in thread
From: xgsa at yandex dot ru @ 2011-11-08  8:31 UTC (permalink / raw)
  To: gdb-prs

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.


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2012-04-14 12:24 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-08  8:31 [Bug mi/13393] New: There is no way to access runtime type of C++ variable via MI (using RTTI) xgsa at yandex dot ru
2011-11-08 11:46 ` [Bug mi/13393] " xgsa at yandex dot ru
2011-11-08 16:42 ` tromey at redhat dot com
2011-11-08 16:56 ` andre.poenitz at nokia dot com
2011-11-08 21:38 ` xgsa at yandex dot ru
2011-11-09  7:17 ` andre.poenitz at nokia dot com
2011-11-09 11:36 ` xgsa at yandex dot ru
2011-11-09 13:19 ` andre.poenitz at nokia dot com
2011-11-09 15:26 ` tromey at redhat dot com
2011-11-10  9:10 ` xgsa at yandex dot ru
2011-11-10  9:12 ` xgsa at yandex dot ru
2011-11-10 21:06 ` tromey at redhat dot com
2011-11-11 20:14 ` xgsa at yandex dot ru
2011-11-28 17:14 ` xgsa at yandex dot ru
2011-11-28 17:17 ` xgsa at yandex dot ru
2011-11-28 17:33 ` andre.poenitz at nokia dot com
2011-11-28 17:56 ` xgsa at yandex dot ru
2011-12-02  9:30 ` xgsa at yandex dot ru
2011-12-02 17:17 ` xgsa at yandex dot ru
2011-12-02 19:01 ` tromey at redhat dot com
2011-12-02 19:04 ` tromey at redhat dot com
2011-12-16  8:08 ` xgsa at yandex dot ru
2011-12-16 14:49 ` tromey at redhat dot com
2012-04-14 12:19 ` cvs-commit at gcc dot gnu.org
2012-04-14 12:24 ` xgsa at yandex dot ru

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).