Index: include/lldb/Core/Debugger.h
===================================================================
--- include/lldb/Core/Debugger.h	(revision 234429)
+++ include/lldb/Core/Debugger.h	(working copy)
@@ -210,6 +210,9 @@
     bool
     IsTopIOHandler (const lldb::IOHandlerSP& reader_sp);
 
+    void
+    PrintAsync (const char *s, size_t len);
+
     ConstString
     GetTopIOHandlerControlSequence(char ch);
 
Index: include/lldb/Core/IOHandler.h
===================================================================
--- include/lldb/Core/IOHandler.h	(revision 234429)
+++ include/lldb/Core/IOHandler.h	(working copy)
@@ -246,7 +246,7 @@
         
         void
         WaitForPop ();
-        
+
     protected:
         Debugger &m_debugger;
         lldb::StreamFileSP m_input_sp;
@@ -849,10 +849,14 @@
             return NULL;
         }
 
-    protected:        
+        void
+        PrintAsync (const char *s, size_t len);
+
+    protected:
         
         typedef std::vector<lldb::IOHandlerSP> collection;
         collection m_stack;
+        std::string m_async_output;
         mutable Mutex m_mutex;
         IOHandler *m_top;
         
Index: include/lldb/Core/StreamAsynchronousIO.h
===================================================================
--- include/lldb/Core/StreamAsynchronousIO.h	(revision 234429)
+++ include/lldb/Core/StreamAsynchronousIO.h	(working copy)
@@ -20,7 +20,7 @@
     public Stream
 {
 public:
-    StreamAsynchronousIO (Broadcaster &broadcaster, uint32_t broadcast_event_type);
+    StreamAsynchronousIO (Debugger &debugger);
     
     virtual ~StreamAsynchronousIO ();
     
@@ -32,9 +32,8 @@
     
     
 private:
-    Broadcaster &m_broadcaster;
-    uint32_t m_broadcast_event_type;
-    std::string m_accumulated_data;
+    Debugger &m_debugger;
+    std::string m_data;
 };
 
 } // namespace lldb_private
Index: include/lldb/Target/Process.h
===================================================================
--- include/lldb/Target/Process.h	(revision 234429)
+++ include/lldb/Target/Process.h	(working copy)
@@ -2718,24 +2718,6 @@
                           Stream *stream = NULL);
 
 
