[Lldb-commits] [lldb] r356971 - [Python] Define empty SWIG wrapper for unit testin"

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 25 18:11:15 PDT 2019


Author: jdevlieghere
Date: Mon Mar 25 18:11:15 2019
New Revision: 356971

URL: http://llvm.org/viewvc/llvm-project?rev=356971&view=rev
Log:
[Python] Define empty SWIG wrapper for unit testin"

The python plugin uses wrappers generated by swig. For the symbols to be
available, we'd need to link against liblldb, which is not an option
because the symbols could conflict with the static library we are
testing. Instead we define the symbols ourselves in the unit test.

Modified:
    lldb/trunk/source/API/CMakeLists.txt
    lldb/trunk/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
    lldb/trunk/unittests/ScriptInterpreter/Python/CMakeLists.txt
    lldb/trunk/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Modified: lldb/trunk/source/API/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/CMakeLists.txt?rev=356971&r1=356970&r2=356971&view=diff
==============================================================================
--- lldb/trunk/source/API/CMakeLists.txt (original)
+++ lldb/trunk/source/API/CMakeLists.txt Mon Mar 25 18:11:15 2019
@@ -4,6 +4,11 @@ endif()
 
 get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS)
 
+if(NOT LLDB_DISABLE_PYTHON)
+  get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
+  set(lldb_python_wrapper ${lldb_scripts_dir}/LLDBWrapPython.cpp)
+endif()
+
 add_lldb_library(liblldb SHARED
   SBAddress.cpp
   SBAttachInfo.cpp

Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt?rev=356971&r1=356970&r2=356971&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt Mon Mar 25 18:11:15 2019
@@ -11,16 +11,10 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windo
   endif()
 endif()
 
-if(NOT LLDB_DISABLE_PYTHON)
-  get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
-  set(lldb_python_wrapper ${lldb_scripts_dir}/LLDBWrapPython.cpp)
-endif()
-
 add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
   PythonDataObjects.cpp
   PythonExceptionState.cpp
   ScriptInterpreterPython.cpp
-  ${lldb_python_wrapper}
 
   LINK_LIBS
     lldbBreakpoint
@@ -32,24 +26,3 @@ add_lldb_library(lldbPluginScriptInterpr
   LINK_COMPONENTS
     Support
   )
-
-if(lldb_python_wrapper)
-  add_dependencies(lldbPluginScriptInterpreterPython swig_wrapper)
-
-  if (MSVC)
-    set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
-  else()
-    set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
-  endif()
-
-  set_source_files_properties(${lldb_python_wrapper} PROPERTIES GENERATED ON)
-  if (CLANG_CL)
-    set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING
-      PROPERTY COMPILE_FLAGS " -Wno-unused-function")
-  endif()
-  if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND
-      NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
-    set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING
-      PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual")
-  endif ()
-endif()

Modified: lldb/trunk/unittests/ScriptInterpreter/Python/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/ScriptInterpreter/Python/CMakeLists.txt?rev=356971&r1=356970&r2=356971&view=diff
==============================================================================
--- lldb/trunk/unittests/ScriptInterpreter/Python/CMakeLists.txt (original)
+++ lldb/trunk/unittests/ScriptInterpreter/Python/CMakeLists.txt Mon Mar 25 18:11:15 2019
@@ -7,7 +7,7 @@ add_lldb_unittest(ScriptInterpreterPytho
     lldbHost
     lldbPluginScriptInterpreterPython
     ${PYTHON_LIBRARY}
-    ${lldb_python_wrapper}
   LINK_COMPONENTS
     Support
   )
+  
\ No newline at end of file

Modified: lldb/trunk/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp?rev=356971&r1=356970&r2=356971&view=diff
==============================================================================
--- lldb/trunk/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp (original)
+++ lldb/trunk/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp Mon Mar 25 18:11:15 2019
@@ -45,3 +45,190 @@ void PythonTestSuite::TearDown() {
   HostInfoBase::Terminate();
   FileSystem::Terminate();
 }
