This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] Incorrect hist_log on 32 bit system
- From: Wenji Huang <wenji dot huang at oracle dot com>
- To: SystemTAP <systemtap at sources dot redhat dot com>
- Date: Mon, 19 Oct 2009 16:24:22 +0800
- Subject: [PATCH] Incorrect hist_log on 32 bit system
- Reply-to: wenji dot huang at oracle dot com
Hi,
I got odd error for latest source on 32 bit system, like RHEL5 and FC11.
$ stap -e 'global a probe begin{ a <<< 2 print(@hist_log(a)) exit()}'
value |-------------------------------------------------- count
0 | 0
1 | 0
2 |@ 4294967296
4 | 0
8 | 0
The reason is the following line on _stp_stat_print_histogram_buf
HIST_PRINTF("%*lld\n", HIST_WIDTH - v + 1 + cnt_space, sd->histogram[i]);
It seems that we need to do explicit type cast for the width so as
to eliminate the possibility of uncertain value generated by
delay calculation and ## macro.
diff --git a/runtime/stat-common.c b/runtime/stat-common.c
index e6fd3a1..7123dc8 100644
--- a/runtime/stat-common.c
+++ b/runtime/stat-common.c
@@ -270,7 +270,7 @@ static void _stp_stat_print_histogram_buf(char *buf,
size_t size, Hist st, stat
for (j = 0; j < v; ++j)
HIST_PRINTF("@");
- HIST_PRINTF("%*lld\n", HIST_WIDTH - v + 1 + cnt_space,
sd->histogram[i]);
+ HIST_PRINTF("%*lld\n", (int)(HIST_WIDTH - v + 1 +
cnt_space), sd->histogram[i]);
}
HIST_PRINTF("\n");
#undef HIST_PRINTF