[PATCH] Incorrect hist_log on 32 bit system

Wenji Huang wenji.huang@oracle.com
Mon Oct 19 08:27:00 GMT 2009


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



More information about the Systemtap mailing list