https://github.com/danobi created https://github.com/llvm/llvm-project/pull/105757
Previously python was initialized during static registration of the plugin. This causes the python interpreter to run even if python support is explicitly disabled thru: SBDebugger::SetScriptLanguage(ScriptLanguage::eScriptLanguageNone) This commit defers python initialization until a ScriptInterpreterPython instance is created. >From 049c89e9e8e92cb1564020335d6f69d89d8adf43 Mon Sep 17 00:00:00 2001 From: Daniel Xu <d...@dxuuu.xyz> Date: Thu, 22 Aug 2024 17:32:22 -0700 Subject: [PATCH] [lldb][NFC] Defer python init until ScriptInterpreter is created Previously python was initialized during static registration of the plugin. This causes the python interpreter to run even if python support is explicitly disabled thru: SBDebugger::SetScriptLanguage(ScriptLanguage::eScriptLanguageNone) This commit defers python initialization until a ScriptInterpreterPython instance is created. --- .../ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 335c482f8495ad..bc4e7485067048 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -352,7 +352,6 @@ void ScriptInterpreterPython::Initialize() { GetPluginDescriptionStatic(), lldb::eScriptLanguagePython, ScriptInterpreterPythonImpl::CreateInstance); - ScriptInterpreterPythonImpl::Initialize(); }); } @@ -429,6 +428,10 @@ ScriptInterpreterPythonImpl::ScriptInterpreterPythonImpl(Debugger &debugger) m_active_io_handler(eIOHandlerNone), m_session_is_active(false), m_pty_secondary_is_open(false), m_valid_session(true), m_lock_count(0), m_command_thread_state(nullptr) { + static llvm::once_flag g_once_flag; + llvm::call_once(g_once_flag, []() { + ScriptInterpreterPythonImpl::Initialize(); + }); m_dictionary_name.append("_dict"); StreamString run_string; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits