[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

@@ -272,12 +272,21 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) {
}
switch (pst.pe_report_event) {
case PTRACE_LWP_CREATE:
case PTRACE_LWP_CREATE: {
LLDB_LOG(log,
"monitoring new thread, pid = {0}, LWP = {1}", pid,
pst.pe_lwp);
AddThread(pst.pe_lwp);
break;
NativeThreadNetBSD& t = AddThread(pst.pe_lwp);
error = t.CopyWatchpointsFrom(
static_cast<NativeThreadNetBSD &>(*GetCurrentThread()));
if (error.Fail()) {
LLDB_LOG(log,
"failed to copy watchpoints to new thread {0}: {1}",
pst.pe_lwp, error);
SetState(StateType::eStateInvalid);
return;
}
} break;
case PTRACE_LWP_EXIT:
LLDB_LOG(log,
"removing exited thread, pid = {0}, LWP = {1}", pid,