aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h9
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp11
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h3
3 files changed, 23 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
index 61ec4307..012f16e 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -343,6 +343,15 @@ public:
return python::Take<PythonObject>(obj);
}
+ llvm::Expected<PythonObject> GetType() const {
+ if (!m_py_obj)
+ return nullDeref();
+ PyObject *obj = PyObject_Type(m_py_obj);
+ if (!obj)
+ return exception();
+ return python::Take<PythonObject>(obj);
+ }
+
llvm::Expected<bool> IsTrue() {
if (!m_py_obj)
return nullDeref();
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 902c7fa..55b7a73 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1519,6 +1519,17 @@ ScriptInterpreterPythonImpl::CreateScriptedProcessInterface() {
return std::make_unique<ScriptedProcessPythonInterface>(*this);
}
+StructuredData::ObjectSP
+ScriptInterpreterPythonImpl::CreateStructuredDataFromScriptObject(
+ ScriptObject obj) {
+ void *ptr = const_cast<void *>(obj.GetPointer());
+ PythonObject py_obj(PyRefType::Borrowed, static_cast<PyObject *>(ptr));
+ if (!py_obj.IsValid() || py_obj.IsNone())
+ return {};
+ Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
+ return py_obj.CreateStructuredObject();
+}
+
StructuredData::GenericSP
ScriptInterpreterPythonImpl::OSPlugin_CreatePluginObject(
const char *class_name, lldb::ProcessSP process_sp) {
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
index 55ade49..01db6c5 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -83,6 +83,9 @@ public:
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;