]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Small changes in callgrind_annotate and callgrind manual
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Fri, 11 Nov 2016 14:22:34 +0000 (14:22 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Fri, 11 Nov 2016 14:22:34 +0000 (14:22 +0000)
* 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
callgrind/docs/cl-manual.xml

index 82f6f052dbbdd23ffa80d36c49b1608a169c1700..2588fce92a133baf87e583a2223195f8dfac8ba8 100644 (file)
@@ -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);
index 508094e004593b069030a2a67f168db6a5376df2..b5841aa0567c90a8f742ccbbb4e8de9a0c72adaf 100644 (file)
@@ -1257,6 +1257,8 @@ their arguments.</para>
     </term>
     <listitem>
       <para>Sort columns by events A,B,C [event column order].</para>
+      <para>Optionally, each event is followed by a : and a threshold,
+        to specify different thresholds depending on the event.</para>
     </listitem>
   </varlistentry>