【发布时间】:2012-05-02 09:35:06
【问题描述】:
我正在开发一个应用程序,在某些时候,它必须使用不同的堆栈,它将由我开发的库管理。于是,我调用了这个库的初始化函数,堆栈指针($sp)被设置为我想要的内存地址。
当通过 GDB 运行这段代码时,在我的另一个堆栈的初始化完成并且执行返回到调用者函数之后,GDB 给我这个警告:
warning: GDB can't find the start of the function at 0x12.
GDB is unable to find the start of the function at 0x12
and thus can't determine the size of that function's stack frame.
This means that GDB may be unable to access that stack frame, or
the frames below it.
This problem is most likely caused by an invalid program counter or
stack pointer.
However, if you think GDB should simply search farther back
from 0x12 for code which looks like the beginning of a
function, you can increase the range of the search using the `set
heuristic-fence-post' command.
另外,打印 $sp 时,会显示旧值。
由于这部分代码在没有 GDB 的情况下可以正常执行,并且在 0x12 处没有函数,这是因为 GDB 使用堆栈指针来寻址来跟踪函数的帧。
有什么方法可以避免这种行为并能够调试这个应用程序?
【问题讨论】:
标签: debugging gdb stack cpu-registers