Two files are used to initialize GDB and the readline library, respectively.
At startup, GDB reads its initialization file. This is a file of commands, such as option settings, for example, that you tell GDB to run every time it starts up. The initialization file is named .gdbinit on Unix (BSD, Linux, etc.) systems. Some MS-Windows versions of GDB use gdb.ini instead. Empty lines (they do nothing) are allowed, and comments in initialization files start with a
# and continue to the end of the line. GDB executes commands from initialization files and from the command line in the following order:
Commands in $HOME/.gdbinit. This acts as a “global” initialization; settings that should always be used go here.
Command-line options and operands.
Commands in ./.gdbinit. This allows for option settings that apply to a particular program by keeping the file in the same directory as the program’s source code.
Command files specified with the
You may use the
-nx option to make GDB skip the execution of the initialization files.
Just like the Bash shell, GDB uses the readline library to provide command-line history and editing. You may use either
vi- or Emacs-style commands for editing your command line. The readline library reads the file ~/.inputrc to initialize its settings and options. The details are beyond the scope of this book; see the Bash and GDB documentation or the online Info system for the full story. Here is a sample ...