In the process of debugging can often happen a situation with a failure of the debug stack, this is due to many reasons, usually playing with stack registers RBP/RSP.
When the stack is broken, it is not clear where the call came from and it causes great difficulties when debugging such code.
In such a situation, the “Step Out” command will be executed incorrectly and with 99% probability will simply start the process for execution instead of stopping at the address of the current procedure call.
I have to double check, but I think the "Step out" is not currently even using the same "smarts" as the callstack.
Originally, both just had the "RSP" (which already becomes tricky, when the code is asm stepping through the "leave" part of the procedure.
Also the RSP has a habit of skipping frames, when you have an optimized fpc RTL (or your own code) with omitted frames (some functions not setting the RSP). Then those functions will be visible, but their caller will be hidden. (Hence the RTL can hide routines from the users code in the stack).
The stack then was improved.
- The stack now can use dwarf to find its parent
- The stack can actually disassemble the machine code, and often find exactly where the code would return, and what would be popped of the stack before.
Of course the disassembling is limited. It only has a known subset of asm that it "interprets". But it manages most of the Window and Linux kernel and system libs (well in my tests, that is)
But the "Step out" has not yet been updated. So even in cases where the stack shows this, the step out may not use it and fail. That is another todo.
----
As for the stack, in cases nothing can be found, your idea is a good last resort. I have seen gdb doing something like that: any code address was shown as a stackframe. So there were many extra/wrong frames. But the correct ones where in there too.