aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-01-27 22:17:16 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-06-04 11:59:19 +0000
commit390adc38fc112be360bd15499e5241bf4e675b6f (patch)
tree712d68d3aa03f7aa4902ba03dcac2a56f49ae0e5 /contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
parent8a84287b0edc66fc6dede3db770d10ff41da5464 (diff)
Diffstat (limited to 'contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp b/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
index 6a881bfe625c..d471b2c5f7e3 100644
--- a/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
+++ b/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
@@ -31,9 +31,8 @@ ScriptedThreadPythonInterface::ScriptedThreadPythonInterface(
StructuredData::GenericSP ScriptedThreadPythonInterface::CreatePluginObject(
const llvm::StringRef class_name, ExecutionContext &exe_ctx,
- StructuredData::DictionarySP args_sp) {
-
- if (class_name.empty())
+ StructuredData::DictionarySP args_sp, StructuredData::Generic *script_obj) {
+ if (class_name.empty() && !script_obj)
return {};
ProcessSP process_sp = exe_ctx.GetProcessSP();
@@ -43,15 +42,21 @@ StructuredData::GenericSP ScriptedThreadPythonInterface::CreatePluginObject(
Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
Locker::FreeLock);
- void *ret_val = LLDBSwigPythonCreateScriptedThread(
- class_name.str().c_str(), m_interpreter.GetDictionaryName(), process_sp,
- args_impl, error_string);
+ PythonObject ret_val;
+
+ if (!script_obj)
+ ret_val = LLDBSwigPythonCreateScriptedThread(
+ class_name.str().c_str(), m_interpreter.GetDictionaryName(), process_sp,
+ args_impl, error_string);
+ else
+ ret_val = PythonObject(PyRefType::Borrowed,
+ static_cast<PyObject *>(script_obj->GetValue()));
if (!ret_val)
return {};
m_object_instance_sp =
- StructuredData::GenericSP(new StructuredPythonObject(ret_val));
+ StructuredData::GenericSP(new StructuredPythonObject(std::move(ret_val)));
return m_object_instance_sp;
}