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
24 lines
367 B
C
24 lines
367 B
C
#include <pthread.h>
|
|
|
|
int g_watchme = 0;
|
|
|
|
void *thread_func(void *arg) {
|
|
/* watchpoint trigger from subthread */
|
|
g_watchme = 2;
|
|
return 0;
|
|
}
|
|
|
|
int main() {
|
|
pthread_t thread;
|
|
if (pthread_create(&thread, 0, thread_func, 0))
|
|
return 1;
|
|
|
|
/* watchpoint trigger from main thread */
|
|
g_watchme = 1;
|
|
|
|
if (pthread_join(thread, 0))
|
|
return 2;
|
|
|
|
return 0;
|
|
}
|