Python has a gdb helper that allows doing python backtraces from gdb
and other such things. We currently don't install it in Python packages,
and also gdb looks in a bogus directory "${prefix}/share/auto-load" (!)
to find autoload files:

(gdb) show auto-load scripts-directory
List of directories from which to load auto-loaded scripts is 
:${prefix}/share/auto-load.
(gdb) set debug auto-load
(gdb) file /usr/local/bin/python3.8
Reading symbols from /usr/local/bin/python3.8...Reading symbols from 
/usr/local/bin/.debug/python3.8.dbg...done.
auto-load: Attempted file "/usr/local/bin/.debug/python3.8.dbg-gdb.gdb" does 
not exist.
auto-load: Searching 'set auto-load scripts-directory' path 
":${prefix}/share/auto-load".
auto-load: Attempted file "/usr/local/bin/.debug/python3.8.dbg-gdb.gdb" does 
not exist.
auto-load: Attempted file 
"${prefix}/share/auto-load/usr/local/bin/.debug/python3.8.dbg-gdb.gdb" does not 
exist.
auto-load: Attempted file "/usr/local/bin/.debug/python3.8.dbg-gdb.py" does not 
exist.
auto-load: Searching 'set auto-load scripts-directory' path 
":${prefix}/share/auto-load".
auto-load: Attempted file "/usr/local/bin/.debug/python3.8.dbg-gdb.py" does not 
exist.
auto-load: Attempted file 
"${prefix}/share/auto-load/usr/local/bin/.debug/python3.8.dbg-gdb.py" does not 
exist.
done.
auto-load: Attempted file "/usr/local/bin/python3.8-gdb.gdb" does not exist.
auto-load: Searching 'set auto-load scripts-directory' path 
":${prefix}/share/auto-load".
auto-load: Attempted file "/usr/local/bin/python3.8-gdb.gdb" does not exist.
auto-load: Attempted file 
"${prefix}/share/auto-load/usr/local/bin/python3.8-gdb.gdb" does not exist.
auto-load: Attempted file "/usr/local/bin/python3.8-gdb.py" does not exist.
auto-load: Searching 'set auto-load scripts-directory' path 
":${prefix}/share/auto-load".
auto-load: Attempted file "/usr/local/bin/python3.8-gdb.py" does not exist.
auto-load: Attempted file 
"${prefix}/share/auto-load/usr/local/bin/python3.8-gdb.py" does not exist.

$ kdump|grep auto-load
 52790 egdb     NAMI  "${prefix}/share/auto-load"
        \^A\0t  \M^C\0\^A\0d\^BS\0)\^Cz3Update sys.path, reload gdb and 
auto-load packages.r\^A\0\0\
       "#set auto-load-safe-path = ~/.gdb/
 52790 egdb     NAMI  
"${prefix}/share/auto-load/usr/local/bin/.debug/python3.8.dbg-gdb.gdb"
 52790 egdb     NAMI  
"${prefix}/share/auto-load/usr/local/bin/.debug/python3.8.dbg-gdb.py"
 52790 egdb     NAMI  
"${prefix}/share/auto-load/usr/local/bin/python3.8-gdb.gdb"
 52790 egdb     NAMI  "${prefix}/share/auto-load/usr/local/bin/python3.8-gdb.py"

Diff below fixes the two problems.

OK?   Here's a simple example of using it:

-----
$ egdb python3.8
...
(gdb) run /usr/local/bin/chardetect 
Starting program: /usr/local/bin/python3.8 /usr/local/bin/chardetect
You are running chardetect interactively. Press CTRL-D twice at the start of a 
blank line to signal the end of your input. If you want help, run chardetect 
--help

^C
Program received signal SIGINT, Interrupt.
_thread_sys_read () at /tmp/-:3
3       /tmp/-: No such file or directory.
(gdb) py-bt
Traceback (most recent call first):
  File "/usr/local/lib/python3.8/site-packages/chardet/cli/chardetect.py", line 
36, in description_of
    for line in lines:
  File "/usr/local/lib/python3.8/site-packages/chardet/cli/chardetect.py", line 
1104, in main
  File "/usr/local/bin/chardetect", line 11, in <module>
    load_entry_point('chardet==4.0.0', 'console_scripts', 'chardetect')()
-----

Index: devel/gdb/Makefile
===================================================================
RCS file: /cvs/ports/devel/gdb/Makefile,v
retrieving revision 1.71
diff -u -p -r1.71 Makefile
--- devel/gdb/Makefile  23 Feb 2021 19:39:14 -0000      1.71
+++ devel/gdb/Makefile  6 Mar 2021 18:24:05 -0000
@@ -4,7 +4,7 @@ COMMENT=        GNU debugger
 CATEGORIES=    devel
 
 DISTNAME=      gdb-7.12.1
-REVISION=      15
+REVISION=      16
 
 HOMEPAGE=      https://www.gnu.org/software/gdb/
 
