From 48d506364ce9c4aac2aa5ec65ed78b47576bacb7 Mon Sep 17 00:00:00 2001 From: Philippe Waroquiers Date: Fri, 11 Nov 2016 14:22:34 +0000 Subject: [PATCH] Small changes in callgrind_annotate and callgrind manual * callgrind_annotate: ignore the lines giving the long names of the events: such lines are used by kcachegrind for the GUI, so are better accepted (and ignored) by callgrind_annotate * Document in callgrind_annotate manual that thresholds can be given per event kind. * Avoid a division by zero in callgrind_annotate, for 'special data' such as produced by (some) xtrees. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16125 --- callgrind/callgrind_annotate.in | 17 ++++++++++++++--- callgrind/docs/cl-manual.xml | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/callgrind/callgrind_annotate.in b/callgrind/callgrind_annotate.in index 82f6f052db..2588fce92a 100644 --- a/callgrind/callgrind_annotate.in +++ b/callgrind/callgrind_annotate.in @@ -429,6 +429,9 @@ sub read_input_file() $has_line = ($positions =~ /line/); $has_addr = ($positions =~ /(addr|instr)/); } + elsif (/^event:\s+.*$/) { + # ignore lines giving a long name to an event + } elsif (/^events:\s+(.*)$/) { $events = $1; @@ -1216,9 +1219,17 @@ sub annotate_ann_files($) if ($did_annotations) { my $percent_printed_CC; foreach (my $i = 0; $i < @$summary_CC; $i++) { - $percent_printed_CC->[$i] = - sprintf("%.0f", - $printed_totals_CC->[$i] / $summary_CC->[$i] * 100); + # Some files (in particular the files produced by --xtree-memory) + # have non additive self costs, so have a special case for these + # to print all functions and also to avoid a division by 0. + if ($summary_CC->[$i] == 0 + || $printed_totals_CC->[$i] > $summary_CC->[$i]) { + $percent_printed_CC->[$i] = "100"; + } else { + $percent_printed_CC->[$i] = + sprintf("%.0f", + $printed_totals_CC->[$i] / $summary_CC->[$i] * 100); + } } my $pp_CC_col_widths = compute_CC_col_widths($percent_printed_CC); print($fancy); diff --git a/callgrind/docs/cl-manual.xml b/callgrind/docs/cl-manual.xml index 508094e004..b5841aa056 100644 --- a/callgrind/docs/cl-manual.xml +++ b/callgrind/docs/cl-manual.xml @@ -1257,6 +1257,8 @@ their arguments. Sort columns by events A,B,C [event column order]. + Optionally, each event is followed by a : and a threshold, + to specify different thresholds depending on the event. -- 2.47.2