[Lldb-commits] [lldb] r131110 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/Core/Debugger.h source/API/SBDebugger.cpp source/Core/Debugger.cpp tools/driver/Driver.h tools/driver/IOChannel.cpp

Caroline Tice ctice at apple.com
Mon May 9 16:06:58 PDT 2011


Author: ctice
Date: Mon May  9 18:06:58 2011
New Revision: 131110

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

Make sure writing asynchronous output only backs up
& overwrites prompt if the IOChannel input reader is the top
input reader.


Modified:
    lldb/trunk/include/lldb/API/SBDebugger.h
    lldb/trunk/include/lldb/Core/Debugger.h
    lldb/trunk/source/API/SBDebugger.cpp
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/tools/driver/Driver.h
    lldb/trunk/tools/driver/IOChannel.cpp

Modified: lldb/trunk/include/lldb/API/SBDebugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=131110&r1=131109&r2=131110&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDebugger.h (original)
+++ lldb/trunk/include/lldb/API/SBDebugger.h Mon May  9 18:06:58 2011
@@ -166,6 +166,9 @@
     void
     NotifyTopInputReader (lldb::InputReaderAction notification);
 
+    bool
+    InputReaderIsTopReader (const lldb::SBInputReader &reader);
+
     const char *
     GetInstanceName  ();
 

Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=131110&r1=131109&r2=131110&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Mon May  9 18:06:58 2011
@@ -391,6 +391,9 @@
     void
     NotifyTopInputReader (lldb::InputReaderAction notification);
 
+    bool
+    InputReaderIsTopReader (const lldb::InputReaderSP& reader_sp);
+    
     static lldb::DebuggerSP
     FindDebuggerWithID (lldb::user_id_t id);
     

Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=131110&r1=131109&r2=131110&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Mon May  9 18:06:58 2011
@@ -619,6 +619,24 @@
     if (m_opaque_sp)
         m_opaque_sp->DispatchInputEndOfFile ();
 }
+    
+bool
+SBDebugger::InputReaderIsTopReader (const lldb::SBInputReader &reader)
+{
+    LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+    if (log)
+        log->Printf ("SBDebugger(%p)::InputReaderIsTopReader (SBInputReader(%p))", m_opaque_sp.get(), &reader);
+
+    if (m_opaque_sp && reader.IsValid())
+    {
+        InputReaderSP reader_sp (*reader);
+        return m_opaque_sp->InputReaderIsTopReader (reader_sp);
+    }
+
+    return false;
+}
+
 
 void
 SBDebugger::PushInputReader (SBInputReader &reader)

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=131110&r1=131109&r2=131110&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Mon May  9 18:06:58 2011
@@ -437,6 +437,25 @@
     }
 }
 
+bool
+Debugger::InputReaderIsTopReader (const lldb::InputReaderSP& reader_sp)
+{
+    if (reader_sp)
+    {
+        InputReaderSP top_reader_sp (GetCurrentInputReader());
+        if (top_reader_sp)
+        {
+            return (reader_sp.get() == top_reader_sp.get());
+        }
+        else
+            return false;
+    }
+    else
+        return false;
+
+}
+    
+
 void
 Debugger::WriteToDefaultReader (const char *bytes, size_t bytes_len)
 {

Modified: lldb/trunk/tools/driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.h?rev=131110&r1=131109&r2=131110&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.h (original)
+++ lldb/trunk/tools/driver/Driver.h Mon May  9 18:06:58 2011
@@ -122,6 +122,12 @@
     {
         return m_debugger;
     }
+    
+    bool
+    EditlineReaderIsTop ()
+    {
+        return m_debugger.InputReaderIsTopReader (m_editline_reader);
+    }
 
 private:
     lldb::SBDebugger m_debugger;

Modified: lldb/trunk/tools/driver/IOChannel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/IOChannel.cpp?rev=131110&r1=131109&r2=131110&view=diff
==============================================================================
--- lldb/trunk/tools/driver/IOChannel.cpp (original)
+++ lldb/trunk/tools/driver/IOChannel.cpp Mon May  9 18:06:58 2011
@@ -499,7 +499,7 @@
 
     // Use the mutex to make sure OutWrite and ErrWrite do not interfere with each other's output.
     IOLocker locker (m_output_mutex);
-    if (asynchronous)
+    if (m_driver->EditlineReaderIsTop() && asynchronous)
         ::fwrite (undo_prompt_string, 1, 4, m_out_file);
     ::fwrite (buffer, 1, len, m_out_file);
     if (asynchronous)





More information about the lldb-commits mailing list