17.3. Initialization Files

 < Day Day Up > 

Two files are used to initialize GDB and the readline library, respectively.

17.3.1. The .gdbinit File

At startup, GDB reads its initialization file. This is a file of commands, such as option settings, 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:

  1. Commands in $HOME/.gdbinit. This acts as a "global" initialization; settings that should always be used go here.

  2. Command-line options and operands.

  3. 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.

  4. Command files specified with the -x option.

You may use the -nx option to make GDB skip the execution of the initialization files.

17.3.2. The .inputrc File

Just like the Bash shell (see Chapter 4), 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 .inputrc file:

     set editing-mode vi                Use vi editor commands     set horizontal-scroll-mode On      Scroll line left/right as cursor moves along it     control-h: backward-delete-char    Use ^H as backspace character     set comment-begin #                For Bash, # starts comments     set expand-tilde On                Expand ~ notation     "\C-r": redraw-current-line        Make ^R redraw the current input line

     < Day Day Up > 


    Unix in a Nutshell
    Unix in a Nutshell, Fourth Edition
    ISBN: 0596100299
    EAN: 2147483647
    Year: 2005
    Pages: 201

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net