Reset the debug status register, only if necessary, before we resume,

which saves unnecessary traffic to the kernel.

llvm-svn: 139410
This commit is contained in:
Johnny Chen 2011-09-09 21:11:25 +00:00
parent 32ed0d204d
commit 67b20bbbee
2 changed files with 27 additions and 9 deletions

View File

@ -546,15 +546,24 @@ DNBArchImplI386::ThreadWillResume()
EnableHardwareSingleStep(true);
}
// Reset the debug status register before we resume.
// Reset the debug status register, if necessary, before we resume.
kern_return_t kret = GetDBGState(false);
DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplI386::ThreadWillResume() GetDBGState() => 0x%8.8x.", kret);
if (kret == KERN_SUCCESS)
DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::ThreadWillResume() GetDBGState() => 0x%8.8x.", kret);
if (kret != KERN_SUCCESS)
return;
DBG debug_state = m_state.context.dbg;
bool need_reset = false;
uint32_t i, num = NumSupportedHardwareWatchpoints();
for (i = 0; i < num; ++i)
if (IsWatchpointHit(debug_state, i))
need_reset = true;
if (need_reset)
{
DBG debug_state = m_state.context.dbg;
ClearWatchpointHits(debug_state);
kret = SetDBGState();
DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplI386::ThreadWillResume() SetDBGState() => 0x%8.8x.", kret);
DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::ThreadWillResume() SetDBGState() => 0x%8.8x.", kret);
}
}

View File

@ -475,12 +475,21 @@ DNBArchImplX86_64::ThreadWillResume()
EnableHardwareSingleStep(true);
}
// Reset the debug status register before we resume.
// Reset the debug status register, if necessary, before we resume.
kern_return_t kret = GetDBGState(false);
DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::ThreadWillResume() GetDBGState() => 0x%8.8x.", kret);
if (kret == KERN_SUCCESS)
if (kret != KERN_SUCCESS)
return;
DBG debug_state = m_state.context.dbg;
bool need_reset = false;
uint32_t i, num = NumSupportedHardwareWatchpoints();
for (i = 0; i < num; ++i)
if (IsWatchpointHit(debug_state, i))
need_reset = true;
if (need_reset)
{
DBG debug_state = m_state.context.dbg;
ClearWatchpointHits(debug_state);
kret = SetDBGState();
DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::ThreadWillResume() SetDBGState() => 0x%8.8x.", kret);
@ -807,7 +816,7 @@ uint32_t
DNBArchImplX86_64::GetHardwareWatchpointHit(nub_addr_t &addr)
{
// Read the debug state
kern_return_t kret = GetDBGState(false);
kern_return_t kret = GetDBGState(true);
DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::GetHardwareWatchpointHit() GetDBGState() => 0x%8.8x.", kret);
if (kret == KERN_SUCCESS)
{