[Lldb-commits] [lldb] r131415 - in /lldb/trunk: source/Commands/CommandObjectBreakpointCommand.cpp tools/driver/Driver.cpp

Caroline Tice ctice at apple.com
Mon May 16 12:20:50 PDT 2011


Author: ctice
Date: Mon May 16 14:20:50 2011
New Revision: 131415

URL: http://llvm.org/viewvc/llvm-project?rev=131415&view=rev
Log:

Fix places that were writing directly to the debugger's output
handles to go through the appropriate channels instead.


Modified:
    lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
    lldb/trunk/tools/driver/Driver.cpp

Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=131415&r1=131414&r2=131415&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Mon May 16 14:20:50 2011
@@ -23,6 +23,7 @@
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
 #include "lldb/Core/State.h"
+#include "lldb/Core/StreamAsynchronousIO.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -802,9 +803,13 @@
             // Rig up the results secondary output stream to the debugger's, so the output will come out synchronously
             // if the debugger is set up that way.
                 
-            result.SetImmediateOutputFile (debugger.GetOutputFile().GetStream());
-            result.SetImmediateErrorFile (debugger.GetErrorFile().GetStream());
-
+            StreamSP output_stream (new StreamAsynchronousIO (debugger.GetCommandInterpreter(),
+                                                              CommandInterpreter::eBroadcastBitAsynchronousOutputData));
+            StreamSP error_stream (new StreamAsynchronousIO (debugger.GetCommandInterpreter(),
+                                                             CommandInterpreter::eBroadcastBitAsynchronousErrorData));
+            result.SetImmediateOutputStream (output_stream);
+            result.SetImmediateErrorStream (error_stream);
+    
             bool stop_on_continue = true;
             bool echo_commands    = false;
             bool print_results    = true;
@@ -816,7 +821,9 @@
                                                              echo_commands, 
                                                              print_results, 
                                                              result);
-        }
+            result.GetImmediateOutputStream()->Flush();
+            result.GetImmediateErrorStream()->Flush();
+       }
     }
     return ret_value;
 }

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=131415&r1=131414&r2=131415&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Mon May 16 14:20:50 2011
@@ -851,12 +851,17 @@
         if (command_string == NULL)
             command_string = "";
         SBCommandReturnObject result;
-        result.SetImmediateOutputFile (m_debugger.GetOutputFileHandle());
-        result.SetImmediateErrorFile (m_debugger.GetErrorFileHandle());
         
-        // We've set the result to dump immediately.
+        // We don't want the result to bypass the OutWrite function in IOChannel, as this can result in odd
+        // output orderings and problems with the prompt.
         m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, true);
 
+        if (result.GetOutputSize() > 0)
+            m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize(), NO_ASYNC);
+            
+        if (result.GetErrorSize() > 0)
+            m_io_channel_ap->OutWrite (result.GetError(), result.GetErrorSize(), NO_ASYNC);
+
         // We are done getting and running our command, we can now clear the
         // m_waiting_for_command so we can get another one.
         m_waiting_for_command = false;





More information about the lldb-commits mailing list