Get gdb call stack
2007-01-22 17:37
369 查看
Sometimes GDB cannot parse the call stack correctly, and the call stack in gdb shows as:
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:
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:
Then we can get the call stack is:
- END -
(gdb) bt 0 0xb7f33410 in ?? () 1 0xa89793a8 in ?? () 2 0x00000002 in ?? () 3 0x00000000 in ?? () |
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 ... |
An example:
(gdb) bt 0 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 |
IMSS::PsMutex::lock() + 18 in section .text IMSS::PsMutexLock::privateLock() + 35 in section .text SOAPRequestSocket::Accept(soap*&) + 41 in section .text PolicyRequestHandler::main() + 146 in section .text |
相关文章推荐
- Native code - how to get function call stack (backtrace) programatically 附带源代码
- Get CLR call stack in dump analysis
- Windbg调试--Get the Call Stack back when met UnhandledExceptionFilter
- gdb mysql stack get
- how to get callstack at runtime?
- gdb教程:3. How do I use the call stack?
- Get the Call Stack back when met UnhandledExceptionFilter
- GetThreadCallStack may not work
- ubuntu14.04 install sudo apt-get install gdb-arm-none-eabi err
- strace + pstack + gdb 对函数调试
- attempt to call getDuration without a valid mediaplayer问题
- get system call table in x86-64 Linux
- __construct __destory __call __get __set
- composer 錯誤Call to undefined method Composer\Package\RootPackage::getConfig
- rtdm open call stack
- (启动H5本地存储)WebView显示网页出现Uncaught TypeError: Cannot call method 'getItem' of null异常
- Known Oracle Internal Stack Call Meaning
- Fatal error: Call to undefined function get_magic_quotes_gpc() 解决方案
- Linux 上分析死锁的简单方法--gdb+pstack
- PHP中的魔术方法总结 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep, __wakeup, __toStr