Print C++ vtables using GDB

后端 未结 5 2220
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 16:09

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

5条回答
  •  爱一瞬间的悲伤
    2020-12-02 16:35

    For the example at http://en.cppreference.com/w/cpp/language/virtual

    Without using 'info vtbl'

    (gdb) p b
    $1 = {_vptr.Base = 0x400a60 }
    
    (gdb) x/16x 0x400a60
    0x400a60 <_ZTV4Base+16>:    0x0040094c  0x00000000  0x72654437  0x64657669
    
    (gdb) x/16x 0x0040094c
    0x40094c :   0xe5894855  0x10ec8348  0xf87d8948  0x400a15be
    0x40095c :    0x10c0bf00  0xf9e80060  0xc9fffffd  0x485590c3
    0x40096c :  0x8348e589  0x894810ec  0x1bbef87d  0xbf00400a
    0x40097c : 0x006010c0  0xfffddbe8  0x66c3c9ff  0x00841f0f
    

提交回复
热议问题