[Lldb-commits] [lldb] 7406d23 - [lldb/python] Fix (some) dangling pointers in our glue code

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 20 00:42:52 PST 2021


Author: Pavel Labath
Date: 2021-12-20T09:42:08+01:00
New Revision: 7406d236d873d74b01c3cef285e5d9012dcef151

URL: https://github.com/llvm/llvm-project/commit/7406d236d873d74b01c3cef285e5d9012dcef151
DIFF: https://github.com/llvm/llvm-project/commit/7406d236d873d74b01c3cef285e5d9012dcef151.diff

LOG: [lldb/python] Fix (some) dangling pointers in our glue code

This starts to fix the other half of the lifetime problems in this code
-- dangling references. SB objects created on the stack will go away
when the function returns, which is a problem if the python code they
were meant for stashes a reference to them somewhere.  Most of the time
this goes by unnoticed, as the code rarely has a reason to store these,
but in case it does, we shouldn't respond by crashing.

This patch fixes the management for a couple of SB objects (Debugger,
Frame, Thread). The SB objects are now created on the heap, and
their ownership is immediately passed on to SWIG, which will ensure they
are destroyed when the last python reference goes away. I will handle
the other objects in separate patches.

I include one test which demonstrates the lifetime issue for SBDebugger.
Strictly speaking, one should create a test case for each of these
objects and each of the contexts they are being used. That would require
figuring out how to persist (and later access) each of these objects.
Some of those may involve a lot of hoop-jumping (we can run python code
from within a frame-format string). I don't think that is
necessary/worth it since the new wrapper functions make it very hard to
get this wrong.

Differential Revision: https://reviews.llvm.org/D115925

Added: 
    lldb/test/API/commands/command/script/persistence.py

Modified: 
    lldb/bindings/python/python-swigsafecast.swig
    lldb/bindings/python/python-wrapper.swig
    lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
    lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
    lldb/test/API/commands/command/script/TestCommandScript.py
    lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/bindings/python/python-swigsafecast.swig b/lldb/bindings/python/python-swigsafecast.swig
index 87abe0b3f1872..25c2f44106bc4 100644
--- a/lldb/bindings/python/python-swigsafecast.swig
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -5,18 +5,6 @@ PyObject *SBTypeToSWIGWrapper(lldb::SBEvent &event_sb) {
   return SWIG_NewPointerObj(&event_sb, SWIGTYPE_p_lldb__SBEvent, 0);
 }
 
-PyObject *SBTypeToSWIGWrapper(lldb::SBThread &thread_sb) {
-  return SWIG_NewPointerObj(&thread_sb, SWIGTYPE_p_lldb__SBThread, 0);
-}
-
-PyObject *SBTypeToSWIGWrapper(lldb::SBFrame &frame_sb) {
-  return SWIG_NewPointerObj(&frame_sb, SWIGTYPE_p_lldb__SBFrame, 0);
-}
-
-PyObject *SBTypeToSWIGWrapper(lldb::SBDebugger &debugger_sb) {
-  return SWIG_NewPointerObj(&debugger_sb, SWIGTYPE_p_lldb__SBDebugger, 0);
-}
-
 PyObject *SBTypeToSWIGWrapper(lldb::SBWatchpoint &watchpoint_sb) {
   return SWIG_NewPointerObj(&watchpoint_sb, SWIGTYPE_p_lldb__SBWatchpoint, 0);
 }
@@ -89,5 +77,20 @@ PythonObject ToSWIGWrapper(const StructuredDataImpl &data_impl) {
   return ToSWIGWrapper(std::make_unique<lldb::SBStructuredData>(data_impl));
 }
 
+PythonObject ToSWIGWrapper(lldb::ThreadSP thread_sp) {
+  return ToSWIGHelper(new lldb::SBThread(std::move(thread_sp)),
+                      SWIGTYPE_p_lldb__SBThread);
+}
+
+PythonObject ToSWIGWrapper(lldb::StackFrameSP frame_sp) {
+  return ToSWIGHelper(new lldb::SBFrame(std::move(frame_sp)),
+                      SWIGTYPE_p_lldb__SBFrame);
+}
+
+PythonObject ToSWIGWrapper(lldb::DebuggerSP debugger_sp) {
+  return ToSWIGHelper(new lldb::SBDebugger(std::move(debugger_sp)),
+                      SWIGTYPE_p_lldb__SBDebugger);
+}
+
 } // namespace python
 } // namespace lldb_private

