Click here to Skip to main content
13,256,304 members (49,776 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


8 bookmarked
Posted 30 Jun 2010

Displaying vtable when debugging

, 30 Jun 2010
Rate this:
Please Sign up or sign in to vote.
This tip show how to display all entries from a C++ vtable in the VS debugger.
Due to some limitations the virtual table of an object is not shown by default in the debugger. In some cases only the entries from the base class is shown.

class Base
    virtual void a();
class Derived : public Base
    virtual void b();
Base* ptr = new Derived();

which in a watch window gives
ptr->__vfptr	0x004420f8 const Derived::`vftable'
	[0x0]	0x00415ed3 Base::a(void)

You can look at the entire vtable if you add this helper variable:

void (**vt)() = *(void (***)())ptr;

and then inspect vt,X in a watch window, where X is the number of expected virtual function entries.

vt,2 gives in the example above
vt,2	0x004420f8 const Derived::`vftable'
  [0x0]	0x00415ed3 Base::a(void)
  [0x1]	0x00415ee2 Derived::b(void)

Idea originates from here[^], and it's too good to not share.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

You may also be interested in...

Comments and Discussions

QuestionHelper variable not needed! Pin
Stefan_Lang16-Jul-13 23:59
memberStefan_Lang16-Jul-13 23:59 
GeneralReason for my vote of 5 Thanks Niklas Pin
RioWing23-Dec-11 7:30
memberRioWing23-Dec-11 7:30 
GeneralReason for my vote of 5 Very neat! Pin
Harrison H26-Oct-10 10:43
memberHarrison H26-Oct-10 10:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 1 Jul 2010
Article Copyright 2010 by Niklas Lindquist
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid