Fix ignore counts on breakpoints so they actually work.

llvm-svn: 159233
This commit is contained in:
Jim Ingham 2012-06-26 22:27:55 +00:00
parent 09811c7dd5
commit 0fd1b75f50
5 changed files with 82 additions and 8 deletions

View File

@ -345,7 +345,7 @@ public:
//------------------------------------------------------------------
uint32_t
GetIgnoreCount () const;
//------------------------------------------------------------------
/// Return the current hit count for all locations.
/// @return
@ -551,6 +551,18 @@ protected:
//------------------------------------------------------------------
// 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:
//------------------------------------------------------------------

View File

@ -336,6 +336,12 @@ protected:
bool
SetBreakpointSite (lldb::BreakpointSiteSP& bp_site_sp);
void
DecrementIgnoreCount();
bool
IgnoreCountShouldStop();
private:
//------------------------------------------------------------------

View File

@ -69,12 +69,6 @@ public:
return m_hit_count;
}
void
IncrementHitCount ()
{
++m_hit_count;
}
uint32_t
GetHardwareIndex () const
{
@ -133,6 +127,13 @@ protected:
// 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

View File

@ -152,12 +152,36 @@ Breakpoint::SetIgnoreCount (uint32_t n)
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
{

View File

@ -254,6 +254,34 @@ BreakpointLocation::SetIgnoreCount (uint32_t n)
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 @@ BreakpointLocation::ShouldStop (StoppointCallbackContext *context)
if (!IsEnabled())
return false;
if (GetHitCount() <= GetIgnoreCount())
if (!IgnoreCountShouldStop())
return false;
if (!m_owner.IgnoreCountShouldStop())
return false;
// We only run synchronous callbacks in ShouldStop: