12

How to display vtable using a pointer to base class object having virtual functions?

2 Answers2

19

Did you try set print object on ?

(gdb) help set print object
Set printing of object's derived type based on vtable info.
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • BTW, in lldb this is equivalent to "settings set target.prefer-dynamic run-target". I'm answering this just because gdb is no longer part of Xcode. – kakyo Jul 11 '14 at 20:06
  • Sorry, it should have been "settings set target.prefer-dynamic-value run-target" – kakyo Jul 11 '14 at 20:59
  • Thank you. That's the answer - so glad you posted this all the way in 2010! – Chris Sherlock Jan 15 '15 at 15:54
5

If you have a sufficiently new version of gdb, you may want to look at the "info vtbl" command (or perhaps it is called "info vtable"; my own version of gdb is not sufficiently new, and so I cannot test the feature out myself).

I only noticed the feature when googling for an answer to this question and I noticed posts to the gdb mailing list circa 2012, notably this one from March 2012:

http://permalink.gmane.org/gmane.comp.gdb.patches/73957

pnkfelix
  • 3,770
  • 29
  • 45