Say I am in A() and A() calls B(). I just entered A() and I want the program to run until I am in B(). It doesn't have to be a specific function B(). I just want my program to pause whenever it enters a new function. Is there a way to do that?
If you want gdb to resume normal execution, type "continue" or "c". gdb will run until your program ends, your program crashes, or gdb encounters a breakpoint.
If you do accidentally step into a function, you can use the finish command to finish the function immediately and go back to the next line after the function. This will continue running the program until the next breakpoint or until the program ends.
This command continues the debuggee past the current line until the specified source line in the current stack frame. Use this command to avoid single stepping through a loop more than once, or to skip over the execution of uninteresting code.
GDB normally ignores breakpoints when it resumes execution, until at least one instruction has been executed. If it did not do this, you would be unable to proceed past a breakpoint without first disabling the breakpoint. This rule applies whether or not the breakpoint already existed when your program stopped.
For calls, as mentioned at: List of all function calls made in an application :
set confirm off
rbreak .
rbreak
sets a breakpoint for every function that matches a given regular expression, .
matches all functions.
This command might take a while to run for a large executable with lots of functions. But once it finishes, runtime will be efficient.
The exit is trickier, since we can't know at compile time where we will land: How to set a breakpoint in GDB where the function returns?
At How to break on instruction with a specific opcode in GDB? I also provided a script that single steps until a desired instruction is found, which you could use to find callq
. That one has the advantage of not making you wait on a large executable, but execution will be very slow, so the target can't be very far away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With