For hardware watchpoint enable/disable, in case the kernel call to set the revised debug state fails, we need to recover the local cache to the previous known state.

llvm-svn: 157778
This commit is contained in:
Johnny Chen 2012-05-31 23:02:30 +00:00
parent 288e86ff6b
commit e48fb7d732
2 changed files with 13 additions and 1 deletions

View File

@ -842,6 +842,7 @@ DNBArchImplI386::EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, boo
uint32_t i = 0;
DBG &debug_state = m_state.context.dbg;
DBG dsCheckPoint = m_state.context.dbg;
for (i = 0; i < num_hw_watchpoints; ++i)
{
if (IsWatchpointVacant(debug_state, i))
@ -859,6 +860,8 @@ DNBArchImplI386::EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, boo
if (kret == KERN_SUCCESS)
return i;
else // Recovery block.
m_state.context.dbg = dsCheckPoint;
}
else
{
@ -877,6 +880,7 @@ DNBArchImplI386::DisableHardwareWatchpoint (uint32_t hw_index)
if (kret == KERN_SUCCESS)
{
DBG &debug_state = m_state.context.dbg;
DBG dsCheckPoint = m_state.context.dbg;
if (hw_index < num_hw_points && !IsWatchpointVacant(debug_state, hw_index))
{
// Modify our local copy of the debug state, first.
@ -888,6 +892,8 @@ DNBArchImplI386::DisableHardwareWatchpoint (uint32_t hw_index)
if (kret == KERN_SUCCESS)
return true;
else // Recovery block.
m_state.context.dbg = dsCheckPoint;
}
}
return false;
@ -911,7 +917,7 @@ uint32_t
DNBArchImplI386::GetHardwareWatchpointHit(nub_addr_t &addr)
{
// Read the debug state
kern_return_t kret = GetDBGState(false);
kern_return_t kret = GetDBGState(true);
DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplI386::GetHardwareWatchpointHit() GetDBGState() => 0x%8.8x.", kret);
if (kret == KERN_SUCCESS)
{

View File

@ -819,6 +819,7 @@ DNBArchImplX86_64::EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, b
uint32_t i = 0;
DBG &debug_state = m_state.context.dbg;
DBG dsCheckPoint = m_state.context.dbg;
for (i = 0; i < num_hw_watchpoints; ++i)
{
if (IsWatchpointVacant(debug_state, i))
@ -836,6 +837,8 @@ DNBArchImplX86_64::EnableHardwareWatchpoint (nub_addr_t addr, nub_size_t size, b
if (kret == KERN_SUCCESS)
return i;
else // Recovery block.
m_state.context.dbg = dsCheckPoint;
}
else
{
@ -854,6 +857,7 @@ DNBArchImplX86_64::DisableHardwareWatchpoint (uint32_t hw_index)
if (kret == KERN_SUCCESS)
{
DBG &debug_state = m_state.context.dbg;
DBG dsCheckPoint = m_state.context.dbg;
if (hw_index < num_hw_points && !IsWatchpointVacant(debug_state, hw_index))
{
// Modify our local copy of the debug state, first.
@ -865,6 +869,8 @@ DNBArchImplX86_64::DisableHardwareWatchpoint (uint32_t hw_index)
if (kret == KERN_SUCCESS)
return true;
else // Recovery block.
m_state.context.dbg = dsCheckPoint;
}
}
return false;