Author: gclayton
Date: Thu Jun 19 19:23:57 2014
New Revision: 211329

URL: http://llvm.org/viewvc/llvm-project?rev=211329&view=rev
Log:
Command files that switch input handlers didn't work, now they do.

The issue was when we called Debugger::RunIOHandler(), it would run the current 
IOHandler by activating it, and running it and then try to pop it and exit 
regardless of wether it was on top or not.

The new code will push the IOHandler that was passed in, and run the IOHandlers 
until the one passed in is successfully popped. This allows files for the 
"command source" to switch input handlers:

% cat /tmp/commands
br s -S alignLeftEdges:
br command add
bt
frame var
po self
DONE
b s -n main
br command add
bt
frame var
DONE

Note above we set a breakpoint, then add commands do it. The "br command add" 
will push the breakpoint comment gatherer until it sees "DONE" and then pop 
itself off the stack. The a new breakpoint will be set and it does the same 
thing again.

Now this file can be sourced from the command line:

% lldb -s /tmp/commands /path/to/a.out

And your breakpoints will be correctly setup!

<rdar://problem/17081650>


Modified:
    lldb/trunk/source/Core/Debugger.cpp

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=211329&r1=211328&r2=211329&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Thu Jun 19 19:23:57 2014
@@ -902,9 +902,29 @@ Debugger::RunIOHandler (const IOHandlerS
 {
     Mutex::Locker locker (m_input_reader_stack.GetMutex());
     PushIOHandler (reader_sp);
-    reader_sp->Activate();
-    reader_sp->Run();
-    PopIOHandler (reader_sp);
+    
+    IOHandlerSP top_reader_sp = reader_sp;
+    while (top_reader_sp)
+    {
+        top_reader_sp->Activate();
+        top_reader_sp->Run();
+        top_reader_sp->Deactivate();
+        
+        if (top_reader_sp.get() == reader_sp.get())
+        {
+            if (PopIOHandler (reader_sp))
+                break;
+        }
+        
+        while (1)
+        {
+            top_reader_sp = m_input_reader_stack.Top();
+            if (top_reader_sp && top_reader_sp->GetIsDone())
+                m_input_reader_stack.Pop();
+            else
+                break;
+        }
+    }
 }
 
 void


_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to