[compiler-rt] r276286 - [compiler-rt] Fix broken unittest on win64

Etienne Bergeron via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 07:36:26 PDT 2016


Author: etienneb
Date: Thu Jul 21 09:36:25 2016
New Revision: 276286

URL: http://llvm.org/viewvc/llvm-project?rev=276286&view=rev
Log:
[compiler-rt] Fix broken unittest on win64

Summary:
This is an other tentative to fix:
https://reviews.llvm.org/D22588

It's less clever, but should work.

Turn out there is not an easy way to write a portable print
for a pointer in lowercase without the prefix 0x.

Reviewers: rnk

Subscribers: llvm-commits, wang0109, kubabrecka, chrisha

Differential Revision: https://reviews.llvm.org/D22606

Modified:
    compiler-rt/trunk/test/asan/TestCases/debug_mapping.cc
    compiler-rt/trunk/test/asan/TestCases/debug_stacks.cc

Modified: compiler-rt/trunk/test/asan/TestCases/debug_mapping.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/debug_mapping.cc?rev=276286&r1=276285&r2=276286&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/debug_mapping.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/debug_mapping.cc Thu Jul 21 09:36:25 2016
@@ -6,6 +6,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#if _WIN64
+#define PTR "%llx"
+#else
+#define PTR "%lx"
+#endif
+
 // printed because of verbosity=1
 // CHECK: SHADOW_SCALE: [[SCALE:[0-9]+]]
 // CHECK: SHADOW_OFFSET: [[OFFSET:0x[0-9a-f]+]]
@@ -15,7 +21,7 @@ int main() {
   __asan_get_shadow_mapping(&scale, &offset);
 
   fprintf(stderr, "scale: %d\n", (int)scale);
-  fprintf(stderr, "offset: 0x%lx\n", offset);
+  fprintf(stderr, "offset: 0x" PTR "\n", (void*)offset);
 
   // CHECK: scale: [[SCALE]]
   // CHECK: offset: [[OFFSET]]

Modified: compiler-rt/trunk/test/asan/TestCases/debug_stacks.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/debug_stacks.cc?rev=276286&r1=276285&r2=276286&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/debug_stacks.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/debug_stacks.cc Thu Jul 21 09:36:25 2016
@@ -5,6 +5,12 @@
 // FIXME: Figure out why allocation/free stack traces may be too short on ARM.
 // REQUIRES: stable-runtime
 
+#if _WIN64
+#define PTR "%llx"
+#else
+#define PTR "%lx"
+#endif
+
 #include <sanitizer/asan_interface.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -35,9 +41,9 @@ int main() {
   // CHECK: alloc stack retval ok
   fprintf(stderr, "thread id = %d\n", thread_id);
   // CHECK: thread id = 0
-  fprintf(stderr, "0x%lx\n", trace[0]);
+  fprintf(stderr, "0x" PTR "\n", trace[0]);
   // CHECK: [[ALLOC_FRAME_0:0x[0-9a-f]+]]
-  fprintf(stderr, "0x%lx\n", trace[1]);
+  fprintf(stderr, "0x" PTR "\n", trace[1]);
   // CHECK: [[ALLOC_FRAME_1:0x[0-9a-f]+]]
 
   num_frames = 100;
@@ -48,9 +54,9 @@ int main() {
   // CHECK: free stack retval ok
   fprintf(stderr, "thread id = %d\n", thread_id);
   // CHECK: thread id = 0
-  fprintf(stderr, "0x%lx\n", trace[0]);
+  fprintf(stderr, "0x" PTR "\n", trace[0]);
   // CHECK: [[FREE_FRAME_0:0x[0-9a-f]+]]
-  fprintf(stderr, "0x%lx\n", trace[1]);
+  fprintf(stderr, "0x" PTR "\n", trace[1]);
   // CHECK: [[FREE_FRAME_1:0x[0-9a-f]+]]
 
   mem[0] = 'A'; // BOOM




More information about the llvm-commits mailing list