Next: , Previous: Debugger Operation, Up: Debuggers

27.6.3 Commands of GUD

GUD provides commands for setting and clearing breakpoints, selecting stack frames, and stepping through the program.

C-x <SPC>
Set a breakpoint on the source line that point is on.

C-x <SPC> (gud-break), when called in a source buffer, sets a debugger breakpoint on the current source line. This command is available only after starting GUD. If you call it in a buffer that is not associated with any debugger subprocess, it signals a error.

The following commands are available both in the GUD interaction buffer and globally, but with different key bindings. The keys starting with C-c are available only in the GUD interaction buffer, while those starting with C-x C-a are available globally. Some of these commands are also available via the tool bar; some are not supported by certain debuggers.

C-c C-l
C-x C-a C-l
Display, in another window, the last source line referred to in the GUD interaction buffer (gud-refresh).
C-c C-s
C-x C-a C-s
Execute the next single line of code (gud-step). If the line contains a function call, execution stops after entering the called function.
C-c C-n
C-x C-a C-n
Execute the next single line of code, stepping across function calls without stopping inside the functions (gud-next).
C-c C-i
C-x C-a C-i
Execute a single machine instruction (gud-stepi).
C-c C-p
C-x C-a C-p
Evaluate the expression at point (gud-print). If Emacs does not print the exact expression that you want, mark it as a region first.
C-c C-r
C-x C-a C-r
Continue execution without specifying any stopping point. The program will run until it hits a breakpoint, terminates, or gets a signal that the debugger is checking for (gud-cont).
C-c C-d
C-x C-a C-d
Delete the breakpoint(s) on the current source line, if any (gud-remove). If you use this command in the GUD interaction buffer, it applies to the line where the program last stopped.
C-c C-t
C-x C-a C-t
Set a temporary breakpoint on the current source line, if any (gud-tbreak). If you use this command in the GUD interaction buffer, it applies to the line where the program last stopped.
C-c <
C-x C-a <
Select the next enclosing stack frame (gud-up). This is equivalent to the GDB command ‘up’.
C-c >
C-x C-a >
Select the next inner stack frame (gud-down). This is equivalent to the GDB command ‘down’.
C-c C-u
C-x C-a C-u
Continue execution to the current line (gud-until). The program will run until it hits a breakpoint, terminates, gets a signal that the debugger is checking for, or reaches the line on which the cursor currently sits.
C-c C-f
C-x C-a C-f
Run the program until the selected stack frame returns or stops for some other reason (gud-finish).

If you are using GDB, these additional key bindings are available:

C-x C-a C-j
Only useful in a source buffer, gud-jump transfers the program's execution point to the current line. In other words, the next line that the program executes will be the one where you gave the command. If the new execution line is in a different function from the previously one, GDB prompts for confirmation since the results may be bizarre. See the GDB manual entry regarding jump for details.
<TAB>
With GDB, complete a symbol name (gud-gdb-complete-command). This key is available only in the GUD interaction buffer.

These commands interpret a numeric argument as a repeat count, when that makes sense.

Because <TAB> serves as a completion command, you can't use it to enter a tab as input to the program you are debugging with GDB. Instead, type C-q <TAB> to enter a tab.