5.4.3 Background Execution
gdb's execution commands have two variants: the normal foreground (synchronous) behavior, and a background (asynchronous) behavior. In foreground execution, gdb waits for the program to report that some thread has stopped before prompting for another command. In background execution, gdb immediately gives a command prompt so that you can issue other commands while your program runs.
set target-async on
- Enable asynchronous mode.
set target-async off
- Disable asynchronous mode.
- Show the current target-async setting.
If the target doesn't support async mode, gdb issues an error message if you attempt to use the background execution commands.
To specify background execution, add a
& to the command. For example,
the background form of the
continue command is
c&. The execution commands that accept background execution
- See Starting your Program.
- See Debugging an Already-running Process.
- See step.
- See stepi.
- See next.
- See nexti.
- See continue.
- See finish.
- See until.
Background execution is especially useful in conjunction with non-stop
mode for debugging programs with multiple threads; see Non-Stop Mode.
However, you can also use these commands in the normal all-stop mode with
the restriction that you cannot issue another execution command until the
previous one finishes. Examples of commands that are valid in all-stop
mode while the program is running include
Suspend execution of the running program. In all-stop mode,
interruptstops the whole process, but in non-stop mode, it stops only the current thread. To stop the whole program in non-stop mode, use