|
From: <sv...@va...> - 2005-08-26 19:42:31
|
Author: njn
Date: 2005-08-26 20:42:27 +0100 (Fri, 26 Aug 2005)
New Revision: 4527
Log:
Change slightly the way integers are printed by printf() and friends.
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.
Modified:
trunk/coregrind/m_aspacemgr/aspacemgr.c
trunk/coregrind/m_debuglog.c
trunk/coregrind/m_syswrap/syswrap-generic.c
trunk/coregrind/m_syswrap/syswrap-linux.c
trunk/massif/ms_main.c
Modified: trunk/coregrind/m_aspacemgr/aspacemgr.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-08-26 18:10:45 UTC (rev =
4526)
+++ trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-08-26 19:42:27 UTC (rev =
4527)
@@ -741,9 +741,9 @@
VG_(printf)(
"\n"
"map_file_segment(addr=3D%p len=3D%lu prot=3D0x%x flags=3D0x%x\=
n"
- " dev=3D0x%4x ino=3D%d off=3D%ld\n"
+ " dev=3D0x%4x ino=3D%d off=3D%lld\n"
" filename=3D'%s')\n",
- addr, (ULong)len, prot, flags, dev, ino, off, filename);
+ addr, len, prot, flags, dev, ino, off, filename);
=20
if (0) VG_(show_segments)("before map_file_segment");
=20
Modified: trunk/coregrind/m_debuglog.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_debuglog.c 2005-08-26 18:10:45 UTC (rev 4526)
+++ trunk/coregrind/m_debuglog.c 2005-08-26 19:42:27 UTC (rev 4527)
@@ -384,6 +384,7 @@
Int i;
Int flags;
Int width;
+ Int n_ls =3D 0;
Bool is_long;
=20
/* We assume that vargs has already been initialised by the=20
@@ -408,7 +409,7 @@
continue;
}
flags =3D 0;
- is_long =3D False;
+ n_ls =3D 0;
width =3D 0; /* length of the field. */
if (format[i] =3D=3D '(') {
flags |=3D VG_MSG_PAREN;
@@ -436,9 +437,16 @@
}
while (format[i] =3D=3D 'l') {
i++;
- is_long =3D True;
+ n_ls++;
}
=20
+ // %d means print a 32-bit integer.
+ // %ld means print a word-size integer.
+ // %lld means print a 64-bit integer.
+ if (0 =3D=3D n_ls) { is_long =3D False; }
+ else if (1 =3D=3D n_ls) { is_long =3D ( sizeof(void*) =3D=3D sizeo=
f(Long) ); }
+ else { is_long =3D True; }
+
switch (format[i]) {
case 'd': /* %d */
flags |=3D VG_MSG_SIGNED;
Modified: trunk/coregrind/m_syswrap/syswrap-generic.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/syswrap-generic.c 2005-08-26 18:10:45 UTC (=
rev 4526)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c 2005-08-26 19:42:27 UTC (=
rev 4527)
@@ -2718,7 +2718,7 @@
PRE(sys_ftruncate)
{
*flags |=3D 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, len=
gth);
}
=20
Modified: trunk/coregrind/m_syswrap/syswrap-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/syswrap-linux.c 2005-08-26 18:10:45 UTC (re=
v 4526)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c 2005-08-26 19:42:27 UTC (re=
v 4527)
@@ -456,7 +456,7 @@
PRE(sys_sendfile)
{
*flags |=3D 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 @@
PRE(sys_sendfile64)
{
*flags |=3D 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 @@
{
Int i;
=20
- 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);
Modified: trunk/massif/ms_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/massif/ms_main.c 2005-08-26 18:10:45 UTC (rev 4526)
+++ trunk/massif/ms_main.c 2005-08-26 19:42:27 UTC (rev 4527)
@@ -1531,7 +1531,7 @@
// tl_assert(sum <=3D xpt->exact_ST_dbld);
// tl_assert(sum * 1.05 > xpt->exact_ST_dbld );
// if (sum !=3D xpt->exact_ST_dbld) {
-// VG_(printf)("%ld, %ld\n", sum, xpt->exact_ST_dbld);
+// VG_(printf)("%lld, %lld\n", sum, xpt->exact_ST_dbld);
// }
}
=20
|