Get gdb call stack
来源:互联网 发布:浙江网络发票真伪查询 编辑:程序博客网 时间:2024/05/21 09:27
Sometimes GDB cannot parse the call stack correctly, and the call stack in gdb shows as:
(gdb) bt0 0xb7f33410 in ?? ()
1 0xa89793a8 in ?? ()
2 0x00000002 in ?? ()
3 0x00000000 in ?? ()
since the call stack can be re-calculated by the stack frame, so if we can get the correct %ebp(frame pointer) reigster values, then we can get the call stack easily.
The ebp saves the current bottom of stack frame, and we know, when a function is invoked, the return address will be pushed into stack, and then the current ebp will be pushed, typical code as:
The code:func(params);
means:
push eip;
jmp @func
push %ebp // save previous frame pointer
mov %esp, %ebp // save current frame pointer
...
So we can say, the pointer of %ebp is the last frame pointer, and the %ebp + 1 is the return address, then we can recursively get the address of each function call, and with "info symbol" to get each function's symbol information.
An example:
(gdb) bt0 0xb7f33410 in ?? ()
1 0xa89793a8 in ?? ()
2 0x00000002 in ?? ()
3 0x00000000 in ?? ()
(gdb) x/10 $ebp
0xa89793a8: 0xa89793c8 0x08078734 0x0827e9e4 0x00000000
0xa89793b8: 0x00000000 0x00000000 0x00000000 0x00000000
0xa89793c8: 0xa89793e8 0x0806d1b1
(gdb) info symbol 0x08078734
IMSS::PsMutex::lock() + 18 in section .text
(gdb) x/10 0xa89793c8
0xa89793c8: 0xa89793e8 0x0806d1b1 0x0827e9e0 0x00000000
0xa89793d8: 0x00000000 0x00000000 0x00000000 0x0827e9e0
0xa89793e8: 0xa8979418 0x08077f3f
(gdb) info symbol 0x0806d1b1
IMSS::PsMutexLock::privateLock() + 35 in section .text
(gdb) x/10 0xa89793e8
0xa89793e8: 0xa8979418 0x08077f3f 0xa8979400 0x080a338c
0xa89793f8: 0xa8979418 0x08075d59 0x0827e9e0 0x00000001
0xa8979408: 0x00000001 0x00000000
(gdb) info symbol 0x08077f3f
SOAPRequestSocket::Accept(soap*&) + 41 in section .text
(gdb) x/10 0xa8979418
0xa8979418: 0xa8979438 0x08075c1c 0x0827e9e0 0x0829e8c8
0xa8979428: 0x00000019 0x00000000 0x00000000 0x0829e8b8
0xa8979438: 0xa8979458 0xb73dd797
(gdb) info symbol 0x08075c1c
PolicyRequestHandler::main() + 146 in section .text
Then we can get the call stack is:
IMSS::PsMutex::lock() + 18 in section .textIMSS::PsMutexLock::privateLock() + 35 in section .text
SOAPRequestSocket::Accept(soap*&) + 41 in section .text
PolicyRequestHandler::main() + 146 in section .text
- END -
- Get gdb call stack
- Get Call Stack
- gdb 调用栈 (call stack)
- Get CLR call stack in dump analysis
- Windbg调试--Get the Call Stack back when met UnhandledExceptionFilter
- call stack
- call stack
- Call stack
- call stack
- call stack
- call stack
- call stack
- gdb 中 dump 出所有的 java 线程的 call stack
- 手把手教你玩转GDB(四)—函数调用栈(call stack)探密
- 手把手教你玩转GDB(四)——–函数调用栈(call stack)探密
- GDB工具使用教程_函数调用栈(call stack)探密
- Call stack and stack frame
- Function Call Stack
- 用__doPostBack(eventTarget, eventArgument)提交防止重复提交
- 了解OLE及ActiveX
- [推荐]富人和穷人的12个经典差异
- Javascript useful custom function
- 电脑怎么定时关机和开机
- Get gdb call stack
- DbUnit使用入门
- 如何成为Java高手
- 我和你的千里之外
- 多一份选择没坏处
- Oracle中向视图中插入数据
- Asp.net(c#)数据库操作类
- 网上书店报告
- 建议csdn为blog多做几套漂亮的模板