Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a vtable by name using gdb

When debugging where you have a crash dump, vtable pointers are good indicators of an object in memory.

What I would like to do in gdb is be able to query for the vtable by doing something like

info address 'vtable for Bar'

However, the only way to do this (without requiring a valid instance of the object) I have found is to use the mangled name for the vtable.

Example:

info address _ZTV3Bar

It isn't the end of the world to try and figure out the vtable mangled name, but it is an annoyance (i.e. using objdump -t myexecutable).

Does anyone know of a way where I can find the vtable address of a type in a less painful way (without requiring a valid instance of the type)?
- Rules: can't require a valid instance of the object in question and find the vtable pointer in the object.

like image 664
Gabe Avatar asked Mar 23 '23 16:03

Gabe


2 Answers

Use info variable instead:

info variable vtable for Bar

like image 171
HexMachina Avatar answered Apr 02 '23 08:04

HexMachina


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.

like image 23
gkso Avatar answered Apr 02 '23 06:04

gkso