1#include <pthread.h>
2
3int g_watchme = 0;
4
5void *thread_func(void *arg) {
6 /* watchpoint trigger from subthread */
7 g_watchme = 2;
8 return 0;
9}
10
11int main() {
12 pthread_t thread;
13 if (pthread_create(newthread: &thread, attr: 0, start_routine: thread_func, arg: 0))
14 return 1;
15
16 /* watchpoint trigger from main thread */
17 g_watchme = 1;
18
19 if (pthread_join(th: thread, thread_return: 0))
20 return 2;
21
22 return 0;
23}
24

source code of lldb/test/Shell/Watchpoint/Inputs/thread-dbreg.c