-    //--------------------------------------------------------------------------------------
-    /// Waits for the process state to be running within a given msec timeout.
-    ///
-    /// The main purpose of this is to implement an interlock waiting for HandlePrivateEvent
-    /// to push an IOHandler.
-    ///
-    /// @param[in] timeout_msec
-    ///     The maximum time length to wait for the process to transition to the
-    ///     eStateRunning state, specified in milliseconds.
-    ///
-    /// @return
-    ///     true if successfully signalled that process started and IOHandler pushes, false
-    ///     if it timed out.
-    //--------------------------------------------------------------------------------------
-    bool
-    SyncIOHandler (uint64_t timeout_msec);
-
-
     lldb::StateType
     WaitForStateChangedEvents (const TimeValue *timeout,
                                lldb::EventSP &event_sp,
@@ -3157,7 +3139,6 @@
     std::string                 m_stderr_data;
     Mutex                       m_profile_data_comm_mutex;
     std::vector<std::string>    m_profile_data;
-    Predicate<bool>             m_iohandler_sync;
     MemoryCache                 m_memory_cache;
     AllocatedMemoryCache        m_allocated_memory_cache;
     bool                        m_should_detach;   /// Should we detach if the process object goes away with an explicit call to Kill or Detach?
Index: source/Commands/CommandObjectProcess.cpp
===================================================================
--- source/Commands/CommandObjectProcess.cpp	(revision 234429)
+++ source/Commands/CommandObjectProcess.cpp	(working copy)
@@ -766,11 +766,6 @@
 
             if (error.Success())
             {
-                // There is a race condition where this thread will return up the call stack to the main command
-                // handler and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has
-                // a chance to call PushProcessIOHandler().
-                process->SyncIOHandler(2000);
-
                 result.AppendMessageWithFormat ("Process %" PRIu64 " resuming\n", process->GetID());
                 if (synchronous_execution)
                 {
Index: source/Commands/CommandObjectThread.cpp
===================================================================
--- source/Commands/CommandObjectThread.cpp	(revision 234429)
+++ source/Commands/CommandObjectThread.cpp	(working copy)
@@ -676,11 +676,6 @@
             else
                 error = process->Resume ();
 
-            // There is a race condition where this thread will return up the call stack to the main command handler
-            // and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has
-            // a chance to call PushProcessIOHandler().
-            process->SyncIOHandler(2000);
-
             if (synchronous_execution)
             {
                 // If any state changed events had anything to say, add that to the result
Index: source/Core/Debugger.cpp
===================================================================
--- source/Core/Debugger.cpp	(revision 234429)
+++ source/Core/Debugger.cpp	(working copy)
@@ -926,6 +926,13 @@
     return m_input_reader_stack.IsTop (reader_sp);
 }
 
+void
+Debugger::PrintAsync (const char *s, size_t len)
+{
+    static Mutex g_mutex(Mutex::eMutexTypeRecursive);
+    Mutex::Locker locker(g_mutex);
+    m_input_reader_stack.PrintAsync(s, len);
+}
 
 ConstString
 Debugger::GetTopIOHandlerControlSequence(char ch)
@@ -1102,15 +1109,13 @@
 StreamSP
 Debugger::GetAsyncOutputStream ()
 {
-    return StreamSP (new StreamAsynchronousIO (GetCommandInterpreter(),
-                                               CommandInterpreter::eBroadcastBitAsynchronousOutputData));
+    return StreamSP (new StreamAsynchronousIO (*this));
 }
 
 StreamSP
 Debugger::GetAsyncErrorStream ()
 {
-    return StreamSP (new StreamAsynchronousIO (GetCommandInterpreter(),
-                                               CommandInterpreter::eBroadcastBitAsynchronousErrorData));
+    return StreamSP (new StreamAsynchronousIO (*this));
 }    
 
 size_t
@@ -1490,8 +1495,8 @@
     const uint32_t event_type = event_sp->GetType();
     ProcessSP process_sp = Process::ProcessEventData::GetProcessFromEvent(event_sp.get());
 
-    StreamString output_stream;
-    StreamString error_stream;
+    StreamSP output_stream_sp = GetAsyncOutputStream();
+    StreamSP error_stream_sp = GetAsyncErrorStream();
     const bool gui_enabled = IsForwardingEvents();
 
     if (!gui_enabled)
@@ -1499,47 +1504,43 @@
         bool pop_process_io_handler = false;
         assert (process_sp);
 
-        if (event_type & Process::eBroadcastBitSTDOUT || event_type & Process::eBroadcastBitStateChanged)
+        bool state_is_stopped = false;
+        const bool got_state_changed = (event_type & Process::eBroadcastBitStateChanged) != 0;
+        const bool got_stdout = (event_type & Process::eBroadcastBitSTDOUT) != 0;
+        const bool got_stderr = (event_type & Process::eBroadcastBitSTDERR) != 0;
+        if (got_state_changed)
         {
-            GetProcessSTDOUT (process_sp.get(), &output_stream);
+            StateType event_state = Process::ProcessEventData::GetStateFromEvent (event_sp.get());
+            state_is_stopped = StateIsStoppedState(event_state, false);
         }
 
-        if (event_type & Process::eBroadcastBitSTDERR || event_type & Process::eBroadcastBitStateChanged)
+        // Display running state changes first before any STDIO
+        if (got_state_changed && !state_is_stopped)
         {
-            GetProcessSTDERR (process_sp.get(), &error_stream);
+            Process::HandleProcessStateChangedEvent (event_sp, output_stream_sp.get(), pop_process_io_handler);
         }
 
-        if (event_type & Process::eBroadcastBitStateChanged)
+        // Now display and STDOUT
+        if (got_stdout || got_state_changed)
         {
-            Process::HandleProcessStateChangedEvent (event_sp, &output_stream, pop_process_io_handler);
+            GetProcessSTDOUT (process_sp.get(), output_stream_sp.get());
         }
 
-        if (output_stream.GetSize() || error_stream.GetSize())
+        // Now display and STDERR
+        if (got_stderr || got_state_changed)
         {
-            StreamFileSP error_stream_sp (GetOutputFile());
-            bool top_io_handler_hid = false;
+            GetProcessSTDERR (process_sp.get(), error_stream_sp.get());
+        }
 
-            if (process_sp->ProcessIOHandlerIsActive() == false)
-                top_io_handler_hid = HideTopIOHandler();
+        // Now display any stopped state changes after any STDIO
+        if (got_state_changed && state_is_stopped)
+        {
+            Process::HandleProcessStateChangedEvent (event_sp, output_stream_sp.get(), pop_process_io_handler);
+        }
 
-            if (output_stream.GetSize())
-            {
-                StreamFileSP output_stream_sp (GetOutputFile());
-                if (output_stream_sp)
-                    output_stream_sp->Write (output_stream.GetData(), output_stream.GetSize());
-            }
+        output_stream_sp->Flush();
+        error_stream_sp->Flush();
 
-            if (error_stream.GetSize())
-            {
-                StreamFileSP error_stream_sp (GetErrorFile());
-                if (error_stream_sp)
-                    error_stream_sp->Write (error_stream.GetData(), error_stream.GetSize());
-            }
-
-            if (top_io_handler_hid)
-                RefreshTopIOHandler();
-        }
-
         if (pop_process_io_handler)
             process_sp->PopProcessIOHandler();
     }
Index: source/Core/IOHandler.cpp
===================================================================
--- source/Core/IOHandler.cpp	(revision 234429)
+++ source/Core/IOHandler.cpp	(working copy)
@@ -169,6 +169,18 @@
     m_popped.WaitForValueEqualTo(true);
 }
 
