summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2015-08-11 15:51:40 +0000
committerReid Kleckner <rnk@google.com>2015-08-11 15:51:40 +0000
commit7d9e1e125930404a7ebce2e8d584b34a9065d530 (patch)
tree41e0a50188ff1cf634f84ced36f4fe0e4f42d7ad /compiler-rt/test
parent863bfdbfb446adaef767ff514d1f2ffb5d489562 (diff)
downloadbcm5719-llvm-7d9e1e125930404a7ebce2e8d584b34a9065d530.tar.gz
bcm5719-llvm-7d9e1e125930404a7ebce2e8d584b34a9065d530.zip
[Windows] Use llvm-symbolizer before using dbghelp
Summary: llvm-symbolizer understands both PDBs and DWARF, so it's a better bet if it's available. It prints out the function parameter types and column numbers, so I needed to churn the expected test output a bit. This makes most of the llvm-symbolizer subprocessing code target-independent. Pipes on all platforms use fd_t, and we can use the portable ReadFromFile / WriteToFile wrappers in symbolizer_sanitizer.cc. Only the pipe creation and process spawning is Windows-specific. Please check that the libcdep layering is still correct. I don't know how to reproduce the build configuration that relies on that. Reviewers: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11791 llvm-svn: 244616
Diffstat (limited to 'compiler-rt/test')
-rw-r--r--compiler-rt/test/asan/CMakeLists.txt17
-rw-r--r--compiler-rt/test/asan/TestCases/Windows/fuse-lld.cc23
-rw-r--r--compiler-rt/test/asan/TestCases/Windows/null_deref.cc2
-rw-r--r--compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cc6
4 files changed, 39 insertions, 9 deletions
diff --git a/compiler-rt/test/asan/CMakeLists.txt b/compiler-rt/test/asan/CMakeLists.txt
index aff54db1e77..03da4af6c1c 100644
--- a/compiler-rt/test/asan/CMakeLists.txt
+++ b/compiler-rt/test/asan/CMakeLists.txt
@@ -13,6 +13,17 @@ macro(get_bits_for_arch arch bits)
endif()
endmacro()
+set(ASAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
+if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND ASAN_TEST_DEPS asan)
+ if(WIN32 AND COMPILER_RT_HAS_LLD_SOURCES)
+ list(APPEND ASAN_TEST_DEPS
+ lld
+ )
+ endif()
+endif()
+set(ASAN_DYNAMIC_TEST_DEPS ${ASAN_TEST_DEPS})
+
foreach(arch ${ASAN_SUPPORTED_ARCH})
if(ANDROID)
set(ASAN_TEST_TARGET_ARCH ${arch}-android)
@@ -55,12 +66,6 @@ foreach(arch ${ASAN_SUPPORTED_ARCH})
endif()
endforeach()
-set(ASAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
-if(NOT COMPILER_RT_STANDALONE_BUILD)
- list(APPEND ASAN_TEST_DEPS asan)
-endif()
-set(ASAN_DYNAMIC_TEST_DEPS ${ASAN_TEST_DEPS})
-
# Add unit tests.
if(COMPILER_RT_INCLUDE_TESTS)
set(ASAN_TEST_DYNAMIC False)
diff --git a/compiler-rt/test/asan/TestCases/Windows/fuse-lld.cc b/compiler-rt/test/asan/TestCases/Windows/fuse-lld.cc
new file mode 100644
index 00000000000..b4b3d3907ff
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/Windows/fuse-lld.cc
@@ -0,0 +1,23 @@
+// If we have LLD, see that things more or less work.
+//
+// REQUIRES: lld
+//
+// FIXME: Use -fuse-ld=lld after the old COFF linker is removed.
+// FIXME: Test will fail until we add flags for requesting dwarf or cv.
+// RUNX: %clangxx_asan -O2 %s -o %t.exe -fuse-ld=lld -Wl,-debug
+// RUN: %clangxx_asan -c -O2 %s -o %t.o -gdwarf
+// RUN: lld-link2 %t.o -out:%t.exe -debug -defaultlib:libcmt %asan_lib %asan_cxx_lib
+// RUN: not %run %t.exe 2>&1 | FileCheck %s
+
+#include <stdlib.h>
+
+int main() {
+ char *x = (char*)malloc(10 * sizeof(char));
+ free(x);
+ return x[5];
+ // CHECK: heap-use-after-free
+ // CHECK: free
+ // CHECK: main{{.*}}fuse-lld.cc:[[@LINE-4]]:3
+ // CHECK: malloc
+ // CHECK: main{{.*}}fuse-lld.cc:[[@LINE-7]]:20
+}
diff --git a/compiler-rt/test/asan/TestCases/Windows/null_deref.cc b/compiler-rt/test/asan/TestCases/Windows/null_deref.cc
index 202000f59db..9515602ce89 100644
--- a/compiler-rt/test/asan/TestCases/Windows/null_deref.cc
+++ b/compiler-rt/test/asan/TestCases/Windows/null_deref.cc
@@ -10,6 +10,6 @@ static void NullDeref(int *ptr) {
}
int main() {
NullDeref((int*)0);
- // CHECK: {{ #1 0x.* in main.*null_deref.cc:}}[[@LINE-1]]
+ // CHECK: {{ #1 0x.* in main.*null_deref.cc:}}[[@LINE-1]]:3
// CHECK: AddressSanitizer can not provide additional info.
}
diff --git a/compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cc b/compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cc
index faf5e35db5f..3062318e0db 100644
--- a/compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cc
+++ b/compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cc
@@ -1,4 +1,5 @@
-// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O0 %s -o %t
+// RUN: env ASAN_OPTIONS=external_symbolizer_path=asdf not %run %t 2>&1 | FileCheck %s
#include <windows.h>
#include <dbghelp.h>
@@ -13,7 +14,8 @@ int main() {
*(volatile int*)0 = 42;
// CHECK: ERROR: AddressSanitizer: access-violation on unknown address
+ // CHECK-NEXT: {{WARNING: Failed to use and restart external symbolizer}}
// CHECK-NEXT: {{WARNING: .*DbgHelp}}
- // CHECK: {{#0 0x.* in main.*report_after_syminitialize.cc:}}[[@LINE-3]]
+ // CHECK: {{#0 0x.* in main.*report_after_syminitialize.cc:}}[[@LINE-4]]
// CHECK: AddressSanitizer can not provide additional info.
}
OpenPOWER on IntegriCloud