Initialization files

At startup, UDB executes several initialization files, that is text files containing a series of UDB commands. In these files, comments (lines starting with #) and blank lines are ignored.

UDB tries to execute UDB-specific initialization files first but, if one doesn’t exist, UDB falls back to executing a corresponding GDB initialization file. This way, UDB automatically picks up any existing configuration for GDB.

UDB executes the following initialization files (in the specified order):

  1. System-wide initialization files

    • /etc/udbinit

    • /etc/gdbinit (only if /etc/udbinit doesn’t exist)

    The above files are not executed if the -nx option is passed to UDB.

  2. Home-directory initialization files

    • ~/.udbinit

    • ~/.gdbinit (only if ~/.udbinit doesn’t exist)

    The above files are not executed if the -nx or -nh options are passed to UDB.

  3. Local initialization files (current directory)

    • ./.udbinit

    • ./.gdbinit (only if ./.udbinit doesn’t exist)

    The above files are not executed if the -nx option is passed to UDB.

    If the current directory is the home directory, then initialization files are not executed for a second time.

    For security reasons, UDB only loads files from the current directory if the path is explicitly marked as safe by the user. To enable the execution of a single file, add this line to a system-wide or home-directory initialization file, for instance ~/.udbinit:

    add-auto-load-safe-path <PATH-TO-LOCAL-INITIALIZATION-FILE>
    

    To enable the execution of any file in a directory and its descendants, add:

    add-auto-load-safe-path <TRUSTED-DIRECTORY-PATH>
    

    To completely disable this security protection, add:

    set auto-load safe-path /
    

Sharing initialization commands with GDB

Users who need to use both UDB and GDB on the same machine should:

  • Add common commands to a file executed by GDB, for instance ~/.gdbinit.

  • Add UDB-only commands to a file executed by UDB only, for instance ~/.udbinit.

  • Source the file executed by GDB from the one executed by UDB, for instance by adding this line to ~/.udbinit:

    source ~/.gdbinit
    

Interaction with command-line options

UDB processes initialization files and command-line options in the following order:

  1. System-wide initialization files are executed.

  2. Home-directory initialization files are executed.

  3. The --init-eval-command/-iex and --init-command/-ix options are handled in the order they were passed on the command line.

  4. The inferior (that is, the program or LiveRecorder recording) passed on the command line, if any, is loaded.

  5. Local initialization files are executed.

  6. The --eval-command/-ex and --command/-x options are handled in the order they were passed on the command line.