Commit graph

2 commits

Author SHA1 Message Date
Tom de Vries
79fcceafcb [gdb/python] Fix check-include-guards check in python-limited-api-missing.h
The check-include-guards check fails for
gdb/python/python-limited-api-missing.h:
...
check-include-guards....................................................Failed
- hook id: check-include-guards
- exit code: 1

gdb/python/python-limited-api-missing.h:22: wrong symbol in ifndef
...

Fix this by using GDB_PYTHON_PYTHON_LIMITED_API_MISSING_H instead of
GDB_PYTHON_LIMITED_API_MISSING_H.
2026-05-15 14:15:22 +02:00
Matthieu Longo
58f83d8471 gdb/python: work around missing symbols not yet part of Python limited API
Most Python API usages in GDB can be migrated to the limited API, except
the following:

- PEP-741's configuration structures and functions, which use opaque
  types. They were originally intended to be part of the Python limited
  API, but some Python core maintainers opposed their inclusion at the
  time.
- PyOS_ReadlineFunctionPointer, a global variable storing a function
  used to override PyOS_StdioReadline(). The signature has remained
  unchanged for a long time.
- PyRun_InteractiveLoop, used to read and execute Python statements when
  embedding an interactive interpreter. Its signature has also remained
  stable for a long time.

Since no limited API alternatives exist for these, and given their long
history of ABI stability, one approach is to expose them in a GDB header
and rely on their continued stability. While this is not without risk,
it seems acceptable given the arguments above. This would remove the
remaining obstacles preventing GDB from being agnostic to the Python
version available at runtime.
That said, issues should be opened on CPython issue tracker to request
that these functions be included in the limited API in future versions.
Last but not least, GDB does not need to officially support the Python
limited API. The '--enable-py-limited-api' option can remain experimental,
with appropriate forewarnings about its limitations and guarantees.

This patch adds a new header, python-limited-api-missing.h, which
exposes symbols not yet part of the Python limited API.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23830
Approved-By: Tom Tromey <tom@tromey.com>
2026-05-15 11:12:32 +01:00