Add the ability to catch and do the right thing with Interrupts (often control-c)
and end-of-file (often control-d).

llvm-svn: 119837
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 617edd2f..a06095f 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -338,20 +338,57 @@
 void
 Debugger::DispatchInputCallback (void *baton, const void *bytes, size_t bytes_len)
 {
-    ((Debugger *)baton)->DispatchInput ((char *)bytes, bytes_len);
-}
+    if (bytes_len > 0)
+        ((Debugger *)baton)->DispatchInput ((char *)bytes, bytes_len);
+    else
+        ((Debugger *)baton)->DispatchInputEndOfFile ();
+}   
 
 
 void
 Debugger::DispatchInput (const char *bytes, size_t bytes_len)
 {
-//    if (bytes == NULL || bytes_len == 0)
-//        return;
+    if (bytes == NULL || bytes_len == 0)
+        return;
 
     WriteToDefaultReader (bytes, bytes_len);
 }
 
 void
+Debugger::DispatchInputInterrupt ()
+{
+    m_input_reader_data.clear();
+    
+    if (!m_input_readers.empty())
+    {
+        while (CheckIfTopInputReaderIsDone ()) ;
+        
+        InputReaderSP reader_sp(m_input_readers.top());
+        if (reader_sp)
+            reader_sp->Notify (eInputReaderInterrupt);
+
+        while (CheckIfTopInputReaderIsDone ()) ;
+    }
+}
+
+void
+Debugger::DispatchInputEndOfFile ()
+{
+    m_input_reader_data.clear();
+    
+    if (!m_input_readers.empty())
+    {
+        while (CheckIfTopInputReaderIsDone ()) ;
+        
+        InputReaderSP reader_sp(m_input_readers.top());
+        if (reader_sp)
+            reader_sp->Notify (eInputReaderEndOfFile);
+
+        while (CheckIfTopInputReaderIsDone ()) ;
+    }
+}
+
+void
 Debugger::WriteToDefaultReader (const char *bytes, size_t bytes_len)
 {
     if (bytes && bytes_len)