This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: gdb autoloading python-gdb.py
Type: Stage:
Components: Build Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: dilyan.palauzov, dmalcolm, vstinner
Priority: normal Keywords:

Created on 2017-04-25 12:30 by dilyan.palauzov, last changed 2022-04-11 14:58 by admin.

Messages (3)
msg292260 - (view) Author: Дилян Палаузов (dilyan.palauzov) Date: 2017-04-25 12:30
Please install python-gdb.py in $(datarootdir)/gdb/auto-load/$(libdir)/libpython3.5m.so.1.0-gdb.py during "make install", so that programs linked towards libpython3.5m.so.1.0 will auto-load the -gdb.py script, when debugged.

Likewise for the other gdb versions.

An alternative to achieve the same effect is to put python-gdb.py in a .debug_gdb_scripts section (https://sourceware.org/gdb/onlinedocs/gdb/dotdebug_005fgdb_005fscripts-section.html#dotdebug_005fgdb_005fscripts-section), but I don't know if $(strip) removes it.
msg293177 - (view) Author: Дилян Палаузов (dilyan.palauzov) Date: 2017-05-07 00:25
This is what I mean.  I asked at https://sourceware.org/bugzilla/show_bug.cgi?id=21465 how configure.ac is supposed to be tweaked.
----
diff --git a/Makefile.pre.in b/Makefile.pre.in
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1093,6 +1093,8 @@ $(DESTSHARED):
 
 # Install the interpreter with $(VERSION) affixed
 # This goes into $(exec_prefix)
+datadir=@datadir@
+GDB_AUTO_LOAD_SCRIPTS_DIRECTORY=@GDB_AUTO_LOAD_SCRIPTS_DIRECTORY@
 altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
        @for i in $(BINDIR) $(LIBDIR); \
        do \
@@ -1118,6 +1120,11 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
                        $(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
                else \
                        $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
+                       if test ! -d $(DESTDIR)$(GDB_AUTO_LOAD_SCRIPTS_DIRECTORY); then \
+                               echo "Creating directory $(GDB_AUTO_LOAD_SCRIPTS_DIRECTORY)"; \
+                               $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(GDB_AUTO_LOAD_SCRIPTS_DIRECTORY)/$(LIBDIR); \
+                       fi; \
+                       $(INSTALL_SCRIPT) Tools/gdb/libpython.py $(DESTDIR)$(GDB_AUTO_LOAD_SCRIPTS_DIRECTORY)/$(LIBDIR)/$(INSTSONAME)-gdb.py; \
                        if test $(LDLIBRARY) != $(INSTSONAME); then \
                                (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
                        fi \
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -5422,6 +5422,14 @@ if test "$have_getrandom" = yes; then
               [Define to 1 if the getrandom() function is available])
 fi
 
+AC_CHECK_PROG(gdb, gdb, found)
+if test $gdb = found; then
+  GDB_AUTO_LOAD_SCRIPTS_DIRECTORY=$(gdb -q -ex "show data-directory" -ex "show auto-load scripts-directory" -ex quit |sed "1d;2{N;s/\n//g; s/.*\"\(.*\)\".*:\(.*\)./\1 \2/}; /\$datadir/ {s/\(.*\) \$datadir\(.*\)/\1\2/;q}; s/.* \(.\)/\1/")
+else
+  GDB_AUTO_LOAD_SCRIPTS_DIRECTORY='${datadir}/gdb/auto-load'
+fi
+AC_SUBST(GDB_AUTO_LOAD_SCRIPTS_DIRECTORY)
+
 # generate output files
 AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh)
 AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
msg300602 - (view) Author: Дилян Палаузов (dilyan.palauzov) Date: 2017-08-20 13:13
Alternatively install $(INSTSONAME)-gdb.py into ${LIBDIR} .  ldconfig will complain, when called, but this is how gcc and libisl, glib do it .

This is in anycase better than the current approach, as it lets gdb automatically load the -gdb.py file.
History
Date User Action Args
2022-04-11 14:58:45adminsetgithub: 74345
2017-08-22 10:21:32pitrousetnosy: + dmalcolm
2017-08-20 13:13:24dilyan.palauzovsetmessages: + msg300602
2017-05-11 00:40:03vstinnersetnosy: + vstinner
2017-05-07 00:26:32dilyan.palauzovsetcomponents: + Build
2017-05-07 00:26:00dilyan.palauzovsetmessages: + msg293177
2017-04-25 12:31:00dilyan.palauzovcreate