23.4 Auto-loading extensions

GDB provides two mechanisms for automatically loading extensions when a new object file is read (for example, due to the file command, or because the inferior has loaded a shared library): objfile-gdb.ext and the .debug_gdb_scripts section of modern file formats like ELF.

objfile-gdb.ext file:    The objfile-gdb.ext file
.debug_gdb_scripts section:    The .debug_gdb_scripts section
Which flavor to choose?:   

The auto-loading feature is useful for supplying application-specific debugging commands and features.

Auto-loading can be enabled or disabled, and the list of auto-loaded scripts can be printed. See the ‘auto-loading’ section of each extension language for more information. For GDB command files see Auto-loading sequences. For Python files see Python Auto-loading.

Note that loading of this script file also requires accordingly configured auto-load safe-path (see Auto-loading safe path).