diff  --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig
index 0e857197a5c54..b03d7c02eaa15 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -23,7 +23,6 @@ llvm::Expected<bool> lldb_private::LLDBSwigPythonBreakpointCallbackFunction(
     const lldb_private::StructuredDataImpl &args_impl) {
   using namespace llvm;
 
-  lldb::SBFrame sb_frame(frame_sp);
   lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp);
 
   PyErr_Cleaner py_err_cleaner(true);
@@ -38,7 +37,7 @@ llvm::Expected<bool> lldb_private::LLDBSwigPythonBreakpointCallbackFunction(
   else
     return arg_info.takeError();
 
-  PythonObject frame_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_frame));
+  PythonObject frame_arg = ToSWIGWrapper(frame_sp);
   PythonObject bp_loc_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_bp_loc));
 
   auto result = [&]() -> Expected<PythonObject> {
@@ -71,7 +70,6 @@ llvm::Expected<bool> lldb_private::LLDBSwigPythonBreakpointCallbackFunction(
 bool lldb_private::LLDBSwigPythonWatchpointCallbackFunction(
     const char *python_function_name, const char *session_dictionary_name,
     const lldb::StackFrameSP &frame_sp, const lldb::WatchpointSP &wp_sp) {
-  lldb::SBFrame sb_frame(frame_sp);
   lldb::SBWatchpoint sb_wp(wp_sp);
 
   bool stop_at_watchpoint = true;
@@ -86,7 +84,7 @@ bool lldb_private::LLDBSwigPythonWatchpointCallbackFunction(
   if (!pfunc.IsAllocated())
     return stop_at_watchpoint;
 
-  PythonObject frame_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_frame));
+  PythonObject frame_arg = ToSWIGWrapper(frame_sp);
   PythonObject wp_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_wp));
   PythonObject result = pfunc(frame_arg, wp_arg, dict);
 