@@ -21,7 +21,7 @@ MODGNU_CONFIG_GUESS_DIRS=     ${WRKSRC} ${WR
 
 WANTLIB = c expat kvm m curses pthread ${MODPY_WANTLIB} ${COMPILER_LIBCXX} util
 
-COMPILER =             base-clang ports-gcc base-gcc
+COMPILER=      base-clang ports-gcc base-gcc
 
 SEPARATE_BUILD= Yes
 CONFIGURE_STYLE=gnu
@@ -30,6 +30,7 @@ CONFIGURE_ARGS=       --program-prefix=e \
                --disable-sim \
                --without-guile \
                --without-lzma \
+               --with-auto-load-dir=${TRUEPREFIX}/share/gdb/auto-load \
                --enable-target=all \
                --with-python=${MODPY_BIN}
 
Index: lang/python/Makefile.inc
===================================================================
RCS file: /cvs/ports/lang/python/Makefile.inc,v
retrieving revision 1.135
diff -u -p -r1.135 Makefile.inc
--- lang/python/Makefile.inc    29 Dec 2020 23:59:06 -0000      1.135
+++ lang/python/Makefile.inc    6 Mar 2021 18:24:05 -0000
@@ -146,14 +146,14 @@ do-gen:
 post-configure:
        @cd ${WRKSRC} && ${MAKE_PROGRAM} Makefile
 
-ADJ_FILES = ${WRKSRC}/Tools/scripts/pydoc*
+ADJ_FILES = ${WRKSRC}/Tools/scripts/pydoc* ${WRKSRC}/python-gdb.py
 .if ${VERSION} == "2.7"
 ADJ_FILES += ${WRKSRC}/Tools/scripts/2to3
 .endif
 
 post-build:
        perl -pi -e \
-               's@#! */usr/bin/env +python@#!${PREFIX}/bin/python${VERSION}@' \
+               's@#! */usr/bin/(env 
+)?python@#!${PREFIX}/bin/python${VERSION}@' \
                ${ADJ_FILES}
 
 post-install:
@@ -173,6 +173,9 @@ post-install:
        ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/python${VERSION}
        ${INSTALL_DATA} ${FILESDIR}/CHANGES.OpenBSD \
                ${PREFIX}/share/doc/python${VERSION}/CHANGES.OpenBSD
+       ${INSTALL_DATA_DIR} ${PREFIX}/share/gdb/auto-load/usr/local/bin
+       ${INSTALL_SCRIPT} ${WRKSRC}/python-gdb.py \
+               
${PREFIX}/share/gdb/auto-load/usr/local/bin/python${VERSION}-gdb.py
 
 TEST_TARGET=   test
 TEST_FLAGS=    "EXTRATESTOPTS=-w"
Index: lang/python/2.7/pkg/PLIST-main
===================================================================
RCS file: /cvs/ports/lang/python/2.7/pkg/PLIST-main,v
retrieving revision 1.26
diff -u -p -r1.26 PLIST-main
--- lang/python/2.7/pkg/PLIST-main      23 Apr 2020 07:56:01 -0000      1.26
+++ lang/python/2.7/pkg/PLIST-main      6 Mar 2021 18:24:05 -0000
@@ -2503,3 +2503,9 @@ lib/python2.7/zipfile.pyo
 @man man/man1/python2.7.1
 share/doc/python2.7/
 share/doc/python2.7/CHANGES.OpenBSD
+share/gdb/
+share/gdb/auto-load/
+share/gdb/auto-load/usr/
+share/gdb/auto-load/usr/local/
+share/gdb/auto-load/usr/local/bin/
+share/gdb/auto-load/usr/local/bin/python2.7-gdb.py
Index: lang/python/3.8/Makefile
===================================================================
RCS file: /cvs/ports/lang/python/3.8/Makefile,v
retrieving revision 1.13
diff -u -p -r1.13 Makefile
--- lang/python/3.8/Makefile    21 Feb 2021 19:24:26 -0000      1.13
+++ lang/python/3.8/Makefile    6 Mar 2021 18:24:05 -0000
@@ -9,6 +9,7 @@ VERSION =               3.8
 PATCHLEVEL =           .8
 SHARED_LIBS =          python3.8 0.0
 VERSION_SPEC =         >=3.8,<3.9
+REVISION-main =                0
 
 CONFIGURE_ARGS +=      --with-ensurepip=no
 CONFIGURE_ARGS +=      --enable-loadable-sqlite-extensions
Index: lang/python/3.8/pkg/PLIST-main
===================================================================
RCS file: /cvs/ports/lang/python/3.8/pkg/PLIST-main,v
retrieving revision 1.13
diff -u -p -r1.13 PLIST-main
--- lang/python/3.8/pkg/PLIST-main      21 Feb 2021 19:24:26 -0000      1.13
+++ lang/python/3.8/pkg/PLIST-main      6 Mar 2021 18:24:05 -0000
@@ -2788,3 +2788,9 @@ lib/python3.8/zipimport.py
 @man man/man1/python3.8.1
 share/doc/python3.8/
 share/doc/python3.8/CHANGES.OpenBSD
+share/gdb/
+share/gdb/auto-load/
+share/gdb/auto-load/usr/
+share/gdb/auto-load/usr/local/
+share/gdb/auto-load/usr/local/bin/
+share/gdb/auto-load/usr/local/bin/python3.8-gdb.py
Index: lang/python/3.9/pkg/PLIST-main
===================================================================
RCS file: /cvs/ports/lang/python/3.9/pkg/PLIST-main,v
retrieving revision 1.3
diff -u -p -r1.3 PLIST-main
--- lang/python/3.9/pkg/PLIST-main      21 Feb 2021 19:23:21 -0000      1.3
+++ lang/python/3.9/pkg/PLIST-main      6 Mar 2021 18:24:05 -0000
@@ -2840,3 +2840,9 @@ lib/python3.9/zoneinfo/_zoneinfo.py
 @man man/man1/python3.9.1
 share/doc/python3.9/
 share/doc/python3.9/CHANGES.OpenBSD
+share/gdb/
+share/gdb/auto-load/
+share/gdb/auto-load/usr/
+share/gdb/auto-load/usr/local/
+share/gdb/auto-load/usr/local/bin/
+share/gdb/auto-load/usr/local/bin/python3.9-gdb.py

Reply via email to