summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-09-18 00:30:01 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-09-18 00:30:01 +0000
commit20b52c33ba3960340ecf326314517091b8ec98f4 (patch)
treed70612f82a6ee1469f6c7fe10e3b519a6a8c428e /lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
parent6e353b4df3aa452ed4741a5e5caea02b1a876d8c (diff)
downloadbcm5719-llvm-20b52c33ba3960340ecf326314517091b8ec98f4.tar.gz
bcm5719-llvm-20b52c33ba3960340ecf326314517091b8ec98f4.zip
[ScriptInterpreter] Limit LLDB's globals to interactive mode.
Jim pointed out that the LLDB global variables should only be available in interactive mode. When used from a command for example, their values might be stale or not at all what the user expects. Therefore we want to explicitly make these variables unavailable. Differential revision: https://reviews.llvm.org/D67685 llvm-svn: 372192
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 1eecbc114b2..25a81f65115 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -616,6 +616,10 @@ void ScriptInterpreterPythonImpl::LeaveSession() {
if (log)
log->PutCString("ScriptInterpreterPythonImpl::LeaveSession()");
+ // Unset the LLDB global variables.
+ PyRun_SimpleString("lldb.debugger = None; lldb.target = None; lldb.process "
+ "= None; lldb.thread = None; lldb.frame = None");
+
// checking that we have a valid thread state - since we use our own
// threading and locking in some (rare) cases during cleanup Python may end
// up believing we have no thread state and PyImport_AddModule will crash if
@@ -2687,12 +2691,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) |
- (init_session ? Locker::InitGlobals : 0) | Locker::NoSTDIN,
- Locker::FreeAcquiredLock |
- (init_session ? Locker::TearDownSession : 0));
+ Locker py_lock(this,
+ Locker::AcquireLock |
+ (init_session ? Locker::InitSession : 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);
OpenPOWER on IntegriCloud