使用GDB打印C ++ vtables

使用GDB打印C ++ vtables

问题描述:

我试图使用gdb打印对象的vtable;我找到了

I'm trying to print an object's vtable using gdb; I found the

上的

show print vt bl on

setting, but I still don't actually know how to print the vtable - p *object still doesn't print it out.

如何打印vtable?

How do I print the vtable?


  (gdb) set $i = 0
  (gdb) while $i < 10
     >print $i
     >p /a (*(void ***)obj)[$i]
     >set $i = $i + 1
     >end

其中obj是您要打印的vtable的对象,10是方法数。

Where "obj" is the object whose vtable you'd like to print, and 10 is the number of methods.