Debugging with GDB Manual (5900-1473; WDB 6.2; January 2011)

Table Of Contents
For example, to ignore SIGALRM signals while single-stepping, and treat them normally
during normal execution, you could define:
define hook-stop
handle SIGALRM nopass
end
define hook-run
handle SIGALRM pass
end
define hook-continue
handle SIGLARM pass
end
You can define a hook for any single-word command in GDB, and not for command
aliases; Also you should define a hook for the basic command name, for example,
backtrace rather than bt. If an error occurs during the execution of your hook,
execution of GDB commands stops and GDB issues a prompt (before the command that
you actually typed had a chance to run).
If you try to define a hook which does not match any known command, GDB issues a
warning from the define command.
18.3 Command files
A command file for GDB is a file of lines that are GDB commands. Comments (lines
starting with #) may also be included. An empty line in a command file does nothing; it
does not mean to repeat the last command, as it would from the terminal.
When you start GDB, it executes commands from its init files. These are files named
.gdbinit on UNIX. During startup, GDB does the following:
1. Read the init file (if any) in your home directory.
4
2. Process command-line options and operands.
3. Read the init file (if any) in the current working directory,
4. Read the init file (if any) in the /tmp directory if the GDB_PROCESS_TMP_GDBINIT
environment variable is set.
5. Read command files specified by the `-x' option.
The init file in your home directory can set options (such as `set complaints') that affect
subsequent processing of command line options and operands. Init files are not executed
if you use the `-nx' option (see “Choosing modes” (page 25)).
It can be useful to create a `.gdbinit' file in the directory where you are debugging an
application. This file will set the actions that apply for this application.
For example, one might add lines like:
dir /usr/src/path/to/source/files
to add source directories or:
break fatal
18.3 Command files 291