[Lldb-commits] [lldb] r179332 - Save away the locations at the site we hit and iterate over that collection. Otherwise the action of one location

Jim Ingham jingham at apple.com
Thu Apr 11 15:53:47 PDT 2013


Author: jingham
Date: Thu Apr 11 17:53:47 2013
New Revision: 179332

URL: http://llvm.org/viewvc/llvm-project?rev=179332&view=rev
Log:
Save away the locations at the site we hit and iterate over that collection.  Otherwise the action of one location
could delete the other locations, and that would leave us iterating over a reduced size collection and crash.

<rdar://problem/13592544>

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

Modified: lldb/trunk/source/Target/StopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=179332&r1=179331&r2=179332&view=diff
==============================================================================
--- lldb/trunk/source/Target/StopInfo.cpp (original)
+++ lldb/trunk/source/Target/StopInfo.cpp Thu Apr 11 17:53:47 2013
@@ -363,13 +363,29 @@ protected:
                 }
                 
                 StoppointCallbackContext context (event_ptr, exe_ctx, false);
+                
+                // Let's copy the breakpoint locations out of the site and store them in a local list.  That way if
+                // one of the breakpoint actions changes the site, then we won't be operating on a bad list.
+                
+                BreakpointLocationCollection site_locations;
+                for (size_t j = 0; j < num_owners; j++)
+                    site_locations.Add(bp_site_sp->GetOwnerAtIndex(j));
 
                 for (size_t j = 0; j < num_owners; j++)
                 {
-                    lldb::BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(j);
+                    lldb::BreakpointLocationSP bp_loc_sp = site_locations.GetByIndex(j);
+                    
+                    // If another action disabled this breakpoint or its location, then don't run the actions.
+                    if (!bp_loc_sp->IsEnabled() || !bp_loc_sp->GetBreakpoint().IsEnabled())
+                        continue;
+                    
+                    // The breakpoint site may have many locations associated with it, not all of them valid for
+                    // this thread.  Skip the ones that aren't:
+                    if (!bp_loc_sp->ValidForThisThread(&m_thread))
+                        continue;
                                                       
                     // First run the condition for the breakpoint.  If that says we should stop, then we'll run
-                    // the callback for the breakpoint.  If the callback says we shouldn't stop that will win.
+                    // the callback for the breakpoint.  If the callback says we shouldn't stop that will win.                    
                     
                     bool condition_says_stop = true;
                     if (bp_loc_sp->GetConditionText() != NULL)





More information about the lldb-commits mailing list