For the GCC compiler on Linux, run:
g++ -fdump-class-hierarchy example.h
Output:
Vtable for a
A :: _ ZTV1A: 3u entries
0 (int (*) (...)) 0
8 (int (*) (...)) (& _ZTI1A)
16 (int (*) (...)) A :: doSomeWork
Class a
size = 8 align = 8
base size = 8 base align = 8
A (0x7fb76785a4e0) 0 nearly-empty
vptr = ((& A :: _ ZTV1A) + 16u)
Vtable for b
B :: _ ZTV1B: 3u entries
0 (int (*) (...)) 0
8 (int (*) (...)) (& _ZTI1B)
16 (int (*) (...)) B :: doSomeWork
Class b
size = 8 align = 8
base size = 8 base align = 8
B (0x7fb7678510d0) 0 nearly-empty
vptr = ((& B :: _ ZTV1B) + 16u)
A (0x7fb76785a540) 0 nearly-empty
primary-for B (0x7fb7678510d0)
I also created the vtable-dumper tool to display the contents of virtual tables in shared objects. With this tool, you do not need to compile the headers, just run it on the object:
vtable-dumper SHLIB
aponomarenko
source share