From e3b557809604d036af6e00c60f012c2025b59a5e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 11 Feb 2023 13:38:04 +0100 Subject: Vendor import of llvm-project main llvmorg-16-init-18548-gb0daacf58f41, the last commit before the upstream release/17.x branch was created. --- .../Python/ScriptedThreadPythonInterface.cpp | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp index 3ff592fb83cd..1b31ed2e5881 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp @@ -18,6 +18,7 @@ #include "SWIGPythonBridge.h" #include "ScriptInterpreterPythonImpl.h" #include "ScriptedThreadPythonInterface.h" +#include using namespace lldb; using namespace lldb_private; @@ -34,7 +35,6 @@ StructuredData::GenericSP ScriptedThreadPythonInterface::CreatePluginObject( if (class_name.empty() && !script_obj) return {}; - ProcessSP process_sp = exe_ctx.GetProcessSP(); StructuredDataImpl args_impl(args_sp); std::string error_string; @@ -43,11 +43,13 @@ StructuredData::GenericSP ScriptedThreadPythonInterface::CreatePluginObject( PythonObject ret_val; - if (!script_obj) - ret_val = LLDBSwigPythonCreateScriptedThread( - class_name.str().c_str(), m_interpreter.GetDictionaryName(), process_sp, - args_impl, error_string); - else + if (!script_obj) { + lldb::ExecutionContextRefSP exe_ctx_ref_sp = + std::make_shared(exe_ctx); + ret_val = LLDBSwigPythonCreateScriptedObject( + class_name.str().c_str(), m_interpreter.GetDictionaryName(), + exe_ctx_ref_sp, args_impl, error_string); + } else ret_val = PythonObject(PyRefType::Borrowed, static_cast(script_obj->GetValue())); @@ -70,7 +72,7 @@ lldb::tid_t ScriptedThreadPythonInterface::GetThreadID() { return obj->GetIntegerValue(LLDB_INVALID_THREAD_ID); } -llvm::Optional ScriptedThreadPythonInterface::GetName() { +std::optional ScriptedThreadPythonInterface::GetName() { Status error; StructuredData::ObjectSP obj = Dispatch("get_name", error); @@ -90,7 +92,7 @@ lldb::StateType ScriptedThreadPythonInterface::GetState() { return static_cast(obj->GetIntegerValue(eStateInvalid)); } -llvm::Optional ScriptedThreadPythonInterface::GetQueue() { +std::optional ScriptedThreadPythonInterface::GetQueue() { Status error; StructuredData::ObjectSP obj = Dispatch("get_queue", error); @@ -133,8 +135,7 @@ StructuredData::DictionarySP ScriptedThreadPythonInterface::GetRegisterInfo() { return dict; } -llvm::Optional -ScriptedThreadPythonInterface::GetRegisterContext() { +std::optional ScriptedThreadPythonInterface::GetRegisterContext() { Status error; StructuredData::ObjectSP obj = Dispatch("get_register_context", error); @@ -144,4 +145,15 @@ ScriptedThreadPythonInterface::GetRegisterContext() { return obj->GetAsString()->GetValue().str(); } +StructuredData::ArraySP ScriptedThreadPythonInterface::GetExtendedInfo() { + Status error; + StructuredData::ArraySP arr = + Dispatch("get_extended_info", error); + + if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, arr, error)) + return {}; + + return arr; +} + #endif -- cgit v1.3