From 45a44f3c4da7969ee8534ad16ea841ff301f6b1c Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 15 Jul 2014 00:25:59 +0000 Subject: [PATCH] Any commands that are executed through the public interface using SBCommandInterpreter::HandleCommand() are assumed to be in non-interactive mode. Any commands that want interactivity (stdin) will need to be executed through the normal command interpreter using the debugger's in/out/err file handles, or by using "command source". Individual commands through the API will have their STDIN disabled. The STDOUT and STDERR will be redirected into the SBCommandReturnObject argument to SBCommandInterpreter::HandleCommand() as usual. This helps with a deadlock situation in an IDE (Xcode) where the IDE was managing the breakpoint actions by setting a breakpoint callback and doing things manually. llvm-svn: 213023 --- .../lldb/Interpreter/CommandReturnObject.h | 13 +++++++++++-- lldb/source/API/SBCommandInterpreter.cpp | 1 + .../source/Interpreter/CommandReturnObject.cpp | 18 +++++++++++++++++- .../Interpreter/ScriptInterpreterPython.cpp | 4 ++-- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h b/lldb/include/lldb/Interpreter/CommandReturnObject.h index acd03992e5e6..b922e1731d7e 100644 --- a/lldb/include/lldb/Interpreter/CommandReturnObject.h +++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h @@ -160,9 +160,17 @@ public: bool HasResult (); - bool GetDidChangeProcessState (); + bool + GetDidChangeProcessState (); - void SetDidChangeProcessState (bool b); + void + SetDidChangeProcessState (bool b); + + bool + GetInteractive () const; + + void + SetInteractive (bool b); private: enum @@ -176,6 +184,7 @@ private: lldb::ReturnStatus m_status; bool m_did_change_process_state; + bool m_interactive; // If true, then the input handle from the debugger will be hooked up }; } // namespace lldb_private diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 388dff2a8aa3..e1adea795b08 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -138,6 +138,7 @@ SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnOb result.Clear(); if (command_line && m_opaque_ptr) { + result.ref().SetInteractive(false); m_opaque_ptr->HandleCommand (command_line, add_to_history ? eLazyBoolYes : eLazyBoolNo, result.ref()); } else diff --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp index af9196f2894e..1b5418735069 100644 --- a/lldb/source/Interpreter/CommandReturnObject.cpp +++ b/lldb/source/Interpreter/CommandReturnObject.cpp @@ -46,7 +46,8 @@ CommandReturnObject::CommandReturnObject () : m_out_stream (), m_err_stream (), m_status (eReturnStatusStarted), - m_did_change_process_state (false) + m_did_change_process_state (false), + m_interactive (true) { } @@ -203,6 +204,7 @@ CommandReturnObject::Clear() static_cast(stream_sp.get())->Clear(); m_status = eReturnStatusStarted; m_did_change_process_state = false; + m_interactive = true; } bool @@ -217,3 +219,17 @@ CommandReturnObject::SetDidChangeProcessState (bool b) m_did_change_process_state = b; } + +bool +CommandReturnObject::GetInteractive () const +{ + return m_interactive; +} + +void +CommandReturnObject::SetInteractive (bool b) +{ + m_interactive = b; +} + + diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 5803fe7be252..ac4b29f1040a 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -2438,7 +2438,7 @@ ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function, { error.SetErrorString("invalid Debugger pointer"); return false; - } + } bool ret_val = false; @@ -2446,7 +2446,7 @@ ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function, { Locker py_lock(this, - Locker::AcquireLock | Locker::InitSession, + Locker::AcquireLock | Locker::InitSession | cmd_retobj.GetInteractive() ? 0 : Locker::NoSTDIN, Locker::FreeLock | Locker::TearDownSession); SynchronicityHandler synch_handler(debugger_sp,