Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "André Pönitz" <apoenitz@trolltech.com>
To: gdb@sources.redhat.com
Subject: "print object on"  and  MI interface
Date: Thu, 31 Jul 2008 09:29:00 -0000	[thread overview]
Message-ID: <200807311105.38705.apoenitz@trolltech.com> (raw)


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é 


             reply	other threads:[~2008-07-31  9:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-31  9:29 André Pönitz [this message]
2008-07-31  9:43 ` Vladimir Prus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200807311105.38705.apoenitz@trolltech.com \
    --to=apoenitz@trolltech.com \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox