Index: test/lsan/TestCases/cleanup_in_tsd_destructor.c =================================================================== --- test/lsan/TestCases/cleanup_in_tsd_destructor.c +++ test/lsan/TestCases/cleanup_in_tsd_destructor.c @@ -14,7 +14,7 @@ #include #include "sanitizer/lsan_interface.h" -#include "../../tsan/test.h" +#include "print_address.h" pthread_key_t key; __thread void *p; Index: test/lsan/TestCases/large_allocation_leak.cc =================================================================== --- test/lsan/TestCases/large_allocation_leak.cc +++ test/lsan/TestCases/large_allocation_leak.cc @@ -5,7 +5,7 @@ #include #include -#include "../../tsan/test.h" +#include "print_address.h" int main() { // maxsize in primary allocator is always less than this (1 << 25). Index: test/lsan/TestCases/pointer_to_self.cc =================================================================== --- test/lsan/TestCases/pointer_to_self.cc +++ test/lsan/TestCases/pointer_to_self.cc @@ -6,7 +6,7 @@ #include #include -#include "../../tsan/test.h" +#include "print_address.h" int main() { void *p = malloc(1337); Index: test/lsan/TestCases/stale_stack_leak.cc =================================================================== --- test/lsan/TestCases/stale_stack_leak.cc +++ test/lsan/TestCases/stale_stack_leak.cc @@ -6,7 +6,7 @@ #include #include -#include "../../tsan/test.h" +#include "print_address.h" void **pp; Index: test/lsan/TestCases/use_after_return.cc =================================================================== --- test/lsan/TestCases/use_after_return.cc +++ test/lsan/TestCases/use_after_return.cc @@ -8,7 +8,7 @@ #include #include -#include "../../tsan/test.h" +#include "print_address.h" int main() { void *stack_var = malloc(1337); Index: test/lsan/TestCases/use_globals_initialized.cc =================================================================== --- test/lsan/TestCases/use_globals_initialized.cc +++ test/lsan/TestCases/use_globals_initialized.cc @@ -7,7 +7,7 @@ #include #include -#include "../../tsan/test.h" +#include "print_address.h" void *data_var = (void *)1; Index: test/lsan/TestCases/use_globals_uninitialized.cc =================================================================== --- test/lsan/TestCases/use_globals_uninitialized.cc +++ test/lsan/TestCases/use_globals_uninitialized.cc @@ -7,7 +7,7 @@ #include #include -#include "../../tsan/test.h" +#include "print_address.h" void *bss_var; Index: test/lsan/TestCases/use_poisoned_asan.cc =================================================================== --- test/lsan/TestCases/use_poisoned_asan.cc +++ test/lsan/TestCases/use_poisoned_asan.cc @@ -9,7 +9,7 @@ #include #include #include -#include "../../tsan/test.h" +#include "print_address.h" void **p; Index: test/lsan/TestCases/use_registers.cc =================================================================== --- test/lsan/TestCases/use_registers.cc +++ test/lsan/TestCases/use_registers.cc @@ -10,7 +10,7 @@ #include #include #include -#include "../../tsan/test.h" +#include "print_address.h" extern "C" void *registers_thread_func(void *arg) { Index: test/lsan/TestCases/use_stacks.cc =================================================================== --- test/lsan/TestCases/use_stacks.cc +++ test/lsan/TestCases/use_stacks.cc @@ -7,7 +7,7 @@ #include #include -#include "../../tsan/test.h" +#include "print_address.h" int main() { void *stack_var = malloc(1337); Index: test/lsan/TestCases/use_stacks_threaded.cc =================================================================== --- test/lsan/TestCases/use_stacks_threaded.cc +++ test/lsan/TestCases/use_stacks_threaded.cc @@ -10,7 +10,7 @@ #include #include #include -#include "../../tsan/test.h" +#include "print_address.h" extern "C" void *stacks_thread_func(void *arg) { Index: test/lsan/TestCases/use_tls_dynamic.cc =================================================================== --- test/lsan/TestCases/use_tls_dynamic.cc +++ test/lsan/TestCases/use_tls_dynamic.cc @@ -12,7 +12,7 @@ #include #include #include -#include "../../tsan/test.h" +#include "print_address.h" int main(int argc, char *argv[]) { std::string path = std::string(argv[0]) + "-so.so"; Index: test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc =================================================================== --- test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc +++ test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc @@ -9,7 +9,7 @@ #include #include #include -#include "../../tsan/test.h" +#include "print_address.h" // From glibc: this many keys are stored in the thread descriptor directly. const unsigned PTHREAD_KEY_2NDLEVEL_SIZE = 32; Index: test/lsan/TestCases/use_tls_pthread_specific_static.cc =================================================================== --- test/lsan/TestCases/use_tls_pthread_specific_static.cc +++ test/lsan/TestCases/use_tls_pthread_specific_static.cc @@ -9,7 +9,7 @@ #include #include #include -#include "../../tsan/test.h" +#include "print_address.h" // From glibc: this many keys are stored in the thread descriptor directly. const unsigned PTHREAD_KEY_2NDLEVEL_SIZE = 32; Index: test/lsan/TestCases/use_tls_static.cc =================================================================== --- test/lsan/TestCases/use_tls_static.cc +++ test/lsan/TestCases/use_tls_static.cc @@ -7,7 +7,7 @@ #include #include -#include "../../tsan/test.h" +#include "print_address.h" __thread void *tls_var; Index: test/lsan/TestCases/use_unaligned.cc =================================================================== --- test/lsan/TestCases/use_unaligned.cc +++ test/lsan/TestCases/use_unaligned.cc @@ -7,7 +7,7 @@ #include #include #include -#include "../../tsan/test.h" +#include "print_address.h" void *arr[2]; Index: test/lsan/lit.common.cfg =================================================================== --- test/lsan/lit.common.cfg +++ test/lsan/lit.common.cfg @@ -31,8 +31,9 @@ clang_cflags = ["-O0", config.target_cflags] + config.debug_info_flags clang_cxxflags = config.cxx_mode_flags + clang_cflags -clang_lsan_cflags = clang_cflags + lsan_cflags -clang_lsan_cxxflags = clang_cxxflags + lsan_cflags +lsan_incdir = config.test_source_root + "/../sanitizer_common/" +clang_lsan_cflags = clang_cflags + lsan_cflags + ["-I%s" % lsan_incdir] +clang_lsan_cxxflags = clang_cxxflags + lsan_cflags + ["-I%s" % lsan_incdir] config.clang_cflags = clang_cflags config.clang_cxxflags = clang_cxxflags Index: test/sanitizer_common/print_address.h =================================================================== --- test/sanitizer_common/print_address.h +++ test/sanitizer_common/print_address.h @@ -0,0 +1,19 @@ +#include +#include + +void print_address(const char *str, int n, ...) { + fprintf(stderr, "%s", str); + va_list ap; + va_start(ap, n); + while (n--) { + void *p = va_arg(ap, void *); +#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) + // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not + // match to the format used in the diagnotic message. + fprintf(stderr, "0x%012lx ", (unsigned long) p); +#elif defined(__mips64) + fprintf(stderr, "0x%010lx ", (unsigned long) p); +#endif + } + fprintf(stderr, "\n"); +} Index: test/tsan/deadlock_detector_stress_test.cc =================================================================== --- test/tsan/deadlock_detector_stress_test.cc +++ test/tsan/deadlock_detector_stress_test.cc @@ -11,6 +11,7 @@ #undef NDEBUG #include #include +#include "print_address.h" #ifndef LockType #define LockType PthreadMutex Index: test/tsan/global_race.cc =================================================================== --- test/tsan/global_race.cc +++ test/tsan/global_race.cc @@ -1,5 +1,6 @@ // RUN: %clangxx_tsan -O1 %s -o %T/global_race.cc.exe && %deflake %run %T/global_race.cc.exe | FileCheck %s #include "test.h" +#include "print_address.h" int GlobalData[10]; Index: test/tsan/global_race2.cc =================================================================== --- test/tsan/global_race2.cc +++ test/tsan/global_race2.cc @@ -1,5 +1,6 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s #include "test.h" +#include "print_address.h" int x; Index: test/tsan/global_race3.cc =================================================================== --- test/tsan/global_race3.cc +++ test/tsan/global_race3.cc @@ -1,5 +1,6 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s #include "test.h" +#include "print_address.h" namespace XXX { struct YYY { Index: test/tsan/lit.cfg =================================================================== --- test/tsan/lit.cfg +++ test/tsan/lit.cfg @@ -44,7 +44,8 @@ [config.target_cflags] + config.debug_info_flags + extra_cflags) -clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags + ["-std=c++11"] +tsan_incdir = config.test_source_root + "/../sanitizer_common/" +clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags + ["-std=c++11"] + ["-I%s" % tsan_incdir] # Add additional flags if we're using instrumented libc++. # Instrumented libcxx currently not supported on Darwin. if config.has_libcxx and config.host_os != 'Darwin': Index: test/tsan/memcmp_race.cc =================================================================== --- test/tsan/memcmp_race.cc +++ test/tsan/memcmp_race.cc @@ -1,6 +1,7 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s #include "test.h" #include +#include "print_address.h" char *data0 = new char[10]; char *data1 = new char[10]; Index: test/tsan/memcpy_race.cc =================================================================== --- test/tsan/memcpy_race.cc +++ test/tsan/memcpy_race.cc @@ -1,6 +1,7 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s #include "test.h" #include +#include "print_address.h" char *data = new char[10]; char *data1 = new char[10]; Index: test/tsan/mop_with_offset.cc =================================================================== --- test/tsan/mop_with_offset.cc +++ test/tsan/mop_with_offset.cc @@ -1,5 +1,6 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s #include "test.h" +#include "print_address.h" void *Thread1(void *x) { int *p = (int*)x; Index: test/tsan/mop_with_offset2.cc =================================================================== --- test/tsan/mop_with_offset2.cc +++ test/tsan/mop_with_offset2.cc @@ -1,5 +1,6 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s #include "test.h" +#include "print_address.h" void *Thread1(void *x) { barrier_wait(&barrier); Index: test/tsan/race_on_heap.cc =================================================================== --- test/tsan/race_on_heap.cc +++ test/tsan/race_on_heap.cc @@ -3,6 +3,7 @@ #include #include #include "test.h" +#include "print_address.h" void *Thread1(void *p) { *(int*)p = 42; Index: test/tsan/test.h =================================================================== --- test/tsan/test.h +++ test/tsan/test.h @@ -37,23 +37,6 @@ // Default instance of the barrier, but a test can declare more manually. invisible_barrier_t barrier; -void print_address(const char *str, int n, ...) { - fprintf(stderr, "%s", str); - va_list ap; - va_start(ap, n); - while (n--) { - void *p = va_arg(ap, void *); -#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) - // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not - // match to the format used in the diagnotic message. - fprintf(stderr, "0x%012lx ", (unsigned long) p); -#elif defined(__mips64) - fprintf(stderr, "0x%010lx ", (unsigned long) p); -#endif - } - fprintf(stderr, "\n"); -} - #ifdef __APPLE__ unsigned long long monotonic_clock_ns() { static mach_timebase_info_data_t timebase_info;