How to display vtable using a pointer to base class object having virtual functions?
Asked
Active
Viewed 7,482 times
12
-
3Why do you want to inspect the vtable? It is normally considered an implementation the compiler uses for virtual functions. – Anders Abel Mar 27 '10 at 14:55
-
Very related question: http://stackoverflow.com/questions/2549618/ – Nikolai Fetissov Mar 31 '10 at 21:36
-
if using ddd front-end is an option, it automates a lot of the C++ objects display. – PypeBros Sep 03 '10 at 11:26
2 Answers
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:

pnkfelix
- 3,770
- 29
- 45