1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
|
//===-- PythonTestSuite.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "gtest/gtest.h"
#include "Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h"
#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
#include "PythonTestSuite.h"
#include <optional>
void PythonTestSuite::SetUp() {
// Although we don't care about concurrency for the purposes of running
// this test suite, Python requires the GIL to be locked even for
// deallocating memory, which can happen when you call Py_DECREF or
// Py_INCREF. So acquire the GIL for the entire duration of this
// test suite.
Py_InitializeEx(0);
m_gil_state = PyGILState_Ensure();
PyRun_SimpleString("import sys");
}
void PythonTestSuite::TearDown() {
PyGILState_Release(m_gil_state);
// We could call Py_FinalizeEx here, but initializing and finalizing Python is
// pretty slow, so just keep Python initialized across tests.
}
// The following functions are the Pythonic implementations of the required
// callbacks. Because they're defined in libLLDB which we cannot link for the
// unit test, we have a 'default' implementation here.
extern "C" PyObject *PyInit__lldb(void) { return nullptr; }
llvm::Expected<bool>
lldb_private::python::SWIGBridge::LLDBSwigPythonBreakpointCallbackFunction(
const char *python_function_name, const char *session_dictionary_name,
const lldb::StackFrameSP &sb_frame,
const lldb::BreakpointLocationSP &sb_bp_loc,
const StructuredDataImpl &args_impl) {
return false;
}
bool lldb_private::python::SWIGBridge::LLDBSwigPythonWatchpointCallbackFunction(
const char *python_function_name, const char *session_dictionary_name,
const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp) {
return false;
}
bool lldb_private::python::SWIGBridge::LLDBSwigPythonFormatterCallbackFunction(
const char *python_function_name, const char *session_dictionary_name,
lldb::TypeImplSP type_impl_sp) {
return false;
}
bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallTypeScript(
const char *python_function_name, const void *session_dictionary,
const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,
const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval) {
return false;
}
python::PythonObject
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateSyntheticProvider(
const char *python_class_name, const char *session_dictionary_name,
const lldb::ValueObjectSP &valobj_sp) {
return python::PythonObject();
}
python::PythonObject
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject(
const char *python_class_name, const char *session_dictionary_name,
lldb::DebuggerSP debugger_sp) {
return python::PythonObject();
}
python::PythonObject
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan(
const char *python_class_name, const char *session_dictionary_name,
const StructuredDataImpl &args_data, std::string &error_string,
const lldb::ThreadPlanSP &thread_plan_sp) {
return python::PythonObject();
}
bool lldb_private::python::SWIGBridge::LLDBSWIGPythonCallThreadPlan(
void *implementor, const char *method_name, Event *event_sp,
bool &got_error) {
return false;
}
bool lldb_private::python::SWIGBridge::LLDBSWIGPythonCallThreadPlan(
void *implementor, const char *method_name, Stream *event_sp,
bool &got_error) {
return false;
}
python::PythonObject lldb_private::python::SWIGBridge::
LLDBSwigPythonCreateScriptedBreakpointResolver(
const char *python_class_name, const char *session_dictionary_name,
const StructuredDataImpl &args, const lldb::BreakpointSP &bkpt_sp) {
return python::PythonObject();
}
unsigned int
lldb_private::python::SWIGBridge::LLDBSwigPythonCallBreakpointResolver(
void *implementor, const char *method_name,
lldb_private::SymbolContext *sym_ctx) {
return 0;
}
size_t lldb_private::python::SWIGBridge::LLDBSwigPython_CalculateNumChildren(
PyObject *implementor, uint32_t max) {
return 0;
}
PyObject *lldb_private::python::SWIGBridge::LLDBSwigPython_GetChildAtIndex(
PyObject *implementor, uint32_t idx) {
return nullptr;
}
int lldb_private::python::SWIGBridge::LLDBSwigPython_GetIndexOfChildWithName(
PyObject *implementor, const char *child_name) {
return 0;
}
void *
lldb_private::python::LLDBSWIGPython_CastPyObjectToSBData(PyObject *data) {
return nullptr;
}
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(
PyObject *data) {
return nullptr;
}
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBAttachInfo(
PyObject *data) {
return nullptr;
}
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBLaunchInfo(
PyObject *data) {
return nullptr;
}
void *
lldb_private::python::LLDBSWIGPython_CastPyObjectToSBError(PyObject *data) {
return nullptr;
}
void *
lldb_private::python::LLDBSWIGPython_CastPyObjectToSBValue(PyObject *data) {
return nullptr;
}
void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(
PyObject *data) {
return nullptr;
}
lldb::ValueObjectSP
lldb_private::python::SWIGBridge::LLDBSWIGPython_GetValueObjectSPFromSBValue(
void *data) {
return nullptr;
}
bool lldb_private::python::SWIGBridge::
LLDBSwigPython_UpdateSynthProviderInstance(PyObject *implementor) {
return false;
}
bool lldb_private::python::SWIGBridge::
LLDBSwigPython_MightHaveChildrenSynthProviderInstance(
PyObject *implementor) {
return false;
}
PyObject *
lldb_private::python::SWIGBridge::LLDBSwigPython_GetValueSynthProviderInstance(
PyObject *implementor) {
return nullptr;
}
bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommand(
const char *python_function_name, const char *session_dictionary_name,
lldb::DebuggerSP debugger, const char *args,
lldb_private::CommandReturnObject &cmd_retobj,
lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
return false;
}
bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
PyObject *implementor, lldb::DebuggerSP debugger, const char *args,
lldb_private::CommandReturnObject &cmd_retobj,
lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
return false;
}
bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
PyObject *implementor, lldb::DebuggerSP debugger,
StructuredDataImpl &args_impl,
lldb_private::CommandReturnObject &cmd_retobj,
lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
return false;
}
bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallModuleInit(
const char *python_module_name, const char *session_dictionary_name,
lldb::DebuggerSP debugger) {
return false;
}
python::PythonObject
lldb_private::python::SWIGBridge::LLDBSWIGPythonCreateOSPlugin(
const char *python_class_name, const char *session_dictionary_name,
const lldb::ProcessSP &process_sp) {
return python::PythonObject();
}
python::PythonObject
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedObject(
const char *python_class_name, const char *session_dictionary_name,
lldb::ExecutionContextRefSP exe_ctx_sp, const StructuredDataImpl &args_impl,
std::string &error_string) {
return python::PythonObject();
}
python::PythonObject
lldb_private::python::SWIGBridge::LLDBSWIGPython_CreateFrameRecognizer(
const char *python_class_name, const char *session_dictionary_name) {
return python::PythonObject();
}
PyObject *
lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArguments(
PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
return nullptr;
}
bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordProcess(
const char *python_function_name, const char *session_dictionary_name,
const lldb::ProcessSP &process, std::string &output) {
return false;
}
std::optional<std::string>
lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordThread(
const char *python_function_name, const char *session_dictionary_name,
lldb::ThreadSP thread) {
return std::nullopt;
}
bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordTarget(
const char *python_function_name, const char *session_dictionary_name,
const lldb::TargetSP &target, std::string &output) {
return false;
}
std::optional<std::string>
lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordFrame(
const char *python_function_name, const char *session_dictionary_name,
lldb::StackFrameSP frame) {
return std::nullopt;
}
bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordValue(
const char *python_function_name, const char *session_dictionary_name,
const lldb::ValueObjectSP &value, std::string &output) {
return false;
}
void *lldb_private::python::SWIGBridge::LLDBSWIGPython_GetDynamicSetting(
void *module, const char *setting, const lldb::TargetSP &target_sp) {
return nullptr;
}
python::PythonObject
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedStopHook(
lldb::TargetSP target_sp, const char *python_class_name,
const char *session_dictionary_name, const StructuredDataImpl &args_impl,
Status &error) {
return python::PythonObject();
}
bool lldb_private::python::SWIGBridge::LLDBSwigPythonStopHookCallHandleStop(
void *implementor, lldb::ExecutionContextRefSP exc_ctx_sp,
lldb::StreamSP stream) {
return false;
}
python::PythonObject
lldb_private::python::SWIGBridge::ToSWIGWrapper(const Status &status) {
return python::PythonObject();
}
python::PythonObject
lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ProcessAttachInfoSP) {
return python::PythonObject();
}
python::PythonObject
lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ProcessLaunchInfoSP) {
return python::PythonObject();
}
python::PythonObject
lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::DataExtractorSP) {
return python::PythonObject();
}
python::PythonObject
lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ExecutionContextRefSP) {
return python::PythonObject();
}
|