"print object on" and MI interface
André Pönitz
apoenitz@trolltech.com
Thu Jul 31 09:29:00 GMT 2008
Hi all.
I have a problem with accessing the dynamic type of a variable using
gdb's MI interface.
Given the following code
struct base { virtual ~base() {}; int x; };
struct derived : public base { };
int main()
{
base *b = new derived;
b->x = 1;
}
I get using "gdb -i mi" the following session (skipping the prompts
to improve readability)
~"GNU gdb 6.8-debian\n"
~"Copyright (C) 2008 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n"
~"This is free software: you are free to change and redistribute it.\n"
~"There is NO WARRANTY, to the extent permitted by law. Type \"show copying\"\n"
~"and \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-linux-gnu\"...\n"
set print object on
^done
break main.cpp:10
~"Breakpoint 1 at 0x4008ca: file /tmp/p/main.cpp, line 10.\n"
^done
run
~"Starting program: /tmp/p/p \n"
~"[Thread debugging using libthread_db enabled]\n"
~"[New Thread 0x2ac921fdcf20 (LWP 32536)]\n"
~"[Switching to Thread 0x2ac921fdcf20 (LWP 32536)]\n"
~"\n"
~"Breakpoint 1, main () at /tmp/p/main.cpp:10\n"
~"10\t}\n"
^done
p b
~"$1 = (derived *) 0x602780\n"
^done
-var-create b * b
^done,name="b",numchild="1",value="0x602780",type="base *"
-var-info-type b
^done,type="base *"
-symbol-type b
^error,msg="Undefined mi command: symbol-type (missing implementation)"
So the CLI seems to know the dynamic type of 'b', namely 'derived'. The MI
interface only seems to provide the static type, or warns about a missing
implementation. The "-symbol-type" command is documented at
http://sourceware.org/gdb/current/onlinedocs/gdb_25.html, though.
What could I do to convince the MI interface to give me the dynamic type, too?
Thank you for your help in advance,
André
More information about the Gdb
mailing list