diff --git a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h --- a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h +++ b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h @@ -68,11 +68,9 @@ protected: friend class ScriptedThread; - virtual lldb::ScriptedThreadInterfaceSP GetScriptedThreadInterface() { + virtual lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() { return nullptr; } - - lldb::ScriptedThreadInterfaceSP m_scripted_thread_interface_sp = nullptr; }; class ScriptedThreadInterface : virtual public ScriptedInterface { diff --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.h b/lldb/source/Plugins/Process/scripted/ScriptedThread.h --- a/lldb/source/Plugins/Process/scripted/ScriptedThread.h +++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.h @@ -59,6 +59,7 @@ std::shared_ptr GetDynamicRegisterInfo(); const ScriptedProcess &m_scripted_process; + lldb::ScriptedThreadInterfaceSP m_scripted_thread_interface_sp = nullptr; std::shared_ptr m_register_info_sp = nullptr; lldb_private::StructuredData::ObjectSP m_script_object_sp = nullptr; }; diff --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp --- a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp +++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp @@ -29,7 +29,9 @@ } ScriptedThread::ScriptedThread(ScriptedProcess &process, Status &error) - : Thread(process, LLDB_INVALID_THREAD_ID), m_scripted_process(process) { + : Thread(process, LLDB_INVALID_THREAD_ID), m_scripted_process(process), + m_scripted_thread_interface_sp( + m_scripted_process.GetInterface().CreateScriptedThreadInterface()) { if (!process.IsValid()) { error.SetErrorString("Invalid scripted process"); return; @@ -190,7 +192,7 @@ } lldb::ScriptedThreadInterfaceSP ScriptedThread::GetInterface() const { - return m_scripted_process.GetInterface().GetScriptedThreadInterface(); + return m_scripted_thread_interface_sp; } std::shared_ptr ScriptedThread::GetDynamicRegisterInfo() { diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h @@ -57,7 +57,7 @@ llvm::Optional GetScriptedThreadPluginName() override; private: - lldb::ScriptedThreadInterfaceSP GetScriptedThreadInterface() override; + lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() override; }; } // namespace lldb_private diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp @@ -165,12 +165,8 @@ } lldb::ScriptedThreadInterfaceSP -ScriptedProcessPythonInterface::GetScriptedThreadInterface() { - if (!m_scripted_thread_interface_sp) - m_scripted_thread_interface_sp = - std::make_shared(m_interpreter); - - return m_scripted_thread_interface_sp; +ScriptedProcessPythonInterface::CreateScriptedThreadInterface() { + return std::make_shared(m_interpreter); } #endif