+void
+IOHandlerStack::PrintAsync (const char *s, size_t len)
+{
+    Mutex::Locker locker (m_mutex);
+    if (m_top)
+    {
+        m_top->Hide();
+        m_top->GetOutputStreamFile()->Write (s, len);
+        m_top->Refresh();
+    }
+}
+
 IOHandlerConfirm::IOHandlerConfirm (Debugger &debugger,
                                     const char *prompt,
                                     bool default_response) :
Index: source/Core/StreamAsynchronousIO.cpp
===================================================================
--- source/Core/StreamAsynchronousIO.cpp	(revision 234429)
+++ source/Core/StreamAsynchronousIO.cpp	(working copy)
@@ -7,22 +7,19 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <stdio.h>
+#include "lldb/Core/StreamAsynchronousIO.h"
 
 #include "lldb/lldb-private.h"
-#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/Event.h"
-#include "lldb/Core/StreamAsynchronousIO.h"
+#include "lldb/Core/Debugger.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
 
-StreamAsynchronousIO::StreamAsynchronousIO (Broadcaster &broadcaster, uint32_t broadcast_event_type) :
+StreamAsynchronousIO::StreamAsynchronousIO (Debugger &debugger) :
     Stream (0, 4, eByteOrderBig),
-    m_broadcaster (broadcaster),
-    m_broadcast_event_type (broadcast_event_type),
-    m_accumulated_data ()
+    m_debugger (debugger),
+    m_data ()
 {
 }
 
