From: Nicholas Nethercote Date: Thu, 27 Jan 2011 23:07:56 +0000 (+0000) Subject: If Massif's --threshold value was less than 1.0, in lines like this: X-Git-Tag: svn/VALGRIND_3_7_0~692 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c3ae8f0ad3f28f8b4b5b7ff965c16e8102bc70d9;p=thirdparty%2Fvalgrind.git If Massif's --threshold value was less than 1.0, in lines like this: ->00.00% (0B) in 11 places, all below massif's threshold (00.00%) the threshold would always be incorrectly printed as 00.00%. This was because the percentage printing was broken for percentages less than 1.0. This change fixes this problem, and modifies a test to check for it. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11511 --- diff --git a/massif/ms_main.c b/massif/ms_main.c index acf8d449a0..ae39b7a527 100644 --- a/massif/ms_main.c +++ b/massif/ms_main.c @@ -2106,14 +2106,11 @@ Char FP_buf[BUF_LEN]; }) // Nb: uses a static buffer, each call trashes the last string returned. -static Char* make_perc(ULong x, ULong y) +static Char* make_perc(double x) { static Char mbuf[32]; -// tl_assert(x <= y); XXX; put back in later... - - // XXX: I'm not confident that VG_(percentify) works as it should... - VG_(percentify)(x, y, 2, 6, mbuf); + VG_(percentify)((ULong)(x * 100), 10000, 2, 6, mbuf); // XXX: this is bogus if the denominator was zero -- resulting string is // something like "0 --%") if (' ' == mbuf[0]) mbuf[0] = '0'; @@ -2239,7 +2236,7 @@ static void pp_snapshot_SXPt(Int fd, SXPt* sxpt, Int depth, Char* depth_str, Char* s = ( 1 == sxpt->Insig.n_xpts ? "," : "s, all" ); FP("%sn0: %lu in %d place%s below massif's threshold (%s)\n", depth_str, sxpt->szB, sxpt->Insig.n_xpts, s, - make_perc((ULong)clo_threshold, 100)); + make_perc(clo_threshold)); break; } diff --git a/massif/tests/insig.post.exp b/massif/tests/insig.post.exp index b402eaef13..5963decfeb 100644 --- a/massif/tests/insig.post.exp +++ b/massif/tests/insig.post.exp @@ -1,6 +1,6 @@ -------------------------------------------------------------------------------- Command: ./insig -Massif arguments: --stacks=no --time-unit=B --heap-admin=128 --massif-out-file=massif.out --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element +Massif arguments: --stacks=no --time-unit=B --heap-admin=128 --massif-out-file=massif.out --threshold=0.99 --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element ms_print arguments: massif.out -------------------------------------------------------------------------------- @@ -70,7 +70,7 @@ Number of snapshots: 24 87.28% (16,688B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc. ->83.68% (16,000B) 0x........: main (insig.c:8) | -->01.34% (256B) in 16 places, all below massif's threshold (01.00%) +->01.34% (256B) in 16 places, all below massif's threshold (00.99%) | ->01.26% (240B) 0x........: main (insig.c:9) | diff --git a/massif/tests/insig.vgtest b/massif/tests/insig.vgtest index cb167dfa83..4c3807fb62 100644 --- a/massif/tests/insig.vgtest +++ b/massif/tests/insig.vgtest @@ -1,5 +1,6 @@ +# At one point, thresholds less than 1.0% were misprinted as 00.00%, so test that here. prog: insig -vgopts: --stacks=no --time-unit=B --heap-admin=128 --massif-out-file=massif.out +vgopts: --stacks=no --time-unit=B --heap-admin=128 --massif-out-file=massif.out --threshold=0.99 vgopts: --ignore-fn=__part_load_locale --ignore-fn=__time_load_locale --ignore-fn=dwarf2_unwind_dyld_add_image_hook --ignore-fn=get_or_create_key_element post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses cleanup: rm massif.out