Thursday, October 31, 2019

Re: gdb: Use Python 3

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);
++}
+

No comments:

Post a Comment