brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.7 KiB · a63b740 Raw
361 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "gtest/gtest.h"10 11#include "Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h"12#include "Plugins/ScriptInterpreter/Python/lldb-python.h"13 14#include "PythonTestSuite.h"15#include <optional>16 17void PythonTestSuite::SetUp() {18  // Although we don't care about concurrency for the purposes of running19  // this test suite, Python requires the GIL to be locked even for20  // deallocating memory, which can happen when you call Py_DECREF or21  // Py_INCREF.  So acquire the GIL for the entire duration of this22  // test suite.23  Py_InitializeEx(0);24  m_gil_state = PyGILState_Ensure();25  python::RunSimpleString("import sys");26}27 28void PythonTestSuite::TearDown() {29  PyGILState_Release(m_gil_state);30 31  // We could call Py_FinalizeEx here, but initializing and finalizing Python is32  // pretty slow, so just keep Python initialized across tests.33}34 35// The following functions are the Pythonic implementations of the required36// callbacks. Because they're defined in libLLDB which we cannot link for the37// unit test, we have a 'default' implementation here.38 39extern "C" PyObject *PyInit__lldb(void) { return nullptr; }40 41llvm::Expected<bool>42lldb_private::python::SWIGBridge::LLDBSwigPythonBreakpointCallbackFunction(43    const char *python_function_name, const char *session_dictionary_name,44    const lldb::StackFrameSP &sb_frame,45    const lldb::BreakpointLocationSP &sb_bp_loc,46    const StructuredDataImpl &args_impl) {47  return false;48}49 50bool lldb_private::python::SWIGBridge::LLDBSwigPythonWatchpointCallbackFunction(51    const char *python_function_name, const char *session_dictionary_name,52    const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp) {53  return false;54}55 56bool lldb_private::python::SWIGBridge::LLDBSwigPythonFormatterCallbackFunction(57    const char *python_function_name, const char *session_dictionary_name,58    lldb::TypeImplSP type_impl_sp) {59  return false;60}61 62bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallTypeScript(63    const char *python_function_name, const void *session_dictionary,64    const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,65    const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval) {66  return false;67}68 69python::PythonObject70lldb_private::python::SWIGBridge::LLDBSwigPythonCreateSyntheticProvider(71    const char *python_class_name, const char *session_dictionary_name,72    const lldb::ValueObjectSP &valobj_sp) {73  return python::PythonObject();74}75 76python::PythonObject77lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject(78    const char *python_class_name, const char *session_dictionary_name,79    lldb::DebuggerSP debugger_sp) {80  return python::PythonObject();81}82 83size_t lldb_private::python::SWIGBridge::LLDBSwigPython_CalculateNumChildren(84    PyObject *implementor, uint32_t max) {85  return 0;86}87 88PyObject *lldb_private::python::SWIGBridge::LLDBSwigPython_GetChildAtIndex(89    PyObject *implementor, uint32_t idx) {90  return nullptr;91}92 93uint32_t94lldb_private::python::SWIGBridge::LLDBSwigPython_GetIndexOfChildWithName(95    PyObject *implementor, const char *child_name) {96  return 0;97}98 99void *100lldb_private::python::LLDBSWIGPython_CastPyObjectToSBData(PyObject *data) {101  return nullptr;102}103 104void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(105    PyObject *data) {106  return nullptr;107}108 109void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBBreakpointLocation(110    PyObject *data) {111  return nullptr;112}113 114void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBAttachInfo(115    PyObject *data) {116  return nullptr;117}118 119void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBLaunchInfo(120    PyObject *data) {121  return nullptr;122}123 124void *125lldb_private::python::LLDBSWIGPython_CastPyObjectToSBError(PyObject *data) {126  return nullptr;127}128 129void *130lldb_private::python::LLDBSWIGPython_CastPyObjectToSBEvent(PyObject *data) {131  return nullptr;132}133 134void *135lldb_private::python::LLDBSWIGPython_CastPyObjectToSBStream(PyObject *data) {136  return nullptr;137}138 139void *140lldb_private::python::LLDBSWIGPython_CastPyObjectToSBFrame(PyObject *data) {141  return nullptr;142}143 144void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBSymbolContext(145    PyObject *data) {146  return nullptr;147}148 149void *150lldb_private::python::LLDBSWIGPython_CastPyObjectToSBValue(PyObject *data) {151  return nullptr;152}153 154void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(155    PyObject *data) {156  return nullptr;157}158 159void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBExecutionContext(160    PyObject *data) {161  return nullptr;162}163 164void *165lldb_private::python::LLDBSWIGPython_CastPyObjectToSBFrameList(PyObject *data) {166  return nullptr;167}168 169lldb::ValueObjectSP170lldb_private::python::SWIGBridge::LLDBSWIGPython_GetValueObjectSPFromSBValue(171    void *data) {172  return nullptr;173}174 175bool lldb_private::python::SWIGBridge::176    LLDBSwigPython_UpdateSynthProviderInstance(PyObject *implementor) {177  return false;178}179 180bool lldb_private::python::SWIGBridge::181    LLDBSwigPython_MightHaveChildrenSynthProviderInstance(182        PyObject *implementor) {183  return false;184}185 186PyObject *187lldb_private::python::SWIGBridge::LLDBSwigPython_GetValueSynthProviderInstance(188    PyObject *implementor) {189  return nullptr;190}191 192bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommand(193    const char *python_function_name, const char *session_dictionary_name,194    lldb::DebuggerSP debugger, const char *args,195    lldb_private::CommandReturnObject &cmd_retobj,196    lldb::ExecutionContextRefSP exe_ctx_ref_sp) {197  return false;198}199 200bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(201    PyObject *implementor, lldb::DebuggerSP debugger, const char *args,202    lldb_private::CommandReturnObject &cmd_retobj,203    lldb::ExecutionContextRefSP exe_ctx_ref_sp) {204  return false;205}206 207bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(208    PyObject *implementor, lldb::DebuggerSP debugger,209    StructuredDataImpl &args_impl,210    lldb_private::CommandReturnObject &cmd_retobj,211    lldb::ExecutionContextRefSP exe_ctx_ref_sp) {212  return false;213}214 215std::optional<std::string>216LLDBSwigPythonGetRepeatCommandForScriptedCommand(PyObject *implementor,217                                                 std::string &command) {218  return std::nullopt;219}220 221StructuredData::DictionarySP222LLDBSwigPythonHandleArgumentCompletionForScriptedCommand(223    PyObject *implementor, std::vector<llvm::StringRef> &args, size_t args_pos,224    size_t pos_in_arg) {225  return {};226}227 228StructuredData::DictionarySP229LLDBSwigPythonHandleOptionArgumentCompletionForScriptedCommand(230    PyObject *implementor, llvm::StringRef &long_options, size_t char_in_arg) {231  return {};232}233 234bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallModuleInit(235    const char *python_module_name, const char *session_dictionary_name,236    lldb::DebuggerSP debugger) {237  return false;238}239 240bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallModuleNewTarget(241    const char *python_module_name, const char *session_dictionary_name,242    lldb::TargetSP target) {243  return false;244}245 246python::PythonObject247lldb_private::python::SWIGBridge::LLDBSWIGPythonCreateOSPlugin(248    const char *python_class_name, const char *session_dictionary_name,249    const lldb::ProcessSP &process_sp) {250  return python::PythonObject();251}252 253python::PythonObject254lldb_private::python::SWIGBridge::LLDBSWIGPython_CreateFrameRecognizer(255    const char *python_class_name, const char *session_dictionary_name) {256  return python::PythonObject();257}258 259PyObject *260lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArguments(261    PyObject *implementor, const lldb::StackFrameSP &frame_sp) {262  return nullptr;263}264 265bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordProcess(266    const char *python_function_name, const char *session_dictionary_name,267    const lldb::ProcessSP &process, std::string &output) {268  return false;269}270 271std::optional<std::string>272lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordThread(273    const char *python_function_name, const char *session_dictionary_name,274    lldb::ThreadSP thread) {275  return std::nullopt;276}277 278bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordTarget(279    const char *python_function_name, const char *session_dictionary_name,280    const lldb::TargetSP &target, std::string &output) {281  return false;282}283 284std::optional<std::string>285lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordFrame(286    const char *python_function_name, const char *session_dictionary_name,287    lldb::StackFrameSP frame) {288  return std::nullopt;289}290 291bool lldb_private::python::SWIGBridge::LLDBSWIGPythonRunScriptKeywordValue(292    const char *python_function_name, const char *session_dictionary_name,293    const lldb::ValueObjectSP &value, std::string &output) {294  return false;295}296 297void *lldb_private::python::SWIGBridge::LLDBSWIGPython_GetDynamicSetting(298    void *module, const char *setting, const lldb::TargetSP &target_sp) {299  return nullptr;300}301 302python::PythonObject303lldb_private::python::SWIGBridge::ToSWIGWrapper(Status &&status) {304  return python::PythonObject();305}306 307python::PythonObject308lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ProcessAttachInfoSP) {309  return python::PythonObject();310}311 312python::PythonObject313lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ProcessLaunchInfoSP) {314  return python::PythonObject();315}316 317python::PythonObject318lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::DataExtractorSP) {319  return python::PythonObject();320}321 322python::PythonObject323lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ExecutionContextRefSP) {324  return python::PythonObject();325}326 327python::PythonObject328lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ThreadPlanSP) {329  return python::PythonObject();330}331 332python::PythonObject333lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ProcessSP) {334  return python::PythonObject();335}336 337python::PythonObject338lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::StackFrameListSP) {339  return python::PythonObject();340}341 342python::PythonObject lldb_private::python::SWIGBridge::ToSWIGWrapper(343    const lldb_private::StructuredDataImpl &) {344  return python::PythonObject();345}346 347python::PythonObject348lldb_private::python::SWIGBridge::ToSWIGWrapper(Event *event) {349  return python::PythonObject();350}351 352python::PythonObject353lldb_private::python::SWIGBridge::ToSWIGWrapper(const Stream *stream) {354  return python::PythonObject();355}356 357python::PythonObject lldb_private::python::SWIGBridge::ToSWIGWrapper(358    std::shared_ptr<lldb::SBStream> stream_sb) {359  return python::PythonObject();360}361