27.6.4 GUD Customization
On startup, GUD runs one of the following hooks: gdb-mode-hook
, if you are using GDB; dbx-mode-hook
, if you are using DBX; sdb-mode-hook
, if you are using SDB; xdb-mode-hook
, if you are using XDB; guiler-mode-hook
for Guile REPL debugging; perldb-mode-hook
, for Perl debugging mode; pdb-mode-hook
, for PDB; jdb-mode-hook
, for JDB. See Hooks.
The gud-def
Lisp macro (see Defining Macros in the Emacs Lisp Reference Manual) provides a convenient way to define an Emacs command that sends a particular command string to the debugger, and set up a key binding for in the GUD interaction buffer:
(gud-def function cmdstring binding docstring)
This defines a command named function
which sends cmdstring
to the debugger process, and gives it the documentation string docstring
. You can then use the command function
in any buffer. If binding
is non-nil
, gud-def
also binds the command to C-c binding
in the GUD bufferβs mode and to C-x C-a binding
generally.
The command string cmdstring
may contain certain β%
β-sequences that stand for data to be filled in at the time function
is called:
β%f
ββ
The name of the current source file. If the current buffer is the GUD buffer, then the current source file is the file that the program stopped in.
β%l
ββ
The number of the current source line. If the current buffer is the GUD buffer, then the current source line is the line that the program stopped in.
β%e
ββ
In transient-mark-mode the text in the region, if it is active. Otherwise the text of the C lvalue or function-call expression at or adjacent to point.
β%a
ββ
The text of the hexadecimal address at or adjacent to point.
β%p
ββ
The numeric argument of the called function, as a decimal number. If the command is used without a numeric argument, β%p
β stands for the empty string.
If you donβt use β%p
β in the command string, the command you define ignores any numeric argument.
β%d
ββ
The name of the directory of the current source file.
β%c
ββ
Fully qualified class name derived from the expression surrounding point (jdb only).