On Tue, Oct 22, 2019 at 10:14:11PM +0200, Klemens Nanni wrote:
> Another step in deprecating Python 2;  our 7.12.1 requires an upstream
> commit contained in at least 8.1.50 since gdb uses a private Python API.
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=23252
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=aeab512851bf6ed623d1c6c4305b6ce05e51a10c
> 
> I've been running with this for a while in regular usage, but would be
> happy to see wider testing.
> 
> Feedback?
Diff below now actually contains the patch, so I guess noone tried it yet.

I want to get rid of Python 2 and GDB has been behaving well with this
diff so far, so I'd like to commit this soon eventually.

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/gdb/Makefile,v
retrieving revision 1.62
diff -u -p -r1.62 Makefile
--- Makefile    17 Oct 2019 17:10:26 -0000      1.62
+++ Makefile    22 Oct 2019 19:55:27 -0000
@@ -4,7 +4,7 @@ COMMENT=        GNU debugger
 CATEGORIES=    devel
 
 DISTNAME=      gdb-7.12.1
-REVISION=      8
+REVISION=      9
 
 HOMEPAGE=      https://www.gnu.org/software/gdb/
 
@@ -35,6 +35,8 @@ CONFIGURE_ARGS=       --program-prefix=e \
 USE_GMAKE=     Yes
 
 MODULES +=     lang/python
+MODPY_VERSION =        ${MODPY_DEFAULT_VERSION_3}
+
 LIB_DEPENDS += ${MODPY_LIB_DEPENDS}
 TEST_DEPENDS +=        devel/dejagnu
 MODPY_BUILDDEP = No
Index: patches/patch-gdb_python_python_c
===================================================================
RCS file: patches/patch-gdb_python_python_c
diff -N patches/patch-gdb_python_python_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_python_python_c   22 Oct 2019 19:35:10 -0000
@@ -0,0 +1,47 @@
+$OpenBSD$
+
+"Fix build issue with Python 3.7"; git: 
aeab512851bf6ed623d1c6c4305b6ce05e51a10c
+
+Index: gdb/python/python.c
+--- gdb/python/python.c.orig
++++ gdb/python/python.c
+@@ -1622,7 +1622,18 @@ finalize_python (void *ignore)
+ 
+   restore_active_ext_lang (previous_active);
+ }
++
++#ifdef IS_PY3K
++/* This is called via the PyImport_AppendInittab mechanism called
++   during initialization, to make the built-in _gdb module known to
++   Python.  */
++PyMODINIT_FUNC
++init__gdb_module (void)
++{
++  return PyModule_Create (&python_GdbModuleDef);
++}
+ #endif
++#endif
+ 
+ /* Provide a prototype to silence -Wmissing-prototypes.  */
+ extern initialize_file_ftype _initialize_python;
+@@ -1743,6 +1754,9 @@ message == an error message without a stack will be pr
+      remain alive for the duration of the program's execution, so
+      it is not freed after this call.  */
+   Py_SetProgramName (progname_copy);
++
++  /* Define _gdb as a built-in module.  */
++  PyImport_AppendInittab ("_gdb", init__gdb_module);
+ #else
+   Py_SetProgramName (progname);
+ #endif
+@@ -1752,9 +1766,7 @@ message == an error message without a stack will be pr
+   PyEval_InitThreads ();
+ 
+ #ifdef IS_PY3K
+-  gdb_module = PyModule_Create (&python_GdbModuleDef);
+-  /* Add _gdb module to the list of known built-in modules.  */
+-  _PyImport_FixupBuiltin (gdb_module, "_gdb");
++  gdb_module = PyImport_ImportModule ("_gdb");
+ #else
+   gdb_module = Py_InitModule ("_gdb", python_GdbMethods);
+ #endif
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/devel/gdb/pkg/PLIST,v
retrieving revision 1.19
diff -u -p -r1.19 PLIST
--- pkg/PLIST   1 Nov 2018 20:36:09 -0000       1.19
+++ pkg/PLIST   22 Oct 2019 19:44:41 -0000
@@ -26,54 +26,58 @@ share/gdb/
 share/gdb/python/
 share/gdb/python/gdb/
 share/gdb/python/gdb/FrameDecorator.py
-share/gdb/python/gdb/FrameDecorator.pyc
 share/gdb/python/gdb/FrameIterator.py
-share/gdb/python/gdb/FrameIterator.pyc
 share/gdb/python/gdb/__init__.py