@@ -194,7 +192,7 @@ void *lldb_private::LLDBSwigPythonCreateSyntheticProvider(
 
 void *lldb_private::LLDBSwigPythonCreateCommandObject(
     const char *python_class_name, const char *session_dictionary_name,
-    const lldb::DebuggerSP debugger_sp) {
+    lldb::DebuggerSP debugger_sp) {
   if (python_class_name == NULL || python_class_name[0] == '\0' ||
       !session_dictionary_name)
     Py_RETURN_NONE;
@@ -208,9 +206,7 @@ void *lldb_private::LLDBSwigPythonCreateCommandObject(
   if (!pfunc.IsAllocated())
     return nullptr;
 
-  lldb::SBDebugger debugger_sb(debugger_sp);
-  PythonObject debugger_arg(PyRefType::Owned, SBTypeToSWIGWrapper(debugger_sb));
-  PythonObject result = pfunc(debugger_arg, dict);
+  PythonObject result = pfunc(ToSWIGWrapper(std::move(debugger_sp)), dict);
 
   if (result.IsAllocated())
     return result.release();
@@ -809,11 +805,10 @@ void *lldb_private::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *
 
 bool lldb_private::LLDBSwigPythonCallCommand(
     const char *python_function_name, const char *session_dictionary_name,
-    lldb::DebuggerSP &debugger, const char *args,
+    lldb::DebuggerSP debugger, const char *args,
     lldb_private::CommandReturnObject &cmd_retobj,
     lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
   lldb::SBCommandReturnObject cmd_retobj_sb(cmd_retobj);
-  lldb::SBDebugger debugger_sb(debugger);
   lldb::SBExecutionContext exe_ctx_sb(exe_ctx_ref_sp);
 
   PyErr_Cleaner py_err_cleaner(true);
@@ -830,7 +825,7 @@ bool lldb_private::LLDBSwigPythonCallCommand(
     llvm::consumeError(argc.takeError());
     return false;
   }
-  PythonObject debugger_arg(PyRefType::Owned, SBTypeToSWIGWrapper(debugger_sb));
+  PythonObject debugger_arg = ToSWIGWrapper(std::move(debugger));
   PythonObject exe_ctx_arg(PyRefType::Owned, SBTypeToSWIGWrapper(exe_ctx_sb));
   PythonObject cmd_retobj_arg(PyRefType::Owned,
                               SBTypeToSWIGWrapper(cmd_retobj_sb));
@@ -844,11 +839,10 @@ bool lldb_private::LLDBSwigPythonCallCommand(
 }
 
 bool lldb_private::LLDBSwigPythonCallCommandObject(
-    PyObject * implementor, lldb::DebuggerSP & debugger, const char *args,
+    PyObject *implementor, lldb::DebuggerSP debugger, const char *args,
     lldb_private::CommandReturnObject &cmd_retobj,
     lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
   lldb::SBCommandReturnObject cmd_retobj_sb(cmd_retobj);
-  lldb::SBDebugger debugger_sb(debugger);
   lldb::SBExecutionContext exe_ctx_sb(exe_ctx_ref_sp);
 
   PyErr_Cleaner py_err_cleaner(true);
@@ -859,12 +853,12 @@ bool lldb_private::LLDBSwigPythonCallCommandObject(
   if (!pfunc.IsAllocated())
     return false;
 
-  PythonObject debugger_arg(PyRefType::Owned, SBTypeToSWIGWrapper(debugger_sb));
   PythonObject exe_ctx_arg(PyRefType::Owned, SBTypeToSWIGWrapper(exe_ctx_sb));
   PythonObject cmd_retobj_arg(PyRefType::Owned,
                               SBTypeToSWIGWrapper(cmd_retobj_sb));
 
-  pfunc(debugger_arg, PythonString(args), exe_ctx_arg, cmd_retobj_arg);
+  pfunc(ToSWIGWrapper(std::move(debugger)), PythonString(args), exe_ctx_arg,
+        cmd_retobj_arg);
 
   return true;
 }
@@ -922,8 +916,7 @@ PyObject *lldb_private::LLDBSwigPython_GetRecognizedArguments(
     PyObject * implementor, const lldb::StackFrameSP &frame_sp) {
   static char callee_name[] = "get_recognized_arguments";
 
-  lldb::SBFrame frame_sb(frame_sp);
-  PyObject *arg = SBTypeToSWIGWrapper(frame_sb);
+  PythonObject arg = ToSWIGWrapper(frame_sp);
 
   PythonString str(callee_name);
   PyObject *result =
@@ -973,14 +966,12 @@ bool lldb_private::LLDBSWIGPythonRunScriptKeywordProcess(
   return true;
 }
 
-bool lldb_private::LLDBSWIGPythonRunScriptKeywordThread(
+llvm::Optional<std::string> lldb_private::LLDBSWIGPythonRunScriptKeywordThread(
     const char *python_function_name, const char *session_dictionary_name,
-    lldb::ThreadSP &thread, std::string &output)
-
-{
+    lldb::ThreadSP thread) {
   if (python_function_name == NULL || python_function_name[0] == '\0' ||
       !session_dictionary_name)
-    return false;
+    return llvm::None;
 
   PyErr_Cleaner py_err_cleaner(true);
 
@@ -990,15 +981,11 @@ bool lldb_private::LLDBSWIGPythonRunScriptKeywordThread(
       python_function_name, dict);
 
   if (!pfunc.IsAllocated())
-    return false;
+    return llvm::None;
 
-  lldb::SBThread thread_sb(thread);
-  PythonObject thread_arg(PyRefType::Owned, SBTypeToSWIGWrapper(thread_sb));
-  auto result = pfunc(thread_arg, dict);
+  auto result = pfunc(ToSWIGWrapper(std::move(thread)), dict);
 
-  output = result.Str().GetString().str();
-
-  return true;
+  return result.Str().GetString().str();
 }
 
 bool lldb_private::LLDBSWIGPythonRunScriptKeywordTarget(
@@ -1026,14 +1013,12 @@ bool lldb_private::LLDBSWIGPythonRunScriptKeywordTarget(
   return true;
 }
 
-bool lldb_private::LLDBSWIGPythonRunScriptKeywordFrame(
+llvm::Optional<std::string> lldb_private::LLDBSWIGPythonRunScriptKeywordFrame(
     const char *python_function_name, const char *session_dictionary_name,
-    lldb::StackFrameSP &frame, std::string &output)
-
-{
+    lldb::StackFrameSP frame) {
   if (python_function_name == NULL || python_function_name[0] == '\0' ||
       !session_dictionary_name)
-    return false;
+    return llvm::None;
 
   PyErr_Cleaner py_err_cleaner(true);
 
@@ -1043,15 +1028,11 @@ bool lldb_private::LLDBSWIGPythonRunScriptKeywordFrame(
       python_function_name, dict);
 
   if (!pfunc.IsAllocated())
-    return false;
+    return llvm::None;
 
-  lldb::SBFrame frame_sb(frame);
-  PythonObject frame_arg(PyRefType::Owned, SBTypeToSWIGWrapper(frame_sb));
-  auto result = pfunc(frame_arg, dict);
+  auto result = pfunc(ToSWIGWrapper(std::move(frame)), dict);
 
-  output = result.Str().GetString().str();
-
-  return true;
+  return result.Str().GetString().str();
 }
 
 bool lldb_private::LLDBSWIGPythonRunScriptKeywordValue(
@@ -1081,7 +1062,7 @@ bool lldb_private::LLDBSWIGPythonRunScriptKeywordValue(
 
 bool lldb_private::LLDBSwigPythonCallModuleInit(
     const char *python_module_name, const char *session_dictionary_name,
-    lldb::DebuggerSP &debugger) {
+    lldb::DebuggerSP debugger) {
   std::string python_function_name_string = python_module_name;
   python_function_name_string += ".__lldb_init_module";
   const char *python_function_name = python_function_name_string.c_str();
@@ -1098,9 +1079,7 @@ bool lldb_private::LLDBSwigPythonCallModuleInit(
   if (!pfunc.IsAllocated())
     return true;
 
-  lldb::SBDebugger debugger_sb(debugger);
-  PythonObject debugger_arg(PyRefType::Owned, SBTypeToSWIGWrapper(debugger_sb));
-  pfunc(debugger_arg, dict);
+  pfunc(ToSWIGWrapper(std::move(debugger)), dict);
 
   return true;
 }

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
index 56365a9b6fba4..2bb69dc477313 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
@@ -90,7 +90,7 @@ LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name,
 
 void *LLDBSwigPythonCreateCommandObject(const char *python_class_name,
                                         const char *session_dictionary_name,
-                                        const lldb::DebuggerSP debugger_sp);
+                                        lldb::DebuggerSP debugger_sp);
 
 void *LLDBSwigPythonCreateScriptedThreadPlan(
     const char *python_class_name, const char *session_dictionary_name,
@@ -137,18 +137,18 @@ PyObject *LLDBSwigPython_GetValueSynthProviderInstance(PyObject *implementor);
 
 bool LLDBSwigPythonCallCommand(const char *python_function_name,
                                const char *session_dictionary_name,
-                               lldb::DebuggerSP &debugger, const char *args,
+                               lldb::DebuggerSP debugger, const char *args,
                                lldb_private::CommandReturnObject &cmd_retobj,
                                lldb::ExecutionContextRefSP exe_ctx_ref_sp);
 
 bool LLDBSwigPythonCallCommandObject(
-    PyObject *implementor, lldb::DebuggerSP &debugger, const char *args,
+    PyObject *implementor, lldb::DebuggerSP debugger, const char *args,
     lldb_private::CommandReturnObject &cmd_retobj,
     lldb::ExecutionContextRefSP exe_ctx_ref_sp);
 
 bool LLDBSwigPythonCallModuleInit(const char *python_module_name,
                                   const char *session_dictionary_name,
-                                  lldb::DebuggerSP &debugger);
+                                  lldb::DebuggerSP debugger);
 
 void *LLDBSWIGPythonCreateOSPlugin(const char *python_class_name,
                                    const char *session_dictionary_name,
@@ -166,20 +166,20 @@ bool LLDBSWIGPythonRunScriptKeywordProcess(const char *python_function_name,
                                            const lldb::ProcessSP &process,
                                            std::string &output);
 
-bool LLDBSWIGPythonRunScriptKeywordThread(const char *python_function_name,
-                                          const char *session_dictionary_name,
-                                          lldb::ThreadSP &thread,
-                                          std::string &output);
+llvm::Optional<std::string>
+LLDBSWIGPythonRunScriptKeywordThread(const char *python_function_name,
+                                     const char *session_dictionary_name,
+                                     lldb::ThreadSP thread);
 
 bool LLDBSWIGPythonRunScriptKeywordTarget(const char *python_function_name,
                                           const char *session_dictionary_name,
                                           const lldb::TargetSP &target,
                                           std::string &output);
 
-bool LLDBSWIGPythonRunScriptKeywordFrame(const char *python_function_name,
-                                         const char *session_dictionary_name,
-                                         lldb::StackFrameSP &frame,
-                                         std::string &output);
+llvm::Optional<std::string>
+LLDBSWIGPythonRunScriptKeywordFrame(const char *python_function_name,
+                                    const char *session_dictionary_name,
+                                    lldb::StackFrameSP frame);
 
 bool LLDBSWIGPythonRunScriptKeywordValue(const char *python_function_name,
                                          const char *session_dictionary_name,

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 9187129ab0c00..6afa4742698bd 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -2521,7 +2521,6 @@ bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
 bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
     const char *impl_function, Thread *thread, std::string &output,
     Status &error) {
-  bool ret_val;
   if (!thread) {
     error.SetErrorString("no thread");
     return false;
@@ -2531,16 +2530,16 @@ bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
     return false;
   }
 
-  {
-    ThreadSP thread_sp(thread->shared_from_this());
-    Locker py_lock(this,
-                   Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
-    ret_val = LLDBSWIGPythonRunScriptKeywordThread(
-        impl_function, m_dictionary_name.c_str(), thread_sp, output);
-    if (!ret_val)
-      error.SetErrorString("python script evaluation failed");
+  Locker py_lock(this,
+                 Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
+  if (llvm::Optional<std::string> result = LLDBSWIGPythonRunScriptKeywordThread(
+          impl_function, m_dictionary_name.c_str(),
+          thread->shared_from_this())) {
+    output = std::move(*result);
+    return true;
   }
-  return ret_val;
+  error.SetErrorString("python script evaluation failed");
+  return false;
 }
 
 bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
@@ -2571,7 +2570,6 @@ bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
 bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
     const char *impl_function, StackFrame *frame, std::string &output,
     Status &error) {
-  bool ret_val;
   if (!frame) {
     error.SetErrorString("no frame");
     return false;
@@ -2581,16 +2579,16 @@ bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
     return false;
   }
 
-  {
-    StackFrameSP frame_sp(frame->shared_from_this());
-    Locker py_lock(this,
-                   Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
-    ret_val = LLDBSWIGPythonRunScriptKeywordFrame(
-        impl_function, m_dictionary_name.c_str(), frame_sp, output);
-    if (!ret_val)
-      error.SetErrorString("python script evaluation failed");
+  Locker py_lock(this,
+                 Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
+  if (llvm::Optional<std::string> result = LLDBSWIGPythonRunScriptKeywordFrame(
+          impl_function, m_dictionary_name.c_str(),
+          frame->shared_from_this())) {
+    output = std::move(*result);
+    return true;
   }
-  return ret_val;
+  error.SetErrorString("python script evaluation failed");
+  return false;
 }
 
 bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
@@ -2655,7 +2653,6 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule(
   }
 
   ScriptInterpreterIORedirect &io_redirect = **io_redirect_or_error;
-  lldb::DebuggerSP debugger_sp = m_debugger.shared_from_this();
 
   // Before executing Python code, lock the GIL.
   Locker py_lock(this,
@@ -2792,7 +2789,8 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule(
   // if we are here, everything worked
   // call __lldb_init_module(debugger,dict)
   if (!LLDBSwigPythonCallModuleInit(module_name.c_str(),
-                                    m_dictionary_name.c_str(), debugger_sp)) {
+                                    m_dictionary_name.c_str(),
+                                    m_debugger.shared_from_this())) {
     error.SetErrorString("calling __lldb_init_module failed");
     return false;
   }

diff  --git a/lldb/test/API/commands/command/script/TestCommandScript.py b/lldb/test/API/commands/command/script/TestCommandScript.py
index 975a0a538ed67..33e6a00a404f8 100644
--- a/lldb/test/API/commands/command/script/TestCommandScript.py
+++ b/lldb/test/API/commands/command/script/TestCommandScript.py
@@ -165,3 +165,9 @@ def cleanup():
         self.runCmd('command script add -f bug11569 bug11569')
         # This should not crash.
         self.runCmd('bug11569', check=False)
+
+    def test_persistence(self):
+        self.runCmd("command script import persistence.py")
+        self.runCmd("command script add -f persistence.save_debugger save_debugger")
+        self.expect("save_debugger", substrs=[str(self.dbg)])
+        self.expect("script str(persistence.debugger_copy)", substrs=[str(self.dbg)])

diff  --git a/lldb/test/API/commands/command/script/persistence.py b/lldb/test/API/commands/command/script/persistence.py
new file mode 100644
index 0000000000000..bc08b4f4dcf48
--- /dev/null
+++ b/lldb/test/API/commands/command/script/persistence.py
@@ -0,0 +1,9 @@
+import lldb
+
+debugger_copy = None
+
+def save_debugger(debugger, command, context, result, internal_dict):
+    global debugger_copy
+    debugger_copy = debugger
+    result.AppendMessage(str(debugger))
+    result.SetStatus(lldb.eReturnStatusSuccessFinishResult)

diff  --git a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
index c27fc037bce2d..837f6cbf4dfa7 100644
--- a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -88,7 +88,7 @@ void *lldb_private::LLDBSwigPythonCreateSyntheticProvider(
 
 void *lldb_private::LLDBSwigPythonCreateCommandObject(
     const char *python_class_name, const char *session_dictionary_name,
-    const lldb::DebuggerSP debugger_sp) {
+    lldb::DebuggerSP debugger_sp) {
   return nullptr;
 }
 
@@ -172,14 +172,14 @@ PyObject *lldb_private::LLDBSwigPython_GetValueSynthProviderInstance(
 
 bool lldb_private::LLDBSwigPythonCallCommand(
     const char *python_function_name, const char *session_dictionary_name,
-    lldb::DebuggerSP &debugger, const char *args,
+    lldb::DebuggerSP debugger, const char *args,
     lldb_private::CommandReturnObject &cmd_retobj,
     lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
   return false;
 }
 
 bool lldb_private::LLDBSwigPythonCallCommandObject(
-    PyObject *implementor, lldb::DebuggerSP &debugger, const char *args,
+    PyObject *implementor, lldb::DebuggerSP debugger, const char *args,
     lldb_private::CommandReturnObject &cmd_retobj,
     lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
   return false;
@@ -187,7 +187,7 @@ bool lldb_private::LLDBSwigPythonCallCommandObject(
 
 bool lldb_private::LLDBSwigPythonCallModuleInit(
     const char *python_module_name, const char *session_dictionary_name,
-    lldb::DebuggerSP &debugger) {
+    lldb::DebuggerSP debugger) {
   return false;
 }
 
@@ -228,10 +228,10 @@ bool lldb_private::LLDBSWIGPythonRunScriptKeywordProcess(
   return false;
 }
 
-bool lldb_private::LLDBSWIGPythonRunScriptKeywordThread(
+llvm::Optional<std::string> lldb_private::LLDBSWIGPythonRunScriptKeywordThread(
     const char *python_function_name, const char *session_dictionary_name,
-    lldb::ThreadSP &thread, std::string &output) {
-  return false;
+    lldb::ThreadSP thread) {
+  return llvm::None;
 }
 
 bool lldb_private::LLDBSWIGPythonRunScriptKeywordTarget(
@@ -240,10 +240,10 @@ bool lldb_private::LLDBSWIGPythonRunScriptKeywordTarget(
   return false;
 }
 
-bool lldb_private::LLDBSWIGPythonRunScriptKeywordFrame(
+llvm::Optional<std::string> lldb_private::LLDBSWIGPythonRunScriptKeywordFrame(
     const char *python_function_name, const char *session_dictionary_name,
-    lldb::StackFrameSP &frame, std::string &output) {
-  return false;
+    lldb::StackFrameSP frame) {
+  return llvm::None;
 }
 
 bool lldb_private::LLDBSWIGPythonRunScriptKeywordValue(


        


More information about the lldb-commits mailing list