summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2019-10-02 21:20:37 +0000
committerVitaly Buka <vitalybuka@google.com>2019-10-02 21:20:37 +0000
commitd39e7e2cf156f5f444637fb3d26e98d33b1bfc19 (patch)
tree04f2a2b3e3a87f2b799d2d40b5a029619d19f482 /compiler-rt/test
parent59bf75caabe4edaeff3754feb58fc70b11520f9b (diff)
downloadbcm5719-llvm-d39e7e2cf156f5f444637fb3d26e98d33b1bfc19.tar.gz
bcm5719-llvm-d39e7e2cf156f5f444637fb3d26e98d33b1bfc19.zip
[compiler-rt] Use GetNextInstructionPc in signal handlers
Summary: All other stack trace callers assume that PC contains return address. HWAsan already use GetNextInstructionPc in similar code. PR43339 Reviewers: eugenis, kcc, jfb Subscribers: dexonsmith, dberris, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68313 llvm-svn: 373529
Diffstat (limited to 'compiler-rt/test')
-rw-r--r--compiler-rt/test/sanitizer_common/TestCases/Linux/signal_line.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/signal_line.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/signal_line.cpp
new file mode 100644
index 00000000000..57175effe55
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/signal_line.cpp
@@ -0,0 +1,36 @@
+// Test line numbers in signal handlers
+
+// RUN: %clangxx %s -o %t -O0
+// RUN: %env_tool_opts=handle_segv=1:print_stacktrace=1 not %run %t 1 2>&1 | FileCheck --check-prefixes=CHECK1,CHECK %s
+// RUN: %env_tool_opts=handle_segv=1:print_stacktrace=1 not %run %t 2 2>&1 | FileCheck --check-prefixes=CHECK2,CHECK %s
+// RUN: %env_tool_opts=handle_segv=1:print_stacktrace=1 not %run %t 3 2>&1 | FileCheck --check-prefixes=CHECK3,CHECK %s
+// RUN: %env_tool_opts=handle_segv=1:print_stacktrace=1 not %run %t 4 2>&1 | FileCheck --check-prefixes=CHECK4,CHECK %s
+
+#include <cstdio>
+#include <string>
+
+// CHECK: [[SAN:.*Sanitizer]]:DEADLYSIGNAL
+// CHECK: ERROR: [[SAN]]: SEGV on unknown address {{0x[^ ]*}} (pc
+int main(int argc, char **argv) {
+ int n = atoi(argv[1]);
+
+ if (n == 1)
+ *((volatile int *)0x0) = __LINE__;
+ // CHECK1: #{{[0-9]+ .*}}main {{.*}}signal_line.cpp:[[@LINE-1]]:[[TAB:[0-9]+]]
+ // CHECK1: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main
+
+ if (n == 2)
+ *((volatile int *)0x0) = __LINE__;
+ // CHECK2: #{{[0-9]+ .*}}main {{.*}}signal_line.cpp:[[@LINE-1]]:[[TAB:[0-9]+]]
+ // CHECK2: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main
+
+ if (n == 3)
+ *((volatile int *)0x0) = __LINE__;
+ // CHECK3: #{{[0-9]+ .*}}main {{.*}}signal_line.cpp:[[@LINE-1]]:[[TAB:[0-9]+]]
+ // CHECK3: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main
+
+ if (n == 4)
+ *((volatile int *)0x0) = __LINE__;
+ // CHECK4: #{{[0-9]+ .*}}main {{.*}}signal_line.cpp:[[@LINE-1]]:[[TAB:[0-9]+]]
+ // CHECK4: SUMMARY: [[SAN]]: SEGV {{.*}}signal_line.cpp:[[@LINE-2]]:[[TAB]] in main
+}
OpenPOWER on IntegriCloud