[Lldb-commits] [lldb] r213023 - Any commands that are executed through the public interface using SBCommandInterpreter::HandleCommand() are assumed to be in non-interactive mode.

Greg Clayton gclayton at apple.com
Mon Jul 14 17:25:59 PDT 2014


Author: gclayton
Date: Mon Jul 14 19:25:59 2014
New Revision: 213023

URL: http://llvm.org/viewvc/llvm-project?rev=213023&view=rev
Log:
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.

<rdar://problem/17386271>

Modified:
    lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h
    lldb/trunk/source/API/SBCommandInterpreter.cpp
    lldb/trunk/source/Interpreter/CommandReturnObject.cpp
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp

Modified: lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h?rev=213023&r1=213022&r2=213023&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h Mon Jul 14 19:25:59 2014
@@ -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

Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=213023&r1=213022&r2=213023&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommandInterpreter.cpp (original)
+++ lldb/trunk/source/API/SBCommandInterpreter.cpp Mon Jul 14 19:25:59 2014
@@ -138,6 +138,7 @@ SBCommandInterpreter::HandleCommand (con
     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

Modified: lldb/trunk/source/Interpreter/CommandReturnObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandReturnObject.cpp?rev=213023&r1=213022&r2=213023&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandReturnObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandReturnObject.cpp Mon Jul 14 19:25:59 2014
@@ -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<StreamString *>(stream_sp.get())->Clear();
     m_status = eReturnStatusStarted;
     m_did_change_process_state = false;
+    m_interactive = true;
 }
 
 bool
@@ -217,3 +219,17 @@ CommandReturnObject::SetDidChangeProcess
     m_did_change_process_state = b;
 }
 
+
+bool
+CommandReturnObject::GetInteractive () const
+{
+    return m_interactive;
+}
+
+void
+CommandReturnObject::SetInteractive (bool b)
+{
+    m_interactive = b;
+}
+
+

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=213023&r1=213022&r2=213023&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Jul 14 19:25:59 2014
@@ -2438,7 +2438,7 @@ ScriptInterpreterPython::RunScriptBasedC
     {
         error.SetErrorString("invalid Debugger pointer");
         return false;
-    }
+   }
     
     bool ret_val = false;
     
@@ -2446,7 +2446,7 @@ ScriptInterpreterPython::RunScriptBasedC
     
     {
         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,





More information about the lldb-commits mailing list