* "print object on" and MI interface
@ 2008-07-31 9:29 André Pönitz
2008-07-31 9:43 ` Vladimir Prus
0 siblings, 1 reply; 2+ messages in thread
From: André Pönitz @ 2008-07-31 9:29 UTC (permalink / raw)
To: gdb
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é
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: "print object on" and MI interface
2008-07-31 9:29 "print object on" and MI interface André Pönitz
@ 2008-07-31 9:43 ` Vladimir Prus
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Prus @ 2008-07-31 9:43 UTC (permalink / raw)
To: gdb
André Pönitz wrote:
>
> 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?
Nothing, it's not implemented yet. It's one of two high-priority issues in my
queue, however.
- Volodya
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-07-31 9:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-31 9:29 "print object on" and MI interface André Pönitz
2008-07-31 9:43 ` Vladimir Prus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox