[Lldb-commits] [lldb] r159233 - in /lldb/trunk: include/lldb/Breakpoint/Breakpoint.h include/lldb/Breakpoint/BreakpointLocation.h include/lldb/Breakpoint/StoppointLocation.h source/Breakpoint/Breakpoint.cpp source/Breakpoint/BreakpointLocation.cpp

Jim Ingham jingham at apple.com
Tue Jun 26 15:27:55 PDT 2012


Author: jingham
Date: Tue Jun 26 17:27:55 2012
New Revision: 159233

URL: http://llvm.org/viewvc/llvm-project?rev=159233&view=rev
Log:
Fix ignore counts on breakpoints so they actually work.

Modified:
    lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
    lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h
    lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h
    lldb/trunk/source/Breakpoint/Breakpoint.cpp
    lldb/trunk/source/Breakpoint/BreakpointLocation.cpp

Modified: lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Breakpoint.h?rev=159233&r1=159232&r2=159233&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/Breakpoint.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/Breakpoint.h Tue Jun 26 17:27:55 2012
@@ -345,7 +345,7 @@
     //------------------------------------------------------------------
     uint32_t
     GetIgnoreCount () const;
-
+    
     //------------------------------------------------------------------
     /// Return the current hit count for all locations.
     /// @return
@@ -551,6 +551,18 @@
     //------------------------------------------------------------------
     // This is the generic constructor
     Breakpoint(Target &target, lldb::SearchFilterSP &filter_sp, lldb::BreakpointResolverSP &resolver_sp);
+    
+    friend class BreakpointLocation;  // To call the following two when determining whether to stop.
+
+    void
+    DecrementIgnoreCount();
+
+    // BreakpointLocation::IgnoreCountShouldStop & Breakpoint::IgnoreCountShouldStop can only be called once per stop, 
+    // and BreakpointLocation::IgnoreCountShouldStop should be tested first, and if it returns false we should
+    // continue, otherwise we should test Breakpoint::IgnoreCountShouldStop.
+    
+    bool
+    IgnoreCountShouldStop ();
 
 private:
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h?rev=159233&r1=159232&r2=159233&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h Tue Jun 26 17:27:55 2012
@@ -336,6 +336,12 @@
     bool
     SetBreakpointSite (lldb::BreakpointSiteSP& bp_site_sp);
 
+    void
+    DecrementIgnoreCount();
+
+    bool
+    IgnoreCountShouldStop();
+
 private:
 
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h?rev=159233&r1=159232&r2=159233&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h Tue Jun 26 17:27:55 2012
@@ -69,12 +69,6 @@
         return m_hit_count;
     }
 
-    void
-    IncrementHitCount ()
-    {
-        ++m_hit_count;
-    }
-
     uint32_t
     GetHardwareIndex () const
     {
@@ -133,6 +127,13 @@
                                     // hardware breakpoints, or the length of the watchpoint.
     uint32_t    m_hit_count;        // Number of times this breakpoint/watchpoint has been hit
 
+    // If you override this, be sure to call the base class to increment the internal counter.
+    void
+    IncrementHitCount ()
+    {
+        ++m_hit_count;
+    }
+
 private:
     //------------------------------------------------------------------
     // For StoppointLocation only

Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=159233&r1=159232&r2=159233&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Tue Jun 26 17:27:55 2012
@@ -152,12 +152,36 @@
     SendBreakpointChangedEvent (eBreakpointEventTypeIgnoreChanged);
 }
 
+void
+Breakpoint::DecrementIgnoreCount ()
+{
+    uint32_t ignore = m_options.GetIgnoreCount();
+    if (ignore != 0)
+        m_options.SetIgnoreCount(ignore - 1);
+}
+
 uint32_t
 Breakpoint::GetIgnoreCount () const
 {
     return m_options.GetIgnoreCount();
 }
 
+bool
+Breakpoint::IgnoreCountShouldStop ()
+{
+    uint32_t ignore = GetIgnoreCount();
+    if (ignore != 0)
+    {
+        // When we get here we know the location that caused the stop doesn't have an ignore count,
+        // since by contract we call it first...  So we don't have to find & decrement it, we only have
+        // to decrement our own ignore count.
+        DecrementIgnoreCount();
+        return false;
+    }
+    else
+        return true;
+}
+
 uint32_t
 Breakpoint::GetHitCount () const
 {

Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=159233&r1=159232&r2=159233&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Tue Jun 26 17:27:55 2012
@@ -254,6 +254,34 @@
     SendBreakpointLocationChangedEvent (eBreakpointEventTypeIgnoreChanged);
 }
 
+void
+BreakpointLocation::DecrementIgnoreCount()
+{
+    if (m_options_ap.get() != NULL)
+    {
+        uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
+        if (loc_ignore != 0)
+            m_options_ap->SetIgnoreCount(loc_ignore - 1);
+    }
+}
+
+bool
+BreakpointLocation::IgnoreCountShouldStop()
+{
+    if (m_options_ap.get() != NULL)
+    {
+        uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
+        if (loc_ignore != 0)
+        {
+            m_owner.DecrementIgnoreCount();
+            DecrementIgnoreCount();          // Have to decrement our owners' ignore count, since it won't get a
+                                             // chance to.
+            return false;
+        }
+    }
+    return true;
+}
+
 const BreakpointOptions *
 BreakpointLocation::GetOptionsNoCreate () const
 {
@@ -297,7 +325,10 @@
     if (!IsEnabled())
         return false;
 
-    if (GetHitCount() <= GetIgnoreCount())
+    if (!IgnoreCountShouldStop())
+        return false;
+    
+    if (!m_owner.IgnoreCountShouldStop())
         return false;
 
     // We only run synchronous callbacks in ShouldStop:





More information about the lldb-commits mailing list