This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17435] New: "info vtbl" doesn't respect "set print object on"


https://sourceware.org/bugzilla/show_bug.cgi?id=17435

            Bug ID: 17435
           Summary: "info vtbl" doesn't respect "set print object on"
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: tromey at sourceware dot org

Compile this program with g++ -g

struct Base1
{
  virtual void b1() { }

  int mb1;
  Base1() : mb1(0) { }
};

struct Base2
{
  virtual void b2() { }

  int mb2;
  Base2() : mb2(3) { }
};

struct Der : public Base1, Base2
{
  int x, y;

  Der(): x(5), y(6) { }

  void b1() { }
  void b2() { }
};

int main()
{
  Base1* b1 = new Der();
  Base2* b2 = new Der();
  Der* d = new Der();

  return 0;
}


Now break on the "return" and run it under "gdb -nx".

Without "set print object on" I get:

(gdb) p b1
$1 = (Base1 *) 0x602010
(gdb) info vtbl b1
vtable for 'Base1' @ 0x4008f0 (subobject @ 0x602010):
[0]: 0x40080c <Der::b1()>


This seems basically reasonable, but now try with
"set print object on":
(gdb) set print object on
(gdb) p b1
$2 = (Der *) 0x602010
(gdb) info vtbl b1
vtable for 'Base1' @ 0x4008f0 (subobject @ 0x602010):
[0]: 0x40080c <Der::b1()>

I expected this to print the vtable of the full object,
just as "print" did.  I can make it happen manually
using a cast:

(gdb) info vtbl (Der *) b1
vtable for 'Der' @ 0x4008f0 (subobject @ 0x602010):
[0]: 0x40080c <Der::b1()>
[1]: 0x400816 <Der::b2()>

vtable for 'Base2' @ 0x400910 (subobject @ 0x602020):
[0]: 0x400820 <non-virtual thunk to Der::b2()>

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]