Supported on windows
Supported on linux
Supported on embedded
Supported on android

info vtbl command

Displays information about a virtual method table (vtable) of an object

Syntax

info vtbl [Expression]

Parameters

Expression
Specifies an expression that will be evaluted to get the pointer to the object which virtual method table should be displayed.

Remarks

Vtable contains the list of pointers to virtual methods defined in the class of the object. The address of the vtable can also be used to identify the actual type of the object using the info symbol command.

Examples

We will demonstrate the use of the info vtbl command using C++ program containing of 2 classes:

class BaseClass
{
public:
    virtual void Test()
    {
    }
};

class ChildClass : public BaseClass
{
public:
    virtual void Test()
    {
    }
};

typedef int UnusedType, UsedType;

int main(int argc, char **argv)
{
    BaseClass *pObject = new ChildClass();
    asm("int3");
    delete pObject;
    return 0;
}

The program creates an instance of ChildClass and stores its address it in a BaseClass pointer. We will now use the info vtbl command to display vtable and show that the object pointed by a BaseClass pointer is actually an instance of ChildClass:

(gdb) run
Starting program: /home/bazis/test

Program received signal SIGTRAP, Trace/breakpoint trap.
main (argc=1, argv=0xbffff064) at test.cpp:23
23 delete pObject;
(gdb) print pObject
$1 = (BaseClass *) 0x804b008
(gdb) info vtbl pObject
vtable for 'BaseClass' @ 0x80486c8 (subobject @ 0x804b008):
[0]: 0x80485f4 <ChildClass::Test()>
(gdb) info symbol 0x80486c8
vtable for ChildClass + 8 in section .rodata of /home/bazis/test

Compatibility with VisualGDB

You can execute the info vtbl command under VisualGDB using the GDB Session window in Visual Studio.

See also