From a879f40ba105ab5ceb79725424c77c1fd68a58a1 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 17 Sep 2019 03:55:58 +0000 Subject: [ScriptInterpreter] Initialize globals when loading a scripting module. The LoadScriptingModule used by command script import wasn't initializing the LLDB global variables (things like `lldb.frame` and `lldb.debugger`). They would get initialized however when running the interactive script interpreter or running a single script line (e.g. `script print(lldb.frame)`). This patch fixes that by properly initializing the globals when loading a Python module. Differential revision: https://reviews.llvm.org/D67644 llvm-svn: 372060 --- .../ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 7fe3157dfc2..8b11be665c1 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -2699,12 +2699,12 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule( StreamString command_stream; // Before executing Python code, lock the GIL. - Locker py_lock(this, - Locker::AcquireLock | - (init_session ? Locker::InitSession : 0) | - Locker::NoSTDIN, - Locker::FreeAcquiredLock | - (init_session ? Locker::TearDownSession : 0)); + Locker py_lock( + this, + Locker::AcquireLock | (init_session ? Locker::InitSession : 0) | + (init_session ? Locker::InitGlobals : 0) | Locker::NoSTDIN, + Locker::FreeAcquiredLock | + (init_session ? Locker::TearDownSession : 0)); namespace fs = llvm::sys::fs; fs::file_status st; std::error_code ec = status(target_file.GetPath(), st); -- cgit v1.2.3