summaryrefslogtreecommitdiffstats
path: root/lldb/test/Shell/Watchpoint
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2019-11-09 11:56:08 +0100
committerMichał Górny <mgorny@gentoo.org>2019-11-25 20:11:59 +0100
commitd970d4d4aa7345ebf8b7169b09f2775a93f86c33 (patch)
treeb65fdfad38ad39bc75f52397dab60b2479f1278b /lldb/test/Shell/Watchpoint
parent8d9400b65b972cb50fe2266360443192ea107ec9 (diff)
downloadbcm5719-llvm-d970d4d4aa7345ebf8b7169b09f2775a93f86c33.tar.gz
bcm5719-llvm-d970d4d4aa7345ebf8b7169b09f2775a93f86c33.zip
[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
Diffstat (limited to 'lldb/test/Shell/Watchpoint')
-rw-r--r--lldb/test/Shell/Watchpoint/Inputs/thread-dbreg.c23
-rw-r--r--lldb/test/Shell/Watchpoint/netbsd-nouserdbregs.test22
2 files changed, 45 insertions, 0 deletions
diff --git a/lldb/test/Shell/Watchpoint/Inputs/thread-dbreg.c b/lldb/test/Shell/Watchpoint/Inputs/thread-dbreg.c
new file mode 100644
index 00000000000..14f3474789a
--- /dev/null
+++ b/lldb/test/Shell/Watchpoint/Inputs/thread-dbreg.c
@@ -0,0 +1,23 @@
+#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;
+}
diff --git a/lldb/test/Shell/Watchpoint/netbsd-nouserdbregs.test b/lldb/test/Shell/Watchpoint/netbsd-nouserdbregs.test
new file mode 100644
index 00000000000..884636c7cdf
--- /dev/null
+++ b/lldb/test/Shell/Watchpoint/netbsd-nouserdbregs.test
@@ -0,0 +1,22 @@
+# Check that 'watchpoint set' errors out gracefully when we can't set dbregs
+# and that new threads are monitored correctly even though we can't copy dbregs.
+
+# REQUIRES: system-netbsd && (target-x86 || target-x86_64) && !dbregs-set
+# RUN: %clang_host %p/Inputs/thread-dbreg.c -pthread -g -o %t.out
+# RUN: %lldb -b -o 'settings set interpreter.stop-command-source-on-error false' -s %s %t.out 2>&1 | FileCheck %s
+
+settings show interpreter.stop-command-source-on-error
+# CHECK: interpreter.stop-command-source-on-error (boolean) = false
+
+b main
+# CHECK: Breakpoint {{[0-9]+}}: where = {{.*}}`main
+b thread_func
+# CHECK: Breakpoint {{[0-9]+}}: where = {{.*}}`thread_func
+run
+# CHECK: stop reason = breakpoint
+watchpoint set variable g_watchme
+# CHECK: error: Watchpoint creation failed
+cont
+# CHECK: stop reason = breakpoint
+cont
+# CHECK: Process {{[0-9]+}} exited with status = 0
OpenPOWER on IntegriCloud