LLDB mainline
lldb-python.h
Go to the documentation of this file.
1//===-- lldb-python.h -------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_SOURCE_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
10#define LLDB_SOURCE_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
11
12// BEGIN FIXME
13// This declaration works around a clang module build failure.
14// It should be deleted ASAP.
15#include "llvm/Support/Error.h"
16static llvm::Expected<bool> *g_fcxx_modules_workaround [[maybe_unused]];
17// END
18
19#include "llvm/Support/Compiler.h"
20#if defined(__linux__)
21// features.h will define _POSIX_C_SOURCE if _GNU_SOURCE is defined. This value
22// may be different from the value that Python defines it to be which results
23// in a warning. Undefine _POSIX_C_SOURCE before including Python.h The same
24// holds for _XOPEN_SOURCE.
25#undef _POSIX_C_SOURCE
26#undef _XOPEN_SOURCE
27#endif
28
29// Include locale before Python so _PY_PORT_CTYPE_UTF8_ISSUE doesn't cause
30// macro redefinitions.
31#if defined(__APPLE__)
32#include <locale>
33#endif
34
35#define LLDB_MINIMUM_PYTHON_VERSION 0x03080000
36
37// Config.h must be included before Python.h so that
38// LLDB_ENABLE_PYTHON_LIMITED_API is defined when pyconfig.h selects the Windows
39// import library via #pragma comment.
40#include "lldb/Host/Config.h"
41
42#if LLDB_ENABLE_PYTHON_LIMITED_API
43// If defined, LLDB will be ABI-compatible with all Python 3 releases from the
44// specified one onward, and can use Limited API introduced up to that version.
45#define Py_LIMITED_API LLDB_MINIMUM_PYTHON_VERSION
46#endif
47
48// Include python for non windows machines
49#include <Python.h>
50
51// Provide a meaningful diagnostic error if someone tries to compile this file
52// with a version of Python we don't support.
53static_assert(PY_VERSION_HEX >= LLDB_MINIMUM_PYTHON_VERSION,
54 "LLDB requires at least Python 3.8");
55
56// PyMemoryView_FromMemory is part of stable ABI but the flag constants are not.
57// See https://github.com/python/cpython/issues/98680
58#ifndef PyBUF_READ
59#define PyBUF_READ 0x100
60#endif
61
62#endif // LLDB_SOURCE_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
#define LLDB_MINIMUM_PYTHON_VERSION
Definition lldb-python.h:35
static llvm::Expected< bool > * g_fcxx_modules_workaround
Definition lldb-python.h:16