[Lldb-commits] [lldb] r124017 - /lldb/trunk/source/Target/Process.cpp

Jim Ingham jingham at apple.com
Fri Jan 21 17:30:53 PST 2011


Author: jingham
Date: Fri Jan 21 19:30:53 2011
New Revision: 124017

URL: http://llvm.org/viewvc/llvm-project?rev=124017&view=rev
Log:
Add more logging.  Try to handle the case where "Halt" fails.  This is kind of a losing game in the end, if we can't halt the target, it is not clear what we can do but keep trying...

Modified:
    lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=124017&r1=124016&r2=124017&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Fri Jan 21 19:30:53 2011
@@ -2651,7 +2651,9 @@
                                  single_thread_timeout_usec);
             }
             
-            if (exe_ctx.process->Halt().Success())
+            Error halt_error = exe_ctx.process->Halt();
+            
+            if (halt_error.Success())
             {
                 timeout_ptr = NULL;
                 if (log)
@@ -2698,6 +2700,22 @@
                     }
                 }
             }
+            else
+            {
+                
+                if (log)
+                    log->Printf ("Halt failed: \"%s\", I'm just going to wait a little longer and see if the world gets nicer to me.", 
+                                 halt_error.AsCString());
+                
+                    if (single_thread_timeout_usec != 0)
+                    {
+                        real_timeout = TimeValue::Now();
+                        real_timeout.OffsetWithMicroSeconds(single_thread_timeout_usec);
+                        timeout_ptr = &real_timeout;
+                    }
+                    continue;
+            }
+
         }
         
         stop_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
@@ -2722,7 +2740,13 @@
             if (log)
             {
                 StreamString s;
-                event_sp->Dump (&s);
+                if (event_sp)
+                    event_sp->Dump (&s);
+                else
+                {
+                    log->Printf ("Stop event that interrupted us is NULL.");
+                }
+
                 StreamString ts;
 
                 const char *event_explanation;                
@@ -2764,7 +2788,7 @@
                             continue;
                         }
                         
-                        ts.Printf("<");
+                        ts.Printf("<0x%4.4x ", thread->GetID());
                         RegisterContext *register_context = thread->GetRegisterContext().get();
                         
                         if (register_context)
@@ -2785,8 +2809,26 @@
                     event_explanation = ts.GetData();
                 } while (0);
                 
-                if (log)
-                    log->Printf("Execution interrupted: %s %s", s.GetData(), event_explanation);
+                // See if any of the threads that stopped think we ought to stop.  Otherwise continue on.
+                if (!GetThreadList().ShouldStop(event_sp.get()))
+                {
+                    if (log)
+                        log->Printf("Execution interrupted, but nobody wanted to stop, so we continued: %s %s", 
+                                    s.GetData(), event_explanation);
+                    if (single_thread_timeout_usec != 0)
+                    {
+                        real_timeout = TimeValue::Now();
+                        real_timeout.OffsetWithMicroSeconds(single_thread_timeout_usec);
+                        timeout_ptr = &real_timeout;
+                    }
+    
+                    continue;
+                }
+                else
+                {
+                    if (log)
+                        log->Printf("Execution interrupted: %s %s", s.GetData(), event_explanation);
+                }
             }
             
             if (discard_on_error && thread_plan_sp)





More information about the lldb-commits mailing list