+
+// 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.
+
+#if PY_MAJOR_VERSION >= 3
+extern "C" PyObject *PyInit__lldb(void) { return nullptr; }
+#define LLDBSwigPyInit PyInit__lldb
+#else
+extern "C" void init_lldb(void) {}
+#define LLDBSwigPyInit init_lldb
+#endif
+
+extern "C" bool LLDBSwigPythonBreakpointCallbackFunction(
+    const char *python_function_name, const char *session_dictionary_name,
+    const lldb::StackFrameSP &sb_frame,
+    const lldb::BreakpointLocationSP &sb_bp_loc) {
+  return false;
+}
+
+extern "C" bool LLDBSwigPythonWatchpointCallbackFunction(
+    const char *python_function_name, const char *session_dictionary_name,
+    const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp) {
+  return false;
+}
+
+extern "C" bool LLDBSwigPythonCallTypeScript(
+    const char *python_function_name, void *session_dictionary,
+    const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,
+    const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval) {
+  return false;
+}
+
+extern "C" void *
+LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name,
+                                      const char *session_dictionary_name,
+                                      const lldb::ValueObjectSP &valobj_sp) {
+  return nullptr;
+}
+
+extern "C" void *
+LLDBSwigPythonCreateCommandObject(const char *python_class_name,
+                                  const char *session_dictionary_name,
+                                  const lldb::DebuggerSP debugger_sp) {
+  return nullptr;
+}
+
+extern "C" void *LLDBSwigPythonCreateScriptedThreadPlan(
+    const char *python_class_name, const char *session_dictionary_name,
+    const lldb::ThreadPlanSP &thread_plan_sp) {
+  return nullptr;
+}
+
+extern "C" bool LLDBSWIGPythonCallThreadPlan(void *implementor,
+                                             const char *method_name,
+                                             Event *event_sp, bool &got_error) {
+  return false;
+}
+
+extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver(
+    const char *python_class_name, const char *session_dictionary_name,
+    lldb_private::StructuredDataImpl *args, lldb::BreakpointSP &bkpt_sp) {
+  return nullptr;
+}
+
+extern "C" unsigned int
+LLDBSwigPythonCallBreakpointResolver(void *implementor, const char *method_name,
+                                     lldb_private::SymbolContext *sym_ctx) {
+  return 0;
+}
+
+extern "C" size_t LLDBSwigPython_CalculateNumChildren(void *implementor,
+                                                      uint32_t max) {
+  return 0;
+}
+
+extern "C" void *LLDBSwigPython_GetChildAtIndex(void *implementor,
+                                                uint32_t idx) {
+  return nullptr;
+}
+
+extern "C" int LLDBSwigPython_GetIndexOfChildWithName(void *implementor,
+                                                      const char *child_name) {
+  return 0;
+}
+
+extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data) {
+  return nullptr;
+}
+
+extern lldb::ValueObjectSP
+LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data) {
+  return nullptr;
+}
+
+extern "C" bool LLDBSwigPython_UpdateSynthProviderInstance(void *implementor) {
+  return false;
+}
+
+extern "C" bool
+LLDBSwigPython_MightHaveChildrenSynthProviderInstance(void *implementor) {
+  return false;
+}
+
+extern "C" void *
+LLDBSwigPython_GetValueSynthProviderInstance(void *implementor) {
+  return nullptr;
+}
+
+extern "C" bool
+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;
+}
+
+extern "C" bool
+LLDBSwigPythonCallCommandObject(void *implementor, lldb::DebuggerSP &debugger,
+                                const char *args,
+                                lldb_private::CommandReturnObject &cmd_retobj,
+                                lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
+  return false;
+}
+
+extern "C" bool
+LLDBSwigPythonCallModuleInit(const char *python_module_name,
+                             const char *session_dictionary_name,
+                             lldb::DebuggerSP &debugger) {
+  return false;
+}
+
+extern "C" void *
+LLDBSWIGPythonCreateOSPlugin(const char *python_class_name,
+                             const char *session_dictionary_name,
+                             const lldb::ProcessSP &process_sp) {
+  return nullptr;
+}
+
+extern "C" void *
+LLDBSWIGPython_CreateFrameRecognizer(const char *python_class_name,
+                                     const char *session_dictionary_name) {
+  return nullptr;
+}
+
+extern "C" void *
+LLDBSwigPython_GetRecognizedArguments(void *implementor,
+                                      const lldb::StackFrameSP &frame_sp) {
+  return nullptr;
+}
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordProcess(
+    const char *python_function_name, const char *session_dictionary_name,
+    lldb::ProcessSP &process, std::string &output) {
+  return false;
+}
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordThread(
+    const char *python_function_name, const char *session_dictionary_name,
+    lldb::ThreadSP &thread, std::string &output) {
+  return false;
+}
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordTarget(
+    const char *python_function_name, const char *session_dictionary_name,
+    lldb::TargetSP &target, std::string &output) {
+  return false;
+}
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordFrame(
+    const char *python_function_name, const char *session_dictionary_name,
+    lldb::StackFrameSP &frame, std::string &output) {
+  return false;
+}
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordValue(
+    const char *python_function_name, const char *session_dictionary_name,
+    lldb::ValueObjectSP &value, std::string &output) {
+  return false;
+}
+
+extern "C" void *
+LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting,
+                                 const lldb::TargetSP &target_sp) {
+  return nullptr;
+}




More information about the lldb-commits mailing list