[compiler-rt] r286816 - [lsan] [aarch64] Fix printing of pointers in make check tests - update
Strahinja Petrovic via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 14 03:40:56 PST 2016
Author: spetrovic
Date: Mon Nov 14 05:40:56 2016
New Revision: 286816
URL: http://llvm.org/viewvc/llvm-project?rev=286816&view=rev
Log:
[lsan] [aarch64] Fix printing of pointers in make check tests - update
This patch replaces fprintf with print_address function in LSAN
tests. This is necessary because of different printing of pointers
in fprintf and sanitizer's print function.
Differential Revision: https://reviews.llvm.org/D26084.
Added:
compiler-rt/trunk/test/sanitizer_common/print_address.h
Modified:
compiler-rt/trunk/test/lsan/TestCases/cleanup_in_tsd_destructor.c
compiler-rt/trunk/test/lsan/TestCases/large_allocation_leak.cc
compiler-rt/trunk/test/lsan/TestCases/pointer_to_self.cc
compiler-rt/trunk/test/lsan/TestCases/stale_stack_leak.cc
compiler-rt/trunk/test/lsan/TestCases/use_after_return.cc
compiler-rt/trunk/test/lsan/TestCases/use_globals_initialized.cc
compiler-rt/trunk/test/lsan/TestCases/use_globals_uninitialized.cc
compiler-rt/trunk/test/lsan/TestCases/use_poisoned_asan.cc
compiler-rt/trunk/test/lsan/TestCases/use_registers.cc
compiler-rt/trunk/test/lsan/TestCases/use_stacks.cc
compiler-rt/trunk/test/lsan/TestCases/use_stacks_threaded.cc
compiler-rt/trunk/test/lsan/TestCases/use_tls_dynamic.cc
compiler-rt/trunk/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc
compiler-rt/trunk/test/lsan/TestCases/use_tls_pthread_specific_static.cc
compiler-rt/trunk/test/lsan/TestCases/use_tls_static.cc
compiler-rt/trunk/test/lsan/TestCases/use_unaligned.cc
compiler-rt/trunk/test/lsan/lit.common.cfg
compiler-rt/trunk/test/tsan/lit.cfg
compiler-rt/trunk/test/tsan/test.h
Modified: compiler-rt/trunk/test/lsan/TestCases/cleanup_in_tsd_destructor.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/cleanup_in_tsd_destructor.c?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/cleanup_in_tsd_destructor.c (original)
+++ compiler-rt/trunk/test/lsan/TestCases/cleanup_in_tsd_destructor.c Mon Nov 14 05:40:56 2016
@@ -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;
Modified: compiler-rt/trunk/test/lsan/TestCases/large_allocation_leak.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/large_allocation_leak.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/large_allocation_leak.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/large_allocation_leak.cc Mon Nov 14 05:40:56 2016
@@ -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).
Modified: compiler-rt/trunk/test/lsan/TestCases/pointer_to_self.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/pointer_to_self.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/pointer_to_self.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/pointer_to_self.cc Mon Nov 14 05:40:56 2016
@@ -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);
Modified: compiler-rt/trunk/test/lsan/TestCases/stale_stack_leak.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/stale_stack_leak.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/stale_stack_leak.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/stale_stack_leak.cc Mon Nov 14 05:40:56 2016
@@ -6,7 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "../../tsan/test.h"
+#include "sanitizer_common/print_address.h"
void **pp;
Modified: compiler-rt/trunk/test/lsan/TestCases/use_after_return.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_after_return.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_after_return.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_after_return.cc Mon Nov 14 05:40:56 2016
@@ -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);
Modified: compiler-rt/trunk/test/lsan/TestCases/use_globals_initialized.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_globals_initialized.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_globals_initialized.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_globals_initialized.cc Mon Nov 14 05:40:56 2016
@@ -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;
Modified: compiler-rt/trunk/test/lsan/TestCases/use_globals_uninitialized.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_globals_uninitialized.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_globals_uninitialized.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_globals_uninitialized.cc Mon Nov 14 05:40:56 2016
@@ -7,7 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "../../tsan/test.h"
+#include "sanitizer_common/print_address.h"
void *bss_var;
Modified: compiler-rt/trunk/test/lsan/TestCases/use_poisoned_asan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_poisoned_asan.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_poisoned_asan.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_poisoned_asan.cc Mon Nov 14 05:40:56 2016
@@ -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;
Modified: compiler-rt/trunk/test/lsan/TestCases/use_registers.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_registers.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_registers.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_registers.cc Mon Nov 14 05:40:56 2016
@@ -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) {
Modified: compiler-rt/trunk/test/lsan/TestCases/use_stacks.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_stacks.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_stacks.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_stacks.cc Mon Nov 14 05:40:56 2016
@@ -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);
Modified: compiler-rt/trunk/test/lsan/TestCases/use_stacks_threaded.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_stacks_threaded.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_stacks_threaded.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_stacks_threaded.cc Mon Nov 14 05:40:56 2016
@@ -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) {
Modified: compiler-rt/trunk/test/lsan/TestCases/use_tls_dynamic.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_tls_dynamic.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_tls_dynamic.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_tls_dynamic.cc Mon Nov 14 05:40:56 2016
@@ -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";
Modified: compiler-rt/trunk/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc Mon Nov 14 05:40:56 2016
@@ -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;
Modified: compiler-rt/trunk/test/lsan/TestCases/use_tls_pthread_specific_static.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_tls_pthread_specific_static.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_tls_pthread_specific_static.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_tls_pthread_specific_static.cc Mon Nov 14 05:40:56 2016
@@ -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;
Modified: compiler-rt/trunk/test/lsan/TestCases/use_tls_static.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_tls_static.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_tls_static.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_tls_static.cc Mon Nov 14 05:40:56 2016
@@ -7,7 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "../../tsan/test.h"
+#include "sanitizer_common/print_address.h"
__thread void *tls_var;
Modified: compiler-rt/trunk/test/lsan/TestCases/use_unaligned.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_unaligned.cc?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_unaligned.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_unaligned.cc Mon Nov 14 05:40:56 2016
@@ -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];
Modified: compiler-rt/trunk/test/lsan/lit.common.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/lit.common.cfg?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/lit.common.cfg (original)
+++ compiler-rt/trunk/test/lsan/lit.common.cfg Mon Nov 14 05:40:56 2016
@@ -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
Added: compiler-rt/trunk/test/sanitizer_common/print_address.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/print_address.h?rev=286816&view=auto
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/print_address.h (added)
+++ compiler-rt/trunk/test/sanitizer_common/print_address.h Mon Nov 14 05:40:56 2016
@@ -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");
+}
Modified: compiler-rt/trunk/test/tsan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/lit.cfg?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/lit.cfg (original)
+++ compiler-rt/trunk/test/tsan/lit.cfg Mon Nov 14 05:40:56 2016
@@ -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':
Modified: compiler-rt/trunk/test/tsan/test.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/test.h?rev=286816&r1=286815&r2=286816&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/test.h (original)
+++ compiler-rt/trunk/test/tsan/test.h Mon Nov 14 05:40:56 2016
@@ -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(invisibl
// 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;
More information about the llvm-commits
mailing list