Skip to content

Make LLDB compatible with the Python Limited C API #151617

@JDevlieghere

Description

@JDevlieghere

Currently, LLDB uses the Python private or unstable API. This means that LLDB only works with the exact same version of Python that LLDB was compiled with. See https://docs.python.org/3/c-api/stable.html for more details.

Previously, we were limited by SWIG, which generated code that wasn't part of the limited API. As of version 4.2, SWIG generates code that's compatible with the Python 3.4 stable API and later.

Currently, the minimum Python version is 3.8. Based on a quick attempt to define Py_LIMITED_API to 0x03080000, we'll need to find replacements for the following identifiers:

  • PyImport_Inittab (Guarded by LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE)
  • PyThreadState (Guarded by !LLDB_USE_PYTHON_SET_INTERRUPT)
  • PyUnicode_AsUTF8AndSize (Stable ABI since version 3.10)
  • PyConfig
  • _Py_IsFinalizing (Stable ABI since version 3.13)
  • Py_buffer (Stable ABI since version 3.11)
  • PyBUF_SIMPLE
  • PyBUF_READ
  • PyObject_Print
  • PyGILState_Check
  • _PyObject_Dump
  • PyRun_SimpleString
  • PyRun_String
  • PyBytes_AS_STRING
  • PyList_GET_SIZE
  • PyTuple_GET_SIZE

This issue tracks the work to migrate over to only using the limited C API in LLDB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lldbmetaissueIssue to collect references to a group of similar or related issues.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions