Skip to content

Commit 049c89e

Browse files
committed
[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.
1 parent 0d21c2b commit 049c89e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ void ScriptInterpreterPython::Initialize() {
352352
GetPluginDescriptionStatic(),
353353
lldb::eScriptLanguagePython,
354354
ScriptInterpreterPythonImpl::CreateInstance);
355-
ScriptInterpreterPythonImpl::Initialize();
356355
});
357356
}
358357

@@ -429,6 +428,10 @@ ScriptInterpreterPythonImpl::ScriptInterpreterPythonImpl(Debugger &debugger)
429428
m_active_io_handler(eIOHandlerNone), m_session_is_active(false),
430429
m_pty_secondary_is_open(false), m_valid_session(true), m_lock_count(0),
431430
m_command_thread_state(nullptr) {
431+
static llvm::once_flag g_once_flag;
432+
llvm::call_once(g_once_flag, []() {
433+
ScriptInterpreterPythonImpl::Initialize();
434+
});
432435

433436
m_dictionary_name.append("_dict");
434437
StreamString run_string;

0 commit comments

Comments
 (0)