> From: "Ted Unangst" <t...@tedunangst.com> > Date: Wed, 27 Apr 2022 04:07:24 -0400 > > btrace needs a little more help printing very large numbers. If you > have something like 2^61 in your histogram, it gets printed as 1K > because that's what's left over after dividing by G and M. Add some > more units, and it prints as 1E. > > (It seems like there might be another bug, because I'm not really > expecting values this large, but at least now I can see that they > are large.)
Hmm, using multiples of 1024 instead of 1000 here is wierd. But that's not necessarily your fault... > Index: map.c > =================================================================== > RCS file: /home/cvs/src/usr.sbin/btrace/map.c,v > retrieving revision 1.19 > diff -u -p -r1.19 map.c > --- map.c 15 Nov 2021 14:57:57 -0000 1.19 > +++ map.c 27 Apr 2022 08:04:10 -0000 > @@ -267,11 +267,26 @@ hist_increment(struct hist *hist, const > long > hist_get_bin_suffix(long bin, char **suffix) > { > +#define EXA (PETA * 1024) > +#define PETA (TERA * 1024) > +#define TERA (GIGA * 1024) > #define GIGA (MEGA * 1024) > #define MEGA (KILO * 1024) > -#define KILO (1024) > +#define KILO (1024LL) > > *suffix = ""; > + if (bin >= EXA) { > + bin /= EXA; > + *suffix = "E"; > + } > + if (bin >= PETA) { > + bin /= PETA; > + *suffix = "P"; > + } > + if (bin >= TERA) { > + bin /= TERA; > + *suffix = "T"; > + } > if (bin >= GIGA) { > bin /= GIGA; > *suffix = "G"; > @@ -284,10 +299,7 @@ hist_get_bin_suffix(long bin, char **suf > bin /= KILO; > *suffix = "K"; > } > - > return bin; > -#undef MEGA > -#undef KILO > } > > /* > >