diff options
20 files changed, 43 insertions, 37 deletions
diff --git a/compiler-rt/test/lsan/TestCases/cleanup_in_tsd_destructor.c b/compiler-rt/test/lsan/TestCases/cleanup_in_tsd_destructor.c index c43f696af91..6da75956345 100644 --- a/compiler-rt/test/lsan/TestCases/cleanup_in_tsd_destructor.c +++ b/compiler-rt/test/lsan/TestCases/cleanup_in_tsd_destructor.c @@ -14,7 +14,7 @@ #include <stdlib.h> #include "sanitizer/lsan_interface.h" -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" pthread_key_t key; __thread void *p; diff --git a/compiler-rt/test/lsan/TestCases/large_allocation_leak.cc b/compiler-rt/test/lsan/TestCases/large_allocation_leak.cc index 70b36c96e2b..9d5698c9f8a 100644 --- a/compiler-rt/test/lsan/TestCases/large_allocation_leak.cc +++ b/compiler-rt/test/lsan/TestCases/large_allocation_leak.cc @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" int main() { // maxsize in primary allocator is always less than this (1 << 25). diff --git a/compiler-rt/test/lsan/TestCases/pointer_to_self.cc b/compiler-rt/test/lsan/TestCases/pointer_to_self.cc index 5696a6565dd..40c122811f1 100644 --- a/compiler-rt/test/lsan/TestCases/pointer_to_self.cc +++ b/compiler-rt/test/lsan/TestCases/pointer_to_self.cc @@ -6,7 +6,7 @@ #include <stdio.h> #include <stdlib.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" int main() { void *p = malloc(1337); diff --git a/compiler-rt/test/lsan/TestCases/stale_stack_leak.cc b/compiler-rt/test/lsan/TestCases/stale_stack_leak.cc index 4bba1f73c52..770096b0888 100644 --- a/compiler-rt/test/lsan/TestCases/stale_stack_leak.cc +++ b/compiler-rt/test/lsan/TestCases/stale_stack_leak.cc @@ -6,7 +6,7 @@ #include <stdio.h> #include <stdlib.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" void **pp; diff --git a/compiler-rt/test/lsan/TestCases/use_after_return.cc b/compiler-rt/test/lsan/TestCases/use_after_return.cc index 903e3e37357..ed9cc785f0f 100644 --- a/compiler-rt/test/lsan/TestCases/use_after_return.cc +++ b/compiler-rt/test/lsan/TestCases/use_after_return.cc @@ -8,7 +8,7 @@ #include <stdio.h> #include <stdlib.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" int main() { void *stack_var = malloc(1337); diff --git a/compiler-rt/test/lsan/TestCases/use_globals_initialized.cc b/compiler-rt/test/lsan/TestCases/use_globals_initialized.cc index bb2b3f659f7..45c12dc4e12 100644 --- a/compiler-rt/test/lsan/TestCases/use_globals_initialized.cc +++ b/compiler-rt/test/lsan/TestCases/use_globals_initialized.cc @@ -7,7 +7,7 @@ #include <stdio.h> #include <stdlib.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" void *data_var = (void *)1; diff --git a/compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cc b/compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cc index 46d9f65a819..c198fcc7cbb 100644 --- a/compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cc +++ b/compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cc @@ -7,7 +7,7 @@ #include <stdio.h> #include <stdlib.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" void *bss_var; diff --git a/compiler-rt/test/lsan/TestCases/use_poisoned_asan.cc b/compiler-rt/test/lsan/TestCases/use_poisoned_asan.cc index c2b7bbcfd07..5acceeb8ce0 100644 --- a/compiler-rt/test/lsan/TestCases/use_poisoned_asan.cc +++ b/compiler-rt/test/lsan/TestCases/use_poisoned_asan.cc @@ -9,7 +9,7 @@ #include <stdlib.h> #include <sanitizer/asan_interface.h> #include <assert.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" void **p; diff --git a/compiler-rt/test/lsan/TestCases/use_registers.cc b/compiler-rt/test/lsan/TestCases/use_registers.cc index 49c3702618f..7647679f479 100644 --- a/compiler-rt/test/lsan/TestCases/use_registers.cc +++ b/compiler-rt/test/lsan/TestCases/use_registers.cc @@ -10,7 +10,7 @@ #include <sched.h> #include <stdio.h> #include <stdlib.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" extern "C" void *registers_thread_func(void *arg) { diff --git a/compiler-rt/test/lsan/TestCases/use_stacks.cc b/compiler-rt/test/lsan/TestCases/use_stacks.cc index 708f352d782..c32af684126 100644 --- a/compiler-rt/test/lsan/TestCases/use_stacks.cc +++ b/compiler-rt/test/lsan/TestCases/use_stacks.cc @@ -7,7 +7,7 @@ #include <stdio.h> #include <stdlib.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" int main() { void *stack_var = malloc(1337); diff --git a/compiler-rt/test/lsan/TestCases/use_stacks_threaded.cc b/compiler-rt/test/lsan/TestCases/use_stacks_threaded.cc index 9effa325cc5..ac1fb466fa0 100644 --- a/compiler-rt/test/lsan/TestCases/use_stacks_threaded.cc +++ b/compiler-rt/test/lsan/TestCases/use_stacks_threaded.cc @@ -10,7 +10,7 @@ #include <sched.h> #include <stdio.h> #include <stdlib.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" extern "C" void *stacks_thread_func(void *arg) { diff --git a/compiler-rt/test/lsan/TestCases/use_tls_dynamic.cc b/compiler-rt/test/lsan/TestCases/use_tls_dynamic.cc index 208df11ea89..927c5c4f768 100644 --- a/compiler-rt/test/lsan/TestCases/use_tls_dynamic.cc +++ b/compiler-rt/test/lsan/TestCases/use_tls_dynamic.cc @@ -12,7 +12,7 @@ #include <stdio.h> #include <stdlib.h> #include <string> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" int main(int argc, char *argv[]) { std::string path = std::string(argv[0]) + "-so.so"; diff --git a/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc b/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc index b80c4603e5d..9ab4e1cdbc0 100644 --- a/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc +++ b/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc @@ -9,7 +9,7 @@ #include <pthread.h> #include <stdio.h> #include <stdlib.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" // From glibc: this many keys are stored in the thread descriptor directly. const unsigned PTHREAD_KEY_2NDLEVEL_SIZE = 32; diff --git a/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_static.cc b/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_static.cc index 2225bf1e9f1..be0bcf62875 100644 --- a/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_static.cc +++ b/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_static.cc @@ -9,7 +9,7 @@ #include <pthread.h> #include <stdio.h> #include <stdlib.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" // From glibc: this many keys are stored in the thread descriptor directly. const unsigned PTHREAD_KEY_2NDLEVEL_SIZE = 32; diff --git a/compiler-rt/test/lsan/TestCases/use_tls_static.cc b/compiler-rt/test/lsan/TestCases/use_tls_static.cc index 6f04ba27e17..5ffaf166bcd 100644 --- a/compiler-rt/test/lsan/TestCases/use_tls_static.cc +++ b/compiler-rt/test/lsan/TestCases/use_tls_static.cc @@ -7,7 +7,7 @@ #include <stdio.h> #include <stdlib.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" __thread void *tls_var; diff --git a/compiler-rt/test/lsan/TestCases/use_unaligned.cc b/compiler-rt/test/lsan/TestCases/use_unaligned.cc index 8ecfa9ba6f4..86c3ed5200a 100644 --- a/compiler-rt/test/lsan/TestCases/use_unaligned.cc +++ b/compiler-rt/test/lsan/TestCases/use_unaligned.cc @@ -7,7 +7,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "../../tsan/test.h" +#include "sanitizer_common/print_address.h" void *arr[2]; diff --git a/compiler-rt/test/lsan/lit.common.cfg b/compiler-rt/test/lsan/lit.common.cfg index a04c113269f..6002e2d6944 100644 --- a/compiler-rt/test/lsan/lit.common.cfg +++ b/compiler-rt/test/lsan/lit.common.cfg @@ -31,8 +31,9 @@ config.name += config.name_suffix 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 + "/../" +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 diff --git a/compiler-rt/test/sanitizer_common/print_address.h b/compiler-rt/test/sanitizer_common/print_address.h new file mode 100644 index 00000000000..018db61800d --- /dev/null +++ b/compiler-rt/test/sanitizer_common/print_address.h @@ -0,0 +1,19 @@ +#include <stdio.h> +#include <stdarg.h> + +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"); +} diff --git a/compiler-rt/test/tsan/lit.cfg b/compiler-rt/test/tsan/lit.cfg index e0f93c7dd7b..9dd890aa68b 100644 --- a/compiler-rt/test/tsan/lit.cfg +++ b/compiler-rt/test/tsan/lit.cfg @@ -38,13 +38,15 @@ if config.compiler_id == 'GNU': else: extra_cflags = [] +tsan_incdir = config.test_source_root + "/../" # Setup default compiler flags used with -fsanitize=thread option. clang_tsan_cflags = (["-fsanitize=thread", "-Wall"] + [config.target_cflags] + config.debug_info_flags + - extra_cflags) -clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags + ["-std=c++11"] + extra_cflags + + ["-I%s" % tsan_incdir]) +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': diff --git a/compiler-rt/test/tsan/test.h b/compiler-rt/test/tsan/test.h index e3affdc0837..ed300dbbeb5 100644 --- a/compiler-rt/test/tsan/test.h +++ b/compiler-rt/test/tsan/test.h @@ -6,6 +6,7 @@ #include <stddef.h> #include <sched.h> #include <stdarg.h> +#include "sanitizer_common/print_address.h" #ifdef __APPLE__ #include <mach/mach_time.h> @@ -37,23 +38,6 @@ static inline void barrier_wait(invisible_barrier_t *barrier) { // 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; |