forked from OSchip/llvm-project
[ASan] use llvm-symbolizer for ASan lit-style tests on Mac
llvm-svn: 165391
This commit is contained in:
parent
0ae35af518
commit
480477c0e1
|
@ -15,12 +15,9 @@ if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}")
|
|||
# Run ASan output tests only if we're not cross-compiling,
|
||||
# and can be sure that clang would produce working binaries.
|
||||
set(ASAN_TEST_DEPS
|
||||
clang clang-headers FileCheck count not llvm-nm
|
||||
clang clang-headers FileCheck count not llvm-nm llvm-symbolizer
|
||||
${ASAN_RUNTIME_LIBRARIES}
|
||||
)
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
list(APPEND ASAN_TEST_DEPS llvm-symbolizer)
|
||||
endif()
|
||||
set(ASAN_TEST_PARAMS
|
||||
asan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
||||
)
|
||||
|
|
|
@ -17,7 +17,7 @@ int main(int argc, char **argv) {
|
|||
memset(ZZZ, 0, 10);
|
||||
int res = YYY[argc * 10]; // BOOOM
|
||||
// CHECK: {{READ of size 1 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in main .*global-overflow.cc:18}}
|
||||
// CHECK: {{ #0 0x.* in _?main .*global-overflow.cc:18}}
|
||||
// CHECK: {{0x.* is located 0 bytes to the right of global variable}}
|
||||
// CHECK: {{.*YYY.* of size 10}}
|
||||
res += XXX[argc] + ZZZ[argc];
|
||||
|
|
|
@ -22,7 +22,7 @@ int main(int argc, char **argv) {
|
|||
memset(x, 0, 10);
|
||||
int res = x[argc * 10]; // BOOOM
|
||||
// CHECK: {{READ of size 1 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in main .*heap-overflow.cc:23}}
|
||||
// CHECK: {{ #0 0x.* in _?main .*heap-overflow.cc:23}}
|
||||
// CHECK: {{0x.* is located 0 bytes to the right of 10-byte region}}
|
||||
// CHECK: {{allocated by thread T0 here:}}
|
||||
|
||||
|
@ -32,7 +32,7 @@ int main(int argc, char **argv) {
|
|||
// CHECK-Darwin: {{ #0 0x.* in .*mz_malloc.*}}
|
||||
// CHECK-Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
|
||||
// CHECK-Darwin: {{ #2 0x.* in malloc.*}}
|
||||
// CHECK-Darwin: {{ #3 0x.* in main heap-overflow.cc:21}}
|
||||
// CHECK-Darwin: {{ #3 0x.* in _?main .*heap-overflow.cc:21}}
|
||||
free(x);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -58,8 +58,8 @@ int main(int argc, char **argv) {
|
|||
// CHECK-Linux: {{ #0 0x.* in LargeFunction.*large_func_test.cc:32}}
|
||||
// CHECK-Darwin: {{ #0 0x.* in .*LargeFunction.*large_func_test.cc:32}}
|
||||
|
||||
// CHECK: {{ #1 0x.* in main .*large_func_test.cc:48}}
|
||||
// CHECK: {{ #1 0x.* in _?main .*large_func_test.cc:48}}
|
||||
// CHECK: {{0x.* is located 44 bytes to the right of 400-byte region}}
|
||||
// CHECK: {{allocated by thread T0 here:}}
|
||||
// CHECK: {{ #0 0x.* in operator new.*}}
|
||||
// CHECK: {{ #1 0x.* in main .*large_func_test.cc:47}}
|
||||
// CHECK: {{ #1 0x.* in _?main .*large_func_test.cc:47}}
|
||||
|
|
|
@ -69,13 +69,11 @@ config.substitutions.append( ("%clangxx_asan ", (" " + config.clang + " " +
|
|||
clang_asan_cxxflags + " ")) )
|
||||
|
||||
# Setup path to external LLVM symbolizer to run AddressSanitizer output tests.
|
||||
# Currently llvm-symbolizer is supported on Linux only.
|
||||
if config.host_os == 'Linux':
|
||||
llvm_obj_root = getattr(config, 'llvm_obj_root', None)
|
||||
if llvm_obj_root:
|
||||
config.environment['LLVM_SYMBOLIZER_PATH'] = os.path.join(
|
||||
config.llvm_obj_root, "projects", "compiler-rt", "utils",
|
||||
"llvm-symbolizer", "llvm-symbolizer")
|
||||
llvm_obj_root = getattr(config, 'llvm_obj_root', None)
|
||||
if llvm_obj_root:
|
||||
config.environment['LLVM_SYMBOLIZER_PATH'] = os.path.join(
|
||||
config.llvm_obj_root, "projects", "compiler-rt", "utils",
|
||||
"llvm-symbolizer", "llvm-symbolizer")
|
||||
|
||||
# Setup path to symbolizer script.
|
||||
# FIXME: Instead we should copy this script to the build tree and point
|
||||
|
|
|
@ -31,4 +31,4 @@ int main() {
|
|||
// CHECK-Linux: {{ #0 0x.* in NullDeref.*null_deref.cc:20}}
|
||||
// CHECK-Darwin: {{ #0 0x.* in .*NullDeref.*null_deref.cc:20}}
|
||||
|
||||
// CHECK: {{ #1 0x.* in main.*null_deref.cc:23}}
|
||||
// CHECK: {{ #1 0x.* in _?main.*null_deref.cc:23}}
|
||||
|
|
|
@ -49,6 +49,6 @@ int main(int argc, char *argv[]) {
|
|||
// CHECK: {{.*ERROR: AddressSanitizer global-buffer-overflow}}
|
||||
// CHECK: {{READ of size 4 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.*}}
|
||||
// CHECK: {{ #1 0x.* in main .*shared-lib-test.cc:48}}
|
||||
// CHECK: {{ #1 0x.* in _?main .*shared-lib-test.cc:48}}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ int main(int argc, char **argv) {
|
|||
memset(x, 0, 10);
|
||||
int res = x[argc * 10]; // BOOOM
|
||||
// CHECK: {{READ of size 1 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in main .*stack-overflow.cc:14}}
|
||||
// CHECK: {{ #0 0x.* in _?main .*stack-overflow.cc:14}}
|
||||
// CHECK: {{Address 0x.* is .* frame <main>}}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ int main(int argc, char **argv) {
|
|||
// CHECK: {{WRITE of size 1 at 0x.* thread T0}}
|
||||
// CHECK-Linux: {{ #0 0x.* in .*strncpy}}
|
||||
// CHECK-Darwin: {{ #0 0x.* in wrap_strncpy}}
|
||||
// CHECK: {{ #1 0x.* in main .*strncpy-overflow.cc:24}}
|
||||
// CHECK: {{ #1 0x.* in _?main .*strncpy-overflow.cc:24}}
|
||||
// CHECK: {{0x.* is located 0 bytes to the right of 9-byte region}}
|
||||
// CHECK: {{allocated by thread T0 here:}}
|
||||
|
||||
|
@ -35,6 +35,6 @@ int main(int argc, char **argv) {
|
|||
// CHECK-Darwin: {{ #0 0x.* in .*mz_malloc.*}}
|
||||
// CHECK-Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
|
||||
// CHECK-Darwin: {{ #2 0x.* in malloc.*}}
|
||||
// CHECK-Darwin: {{ #3 0x.* in main .*strncpy-overflow.cc:23}}
|
||||
// CHECK-Darwin: {{ #3 0x.* in _?main .*strncpy-overflow.cc:23}}
|
||||
return short_buffer[8];
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ int main() {
|
|||
// CHECK: {{.*ERROR: AddressSanitizer heap-use-after-free on address}}
|
||||
// CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
|
||||
// CHECK: {{READ of size 1 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in main .*use-after-free.cc:22}}
|
||||
// CHECK: {{ #0 0x.* in _?main .*use-after-free.cc:22}}
|
||||
// CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}
|
||||
// CHECK: {{freed by thread T0 here:}}
|
||||
|
||||
|
@ -33,7 +33,7 @@ int main() {
|
|||
// CHECK-Darwin: {{ #0 0x.* in .*mz_free.*}}
|
||||
// We override free() on Darwin, thus no malloc_zone_free
|
||||
// CHECK-Darwin: {{ #1 0x.* in wrap_free}}
|
||||
// CHECK-Darwin: {{ #2 0x.* in main .*use-after-free.cc:21}}
|
||||
// CHECK-Darwin: {{ #2 0x.* in _?main .*use-after-free.cc:21}}
|
||||
|
||||
// CHECK: {{previously allocated by thread T0 here:}}
|
||||
|
||||
|
@ -43,5 +43,5 @@ int main() {
|
|||
// CHECK-Darwin: {{ #0 0x.* in .*mz_malloc.*}}
|
||||
// CHECK-Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
|
||||
// CHECK-Darwin: {{ #2 0x.* in malloc.*}}
|
||||
// CHECK-Darwin: {{ #3 0x.* in main .*use-after-free.cc:20}}
|
||||
// CHECK-Darwin: {{ #3 0x.* in _?main .*use-after-free.cc:20}}
|
||||
}
|
||||
|
|
|
@ -97,13 +97,11 @@ class LLVMSymbolizer(Symbolizer):
|
|||
|
||||
|
||||
def LLVMSymbolizerFactory(system):
|
||||
if system == 'Linux':
|
||||
symbolizer_path = os.getenv('LLVM_SYMBOLIZER_PATH')
|
||||
if not symbolizer_path:
|
||||
# Assume llvm-symbolizer is in PATH.
|
||||
symbolizer_path = 'llvm-symbolizer'
|
||||
return LLVMSymbolizer(symbolizer_path)
|
||||
return None
|
||||
symbolizer_path = os.getenv('LLVM_SYMBOLIZER_PATH')
|
||||
if not symbolizer_path:
|
||||
# Assume llvm-symbolizer is in PATH.
|
||||
symbolizer_path = 'llvm-symbolizer'
|
||||
return LLVMSymbolizer(symbolizer_path)
|
||||
|
||||
|
||||
class Addr2LineSymbolizer(Symbolizer):
|
||||
|
|
Loading…
Reference in New Issue