FreeBSD hardware watchpoint implementation

Implement x86_64 debug register read/write in support of hardware
watchpoints. Hoist LinuxThread::TraceNotify code back into
POSIXThread::TraceNotify()

Patch by John Wolfe.

We still need to rework this later to avoid the #ifdef FreeBSD.

llvm-reviews.chandlerc.com/D2572
llvm.org/pr16706

llvm-svn: 201706
This commit is contained in:
Ed Maste
2014-02-19 18:34:06 +00:00
parent 01fd1c60cd
commit a4be2c5dcd
23 changed files with 195 additions and 70 deletions

View File

@@ -65,7 +65,16 @@ POSIXThread::POSIXThread(Process &process, lldb::tid_t tid)
lldb::WatchpointSP wp = wp_list.GetByIndex(wp_idx);
if (wp.get() && wp->IsEnabled())
{
assert(EnableHardwareWatchpoint(wp.get()));
// This watchpoint as been enabled; obviously this "new" thread
// has been created since that watchpoint was enabled. Since
// the POSIXBreakpointProtocol has yet to be initialized, its
// m_watchpoints_initialized member will be FALSE. Attempting to
// read the debug status register to determine if a watchpoint
// has been hit would result in the zeroing of that register.
// Since the active debug registers would have been cloned when
// this thread was created, simply force the m_watchpoints_initized
// member to TRUE and avoid resetting dr6 and dr7.
GetPOSIXBreakpointProtocol()->ForceWatchpointsInitialized();
}
}
}
@@ -509,6 +518,21 @@ POSIXThread::WatchNotify(const ProcessMessage &message)
void
POSIXThread::TraceNotify(const ProcessMessage &message)
{
POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol();
if (reg_ctx)
{
uint32_t num_hw_wps = reg_ctx->NumSupportedHardwareWatchpoints();
uint32_t wp_idx;
for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++)
{
if (reg_ctx->IsWatchpointHit(wp_idx))
{
WatchNotify(message);
return;
}
}
}
SetStopInfo (StopInfo::CreateStopReasonToTrace(*this));
}