[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / lldb / unittests / ScriptInterpreter / Python / PythonTestSuite.cpp
blob7f3359f6bf26b20c7365c86d233e073190b1f874
1 //===-- PythonTestSuite.cpp -----------------------------------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "gtest/gtest.h"
11 #include "Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h"
12 #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
13 #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h"
14 #include "Plugins/ScriptInterpreter/Python/lldb-python.h"
16 #include "lldb/Host/FileSystem.h"
17 #include "lldb/Host/HostInfo.h"
19 #include "PythonTestSuite.h"
20 #include <optional>
22 using namespace lldb_private;
23 class TestScriptInterpreterPython : public ScriptInterpreterPythonImpl {
24 public:
25 using ScriptInterpreterPythonImpl::Initialize;
28 void PythonTestSuite::SetUp() {
29 FileSystem::Initialize();
30 HostInfoBase::Initialize();
31 // ScriptInterpreterPython::Initialize() depends on HostInfo being
32 // initializedso it can compute the python directory etc.
33 TestScriptInterpreterPython::Initialize();
35 // Although we don't care about concurrency for the purposes of running
36 // this test suite, Python requires the GIL to be locked even for
37 // deallocating memory, which can happen when you call Py_DECREF or
38 // Py_INCREF. So acquire the GIL for the entire duration of this
39 // test suite.
40 m_gil_state = PyGILState_Ensure();
43 void PythonTestSuite::TearDown() {
44 PyGILState_Release(m_gil_state);
46 TestScriptInterpreterPython::Terminate();
47 HostInfoBase::Terminate();
48 FileSystem::Terminate();
51 // The following functions are the Pythonic implementations of the required
52 // callbacks. Because they're defined in libLLDB which we cannot link for the
53 // unit test, we have a 'default' implementation here.
55 extern "C" PyObject *PyInit__lldb(void) { return nullptr; }
57 llvm::Expected<bool>
58 lldb_private::python::SWIGBridge::LLDBSwigPythonBreakpointCallbackFunction(
59 const char *python_function_name, const char *session_dictionary_name,
60 const lldb::StackFrameSP &sb_frame,
61 const lldb::BreakpointLocationSP &sb_bp_loc,
62 const StructuredDataImpl &args_impl) {
63 return false;
66 bool lldb_private::python::SWIGBridge::LLDBSwigPythonWatchpointCallbackFunction(
67 const char *python_function_name, const char *session_dictionary_name,
68 const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp) {
69 return false;
72 bool lldb_private::python::SWIGBridge::LLDBSwigPythonFormatterCallbackFunction(
73 const char *python_function_name, const char *session_dictionary_name,
74 lldb::TypeImplSP type_impl_sp) {
75 return false;
78 bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallTypeScript(
79 const char *python_function_name, const void *session_dictionary,
80 const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,
81 const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval) {
82 return false;
85 python::PythonObject
86 lldb_private::python::SWIGBridge::LLDBSwigPythonCreateSyntheticProvider(
87 const char *python_class_name, const char *session_dictionary_name,
88 const lldb::ValueObjectSP &valobj_sp) {
89 return python::PythonObject();
92 python::PythonObject
93 lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject(
94 const char *python_class_name, const char *session_dictionary_name,
95 lldb::DebuggerSP debugger_sp) {
96 return python::PythonObject();
99 python::PythonObject
100 lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan(
101 const char *python_class_name, const char *session_dictionary_name,
102 const StructuredDataImpl &args_data, std::string &error_string,
103 const lldb::ThreadPlanSP &thread_plan_sp) {
104 return python::PythonObject();
107 bool lldb_private::python::SWIGBridge::LLDBSWIGPythonCallThreadPlan(
108 void *implementor, const char *method_name, Event *event_sp,
109 bool &got_error) {
110 return false;
113 bool lldb_private::python::SWIGBridge::LLDBSWIGPythonCallThreadPlan(
114 void *implementor, const char *method_name, Stream *event_sp,
115 bool &got_error) {
116 return false;
119 python::PythonObject lldb_private::python::SWIGBridge::
120 LLDBSwigPythonCreateScriptedBreakpointResolver(
121 const char *python_class_name, const char *session_dictionary_name,
122 const StructuredDataImpl &args, const lldb::BreakpointSP &bkpt_sp) {
123 return python::PythonObject();
126 unsigned int
127 lldb_private::python::SWIGBridge::LLDBSwigPythonCallBreakpointResolver(
128 void *implementor, const char *method_name,
129 lldb_private::SymbolContext *sym_ctx) {
130 return 0;
133 size_t lldb_private::python::SWIGBridge::LLDBSwigPython_CalculateNumChildren(
134 PyObject *implementor, uint32_t max) {
135 return 0;
138 PyObject *lldb_private::python::SWIGBridge::LLDBSwigPython_GetChildAtIndex(
139 PyObject *implementor, uint32_t idx) {
140 return nullptr;
143 int lldb_private::python::SWIGBridge::LLDBSwigPython_GetIndexOfChildWithName(
144 PyObject *implementor, const char *child_name) {
145 return 0;
148 void *
149 lldb_private::python::LLDBSWIGPython_CastPyObjectToSBData(PyObject *data) {
150 return nullptr;
153 void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(
154 PyObject *data) {
155 return nullptr;
158 void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBAttachInfo(
159 PyObject *data) {
160 return nullptr;
163 void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBLaunchInfo(
164 PyObject *data) {
165 return nullptr;
168 void *
169 lldb_private::python::LLDBSWIGPython_CastPyObjectToSBError(PyObject *data) {
170 return nullptr;
173 void *
174 lldb_private::python::LLDBSWIGPython_CastPyObjectToSBValue(PyObject *data) {
175 return nullptr;
178 void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(
179 PyObject *data) {
180 return nullptr;
183 lldb::ValueObjectSP
184 lldb_private::python::SWIGBridge::LLDBSWIGPython_GetValueObjectSPFromSBValue(
185 void *data) {
186 return nullptr;
189 bool lldb_private::python::SWIGBridge::
190 LLDBSwigPython_UpdateSynthProviderInstance(PyObject *implementor) {
191 return false;
194 bool lldb_private::python::SWIGBridge::
195 LLDBSwigPython_MightHaveChildrenSynthProviderInstance(
196 PyObject *implementor) {
197 return false;
200 PyObject *
201 lldb_private::python::SWIGBridge::LLDBSwigPython_GetValueSynthProviderInstance(
202 PyObject *implementor) {
203 return nullptr;
206 bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommand(
207 const char *python_function_name, const char *session_dictionary_name,
208 lldb::DebuggerSP debugger, const char *args,
209 lldb_private::CommandReturnObject &cmd_retobj,
210 lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
211 return false;
214 bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
215 PyObject *implementor, lldb::DebuggerSP debugger, const char *args,
216 lldb_private::CommandReturnObject &cmd_retobj,
217 lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
218 return false;
221 bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallModuleInit(
222 const char *python_module_name, const char *session_dictionary_name,
223 lldb::DebuggerSP debugger) {
224 return false;
227 python::PythonObject
228 lldb_private::python::SWIGBridge::LLDBSWIGPythonCreateOSPlugin(
229 const char *python_class_name, const char *session_dictionary_name,
230 const lldb::ProcessSP &process_sp) {
231 return python::PythonObject();
234 python::PythonObject
235 lldb_private::python::SWIGBridge::LLDBSWIGPython_CreateFrameRecognizer(
236 const char *python_class_name, const char *session_dictionary_name) {
237 return python::PythonObject();
240 PyObject *
241 lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArguments(
242 PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
243 return nullptr;
246 bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordProcess(
247 const char *python_function_name, const char *session_dictionary_name,
248 const lldb::ProcessSP &process, std::string &output) {
249 return false;
252 std::optional<std::string>
253 lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordThread(
254 const char *python_function_name, const char *session_dictionary_name,
255 lldb::ThreadSP thread) {
256 return std::nullopt;
259 bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordTarget(
260 const char *python_function_name, const char *session_dictionary_name,
261 const lldb::TargetSP &target, std::string &output) {
262 return false;
265 std::optional<std::string>
266 lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordFrame(
267 const char *python_function_name, const char *session_dictionary_name,
268 lldb::StackFrameSP frame) {
269 return std::nullopt;
272 bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordValue(
273 const char *python_function_name, const char *session_dictionary_name,
274 const lldb::ValueObjectSP &value, std::string &output) {
275 return false;
278 void *lldb_private::python::SWIGBridge::LLDBSWIGPython_GetDynamicSetting(
279 void *module, const char *setting, const lldb::TargetSP &target_sp) {
280 return nullptr;
283 python::PythonObject
284 lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedStopHook(
285 lldb::TargetSP target_sp, const char *python_class_name,
286 const char *session_dictionary_name, const StructuredDataImpl &args_impl,
287 Status &error) {
288 return python::PythonObject();
291 bool lldb_private::python::SWIGBridge::LLDBSwigPythonStopHookCallHandleStop(
292 void *implementor, lldb::ExecutionContextRefSP exc_ctx_sp,
293 lldb::StreamSP stream) {
294 return false;
297 python::PythonObject
298 lldb_private::python::SWIGBridge::ToSWIGWrapper(const Status &status) {
299 return python::PythonObject();
302 python::PythonObject
303 lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ProcessAttachInfoSP) {
304 return python::PythonObject();
307 python::PythonObject
308 lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ProcessLaunchInfoSP) {
309 return python::PythonObject();
312 python::PythonObject
313 lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::DataExtractorSP) {
314 return python::PythonObject();
317 python::PythonObject
318 lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ExecutionContextRefSP) {
319 return python::PythonObject();
322 python::PythonObject
323 lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ProcessSP) {
324 return python::PythonObject();
327 python::PythonObject lldb_private::python::SWIGBridge::ToSWIGWrapper(
328 const lldb_private::StructuredDataImpl &) {
329 return python::PythonObject();