我正在开发一个应用程序,在某些时候,它必须使用不同的堆栈,它将由我开发的库管理。所以,我调用了这个库的初始化函数,并将堆栈指针($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 使用堆栈指针来寻址来跟踪函数的帧。
有没有办法避免这种行为并能够调试这个应用程序?