|
[Valgrind-developers] Valgrind: r14836 - in /trunk:
coregrind/m_debuglog.c include/pub_tool_basics.h
From: <sv...@va...> - 2014-12-29 19:06:58
|
Author: florian
Date: Mon Dec 29 19:06:40 2014
New Revision: 14836
Log:
Move definition of type SizeT to VEX (see VEX r3046).
Enhance printeffery to print SizeT values.
Modified:
trunk/coregrind/m_debuglog.c
trunk/include/pub_tool_basics.h
Modified: trunk/coregrind/m_debuglog.c
==============================================================================
--- trunk/coregrind/m_debuglog.c (original)
+++ trunk/coregrind/m_debuglog.c Mon Dec 29 19:06:40 2014
@@ -731,7 +731,7 @@
Int flags;
Int width, precision;
Int n_ls = 0;
- Bool is_long, caps;
+ Bool is_long, is_sizet, caps;
/* We assume that vargs has already been initialised by the
caller, using va_start, and that the caller will similarly
@@ -811,9 +811,15 @@
}
}
}
- while (format[i] == 'l') {
- i++;
- n_ls++;
+
+ is_sizet = False;
+ if (format[i] == 'z') {
+ is_sizet = True;
+ } else {
+ while (format[i] == 'l') {
+ i++;
+ n_ls++;
+ }
}
// %d means print a 32-bit integer.
@@ -829,7 +835,10 @@
ret += 2;
send('0',send_arg2);
}
- if (is_long)
+ if (is_sizet)
+ ret += myvprintf_int64(send, send_arg2, flags, 8, width, False,
+ (ULong)(va_arg (vargs, SizeT)));
+ else if (is_long)
ret += myvprintf_int64(send, send_arg2, flags, 8, width, False,
(ULong)(va_arg (vargs, ULong)));
else
@@ -846,7 +855,10 @@
(ULong)(va_arg (vargs, Int)));
break;
case 'u': /* %u */
- if (is_long)
+ if (is_sizet)
+ ret += myvprintf_int64(send, send_arg2, flags, 10, width, False,
+ (ULong)(va_arg (vargs, SizeT)));
+ else if (is_long)
ret += myvprintf_int64(send, send_arg2, flags, 10, width, False,
(ULong)(va_arg (vargs, ULong)));
else
@@ -890,7 +902,10 @@
send('0',send_arg2);
send('x',send_arg2);
}
- if (is_long)
+ if (is_sizet)
+ ret += myvprintf_int64(send, send_arg2, flags, 16, width, False,
+ (ULong)(va_arg (vargs, SizeT)));
+ else if (is_long)
ret += myvprintf_int64(send, send_arg2, flags, 16, width, caps,
(ULong)(va_arg (vargs, ULong)));
else
Modified: trunk/include/pub_tool_basics.h
==============================================================================
--- trunk/include/pub_tool_basics.h (original)
+++ trunk/include/pub_tool_basics.h Mon Dec 29 19:06:40 2014
@@ -42,7 +42,7 @@
Other headers to include
------------------------------------------------------------------ */
-// VEX defines Char, UChar, Short, UShort, Int, UInt, Long, ULong,
+// VEX defines Char, UChar, Short, UShort, Int, UInt, Long, ULong, SizeT,
// Addr32, Addr64, HWord, HChar, Bool, False and True.
#include "libvex_basictypes.h"
@@ -89,10 +89,8 @@
// Addr is for holding an address.
typedef UWord Addr; // 32 64
-// Our equivalents of POSIX 'size_t' and 'ssize_t':
-// - size_t is an "unsigned integer type of the result of the sizeof operator".
+// Our equivalent of POSIX 'ssize_t':
// - ssize_t is "used for a count of bytes or an error indication".
-typedef UWord SizeT; // 32 64
typedef Word SSizeT; // 32 64
// Our equivalent of POSIX 'ptrdiff_t':
|