[compiler-rt] r284722 - [lsan] [aarch64] Fix printing of pointers in make check tests
Strahinja Petrovic via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 20 05:25:58 PDT 2016
Author: spetrovic
Date: Thu Oct 20 07:25:57 2016
New Revision: 284722
URL: http://llvm.org/viewvc/llvm-project?rev=284722&view=rev
Log:
[lsan] [aarch64] Fix printing of pointers in make check tests
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/D25270.
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
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=284722&r1=284721&r2=284722&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 Thu Oct 20 07:25:57 2016
@@ -14,6 +14,7 @@
#include <stdlib.h>
#include "sanitizer/lsan_interface.h"
+#include "../../tsan/test.h"
pthread_key_t key;
__thread void *p;
@@ -25,7 +26,7 @@ void key_destructor(void *arg) {
void *thread_func(void *arg) {
p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
int res = pthread_setspecific(key, (void*)1);
assert(res == 0);
return 0;
@@ -41,5 +42,5 @@ int main() {
assert(res == 0);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: [[ADDR]] (1337 bytes)
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/large_allocation_leak.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/large_allocation_leak.cc Thu Oct 20 07:25:57 2016
@@ -5,14 +5,15 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
int main() {
// maxsize in primary allocator is always less than this (1 << 25).
void *large_alloc = malloc(33554432);
- fprintf(stderr, "Test alloc: %p.\n", large_alloc);
+ print_address("Test alloc: ", 1, large_alloc);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (33554432 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/pointer_to_self.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/pointer_to_self.cc Thu Oct 20 07:25:57 2016
@@ -6,13 +6,14 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
int main() {
void *p = malloc(1337);
*reinterpret_cast<void **>(p) = p;
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/stale_stack_leak.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/stale_stack_leak.cc Thu Oct 20 07:25:57 2016
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
void **pp;
@@ -18,7 +19,7 @@ void *PutPointerOnStaleStack(void *p) {
void *locals[2048];
locals[0] = p;
pp = &locals[0];
- fprintf(stderr, "Test alloc: %p.\n", locals[0]);
+ print_address("Test alloc: ", 1, locals[0]);
return 0;
}
@@ -33,11 +34,11 @@ int main() {
__attribute__((destructor))
__attribute__((no_sanitize_address))
void ConfirmPointerHasSurvived() {
- fprintf(stderr, "Value after LSan: %p.\n", *pp);
+ print_address("Value after LSan: ", 1, *pp);
}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK-sanity: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
+// CHECK-sanity: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
-// CHECK-sanity: Value after LSan: [[ADDR]].
+// CHECK-sanity: Value after LSan: [[ADDR]]
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_after_return.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_after_return.cc Thu Oct 20 07:25:57 2016
@@ -8,16 +8,17 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
int main() {
void *stack_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", stack_var);
+ print_address("Test alloc: ", 1, stack_var);
// Take pointer to variable, to ensure it's not optimized into a register.
- fprintf(stderr, "Stack var at: %p.\n", &stack_var);
+ print_address("Stack var at: ", 1, &stack_var);
// Do not return from main to prevent the pointer from going out of scope.
exit(0);
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_globals_initialized.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_globals_initialized.cc Thu Oct 20 07:25:57 2016
@@ -7,15 +7,16 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
void *data_var = (void *)1;
int main() {
data_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", data_var);
+ print_address("Test alloc: ", 1, data_var);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_globals_uninitialized.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_globals_uninitialized.cc Thu Oct 20 07:25:57 2016
@@ -7,15 +7,16 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
void *bss_var;
int main() {
bss_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", bss_var);
+ print_address("Test alloc: ", 1, bss_var);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_poisoned_asan.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_poisoned_asan.cc Thu Oct 20 07:25:57 2016
@@ -9,17 +9,18 @@
#include <stdlib.h>
#include <sanitizer/asan_interface.h>
#include <assert.h>
+#include "../../tsan/test.h"
void **p;
int main() {
p = new void *;
*p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", *p);
+ print_address("Test alloc: ", 1, *p);
__asan_poison_memory_region(p, sizeof(*p));
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: AddressSanitizer:
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_registers.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_registers.cc Thu Oct 20 07:25:57 2016
@@ -10,6 +10,7 @@
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
extern "C"
void *registers_thread_func(void *arg) {
@@ -35,7 +36,7 @@ void *registers_thread_func(void *arg) {
#else
#error "Test is not supported on this architecture."
#endif
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
fflush(stderr);
__sync_fetch_and_xor(sync, 1);
while (true)
@@ -51,7 +52,7 @@ int main() {
sched_yield();
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_stacks.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_stacks.cc Thu Oct 20 07:25:57 2016
@@ -7,14 +7,15 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
int main() {
void *stack_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", stack_var);
+ print_address("Test alloc: ", 1, stack_var);
// Do not return from main to prevent the pointer from going out of scope.
exit(0);
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_stacks_threaded.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_stacks_threaded.cc Thu Oct 20 07:25:57 2016
@@ -10,12 +10,13 @@
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
extern "C"
void *stacks_thread_func(void *arg) {
int *sync = reinterpret_cast<int *>(arg);
void *p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
fflush(stderr);
__sync_fetch_and_xor(sync, 1);
while (true)
@@ -31,7 +32,7 @@ int main() {
sched_yield();
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_tls_dynamic.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_tls_dynamic.cc Thu Oct 20 07:25:57 2016
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string>
+#include "../../tsan/test.h"
int main(int argc, char *argv[]) {
std::string path = std::string(argv[0]) + "-so.so";
@@ -26,10 +27,10 @@ int main(int argc, char *argv[]) {
// If we don't know about dynamic TLS, we will return a false leak above.
void **p_in_tls = StoreToTLS(p);
assert(*p_in_tls == p);
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
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=284722&r1=284721&r2=284722&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 Thu Oct 20 07:25:57 2016
@@ -9,6 +9,7 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
// From glibc: this many keys are stored in the thread descriptor directly.
const unsigned PTHREAD_KEY_2NDLEVEL_SIZE = 32;
@@ -28,10 +29,10 @@ int main() {
void *p = malloc(1337);
res = pthread_setspecific(key, p);
assert(res == 0);
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
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=284722&r1=284721&r2=284722&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 Thu Oct 20 07:25:57 2016
@@ -9,6 +9,7 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
// From glibc: this many keys are stored in the thread descriptor directly.
const unsigned PTHREAD_KEY_2NDLEVEL_SIZE = 32;
@@ -22,10 +23,10 @@ int main() {
void *p = malloc(1337);
res = pthread_setspecific(key, p);
assert(res == 0);
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_tls_static.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_tls_static.cc Thu Oct 20 07:25:57 2016
@@ -7,15 +7,16 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
__thread void *tls_var;
int main() {
tls_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", tls_var);
+ print_address("Test alloc: ", 1, tls_var);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
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=284722&r1=284721&r2=284722&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_unaligned.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_unaligned.cc Thu Oct 20 07:25:57 2016
@@ -7,17 +7,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "../../tsan/test.h"
void *arr[2];
int main() {
void *p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
char *char_arr = (char *)arr;
memcpy(char_arr + 1, &p, sizeof(p));
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
More information about the llvm-commits
mailing list