-share/gdb/python/gdb/__init__.pyc
+${MODPY_COMMENT}share/gdb/python/gdb/${MODPY_PYCACHE}/
+share/gdb/python/gdb/${MODPY_PYCACHE}FrameDecorator.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/${MODPY_PYCACHE}FrameIterator.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/${MODPY_PYCACHE}__init__.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/${MODPY_PYCACHE}frames.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/${MODPY_PYCACHE}printing.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/${MODPY_PYCACHE}prompt.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/${MODPY_PYCACHE}types.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/${MODPY_PYCACHE}unwinder.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/${MODPY_PYCACHE}xmethod.${MODPY_PYC_MAGIC_TAG}pyc
 share/gdb/python/gdb/command/
 share/gdb/python/gdb/command/__init__.py
-share/gdb/python/gdb/command/__init__.pyc
+${MODPY_COMMENT}share/gdb/python/gdb/command/${MODPY_PYCACHE}/
+share/gdb/python/gdb/command/${MODPY_PYCACHE}__init__.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/command/${MODPY_PYCACHE}explore.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/command/${MODPY_PYCACHE}frame_filters.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/command/${MODPY_PYCACHE}pretty_printers.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/command/${MODPY_PYCACHE}prompt.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/command/${MODPY_PYCACHE}type_printers.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/command/${MODPY_PYCACHE}unwinders.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/command/${MODPY_PYCACHE}xmethods.${MODPY_PYC_MAGIC_TAG}pyc
 share/gdb/python/gdb/command/explore.py
-share/gdb/python/gdb/command/explore.pyc
 share/gdb/python/gdb/command/frame_filters.py
-share/gdb/python/gdb/command/frame_filters.pyc
 share/gdb/python/gdb/command/pretty_printers.py
-share/gdb/python/gdb/command/pretty_printers.pyc
 share/gdb/python/gdb/command/prompt.py
-share/gdb/python/gdb/command/prompt.pyc
 share/gdb/python/gdb/command/type_printers.py
-share/gdb/python/gdb/command/type_printers.pyc
 share/gdb/python/gdb/command/unwinders.py
-share/gdb/python/gdb/command/unwinders.pyc
 share/gdb/python/gdb/command/xmethods.py
-share/gdb/python/gdb/command/xmethods.pyc
 share/gdb/python/gdb/frames.py
-share/gdb/python/gdb/frames.pyc
 share/gdb/python/gdb/function/
 share/gdb/python/gdb/function/__init__.py
-share/gdb/python/gdb/function/__init__.pyc
+${MODPY_COMMENT}share/gdb/python/gdb/function/${MODPY_PYCACHE}/
+share/gdb/python/gdb/function/${MODPY_PYCACHE}__init__.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/function/${MODPY_PYCACHE}as_string.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/function/${MODPY_PYCACHE}caller_is.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/function/${MODPY_PYCACHE}strfns.${MODPY_PYC_MAGIC_TAG}pyc
 share/gdb/python/gdb/function/as_string.py
-share/gdb/python/gdb/function/as_string.pyc
 share/gdb/python/gdb/function/caller_is.py
-share/gdb/python/gdb/function/caller_is.pyc
 share/gdb/python/gdb/function/strfns.py
-share/gdb/python/gdb/function/strfns.pyc
 share/gdb/python/gdb/printer/
 share/gdb/python/gdb/printer/__init__.py
-share/gdb/python/gdb/printer/__init__.pyc
+${MODPY_COMMENT}share/gdb/python/gdb/printer/${MODPY_PYCACHE}/
+share/gdb/python/gdb/printer/${MODPY_PYCACHE}__init__.${MODPY_PYC_MAGIC_TAG}pyc
+share/gdb/python/gdb/printer/${MODPY_PYCACHE}bound_registers.${MODPY_PYC_MAGIC_TAG}pyc
 share/gdb/python/gdb/printer/bound_registers.py
-share/gdb/python/gdb/printer/bound_registers.pyc
 share/gdb/python/gdb/printing.py
-share/gdb/python/gdb/printing.pyc
 share/gdb/python/gdb/prompt.py
-share/gdb/python/gdb/prompt.pyc
 share/gdb/python/gdb/types.py
-share/gdb/python/gdb/types.pyc
 share/gdb/python/gdb/unwinder.py
-share/gdb/python/gdb/unwinder.pyc
 share/gdb/python/gdb/xmethod.py
-share/gdb/python/gdb/xmethod.pyc
 share/gdb/syscalls/
 share/gdb/syscalls/aarch64-linux.xml
 share/gdb/syscalls/amd64-linux.xml

Reply via email to