[PATCH v2 0/9] gdb: more fixes for Python limited C API support

Matthieu Longo
2026-03-03T16:23:47Z

This patch series fixes some of the issues encountered while enabling the Python limited C API in GDB.

Diff with revision 1: https://inbox.sourceware.org/gdb-patches/20260217150259.1391855-1-matthieu.longo@arm.com/
- patches 1,3,4 were already present in revision 1, and I addressed comments from Tom Tromey of revision 1.
- patch 2 is a small refactoring derived from patch 1, and independent of others patches.
- patches 5,6 allows simplification in future patches.
- patches 7,8 are follow-ups on https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=9a84753aa7f8b8939cf4eea9c7f1db4b42e171e1, and simplifies the future migration to heap-allocated types.

All changes were tested by building GDB against the unlimited API of Python 3.10, 3.11, 3.12, 3.13 and 3.14, and the limited API of Python 3.14 (no build regression), and no regressions were observed in the testsuite.

Regards,
Matthieu

Matthieu Longo (9):
gdb: switch tuple object helpers to Python limited API equivalents
gdb: introduce rgb_color type to simplify existing code
gdb: switch bytes object helpers to Python limited API equivalents
gdb: add new helpers for retrieving a type's fully qualified name
gdb/python: allow ref_ptr<T, Policy>::new_reference to accept subclasses of T
gdb/python: flatten functions calling PyObject_New and use gdbpy_ref
gdb/python: accept gdbpy_ref in init helpers and return bool
gdb/python: add gdbpy_dict_wrapper:allocate_dict helper
gdb/python: add accessor helpers for __dict__ in Python extension objects

gdb/Makefile.in | 1 +
gdb/configure | 6 +-
gdb/configure.ac | 6 +-
gdb/python/py-arch.c | 3 +-
gdb/python/py-block.c | 3 +-
gdb/python/py-breakpoint.c | 9 ++-
gdb/python/py-color.c | 17 +++--
gdb/python/py-connection.c | 2 +-
gdb/python/py-corefile.c | 55 +++++++-------
gdb/python/py-disasm.c | 17 ++---
gdb/python/py-event.c | 13 ++--
gdb/python/py-frame.c | 4 +-
gdb/python/py-function.c | 3 +-
gdb/python/py-inferior.c | 56 +++++++--------
gdb/python/py-infthread.c | 22 +++---
gdb/python/py-mi.c | 2 +-
gdb/python/py-micmd.c | 2 +-
gdb/python/py-obj-type.c | 84 ++++++++++++++++++++++
gdb/python/py-obj-type.h | 31 ++++++++
gdb/python/py-objfile.c | 38 +++++-----
gdb/python/py-prettyprint.c | 5 +-
gdb/python/py-progspace.c | 60 ++++++++--------
gdb/python/py-ref.h | 29 +++++++-
gdb/python/py-style.c | 14 ++--
gdb/python/py-symbol.c | 14 ++--
gdb/python/py-type.c | 25 +++----
gdb/python/py-unwind.c | 16 +++--
gdb/python/py-utils.c | 4 +-
gdb/python/py-xmethods.c | 24 +++++--
gdb/python/python-internal.h | 6 +-
gdb/python/python.c | 7 +-
gdb/testsuite/gdb.python/py-disasm.exp.tcl | 8 +--
gdb/testsuite/gdb.python/py-unwind.exp | 2 +-
gdb/tui/tui-io.c | 3 +-
gdb/ui-style.c | 33 ++++-----
gdb/ui-style.h | 38 +++++++++-
gdb/unittests/style-selftests.c | 10 +--
gdbsupport/gdb_ref_ptr.h | 5 +-
38 files changed, 426 insertions(+), 251 deletions(-)
create mode 100644 gdb/python/py-obj-type.c
create mode 100644 gdb/python/py-obj-type.h

--
2.53.0