gdb查看虚函数表、函数地址
(2013-05-21 10:48:47)分类: Makefile/GDB |
1. 查看函数地址
点击(此处)折叠或打开
- (gdb) info line a.cpp:10
- Line 10 of "a.cpp" starts at address 0x80487d4 <_ZN1B5test2Ev> and ends at 0x80487d7 <_ZN1B5test2Ev+3>.
- (gdb) p _ZN1B5test2Ev
- $1 = {void (B * const)} 0x80487d4
- (gdb)
点击(此处)折叠或打开
- 16 public:
- 17 virtual void test2(){
- 18 cout << "If I'm lying, I'm crying!" << endl;
- 19 }
- 20
- (gdb) info line 17
- Line 17 of "a.cpp" starts at address 0x8048808 <_ZN1D5test2Ev> and ends at 0x804880e <_ZN1D5test2Ev+6>.
- (gdb) b *0x804880e
- Note: breakpoint 2 also set at pc 0x804880e.
- Breakpoint 3 at 0x804880e: file a.cpp, line 18.
2. 查看虚函数表
点击(此处)折叠或打开
- (gdb) set print object on
- (gdb) p b
- $3 = (D &) @0xbfe3116c: { = {_vptr.B = 0x8048948}, }
点击(此处)折叠或打开
- (gdb) p b
- $6 = (D &) @0xbfe3116c: { = {_vptr.B = 0x8048948}, }
- (gdb) p /a *(void**)0x8048948@2
- $7 = {0x8048834 <_ZN1D4testEv>, 0x8048808 <_ZN1D5test2Ev>}
点击(此处)折叠或打开
- (gdb) p /a *((void**)0x8048948-1)
- $18 = 0x8048950 <_ZTI1D>
点击(此处)折叠或打开
- sles10sp1:~/test # c++filt _ZTI1D
- typeinfo for D
PS: