]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Change slightly the way integers are printed by printf() and friends.
authorNicholas Nethercote <njn@valgrind.org>
Fri, 26 Aug 2005 19:42:27 +0000 (19:42 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Fri, 26 Aug 2005 19:42:27 +0000 (19:42 +0000)
Previously, %d printed a 32-bit int.  %ld and %lld printed 64-bit ints.
So if you wanted to print a word-sized int (eg. a SizeT variable), you
had to cast it to a Long and then print with %lld in order to work on
both 32-bit and 64-bit platforms.

I changed things so that %d prints a 32-bit int, %ld prints a word-sized
int, and %lld prints a 64-bit int.  There are two advantages to this:
- it now matches the way the normal glibc printf() works;
- you can print word-sized ints without casting.

I also made the corresponding change for %u/lu/llu and %x/lx/llx, and I
changed a couple of VG_(printf)() invocations accordingly.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4527

coregrind/m_aspacemgr/aspacemgr.c
coregrind/m_debuglog.c
coregrind/m_syswrap/syswrap-generic.c
coregrind/m_syswrap/syswrap-linux.c
massif/ms_main.c

index 39e8ca82b7ccbf67a7130e65ff6e626557c5871a..5b1abba7486669851a95d7b0f9310858855cb319 100644 (file)
@@ -741,9 +741,9 @@ VG_(map_file_segment)( Addr addr, SizeT len,
       VG_(printf)(
          "\n"
          "map_file_segment(addr=%p len=%lu prot=0x%x flags=0x%x\n"
-         "                 dev=0x%4x ino=%d off=%ld\n"
+         "                 dev=0x%4x ino=%d off=%lld\n"
          "                 filename='%s')\n",
-         addr, (ULong)len, prot, flags, dev, ino, off, filename);
+         addr, len, prot, flags, dev, ino, off, filename);
 
    if (0) VG_(show_segments)("before map_file_segment");
 
index bdf2769dbad58172c0e2a3541d4382cef26543ad..2cde3d9789ff8b6c118b404ed09b06cf2a764161 100644 (file)
@@ -384,6 +384,7 @@ VG_(debugLog_vprintf) (
    Int  i;
    Int  flags;
    Int  width;
+   Int  n_ls = 0;
    Bool is_long;
 
    /* We assume that vargs has already been initialised by the 
@@ -408,7 +409,7 @@ VG_(debugLog_vprintf) (
          continue;
       }
       flags = 0;
-      is_long = False;
+      n_ls  = 0;
       width = 0; /* length of the field. */
       if (format[i] == '(') {
          flags |= VG_MSG_PAREN;
@@ -436,9 +437,16 @@ VG_(debugLog_vprintf) (
       }
       while (format[i] == 'l') {
          i++;
-         is_long = True;
+         n_ls++;
       }
 
+      //   %d means print a 32-bit integer.
+      //  %ld means print a word-size integer.
+      // %lld means print a 64-bit integer.
+      if      (0 == n_ls) { is_long = False; }
+      else if (1 == n_ls) { is_long = ( sizeof(void*) == sizeof(Long) ); }
+      else                { is_long = True; }
+
       switch (format[i]) {
          case 'd': /* %d */
             flags |= VG_MSG_SIGNED;
index 15db45409d1aa379048669d85815457cb01be060..94d15f2b15a52a46be9b82244e386833c57e4f88 100644 (file)
@@ -2718,7 +2718,7 @@ PRE(sys_fork)
 PRE(sys_ftruncate)
 {
    *flags |= SfMayBlock;
-   PRINT("sys_ftruncate ( %d, %lld )", ARG1,(ULong)ARG2);
+   PRINT("sys_ftruncate ( %d, %ld )", ARG1,ARG2);
    PRE_REG_READ2(long, "ftruncate", unsigned int, fd, unsigned long, length);
 }
 
index 8187a117c4a1a66cb03745723164528da08f5e5b..74282739c6746948eb1214ca8f4c86b25c31cc36 100644 (file)
@@ -456,7 +456,7 @@ PRE(sys_prctl)
 PRE(sys_sendfile)
 {
    *flags |= SfMayBlock;
-   PRINT("sys_sendfile ( %d, %d, %p, %llu )", ARG1,ARG2,ARG3,(ULong)ARG4);
+   PRINT("sys_sendfile ( %d, %d, %p, %lu )", ARG1,ARG2,ARG3,ARG4);
    PRE_REG_READ4(ssize_t, "sendfile",
                  int, out_fd, int, in_fd, vki_off_t *, offset,
                  vki_size_t, count);
@@ -473,7 +473,7 @@ POST(sys_sendfile)
 PRE(sys_sendfile64)
 {
    *flags |= SfMayBlock;
-   PRINT("sendfile64 ( %d, %d, %p, %llu )",ARG1,ARG2,ARG3,(ULong)ARG4);
+   PRINT("sendfile64 ( %d, %d, %p, %lu )",ARG1,ARG2,ARG3,ARG4);
    PRE_REG_READ4(ssize_t, "sendfile64",
                  int, out_fd, int, in_fd, vki_loff_t *, offset,
                  vki_size_t, count);
@@ -794,7 +794,7 @@ PRE(sys_io_submit)
 {
    Int i;
 
-   PRINT("sys_io_submit ( %llu, %lld, %p )", (ULong)ARG1,(Long)ARG2,ARG3);
+   PRINT("sys_io_submit ( %llu, %ld, %p )", (ULong)ARG1,ARG2,ARG3);
    PRE_REG_READ3(long, "io_submit",
                  vki_aio_context_t, ctx_id, long, nr,
                  struct iocb **, iocbpp);
index 03fb3361fb6bb596faf688d670823a5ec38288bf..d4d2b6b3b9d304100023d963a94a30e2fc533aaf 100644 (file)
@@ -1531,7 +1531,7 @@ static void pp_all_XPts2(Int fd, Queue* q, ULong heap_spacetime,
 //         tl_assert(sum <= xpt->exact_ST_dbld);
 //         tl_assert(sum * 1.05 > xpt->exact_ST_dbld );
 //         if (sum != xpt->exact_ST_dbld) {
-//            VG_(printf)("%ld, %ld\n", sum, xpt->exact_ST_dbld);
+//            VG_(printf)("%lld, %lld\n", sum, xpt->exact_ST_dbld);
 //         }
       }