[Lldb-commits] [lldb] r122255 - in /lldb/trunk: include/lldb/Core/Debugger.h source/API/SBDebugger.cpp source/Core/Debugger.cpp

Caroline Tice ctice at apple.com
Mon Dec 20 10:35:50 PST 2010


Author: ctice
Date: Mon Dec 20 12:35:50 2010
New Revision: 122255

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

Add code to make sure InputReaders finish and are cleaned up when
a Debugger object is destroyed or re-set. (Thus making sure that, for
example, the Python interpreter finishes and exits cleanly rather than
being left in an undefined state.)


Modified:
    lldb/trunk/include/lldb/Core/Debugger.h
    lldb/trunk/source/API/SBDebugger.cpp
    lldb/trunk/source/Core/Debugger.cpp

Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=122255&r1=122254&r2=122255&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Mon Dec 20 12:35:50 2010
@@ -372,6 +372,9 @@
                   const char **end);
 
 
+    void
+    CleanUpInputReaders ();
+
 protected:
 
     static void

Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=122255&r1=122254&r2=122255&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Mon Dec 20 12:35:50 2010
@@ -58,6 +58,9 @@
 
     if (log)
         log->Printf ("SBDebugger(%p)::Clear ()", m_opaque_sp.get());
+        
+    if (m_opaque_sp)
+        m_opaque_sp->CleanUpInputReaders ();
 
     m_opaque_sp.reset();
 }

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=122255&r1=122254&r2=122255&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Mon Dec 20 12:35:50 2010
@@ -184,6 +184,7 @@
 
 Debugger::~Debugger ()
 {
+    CleanUpInputReaders();
     int num_targets = m_target_list.GetNumTargets();
     for (int i = 0; i < num_targets; i++)
     {
@@ -390,6 +391,24 @@
 }
 
 void
+Debugger::CleanUpInputReaders ()
+{
+    m_input_reader_data.clear();
+    
+    while (m_input_readers.size() > 1)
+    {
+        while (CheckIfTopInputReaderIsDone ()) ;
+        
+        InputReaderSP reader_sp (m_input_readers.top());
+        if (reader_sp)
+        {
+            reader_sp->Notify (eInputReaderEndOfFile);
+            reader_sp->SetIsDone (true);
+        }
+    }
+}
+
+void
 Debugger::WriteToDefaultReader (const char *bytes, size_t bytes_len)
 {
     if (bytes && bytes_len)





More information about the lldb-commits mailing list