aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python
diff options
context:
space:
mode:
authorMed Ismail Bennani <ismail@bennani.ma>2023-10-30 16:52:17 -0700
committerGitHub <noreply@github.com>2023-10-30 16:52:17 -0700
commit4b3cd379cce3f455bf3c8677ca7a5be6e708a4ce (patch)
tree4d1348946d3a079d0c929de12280dd804854aad7 /lldb/source/Plugins/ScriptInterpreter/Python
parentc2f642d90d33a4e6c987b52e22eca4221c86c601 (diff)
downloadllvm-4b3cd379cce3f455bf3c8677ca7a5be6e708a4ce.zip
llvm-4b3cd379cce3f455bf3c8677ca7a5be6e708a4ce.tar.gz
llvm-4b3cd379cce3f455bf3c8677ca7a5be6e708a4ce.tar.bz2
[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#70392)
This patch makes ScriptedThreadPlan conforming to the ScriptedInterface & ScriptedPythonInterface facilities by introducing 2 ScriptedThreadPlanInterface & ScriptedThreadPlanPythonInterface classes. This allows us to get rid of every ScriptedThreadPlan-specific SWIG method and re-use the same affordances as other scripting offordances, like Scripted{Process,Thread,Platform} & OperatingSystem. To do so, this adds new transformer methods for `ThreadPlan`, `Stream` & `Event`, to allow the bijection between C++ objects and their python counterparts. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt1
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp2
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp34
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h20
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp92
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h44
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp1
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h21
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp122
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h28
10 files changed, 205 insertions, 160 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt
index b22abc4..c60e4bb 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt
@@ -24,6 +24,7 @@ add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces
ScriptedPythonInterface.cpp
ScriptedProcessPythonInterface.cpp
ScriptedThreadPythonInterface.cpp
+ ScriptedThreadPlanPythonInterface.cpp
ScriptedPlatformPythonInterface.cpp
LINK_LIBS
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp
index 9ba4731..6e93bec 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp
@@ -20,6 +20,8 @@
#include "../ScriptInterpreterPythonImpl.h"
#include "ScriptedPlatformPythonInterface.h"
+#include "lldb/Target/ExecutionContext.h"
+
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::python;
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
index 6f22503..7d07221 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
@@ -27,6 +27,15 @@ ScriptedPythonInterface::ScriptedPythonInterface(
: ScriptedInterface(), m_interpreter(interpreter) {}
template <>
+void ScriptedPythonInterface::ReverseTransform(
+ lldb_private::Stream *&original_arg, python::PythonObject transformed_arg,
+ Status &error) {
+ Stream *s = ExtractValueFromPythonObject<Stream *>(transformed_arg, error);
+ *original_arg = *s;
+ original_arg->PutCString(static_cast<StreamString *>(s)->GetData());
+}
+
+template <>
StructuredData::ArraySP
ScriptedPythonInterface::ExtractValueFromPythonObject<StructuredData::ArraySP>(
python::PythonObject &p, Status &error) {
@@ -48,13 +57,34 @@ Status ScriptedPythonInterface::ExtractValueFromPythonObject<Status>(
if (lldb::SBError *sb_error = reinterpret_cast<lldb::SBError *>(
python::LLDBSWIGPython_CastPyObjectToSBError(p.get())))
return m_interpreter.GetStatusFromSBError(*sb_error);
- else
- error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status.");
+ error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status.");
return {};
}
template <>
+Event *ScriptedPythonInterface::ExtractValueFromPythonObject<Event *>(
+ python::PythonObject &p, Status &error) {
+ if (lldb::SBEvent *sb_event = reinterpret_cast<lldb::SBEvent *>(
+ python::LLDBSWIGPython_CastPyObjectToSBEvent(p.get())))
+ return m_interpreter.GetOpaqueTypeFromSBEvent(*sb_event);
+ error.SetErrorString("Couldn't cast lldb::SBEvent to lldb_private::Event.");
+
+ return nullptr;
+}
+
+template <>
+Stream *ScriptedPythonInterface::ExtractValueFromPythonObject<Stream *>(
+ python::PythonObject &p, Status &error) {
+ if (lldb::SBStream *sb_stream = reinterpret_cast<lldb::SBStream *>(
+ python::LLDBSWIGPython_CastPyObjectToSBStream(p.get())))
+ return m_interpreter.GetOpaqueTypeFromSBStream(*sb_stream);
+ error.SetErrorString("Couldn't cast lldb::SBStream to lldb_private::Stream.");
+
+ return nullptr;
+}
+
+template <>
lldb::DataExtractorSP
ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DataExtractorSP>(
python::PythonObject &p, Status &error) {
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 7af9816..cc76093 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -224,6 +224,10 @@ protected:
return python::SWIGBridge::ToSWIGWrapper(arg);
}
+ python::PythonObject Transform(lldb::ThreadPlanSP arg) {
+ return python::SWIGBridge::ToSWIGWrapper(arg);
+ }
+
python::PythonObject Transform(lldb::ProcessAttachInfoSP arg) {
return python::SWIGBridge::ToSWIGWrapper(arg);
}
@@ -232,6 +236,14 @@ protected:
return python::SWIGBridge::ToSWIGWrapper(arg);
}
+ python::PythonObject Transform(Event *arg) {
+ return python::SWIGBridge::ToSWIGWrapper(arg);
+ }
+
+ python::PythonObject Transform(Stream *arg) {
+ return python::SWIGBridge::ToSWIGWrapper(arg);
+ }
+
python::PythonObject Transform(lldb::DataExtractorSP arg) {
return python::SWIGBridge::ToSWIGWrapper(arg);
}
@@ -330,6 +342,14 @@ Status ScriptedPythonInterface::ExtractValueFromPythonObject<Status>(
python::PythonObject &p, Status &error);
template <>
+Event *ScriptedPythonInterface::ExtractValueFromPythonObject<Event *>(
+ python::PythonObject &p, Status &error);
+
+template <>
+Stream *ScriptedPythonInterface::ExtractValueFromPythonObject<Stream *>(
+ python::PythonObject &p, Status &error);
+
+template <>
lldb::BreakpointSP
ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::BreakpointSP>(
python::PythonObject &p, Status &error);
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
new file mode 100644
index 0000000..df9f7db
--- /dev/null
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
@@ -0,0 +1,92 @@
+//===-- ScriptedThreadPlanPythonInterface.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 "lldb/Host/Config.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/lldb-enumerations.h"
+
+#if LLDB_ENABLE_PYTHON
+
+// LLDB Python header must be included first
+#include "../lldb-python.h"
+
+#include "../SWIGPythonBridge.h"
+#include "../ScriptInterpreterPythonImpl.h"
+#include "ScriptedThreadPlanPythonInterface.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::python;
+
+ScriptedThreadPlanPythonInterface::ScriptedThreadPlanPythonInterface(
+ ScriptInterpreterPythonImpl &interpreter)
+ : ScriptedThreadPlanInterface(), ScriptedPythonInterface(interpreter) {}
+
+llvm::Expected<StructuredData::GenericSP>
+ScriptedThreadPlanPythonInterface::CreatePluginObject(
+ const llvm::StringRef class_name, lldb::ThreadPlanSP thread_plan_sp,
+ const StructuredDataImpl &args_sp) {
+ return ScriptedPythonInterface::CreatePluginObject(class_name, nullptr,
+ thread_plan_sp, args_sp);
+}
+
+llvm::Expected<bool>
+ScriptedThreadPlanPythonInterface::ExplainsStop(Event *event) {
+ Status error;
+ StructuredData::ObjectSP obj = Dispatch("explains_stop", error, event);
+
+ if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
+ return error.ToError();
+
+ return obj->GetBooleanValue();
+}
+
+llvm::Expected<bool>
+ScriptedThreadPlanPythonInterface::ShouldStop(Event *event) {
+ Status error;
+ StructuredData::ObjectSP obj = Dispatch("should_stop", error, event);
+
+ if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
+ return error.ToError();
+
+ return obj->GetBooleanValue();
+}
+
+llvm::Expected<bool> ScriptedThreadPlanPythonInterface::IsStale() {
+ Status error;
+ StructuredData::ObjectSP obj = Dispatch("is_stale", error);
+
+ if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
+ return error.ToError();
+
+ return obj->GetBooleanValue();
+}
+
+lldb::StateType ScriptedThreadPlanPythonInterface::GetRunState() {
+ Status error;
+ StructuredData::ObjectSP obj = Dispatch("should_step", error);
+
+ if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
+ return lldb::eStateStepping;
+
+ return static_cast<lldb::StateType>(obj->GetUnsignedIntegerValue(
+ static_cast<uint32_t>(lldb::eStateStepping)));
+}
+
+llvm::Expected<bool>
+ScriptedThreadPlanPythonInterface::GetStopDescription(lldb_private::Stream *s) {
+ Status error;
+ Dispatch("stop_description", error, s);
+
+ if (error.Fail())
+ return error.ToError();
+
+ return true;
+}
+
+#endif
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
new file mode 100644
index 0000000..2eb986e
--- /dev/null
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
@@ -0,0 +1,44 @@
+//===-- ScriptedThreadPlanPythonInterface.h ---------------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDTHREADPLANPYTHONINTERFACE_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDTHREADPLANPYTHONINTERFACE_H
+
+#include "lldb/Host/Config.h"
+
+#if LLDB_ENABLE_PYTHON
+
+#include "ScriptedPythonInterface.h"
+#include "lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h"
+#include <optional>
+
+namespace lldb_private {
+class ScriptedThreadPlanPythonInterface : public ScriptedThreadPlanInterface,
+ public ScriptedPythonInterface {
+public:
+ ScriptedThreadPlanPythonInterface(ScriptInterpreterPythonImpl &interpreter);
+
+ llvm::Expected<StructuredData::GenericSP>
+ CreatePluginObject(const llvm::StringRef class_name,
+ lldb::ThreadPlanSP thread_plan_sp,
+ const StructuredDataImpl &args_sp) override;
+
+ llvm::Expected<bool> ExplainsStop(Event *event) override;
+
+ llvm::Expected<bool> ShouldStop(Event *event) override;
+
+ llvm::Expected<bool> IsStale() override;
+
+ lldb::StateType GetRunState() override;
+
+ llvm::Expected<bool> GetStopDescription(lldb_private::Stream *s) override;
+};
+} // namespace lldb_private
+
+#endif // LLDB_ENABLE_PYTHON
+#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDTHREADPLANPYTHONINTERFACE_H
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp
index 18e2685..ba2ec0e 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/Config.h"
+#include "lldb/Target/ExecutionContext.h"
#include "lldb/Utility/Log.h"
#include "lldb/lldb-enumerations.h"
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
index 7cdd557..41f3a80 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
@@ -96,12 +96,13 @@ public:
static PythonObject ToSWIGWrapper(lldb::ExecutionContextRefSP ctx_sp);
static PythonObject ToSWIGWrapper(const TypeSummaryOptions &summary_options);
static PythonObject ToSWIGWrapper(const SymbolContext &sym_ctx);
+ static PythonObject ToSWIGWrapper(const Stream *stream);
+ static PythonObject ToSWIGWrapper(Event *event);
static PythonObject ToSWIGWrapper(lldb::ProcessAttachInfoSP attach_info_sp);
static PythonObject ToSWIGWrapper(lldb::ProcessLaunchInfoSP launch_info_sp);
static PythonObject ToSWIGWrapper(lldb::DataExtractorSP data_extractor_sp);
- static PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBStream> stream_sb);
static PythonObject
ToSWIGWrapper(std::unique_ptr<lldb::SBStructuredData> data_sb);
static PythonObject
@@ -111,7 +112,6 @@ public:
static python::ScopedPythonObject<lldb::SBCommandReturnObject>
ToSWIGWrapper(CommandReturnObject &cmd_retobj);
- static python::ScopedPythonObject<lldb::SBEvent> ToSWIGWrapper(Event *event);
// These prototypes are the Pythonic implementations of the required
// callbacks. Although these are scripting-language specific, their definition
// depends on the public API.
@@ -146,21 +146,6 @@ public:
const char *session_dictionary_name,
lldb::DebuggerSP debugger_sp);
- static python::PythonObject 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);
-
- static bool LLDBSWIGPythonCallThreadPlan(void *implementor,
- const char *method_name,
- lldb_private::Event *event_sp,
- bool &got_error);
-
- static bool LLDBSWIGPythonCallThreadPlan(void *implementor,
- const char *method_name,
- lldb_private::Stream *stream,
- bool &got_error);
-
static python::PythonObject LLDBSwigPythonCreateScriptedBreakpointResolver(
const char *python_class_name, const char *session_dictionary_name,
const StructuredDataImpl &args, const lldb::BreakpointSP &bkpt_sp);
@@ -262,6 +247,8 @@ void *LLDBSWIGPython_CastPyObjectToSBBreakpoint(PyObject *data);
void *LLDBSWIGPython_CastPyObjectToSBAttachInfo(PyObject *data);
void *LLDBSWIGPython_CastPyObjectToSBLaunchInfo(PyObject *data);
void *LLDBSWIGPython_CastPyObjectToSBError(PyObject *data);
+void *LLDBSWIGPython_CastPyObjectToSBEvent(PyObject *data);
+void *LLDBSWIGPython_CastPyObjectToSBStream(PyObject *data);
void *LLDBSWIGPython_CastPyObjectToSBValue(PyObject *data);
void *LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *data);
} // namespace python
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 953f8b3..b71f856 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -17,6 +17,7 @@
#include "Interfaces/OperatingSystemPythonInterface.h"
#include "Interfaces/ScriptedPlatformPythonInterface.h"
#include "Interfaces/ScriptedProcessPythonInterface.h"
+#include "Interfaces/ScriptedThreadPlanPythonInterface.h"
#include "Interfaces/ScriptedThreadPythonInterface.h"
#include "PythonDataObjects.h"
#include "PythonReadline.h"
@@ -1535,6 +1536,11 @@ ScriptInterpreterPythonImpl::CreateScriptedThreadInterface() {
return std::make_shared<ScriptedThreadPythonInterface>(*this);
}
+ScriptedThreadPlanInterfaceSP
+ScriptInterpreterPythonImpl::CreateScriptedThreadPlanInterface() {
+ return std::make_shared<ScriptedThreadPlanPythonInterface>(*this);
+}
+
OperatingSystemInterfaceSP
ScriptInterpreterPythonImpl::CreateOperatingSystemInterface() {
return std::make_shared<OperatingSystemPythonInterface>(*this);
@@ -1551,122 +1557,6 @@ ScriptInterpreterPythonImpl::CreateStructuredDataFromScriptObject(
return py_obj.CreateStructuredObject();
}
-StructuredData::ObjectSP ScriptInterpreterPythonImpl::CreateScriptedThreadPlan(
- const char *class_name, const StructuredDataImpl &args_data,
- std::string &error_str, lldb::ThreadPlanSP thread_plan_sp) {
- if (class_name == nullptr || class_name[0] == '\0')
- return StructuredData::ObjectSP();
-
- if (!thread_plan_sp.get())
- return {};
-
- Debugger &debugger = thread_plan_sp->GetTarget().GetDebugger();
- ScriptInterpreterPythonImpl *python_interpreter =
- GetPythonInterpreter(debugger);
-
- if (!python_interpreter)
- return {};
-
- Locker py_lock(this,
- Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- PythonObject ret_val = SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan(
- class_name, python_interpreter->m_dictionary_name.c_str(), args_data,
- error_str, thread_plan_sp);
- if (!ret_val)
- return {};
-
- return StructuredData::ObjectSP(
- new StructuredPythonObject(std::move(ret_val)));
-}
-
-bool ScriptInterpreterPythonImpl::ScriptedThreadPlanExplainsStop(
- StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error) {
- bool explains_stop = true;
- StructuredData::Generic *generic = nullptr;
- if (implementor_sp)
- generic = implementor_sp->GetAsGeneric();
- if (generic) {
- Locker py_lock(this,
- Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- explains_stop = SWIGBridge::LLDBSWIGPythonCallThreadPlan(
- generic->GetValue(), "explains_stop", event, script_error);
- if (script_error)
- return true;
- }
- return explains_stop;
-}
-
-bool ScriptInterpreterPythonImpl::ScriptedThreadPlanShouldStop(
- StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error) {
- bool should_stop = true;
- StructuredData::Generic *generic = nullptr;
- if (implementor_sp)
- generic = implementor_sp->GetAsGeneric();
- if (generic) {
- Locker py_lock(this,
- Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- should_stop = SWIGBridge::LLDBSWIGPythonCallThreadPlan(
- generic->GetValue(), "should_stop", event, script_error);
- if (script_error)
- return true;
- }
- return should_stop;
-}
-
-bool ScriptInterpreterPythonImpl::ScriptedThreadPlanIsStale(
- StructuredData::ObjectSP implementor_sp, bool &script_error) {
- bool is_stale = true;
- StructuredData::Generic *generic = nullptr;
- if (implementor_sp)
- generic = implementor_sp->GetAsGeneric();
- if (generic) {
- Locker py_lock(this,
- Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- is_stale = SWIGBridge::LLDBSWIGPythonCallThreadPlan(
- generic->GetValue(), "is_stale", (Event *)nullptr, script_error);
- if (script_error)
- return true;
- }
- return is_stale;
-}
-
-lldb::StateType ScriptInterpreterPythonImpl::ScriptedThreadPlanGetRunState(
- StructuredData::ObjectSP implementor_sp, bool &script_error) {
- bool should_step = false;
- StructuredData::Generic *generic = nullptr;
- if (implementor_sp)
- generic = implementor_sp->GetAsGeneric();
- if (generic) {
- Locker py_lock(this,
- Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- should_step = SWIGBridge::LLDBSWIGPythonCallThreadPlan(
- generic->GetValue(), "should_step", (Event *)nullptr, script_error);
- if (script_error)
- should_step = true;
- }
- if (should_step)
- return lldb::eStateStepping;
- return lldb::eStateRunning;
-}
-
-bool
-ScriptInterpreterPythonImpl::ScriptedThreadPlanGetStopDescription(
- StructuredData::ObjectSP implementor_sp, lldb_private::Stream *stream,
- bool &script_error) {
- StructuredData::Generic *generic = nullptr;
- if (implementor_sp)
- generic = implementor_sp->GetAsGeneric();
- if (!generic) {
- script_error = true;
- return false;
- }
- Locker py_lock(this,
- Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- return SWIGBridge::LLDBSWIGPythonCallThreadPlan(
- generic->GetValue(), "stop_description", stream, script_error);
-}
-
-
StructuredData::GenericSP
ScriptInterpreterPythonImpl::CreateScriptedBreakpointResolver(
const char *class_name, const StructuredDataImpl &args_data,
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
index a3349981..da8e3a6 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -78,33 +78,8 @@ public:
CreateScriptCommandObject(const char *class_name) override;
StructuredData::ObjectSP
- CreateScriptedThreadPlan(const char *class_name,
- const StructuredDataImpl &args_data,
- std::string &error_str,
- lldb::ThreadPlanSP thread_plan) override;
-
- StructuredData::ObjectSP
CreateStructuredDataFromScriptObject(ScriptObject obj) override;
- bool ScriptedThreadPlanExplainsStop(StructuredData::ObjectSP implementor_sp,
- Event *event,
- bool &script_error) override;
-
- bool ScriptedThreadPlanShouldStop(StructuredData::ObjectSP implementor_sp,
- Event *event, bool &script_error) override;
-
- bool ScriptedThreadPlanIsStale(StructuredData::ObjectSP implementor_sp,
- bool &script_error) override;
-
- lldb::StateType
- ScriptedThreadPlanGetRunState(StructuredData::ObjectSP implementor_sp,
- bool &script_error) override;
-
- bool
- ScriptedThreadPlanGetStopDescription(StructuredData::ObjectSP implementor_sp,
- lldb_private::Stream *s,
- bool &script_error) override;
-
StructuredData::GenericSP
CreateScriptedBreakpointResolver(const char *class_name,
const StructuredDataImpl &args_data,
@@ -136,6 +111,9 @@ public:
lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() override;
+ lldb::ScriptedThreadPlanInterfaceSP
+ CreateScriptedThreadPlanInterface() override;
+
lldb::OperatingSystemInterfaceSP CreateOperatingSystemInterface() override;
StructuredData::ObjectSP