[PATCH] [asan] Print SHADOW_SCALE and SHADOW_GRANULARITY as decimal values.

Daniel Sanders Daniel.Sanders at imgtec.com
Thu Apr 23 08:12:41 PDT 2015


Good point. Timur has asked me to cast to int and is wondering whether the prototype should be changed so I'll wait to see what Kostya says before updating the patch to either cast to int or use '%zd'.

From: mats.o.petersson at googlemail.com [mailto:mats.o.petersson at googlemail.com] On Behalf Of mats petersson
Sent: 23 April 2015 15:41
To: reviews+D9224+public+0db905cdbbbc4cdf at reviews.llvm.org
Cc: Daniel Sanders; kcc at google.com; timurrrr at google.com; llvm-commits at cs.uiuc.edu; Sagar Thakur
Subject: Re: [PATCH] [asan] Print SHADOW_SCALE and SHADOW_GRANULARITY as decimal values.



On 23 April 2015 at 15:32, Daniel Sanders <daniel.sanders at imgtec.com<mailto:daniel.sanders at imgtec.com>> wrote:
Hi kcc, timurrrr,

During the review of http://reviews.llvm.org/D9199 where I had originally
changed the debug_mapping.cc test to accept hexadecimal values, we realized
that SHADOW_SCALE and SHADOW_GRANULARITY ought to be printed as decimal values.
This patch makes that change.

This patch also adds a '0x' prefix to the SHADOW_OFFSET to make it clear that
it is hexadecimal while the other two are decimal.

http://reviews.llvm.org/D9224

Files:
  lib/asan/asan_rtl.cc
  test/asan/TestCases/debug_mapping.cc

Index: lib/asan/asan_rtl.cc
===================================================================
--- lib/asan/asan_rtl.cc
+++ lib/asan/asan_rtl.cc
@@ -347,9 +347,9 @@
   Printf("malloc_context_size=%zu\n",
          (uptr)common_flags()->malloc_context_size);

-  Printf("SHADOW_SCALE: %zx\n", (uptr)SHADOW_SCALE);
-  Printf("SHADOW_GRANULARITY: %zx\n", (uptr)SHADOW_GRANULARITY);
-  Printf("SHADOW_OFFSET: %zx\n", (uptr)SHADOW_OFFSET);
+  Printf("SHADOW_SCALE: %d\n", (uptr)SHADOW_SCALE);
If it's cast to uptr, then surely it should be "%zd" or even "%zu", not "%d" (the z means "size_t" length of the value)

--
Mats
+  Printf("SHADOW_GRANULARITY: %d\n", (uptr)SHADOW_GRANULARITY);
+  Printf("SHADOW_OFFSET: 0x%zx\n", (uptr)SHADOW_OFFSET);
   CHECK(SHADOW_SCALE >= 3 && SHADOW_SCALE <= 7);
   if (kMidMemBeg)
     CHECK(kMidShadowBeg > kLowShadowEnd &&
Index: test/asan/TestCases/debug_mapping.cc
===================================================================
--- test/asan/TestCases/debug_mapping.cc
+++ test/asan/TestCases/debug_mapping.cc
@@ -8,14 +8,14 @@

 // printed because of verbosity=1
 // CHECK: SHADOW_SCALE: [[SCALE:[0-9]+]]
-// CHECK: SHADOW_OFFSET: [[OFFSET:[0-9a-f]+]]
+// CHECK: SHADOW_OFFSET: [[OFFSET:0x[0-9a-f]+]]

 int main() {
   size_t scale, offset;
   __asan_get_shadow_mapping(&scale, &offset);

-  fprintf(stderr, "scale: %lx\n", scale);
-  fprintf(stderr, "offset: %lx\n", offset);
+  fprintf(stderr, "scale: %d\n", scale);
Likewise size_t should be "%zd" [and for the hex on the next line "%zx", not "%lx"]
+  fprintf(stderr, "offset: 0x%lx\n", offset);

   // CHECK: scale: [[SCALE]]
   // CHECK: offset: [[OFFSET]]

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/

_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu<mailto:llvm-commits at cs.uiuc.edu>
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150423/c125eb41/attachment.html>


More information about the llvm-commits mailing list