Next: , Previous: ABI, Up: Controlling GDB   [Contents][Index]


22.8 Automatically loading associated files

GDB sometimes reads files with commands and settings automatically, without being explicitly told so by the user. We call this feature auto-loading. While auto-loading is useful for automatically adapting GDB to the needs of your project, it can sometimes produce unexpected results or introduce security risks (e.g., if the file comes from untrusted sources).

There are various kinds of files GDB can automatically load. In addition to these files, GDB supports auto-loading code written in various extension languages. See Auto-loading extensions.

Note that loading of these associated files (including the local .gdbinit file) requires accordingly configured auto-load safe-path (see Auto-loading safe path).

For these reasons, GDB includes commands and options to let you control when to auto-load files and which files should be auto-loaded.

set auto-load off

Globally disable loading of all auto-loaded files. You may want to use this command with the ‘-iex’ option (see Option -init-eval-command) such as:

$ gdb -iex "set auto-load off" untrusted-executable corefile

Be aware that system init file (see System-wide configuration) and init files from your home directory (see Home Directory Init File) still get read (as they come from generally trusted directories). To prevent GDB from auto-loading even those init files, use the -nx option (see Mode Options), in addition to set auto-load no.

show auto-load

Show whether auto-loading of each specific ‘auto-load’ file(s) is enabled or disabled.

(gdb) show auto-load
gdb-scripts:  Auto-loading of canned sequences of commands scripts is on.
libthread-db:  Auto-loading of inferior specific libthread_db is on.
local-gdbinit:  Auto-loading of .gdbinit script from current directory
                is on.
python-scripts:  Auto-loading of Python scripts is on.
safe-path:  List of directories from which it is safe to auto-load files
            is $debugdir:$datadir/auto-load.
scripts-directory:  List of directories from which to load auto-loaded scripts
                    is $debugdir:$datadir/auto-load.
info auto-load

Print whether each specific ‘auto-load’ file(s) have been auto-loaded or not.

(gdb) info auto-load
gdb-scripts:
Loaded  Script
Yes     /home/user/gdb/gdb-gdb.gdb
libthread-db:  No auto-loaded libthread-db.
local-gdbinit:  Local .gdbinit file "/home/user/gdb/.gdbinit" has been
                loaded.
python-scripts:
Loaded  Script
Yes     /home/user/gdb/gdb-gdb.py

These are GDB control commands for the auto-loading:

See set auto-load off.Disable auto-loading globally.
See show auto-load.Show setting of all kinds of files.
See info auto-load.Show state of all kinds of files.
See set auto-load gdb-scripts.Control for GDB command scripts.
See show auto-load gdb-scripts.Show setting of GDB command scripts.
See info auto-load gdb-scripts.Show state of GDB command scripts.
See set auto-load python-scripts.Control for GDB Python scripts.
See show auto-load python-scripts.Show setting of GDB Python scripts.
See info auto-load python-scripts.Show state of GDB Python scripts.
See set auto-load guile-scripts.Control for GDB Guile scripts.
See show auto-load guile-scripts.Show setting of GDB Guile scripts.
See info auto-load guile-scripts.Show state of GDB Guile scripts.
See set auto-load scripts-directory.Control for GDB auto-loaded scripts location.
See show auto-load scripts-directory.Show GDB auto-loaded scripts location.
See add-auto-load-scripts-directory.Add directory for auto-loaded scripts location list.
See set auto-load local-gdbinit.Control for init file in the current directory.
See show auto-load local-gdbinit.Show setting of init file in the current directory.
See info auto-load local-gdbinit.Show state of init file in the current directory.
See set auto-load libthread-db.Control for thread debugging library.
See show auto-load libthread-db.Show setting of thread debugging library.
See info auto-load libthread-db.Show state of thread debugging library.
See set auto-load safe-path.Control directories trusted for automatic loading.
See show auto-load safe-path.Show directories trusted for automatic loading.
See add-auto-load-safe-path.Add directory trusted for automatic loading.

Next: , Previous: ABI, Up: Controlling GDB   [Contents][Index]