@@ -35,19 +32,16 @@
 void
 StreamAsynchronousIO::Flush ()
 {
-    if (!m_accumulated_data.empty())
+    if (!m_data.empty())
     {
-        std::unique_ptr<EventDataBytes> data_bytes_ap (new EventDataBytes);
-        // Let's swap the bytes to avoid LARGE string copies.
-        data_bytes_ap->SwapBytes (m_accumulated_data);
-        EventSP new_event_sp (new Event (m_broadcast_event_type, data_bytes_ap.release()));
-        m_broadcaster.BroadcastEvent (new_event_sp);
+        m_debugger.PrintAsync (m_data.data(), m_data.size());
+        m_data = std::move(std::string());
     }
 }
 
 size_t
 StreamAsynchronousIO::Write (const void *s, size_t length)
 {
-    m_accumulated_data.append ((const char *)s, length);
+    m_data.append ((const char *)s, length);
     return length;
 }
Index: source/Target/Process.cpp
===================================================================
--- source/Target/Process.cpp	(revision 234429)
+++ source/Target/Process.cpp	(working copy)
@@ -740,7 +740,6 @@
     m_stderr_data (),
     m_profile_data_comm_mutex (Mutex::eMutexTypeRecursive),
     m_profile_data (),
-    m_iohandler_sync (false),
     m_memory_cache (*this),
     m_allocated_memory_cache (*this),
     m_should_detach (false),
@@ -949,35 +948,6 @@
     return state;
 }
 
-bool
-Process::SyncIOHandler (uint64_t timeout_msec)
-{
-    bool timed_out = false;
-
-    // don't sync (potentially context switch) in case where there is no process IO
-    if (m_process_input_reader)
-    {
-        TimeValue timeout = TimeValue::Now();
-        timeout.OffsetWithMicroSeconds(timeout_msec*1000);
-
-        m_iohandler_sync.WaitForValueEqualTo(true, &timeout, &timed_out);
-
-        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-        if(log)
-        {
-            if(timed_out)
-                log->Printf ("Process::%s pid %" PRIu64 " (timeout=%" PRIu64 "ms): FAIL", __FUNCTION__, GetID (), timeout_msec);
-            else
-                log->Printf ("Process::%s pid %" PRIu64 ": SUCCESS", __FUNCTION__, GetID ());
-        }
-
-        // reset sync one-shot so it will be ready for next launch
-        m_iohandler_sync.SetValue(false, eBroadcastNever);
-    }
-
-    return !timed_out;
-}
-
 StateType
 Process::WaitForProcessToStop (const TimeValue *timeout,
                                EventSP *event_sp_ptr,
@@ -4435,11 +4405,9 @@
             // Or don't push it if we are launching since it will come up stopped.
             if (!GetTarget().GetDebugger().IsForwardingEvents() && new_state != eStateLaunching)
                 PushProcessIOHandler ();
-            m_iohandler_sync.SetValue(true, eBroadcastAlways);
         }
         else if (StateIsStoppedState(new_state, false))
         {
-            m_iohandler_sync.SetValue(false, eBroadcastNever);
             if (!Process::ProcessEventData::GetRestartedFromEvent(event_sp.get()))
             {
                 // If the lldb_private::Debugger is handling the events, we don't
Index: source/Target/Target.cpp
===================================================================
--- source/Target/Target.cpp	(revision 234429)
+++ source/Target/Target.cpp	(working copy)
@@ -2635,13 +2635,6 @@
                     {
                         m_process_sp->RestoreProcessEvents();
                         error = m_process_sp->PrivateResume();
-                        if (error.Success())
-                        {
-                            // there is a race condition where this thread will return up the call stack to the main command
-                            // handler and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has
-                            // a chance to call PushProcessIOHandler()
-                            m_process_sp->SyncIOHandler(2000);
-                        }
                     }
                     if (!error.Success())
                     {
@@ -2657,11 +2650,6 @@
                     // Target was stopped at entry as was intended. Need to notify the listeners about it.
                     m_process_sp->RestoreProcessEvents();
                     m_process_sp->HandlePrivateEvent(event_sp);
-
-                    // there is a race condition where this thread will return up the call stack to the main command
-                    // handler and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has
-                    // a chance to call PushProcessIOHandler()
-                    m_process_sp->SyncIOHandler(2000);
                 }
             }
             else if (state == eStateExited)
