Debugging with GDB Manual The GNU Source-Level Debugger (769148-001, March 2014)
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 20)).
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
to set breakpoints on fatal error routines or diagnostic routines.
On some configurations of GDB, the init file is known by a different name (these are typically
environments where a specialized form of GDB may need to coexist with other forms, hence a
different name for the specialized version's init file). These are the environments with special
init file names:
• VxWorks (Wind River Systems real-time OS): .vxgdbinit
• OS68K (Enea Data Systems real-time OS): .os68gdbinit
• ES-1800 (Ericsson Telecom AB M68000 emulator): .esgdbinit
You can also request the execution of a command file with the source command:
source filename Execute the command file filename.
The lines in a command file are executed sequentially. They are not printed as they are executed.
An error in any command terminates execution of the command file.
Commands that would ask for confirmation if used interactively proceed without asking when used
in a command file. Many GDB commands that normally print messages to say what they are doing
omit the messages when called from command files.
4
Commands for controlled output
During the execution of a command file or a user-defined command, normal GDB output is
suppressed; the only output that appears is what is explicitly printed by the commands in the
definition. This section describes three commands useful for generating exactly the output you want.
echo text Print text. Nonprinting characters can be included in text
using C escape sequences, such as \n to print a newline.
No newline is printed unless you specify one. In addition
to the standard C escape sequences, a backslash followed
by a space stands for a space. This is useful for displaying
a string with spaces at the beginning or the end, since
leading and trailing spaces are otherwise trimmed from all
arguments. To print and foo = , use the command echo
\ and foo = \ .
A backslash at the end of text can be used, as in C, to
continue the command onto subsequent lines. For example,
echo This is some text\n\
which is continued\n\
onto several lines.\n
produces the same output as
echo This is some text\n
echo which is continued\n
echo onto several lines.\n
4. On DOS/Windows systems, the home directory is the one pointed to by the HOME environment variable.
222 Canned Sequences of Commands