gdb automatically loads the gdb CLI scripts (either Python or Scheme) by looking at the directory trees embedded in directories in the scripts-directory search path. For each downloadable executable or shared object, gdb looks for scripts with the name objfile-gdb.gdb (or objfile-gdb.py or objfile-gdb.scm ).
One way to automatically download gdb extensions for python is to download the python-gdb.py file that you downloaded under one of the directories in your path to the script files. For example, the python2.7-dbg package on Ubuntu installs these files:
-rwxr-xr-x /usr/lib/debug/usr/bin/python2.7-gdb.py lrwxrwxrwx /usr/lib/debug/usr/lib/libpython2.7.so.1.0-gdb.py -> ../bin/python2.7-gdb.py
Here's a gdb session that shows how the python2.7-gdb.py script loads automatically when I start debugging the /usr/bin/python executable:
(gdb) show auto-load scripts-directory List of directories from which to load auto-loaded scripts is $debugdir:$datadir/auto-load. (gdb) set debug auto-load (gdb) file /usr/bin/python Reading symbols from /usr/bin/python...Reading symbols from /usr/lib/debug//usr/bin/python2.7...done. auto-load: Attempted file "/usr/lib/debug/usr/bin/python2.7-gdb.gdb" does not exist. auto-load: Expanded $-variables to "/usr/lib/debug:/usr/share/gdb/auto-load". auto-load: Searching 'set auto-load scripts-directory' path "$debugdir:$datadir/auto-load". auto-load: Attempted file "/usr/share/gdb/auto-load/usr/lib/debug/usr/bin/python2.7-gdb.gdb" does not exist. auto-load: Attempted file "/usr/lib/debug/usr/bin/python2.7-gdb.py" exists. auto-load: Loading python script "/usr/lib/debug/usr/bin/python2.7-gdb.py" by extension for objfile "/usr/lib/debug/usr/bin/python2.7".
source share