Next: dotdebug_gdb_scripts section, Up: Auto-loading extensions [Contents][Index]

#### 23.4.1 The `objfile-gdb.ext` File

When a new object file is read, GDB looks for a file named `objfile-gdb.ext` (we call it script-name below), where objfile is the object file’s name and where ext is the file extension for the extension language:

``objfile-gdb.gdb``

  GDB’s own command language

``objfile-gdb.py``

  Python

``objfile-gdb.scm``

  Guile

script-name is formed by ensuring that the file name of objfile is absolute, following all symlinks, and resolving `.` and `..` components, and appending the `-gdb.ext` suffix. If this file exists and is readable, GDB will evaluate it as a script in the specified extension language.

If this file does not exist, then GDB will look for script-name file in all of the directories as specified below. (On MS-Windows/MS-DOS, the drive letter of the executable’s leading directories is converted to a one-letter subdirectory, i.e. `d:/usr/bin/` is converted to `/d/usr/bin/`, because Windows filesystems disallow colons in file names.)

Note that loading of these files requires an accordingly configured `auto-load safe-path` (see Auto-loading safe path).

For object files using `.exe` suffix GDB tries to load first the scripts normally according to its `.exe` filename. But if no scripts are found GDB also tries script filenames matching the object file without its `.exe` suffix. This `.exe` stripping is case insensitive and it is attempted on any platform. This makes the script filenames compatible between Unix and MS-Windows hosts.

`set auto-load scripts-directory [directories]`

  Control GDB auto-loaded scripts location. Multiple directory entries may be delimited by the host platform path separator in use (‘`:`’ on Unix, ‘`;`’ on MS-Windows and MS-DOS).

  Each entry here needs to be covered also by the security setting `set auto-load safe-path` (see set auto-load safe-path).

  This variable defaults to `$debugdir:$datadir/auto-load`. The default `set auto-load safe-path` value can be also overriden by GDB configuration option `--with-auto-load-dir`.

  Any reference to `$debugdir` will get replaced by debug-file-directory value (see Separate Debug Files) and any reference to `$datadir` will get replaced by data-directory which is determined at GDB startup (see Data Files). `$debugdir` and `$datadir` must be placed as a directory component — either alone or delimited by `/` or `\` directory separators, depending on the host platform.

  The list of directories uses path separator (‘`:`’ on GNU and Unix systems, ‘`;`’ on MS-Windows and MS-DOS) to separate directories, similarly to the `PATH` environment variable.

`show auto-load scripts-directory`

  Show GDB auto-loaded scripts location.

`add-auto-load-scripts-directory [directories…]`

  Add an entry (or list of entries) to the list of auto-loaded scripts locations. Multiple entries may be delimited by the host platform path separator in use.

GDB does not track which files it has already auto-loaded this way. GDB will load the associated script every time the corresponding objfile is opened. So your `-gdb.ext` file should be careful to avoid errors if it is evaluated more than once.

Next: dotdebug_gdb_scripts section, Up: Auto-loading extensions [Contents][Index]