aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/asan/TestCases/Darwin/haswell-symbolication.cc99
-rw-r--r--test/asan/TestCases/Darwin/uuid.cc28
-rw-r--r--test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc1
-rw-r--r--test/lit.common.cfg11
-rw-r--r--test/tsan/simple_stack2.cc12
5 files changed, 144 insertions, 7 deletions
diff --git a/test/asan/TestCases/Darwin/haswell-symbolication.cc b/test/asan/TestCases/Darwin/haswell-symbolication.cc
new file mode 100644
index 000000000000..59c938ca5087
--- /dev/null
+++ b/test/asan/TestCases/Darwin/haswell-symbolication.cc
@@ -0,0 +1,99 @@
+// RUN: %clangxx_asan -arch x86_64 -arch x86_64h -g -O0 %s -c -o %t.o.fat
+// RUN: %clangxx_asan -arch x86_64 -arch x86_64h -g %t.o.fat -o %t.fat
+
+// RUN: lipo %t.fat -thin x86_64 -output %t.thin.x86_64 && lipo %t.thin.x86_64 -info | FileCheck %s --check-prefix=CHECK-LIPO-THIN-X86_64
+// RUN: lipo %t.fat -thin x86_64h -output %t.thin.x86_64h && lipo %t.thin.x86_64h -info | FileCheck %s --check-prefix=CHECK-LIPO-THIN-X86_64H
+// RUN: lipo %t.fat -extract x86_64 -output %t.fat.x86_64 && lipo %t.fat.x86_64 -info | FileCheck %s --check-prefix=CHECK-LIPO-FAT-X86_64
+// RUN: lipo %t.fat -extract x86_64h -output %t.fat.x86_64h && lipo %t.fat.x86_64h -info | FileCheck %s --check-prefix=CHECK-LIPO-FAT-X86_64H
+
+// CHECK-LIPO-THIN-X86_64: Non-fat file: {{.*}} is architecture: x86_64
+// CHECK-LIPO-THIN-X86_64H: Non-fat file: {{.*}} is architecture: x86_64h
+// CHECK-LIPO-FAT-X86_64: Architectures in the fat file: {{.*}} are: x86_64
+// CHECK-LIPO-FAT-X86_64H: Architectures in the fat file: {{.*}} are: x86_64h
+
+// RUN: dsymutil %t.thin.x86_64
+// RUN: dsymutil %t.thin.x86_64h
+// RUN: dsymutil %t.fat.x86_64
+// RUN: dsymutil %t.fat.x86_64h
+
+// Check LLVM symbolizer
+// RUN: %env_asan_opts=external_symbolizer_path=$(which llvm-symbolizer) not %run %t.thin.x86_64 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA
+// RUN: %env_asan_opts=external_symbolizer_path=$(which llvm-symbolizer) not %run %t.thin.x86_64h 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA
+// RUN: %env_asan_opts=external_symbolizer_path=$(which llvm-symbolizer) not %run %t.fat.x86_64 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA
+// RUN: %env_asan_opts=external_symbolizer_path=$(which llvm-symbolizer) not %run %t.fat.x86_64h 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA
+
+// Check atos
+// RUN: %env_asan_opts=external_symbolizer_path=$(which atos) not %run %t.thin.x86_64 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA
+// RUN: %env_asan_opts=external_symbolizer_path=$(which atos) not %run %t.thin.x86_64h 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA
+// RUN: %env_asan_opts=external_symbolizer_path=$(which atos) not %run %t.fat.x86_64 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA
+// RUN: %env_asan_opts=external_symbolizer_path=$(which atos) not %run %t.fat.x86_64h 2>&1 | FileCheck %s --check-prefixes CHECK,CHECK-LI,CHECK-DATA
+
+// Check dladdr
+// RUN: %env_asan_opts=external_symbolizer_path= not %run %t.thin.x86_64 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOLI,CHECK-DATA
+// RUN: %env_asan_opts=external_symbolizer_path= not %run %t.thin.x86_64h 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOLI,CHECK-DATA
+// RUN: %env_asan_opts=external_symbolizer_path= not %run %t.fat.x86_64 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOLI,CHECK-DATA
+// RUN: %env_asan_opts=external_symbolizer_path= not %run %t.fat.x86_64h 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOLI,CHECK-DATA
+
+// Check asan_symbolize.py with llvm-symbolizer
+// RUN: %env_asan_opts=symbolize=0 not %run %t.thin.x86_64 2>&1 | %asan_symbolize | FileCheck %s --check-prefixes CHECK,CHECK-LI
+// RUN: %env_asan_opts=symbolize=0 not %run %t.thin.x86_64h 2>&1 | %asan_symbolize | FileCheck %s --check-prefixes CHECK,CHECK-LI
+// RUN: %env_asan_opts=symbolize=0 not %run %t.fat.x86_64 2>&1 | %asan_symbolize | FileCheck %s --check-prefixes CHECK,CHECK-LI
+// RUN: %env_asan_opts=symbolize=0 not %run %t.fat.x86_64h 2>&1 | %asan_symbolize | FileCheck %s --check-prefixes CHECK,CHECK-LI
+
+// Check asan_symbolize.py with atos
+// RUN: %env_asan_opts=symbolize=0 not %run %t.thin.x86_64 2>&1 | %asan_symbolize --force-system-symbolizer | FileCheck %s --check-prefixes CHECK,CHECK-LI
+// RUN: %env_asan_opts=symbolize=0 not %run %t.thin.x86_64h 2>&1 | %asan_symbolize --force-system-symbolizer | FileCheck %s --check-prefixes CHECK,CHECK-LI
+// RUN: %env_asan_opts=symbolize=0 not %run %t.fat.x86_64 2>&1 | %asan_symbolize --force-system-symbolizer | FileCheck %s --check-prefixes CHECK,CHECK-LI
+// RUN: %env_asan_opts=symbolize=0 not %run %t.fat.x86_64h 2>&1 | %asan_symbolize --force-system-symbolizer | FileCheck %s --check-prefixes CHECK,CHECK-LI
+
+// REQUIRES: x86-target-arch
+// REQUIRES: x86_64h
+
+#include <sanitizer/common_interface_defs.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#if __x86_64h__
+// Unused functions and globals, just to mess up the offsets in x86_64h.
+void dummy(char *a, char *b) {
+ while (*a == *b) {
+ a[0] = b[0];
+ a[1] = b[1];
+ a[2] = b[2];
+ a[3] = b[3];
+ fprintf(stderr, "dummy\n");
+ }
+ fprintf(stderr, "dummy\n");
+}
+long dummy_global;
+long dummy_global2[100];
+#endif
+
+extern "C"
+long faulty_global = 10;
+
+void check_data_symbolication() {
+ char data[100];
+ __sanitizer_symbolize_global(&faulty_global, "%g", data, sizeof(data));
+ fprintf(stderr, "symbolized global: %s\n", data);
+ // CHECK-DATA: symbolized global: faulty_global
+}
+
+extern "C"
+void faulty_func(char *p) {
+ *p = 'x'; // BOOM
+ // CHECK: AddressSanitizer: global-buffer-overflow
+ // CHECK-LI: #0 0x{{.*}} in faulty_func{{.*}} {{.*}}haswell-symbolication.cc:[[@LINE-2]]
+ // CHECK-NOLI: #0 0x{{.*}} in faulty_func{{.*}} {{.*}}haswell-symbolication
+ // CHECK: is located 2 bytes to the right of global variable 'faulty_global'
+ // CHECK-NOT: LLVMSymbolizer: error reading file
+}
+
+int main() {
+ check_data_symbolication();
+
+ char *p = (char *)(void *)&faulty_global;
+ p += 10;
+ faulty_func(p);
+ return 0;
+}
diff --git a/test/asan/TestCases/Darwin/uuid.cc b/test/asan/TestCases/Darwin/uuid.cc
new file mode 100644
index 000000000000..3f50272e901d
--- /dev/null
+++ b/test/asan/TestCases/Darwin/uuid.cc
@@ -0,0 +1,28 @@
+// RUN: %clangxx_asan %s -o %t
+// RUN: %env_asan_opts=print_module_map=1 not %run %t 2>&1 | FileCheck %s
+// RUN: %env_asan_opts=print_module_map=2 not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan %s -o %t -fsanitize-recover=address
+// RUN: %env_asan_opts=print_module_map=2:halt_on_error=0 %run %t 2>&1 | FileCheck %s
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main(int argc, char *argv[]) {
+ char buf[2048];
+ snprintf(buf, sizeof(buf), "otool -l %s 1>&2", argv[0]);
+ system(buf);
+ // CHECK: cmd LC_UUID
+ // CHECK-NEXT: cmdsize 24
+ // CHECK-NEXT: uuid [[UUID:[0-9A-F-]{36}]]
+
+ char *x = (char*)malloc(10 * sizeof(char));
+ free(x);
+ char mybuf[10];
+ memcpy(mybuf, x, 10);
+ // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
+ // CHECK: Process module map:
+ // CHECK: uuid.cc.tmp {{.*}} <[[UUID]]>
+
+ fprintf(stderr, "Done.\n");
+}
diff --git a/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc b/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc
index cb9ca53e8a9a..2c4c133b740c 100644
--- a/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc
+++ b/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc
@@ -7,7 +7,6 @@
// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O0 %s %libdl -o %t
// RUN: %env_asan_opts=symbolize=0 not %run %t 2>&1 | %asan_symbolize | FileCheck %s
-// UNSUPPORTED: x86_64h-darwin,x86_64-darwin
// REQUIRES: stable-runtime
#if !defined(SHARED_LIB)
diff --git a/test/lit.common.cfg b/test/lit.common.cfg
index 1048c46f11bc..b8759923488a 100644
--- a/test/lit.common.cfg
+++ b/test/lit.common.cfg
@@ -141,6 +141,17 @@ if config.host_os == 'Darwin':
except:
pass
+ # Detect x86_64h
+ try:
+ output = subprocess.check_output(["sysctl", "hw.cpusubtype"])
+ output_re = re.match("^hw.cpusubtype: ([0-9]+)$", output)
+ if output_re:
+ cpu_subtype = int(output_re.group(1))
+ if cpu_subtype == 8: # x86_64h
+ config.available_features.add('x86_64h')
+ except:
+ pass
+
config.substitutions.append( ("%macos_min_target_10_11", "-mmacosx-version-min=10.11") )
else:
config.substitutions.append( ("%macos_min_target_10_11", "") )
diff --git a/test/tsan/simple_stack2.cc b/test/tsan/simple_stack2.cc
index 20ef729f7857..12ee0da31090 100644
--- a/test/tsan/simple_stack2.cc
+++ b/test/tsan/simple_stack2.cc
@@ -44,10 +44,10 @@ int main() {
// CHECK: WARNING: ThreadSanitizer: data race
// CHECK-NEXT: Write of size 4 at {{.*}} by thread T1:
-// CHECK-NEXT: #0 foo1{{.*}} {{.*}}simple_stack2.cc:7{{(:10)?}} (simple_stack2.cc.exe+{{.*}})
-// CHECK-NEXT: #1 bar1{{.*}} {{.*}}simple_stack2.cc:14{{(:3)?}} (simple_stack2.cc.exe+{{.*}})
-// CHECK-NEXT: #2 Thread1{{.*}} {{.*}}simple_stack2.cc:32{{(:3)?}} (simple_stack2.cc.exe+{{.*}})
+// CHECK-NEXT: #0 foo1{{.*}} {{.*}}simple_stack2.cc:7{{(:10)?}} ({{.*}})
+// CHECK-NEXT: #1 bar1{{.*}} {{.*}}simple_stack2.cc:14{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #2 Thread1{{.*}} {{.*}}simple_stack2.cc:32{{(:3)?}} ({{.*}})
// CHECK: Previous read of size 4 at {{.*}} by main thread:
-// CHECK-NEXT: #0 foo2{{.*}} {{.*}}simple_stack2.cc:18{{(:22)?}} (simple_stack2.cc.exe+{{.*}})
-// CHECK-NEXT: #1 bar2{{.*}} {{.*}}simple_stack2.cc:27{{(:3)?}} (simple_stack2.cc.exe+{{.*}})
-// CHECK-NEXT: #2 main{{.*}} {{.*}}simple_stack2.cc:40{{(:3)?}} (simple_stack2.cc.exe+{{.*}})
+// CHECK-NEXT: #0 foo2{{.*}} {{.*}}simple_stack2.cc:18{{(:22)?}} ({{.*}})
+// CHECK-NEXT: #1 bar2{{.*}} {{.*}}simple_stack2.cc:27{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #2 main{{.*}} {{.*}}simple_stack2.cc:40{{(:3)?}} ({{.*}})