summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2015-01-10 00:42:12 +0000
committerGreg Clayton <gclayton@apple.com>2015-01-10 00:42:12 +0000
commitf44404407fa8ab1981b4904e180a0dc878d45464 (patch)
treee0207f7d223041bfe4912e6ed098176773ff407a
parent611b127ad81108b43032ddf936c764edbb6af7db (diff)
downloadbcm5719-llvm-f44404407fa8ab1981b4904e180a0dc878d45464.tar.gz
bcm5719-llvm-f44404407fa8ab1981b4904e180a0dc878d45464.zip
Respect the fact that the result object claims it doesn't want to be interactive by not forwarding STDIN to the python invocation when it isn't desired.
This fixes an issue of running "script" commands via SBDebugger::HandleCommand(...) and SBCommandInterpreter::HandleCommand(...) deadlocking Xcode. <rdar://problem/18075038> llvm-svn: 225567
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index cf7a3019268..ab151073f9e 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -444,19 +444,23 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags,
if (in == nullptr || out == nullptr || err == nullptr)
m_interpreter.GetDebugger().AdoptTopIOHandlerFilesIfInvalid (in_sp, out_sp, err_sp);
- if (in == nullptr && in_sp && (on_entry_flags & Locker::NoSTDIN) == 0)
- in = in_sp->GetFile().GetStream();
- if (in)
- {
- m_saved_stdin.Reset(sys_module_dict.GetItemForKey("stdin"));
+ m_saved_stdin.Reset();
- PyObject *new_file = PyFile_FromFile (in, (char *) "", (char *) "r", nullptr);
- sys_module_dict.SetItemForKey ("stdin", new_file);
- Py_DECREF (new_file);
+ if ((on_entry_flags & Locker::NoSTDIN) == 0)
+ {
+ // STDIN is enabled
+ if (in == nullptr && in_sp)
+ in = in_sp->GetFile().GetStream();
+ if (in)
+ {
+ m_saved_stdin.Reset(sys_module_dict.GetItemForKey("stdin"));
+ // This call can deadlock your process if the file is locked
+ PyObject *new_file = PyFile_FromFile (in, (char *) "", (char *) "r", nullptr);
+ sys_module_dict.SetItemForKey ("stdin", new_file);
+ Py_DECREF (new_file);
+ }
}
- else
- m_saved_stdin.Reset();
-
+
if (out == nullptr && out_sp)
out = out_sp->GetFile().GetStream();
if (out)
@@ -648,7 +652,8 @@ ScriptInterpreterPython::ExecuteOneLine (const char *command, CommandReturnObjec
Locker locker(this,
ScriptInterpreterPython::Locker::AcquireLock |
ScriptInterpreterPython::Locker::InitSession |
- (options.GetSetLLDBGlobals() ? ScriptInterpreterPython::Locker::InitGlobals : 0),
+ (options.GetSetLLDBGlobals() ? ScriptInterpreterPython::Locker::InitGlobals : 0) |
+ ((result && result->GetInteractive()) ? 0: Locker::NoSTDIN),
ScriptInterpreterPython::Locker::FreeAcquiredLock |
ScriptInterpreterPython::Locker::TearDownSession,
in_file,
OpenPOWER on IntegriCloud