summaryrefslogtreecommitdiff
path: root/test/asan
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-02-04 02:02:09 +0000
committerKostya Serebryany <kcc@google.com>2016-02-04 02:02:09 +0000
commit2aa0339aea9c1adc1039ae0922e55168cf211ad0 (patch)
tree33f827fc452e3639580a071cc678b7a7a67604ea /test/asan
parenta29fa41fc3ca1602870b790560b468c916316489 (diff)
[asan] When catching a signal caused by a memory access, print if it's a READ or a WRITE. This touches win/mac files which I have not tested, if a win/mac bot fails I'll try to quick-fix
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259741 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan')
-rw-r--r--test/asan/TestCases/Linux/segv_read_write.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/asan/TestCases/Linux/segv_read_write.c b/test/asan/TestCases/Linux/segv_read_write.c
new file mode 100644
index 000000000..841037137
--- /dev/null
+++ b/test/asan/TestCases/Linux/segv_read_write.c
@@ -0,0 +1,17 @@
+// RUN: %clangxx_asan -O0 %s -o %t
+// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=READ
+// RUN: not %run %t write 2>&1 | FileCheck %s --check-prefix=WRITE
+
+static volatile int sink;
+__attribute__((noinline)) void Read(int *ptr) { sink = *ptr; }
+__attribute__((noinline)) void Write(int *ptr) { *ptr = 0; }
+int main(int argc, char **argv) {
+ if (argc == 1)
+ Read((int *)0);
+ else
+ Write((int *)0);
+}
+// READ: AddressSanitizer: SEGV on unknown address
+// READ: The signal is caused by a READ memory access.
+// WRITE: AddressSanitizer: SEGV on unknown address
+// WRITE: The signal is caused by a WRITE memory access.