[lldb] [Process/NetBSD] Copy watchpoints to newly-created threads

NetBSD ptrace interface does not populate watchpoints to newly-created
threads.  Solve this via copying the watchpoints from the current thread
when new thread is reported via TRAP_LWP.

Add a test that verifies that when the user does not have permissions
to set watchpoints on NetBSD, the 'watchpoint set' errors out gracefully
and thread monitoring does not crash on being unable to copy watchpoints
to new threads.

Differential Revision: https://reviews.llvm.org/D70023
This commit is contained in:
Michał Górny
2019-11-09 11:56:08 +01:00
parent 8d9400b65b
commit d970d4d4aa
20 changed files with 114 additions and 19 deletions

View File

@@ -221,9 +221,9 @@ bool NativeThreadNetBSD::GetStopReason(ThreadStopInfo &stop_info,
llvm_unreachable("unhandled StateType!");
}
NativeRegisterContext& NativeThreadNetBSD::GetRegisterContext() {
NativeRegisterContextNetBSD &NativeThreadNetBSD::GetRegisterContext() {
assert(m_reg_context_up);
return *m_reg_context_up;
return *m_reg_context_up;
}
Status NativeThreadNetBSD::SetWatchpoint(lldb::addr_t addr, size_t size,
@@ -284,3 +284,13 @@ Status NativeThreadNetBSD::RemoveHardwareBreakpoint(lldb::addr_t addr) {
return Status("Clearing hardware breakpoint failed.");
}
Status NativeThreadNetBSD::CopyWatchpointsFrom(NativeThreadNetBSD &source) {
Status s = GetRegisterContext().CopyHardwareWatchpointsFrom(
source.GetRegisterContext());
if (!s.Fail()) {
m_watchpoint_index_map = source.m_watchpoint_index_map;
m_hw_break_index_map = source.m_hw_break_index_map;
}
return s;
}