summaryrefslogtreecommitdiff
path: root/lib/mprintf.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-08-24 16:01:15 +0000
committerYang Tse <yangsita@gmail.com>2008-08-24 16:01:15 +0000
commitcbc04a7d40895d731d833c34d1c55e31b3fe4b79 (patch)
tree49753e950f252eadec8d10d6f58ba87c3e7817a0 /lib/mprintf.c
parent71d3c5bf415659162172332362ffa605edc8147e (diff)
downloadcurl-cbc04a7d40895d731d833c34d1c55e31b3fe4b79.tar.gz
Debug trace curl_mprintf() on x86_64 and ia64 systems.
Diffstat (limited to 'lib/mprintf.c')
-rw-r--r--lib/mprintf.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/mprintf.c b/lib/mprintf.c
index 1bbf53ade..fea8e5198 100644
--- a/lib/mprintf.c
+++ b/lib/mprintf.c
@@ -182,6 +182,19 @@ struct asprintf {
int curl_msprintf(char *buffer, const char *format, ...);
+static int trace_this(void)
+{
+ const char * host = OS;
+ const char * arc1 = "x86_64";
+ const char * arc2 = "ia64";
+
+ if(0 == memcmp(host, arc1, strlen(arc1)))
+ return 1;
+ if(0 == memcmp(host, arc2, strlen(arc2)))
+ return 1;
+ return 0;
+}
+
static long dprintf_DollarString(char *input, char **end)
{
int number=0;
@@ -582,30 +595,66 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
#ifdef HAVE_LONG_LONG_TYPE
if((vto[i].flags & FLAGS_LONGLONG) && (vto[i].flags & FLAGS_UNSIGNED)) {
va_unsigned_long_long = va_arg(arglist, mp_uintmax_t);
+ if(trace_this())
+ printf("va_unsigned_long_long = %llu\n",
+ va_unsigned_long_long);
vto[i].data.num.as_unsigned = (mp_uintmax_t)va_unsigned_long_long;
+ if(trace_this())
+ printf("vto[i].data.num.as_unsigned = %llu\n",
+ vto[i].data.num.as_unsigned);
}
else if(vto[i].flags & FLAGS_LONGLONG) {
va_signed_long_long = va_arg(arglist, mp_intmax_t);
+ if(trace_this())
+ printf("va_signed_long_long = %lld\n",
+ va_signed_long_long);
vto[i].data.num.as_signed = (mp_intmax_t)va_signed_long_long;
+ if(trace_this())
+ printf("vto[i].data.num.as_signed = %lld\n",
+ vto[i].data.num.as_signed);
}
else
#endif
{
if((vto[i].flags & FLAGS_LONG) && (vto[i].flags & FLAGS_UNSIGNED)) {
va_unsigned_long = va_arg(arglist, unsigned long);
+ if(trace_this())
+ printf("va_unsigned_long = %lu\n",
+ va_unsigned_long);
vto[i].data.num.as_unsigned = (mp_uintmax_t)va_unsigned_long;
+ if(trace_this())
+ printf("vto[i].data.num.as_unsigned = %llu\n",
+ vto[i].data.num.as_unsigned);
}
else if(vto[i].flags & FLAGS_LONG) {
va_signed_long = va_arg(arglist, long);
+ if(trace_this())
+ printf("va_signed_long = %ld\n",
+ va_signed_long);
vto[i].data.num.as_signed = (mp_intmax_t)va_signed_long;
+ if(trace_this())
+ printf("vto[i].data.num.as_signed = %lld\n",
+ vto[i].data.num.as_signed);
}
else if(vto[i].flags & FLAGS_UNSIGNED) {
va_unsigned_int = va_arg(arglist, unsigned int);
+ if(trace_this())
+ printf("va_unsigned_int = %u\n",
+ va_unsigned_int);
vto[i].data.num.as_unsigned = (mp_uintmax_t)va_unsigned_int;
+ if(trace_this())
+ printf("vto[i].data.num.as_unsigned = %llu\n",
+ vto[i].data.num.as_unsigned);
}
else {
va_signed_int = va_arg(arglist, int);
+ if(trace_this())
+ printf("va_signed_int = %d\n",
+ va_signed_int);
vto[i].data.num.as_signed = (mp_intmax_t)va_signed_int;
+ if(trace_this())
+ printf("vto[i].data.num.as_signed = %lld\n",
+ vto[i].data.num.as_signed);
}
}
break;
@@ -777,13 +826,25 @@ static int dprintf_formatf(
base = 10;
signed_num = p->data.num.as_signed;
+ if(trace_this())
+ printf("1 signed_num = %lld\n", signed_num);
is_neg = (signed_num < (mp_intmax_t)0) ? 1 : 0;
+ if(trace_this())
+ printf("is_neg = %d\n", is_neg);
if(is_neg) {
/* signed_num might fail to hold absolute negative minimum by 1 */
signed_num += (mp_intmax_t)1;
+ if(trace_this())
+ printf("2 signed_num = %lld\n", signed_num);
signed_num = -signed_num;
+ if(trace_this())
+ printf("3 signed_num = %lld\n", signed_num);
num = (mp_uintmax_t)signed_num;
+ if(trace_this())
+ printf("4 num = %llu\n", num);
num += (mp_uintmax_t)0x1;
+ if(trace_this())
+ printf("5 num = %llu\n", num);
}
goto number;