I'm developing an application that, at some point, must use a different stack, that will be managed by a library I developed. So, I call the initialization function of this library and the stack pointer ($sp) is set to the memory address I wanted.
When running this code via GDB, after the initialization of my other stack is done and execution returns to the caller function, GDB gives me this warning:
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.
Also, when printing the $sp, the old value is shown.
Since this part of the code performs correctly without GDB, and there is no function at 0x12, this happens because GDB uses the stack pointer to address to keep track of the function's frame.
Is there any way to avoid this behavior and be able to debug this application?