[Lldb-commits] [lldb] r118189 - in /lldb/trunk: include/lldb/Target/ThreadPlan.h include/lldb/Target/ThreadPlanCallFunction.h source/Expression/ClangFunction.cpp source/Target/ThreadPlanCallFunction.cpp

Sean Callanan scallanan at apple.com
Wed Nov 3 12:36:28 PDT 2010


Author: spyffe
Date: Wed Nov  3 14:36:28 2010
New Revision: 118189

URL: http://llvm.org/viewvc/llvm-project?rev=118189&view=rev
Log:
Modified ThreadPlanCallFunction to perform the
exception checks at the right time, and modified
ClangFunction so that it doesn't misinterpret the
stop as a timeout stop.

Modified:
    lldb/trunk/include/lldb/Target/ThreadPlan.h
    lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h
    lldb/trunk/source/Expression/ClangFunction.cpp
    lldb/trunk/source/Target/ThreadPlanCallFunction.cpp

Modified: lldb/trunk/include/lldb/Target/ThreadPlan.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlan.h?rev=118189&r1=118188&r2=118189&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlan.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlan.h Wed Nov  3 14:36:28 2010
@@ -319,18 +319,18 @@
     {
         return m_kind;
     }
+    
+    bool
+    IsPlanComplete();
+    
+    void
+    SetPlanComplete ();
 
 protected:
     //------------------------------------------------------------------
     // Classes that inherit from ThreadPlan can see and modify these
     //------------------------------------------------------------------
 
-    bool
-    IsPlanComplete();
-
-    void
-    SetPlanComplete ();
-
     // This gets the previous plan to the current plan (for forwarding requests).
     // This is mostly a formal requirement, it allows us to make the Thread's
     // GetPreviousPlan protected, but only friend ThreadPlan to thread.

Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h?rev=118189&r1=118188&r2=118189&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h Wed Nov  3 14:36:28 2010
@@ -83,6 +83,9 @@
     void
     ClearBreakpoints ();
     
+    bool
+    BreakpointsExplainStop ();
+    
     bool                                            m_use_abi;
     bool                                            m_valid;
     bool                                            m_stop_other_threads;

Modified: lldb/trunk/source/Expression/ClangFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=118189&r1=118188&r2=118189&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangFunction.cpp Wed Nov  3 14:36:28 2010
@@ -538,7 +538,7 @@
         // Now wait for the process to stop again:
         bool got_event = listener.WaitForEvent (timeout_ptr, event_sp);
         
-        if (!got_event)
+        if (!got_event && !call_plan_sp->IsPlanComplete())
         {
             // Right now this is the only way to tell we've timed out...
             // We should interrupt the process here...

Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=118189&r1=118188&r2=118189&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Wed Nov  3 14:36:28 2010
@@ -184,6 +184,11 @@
     if(m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop())
         return true;
     
+    // Check if the breakpoint is one of ours.
+    
+    if (BreakpointsExplainStop())
+        return true;
+    
     // If we don't want to discard this plan, than any stop we don't understand should be propagated up the stack.
     if (!OkayToDiscard())
         return false;
@@ -203,21 +208,6 @@
             for (uint32_t i = 0; i < num_owners; i++)
             {
                 Breakpoint &bp = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
-                break_id_t bid = bp.GetID();
-                
-                // Check if the breakpoint is one of ours.
-                
-                if (m_cxx_exception_bp_sp.get() &&
-                    bid == m_cxx_exception_bp_sp->GetID())
-                    return true;
-                
-                if (m_cxx_exception_alloc_bp_sp.get() &&
-                    bid == m_cxx_exception_alloc_bp_sp->GetID())
-                    return true;
-                
-                if (m_objc_exception_bp_sp.get() &&
-                    bid == m_objc_exception_bp_sp->GetID())
-                    return true;
                 
                 if (!bp.IsInternal())
                 {
@@ -342,8 +332,6 @@
     
     ArchSpec arch_spec = target.GetArchitecture();
     
-    // A temporary fix to set breakpoints at points where exceptions are being
-    // thrown.  This functionality will migrate into the Target.
     switch (arch_spec.GetCPUType())
     {
     default:
@@ -398,3 +386,64 @@
         m_cxx_exception_bp_sp.reset();
     }
 }
+
+bool
+ThreadPlanCallFunction::BreakpointsExplainStop()
+{
+    // A temporary fix to set breakpoints at points where exceptions are being
+    // thrown.  This functionality will migrate into the Target.
+    
+    lldb::StopInfoSP stop_info_sp = GetPrivateStopReason();
+    
+    if (!stop_info_sp || 
+        stop_info_sp->GetStopReason() != eStopReasonBreakpoint)
+        return false;
+    
+    uint64_t break_site_id = stop_info_sp->GetValue();
+    lldb::BreakpointSiteSP bp_site_sp = m_thread.GetProcess().GetBreakpointSiteList().FindByID(break_site_id);
+    
+    if (!bp_site_sp)
+        return false;
+    
+    uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
+    
+    bool        check_cxx_exception = false;
+    break_id_t  cxx_exception_bid;
+    
+    bool        check_cxx_exception_alloc = false;
+    break_id_t  cxx_exception_alloc_bid;
+    
+    bool        check_objc_exception = false;
+    break_id_t  objc_exception_bid;
+    
+    if (m_cxx_exception_bp_sp.get())
+    {
+        check_cxx_exception = true;
+        cxx_exception_bid = m_cxx_exception_bp_sp->GetID();
+    }
+    
+    if (m_cxx_exception_bp_sp.get())
+    {
+        check_cxx_exception_alloc = true;
+        cxx_exception_alloc_bid = m_cxx_exception_alloc_bp_sp->GetID();
+    }
+    
+    if (m_cxx_exception_bp_sp.get())
+    {
+        check_objc_exception = true;
+        objc_exception_bid = m_objc_exception_bp_sp->GetID();
+    }
+        
+
+    for (uint32_t i = 0; i < num_owners; i++)
+    {
+        break_id_t bid = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().GetID();
+        
+        if ((check_cxx_exception        && (bid == cxx_exception_bid)) ||
+            (check_cxx_exception_alloc  && (bid == cxx_exception_alloc_bid)) ||
+            (check_objc_exception       && (bid == objc_exception_bid)))
+            return true;
+    }
+    
+    return false;
+}





More information about the lldb-commits mailing list