Say that main() calls foo() which calls bar(). Obviously foo() and bar() are functions defined by the user/programmer. Also, say that these functions are called in the middle of the caller's function.
If I am in Foo() and I suddenly step into bar() accidentally, how do I leave bar() and continue Foo()'s immediate instruction after the call is made in Gdb?
I tried to use the "finish" command, but I've seen it finish foo()'s function call and return me back to main.
Also I used the "ni" command only when program counter points to the "call bar()" instruction inside foo(), but that didn't work since it's not a library function. I assume "ni" is used to skip library functions.
For now, the only idea I have is to create a breakpoint to the instruction after the "call bar()", but I feel like there's a better way to do this. Is there?
Thanks in advance.
Finish
works fine for me. Even GDB manual says "Continue running until just after function in the selected stack frame returns." about theFinish
command – The Philomath