|
From: <sv...@va...> - 2005-12-21 19:45:39
|
Author: njn
Date: 2005-12-21 19:45:29 +0000 (Wed, 21 Dec 2005)
New Revision: 5396
Log:
Fixed cg_annotate bug -- when using the --sort option the primary thresho=
ld
was set to zero and so no annotation was done. =20
Also put the file format into this file, and some other tiny changes.
Modified:
trunk/cachegrind/cg_annotate.in
Modified: trunk/cachegrind/cg_annotate.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/cachegrind/cg_annotate.in 2005-12-21 01:29:37 UTC (rev 5395)
+++ trunk/cachegrind/cg_annotate.in 2005-12-21 19:45:29 UTC (rev 5396)
@@ -1,9 +1,7 @@
-#! @PERL@ -w
+#! @PERL@
=20
##--------------------------------------------------------------------##
-##--- The cache simulation framework: instrumentation, recording ---##
-##--- and results printing. ---##
-##--- cg_annotate.in ---##
+##--- Cachegrind's annotator. cg_annotate.in ---##
##--------------------------------------------------------------------##
=20
# This file is part of Cachegrind, a Valgrind tool for cache
@@ -30,10 +28,53 @@
# The GNU General Public License is contained in the file COPYING.
=20
#-----------------------------------------------------------------------=
-----
-# Annotator for cachegrind.=20
-#
-# File format is described in /docs/techdocs.html.
-#
+# The file format is simple, basically printing the cost centre for ever=
y
+# source line, grouped by files and functions:
+#=20
+# file ::=3D desc_line* cmd_line events_line data_line+ summar=
y_line
+# desc_line ::=3D "desc:" ws? non_nl_string
+# cmd_line ::=3D "cmd:" ws? cmd
+# events_line ::=3D "events:" ws? (event ws)+
+# data_line ::=3D file_line | fn_line | count_line
+# file_line ::=3D ("fl=3D" | "fi=3D" | "fe=3D") filename
+# fn_line ::=3D "fn=3D" fn_name
+# count_line ::=3D line_num ws? (count ws)+
+# summary_line ::=3D "summary:" ws? (count ws)+
+# count ::=3D num | "."
+#=20
+# where
+# 'non_nl_string' is any string not containing a newline.
+# 'cmd' is a string holding the command line of the profiled program.
+# 'filename' and 'fn_name' are strings.
+# 'num' and 'line_num' are decimal integers.
+# 'ws' is whitespace.
+#=20
+# The contents of the "desc:" lines are printed out at the top
+# of the summary. This is a generic way of providing simulation
+# specific information, eg. for giving the cache configuration for
+# cache simulation.
+#=20
+# Counts can be "." to represent "N/A", eg. the number of write misses f=
or an
+# instruction that doesn't write to memory.
+#=20
+# The number of counts in each 'line' and the 'summary_line' should not =
exceed
+# the number of events in the 'event_line'. If the number in each 'line=
' is
+# less, cg_annotate treats those missing as though they were a "." entry=
.
+#=20
+# A 'file_line' changes the current file name. A 'fn_line' changes the
+# current function name. A 'count_line' contains counts that pertain to=
the
+# current filename/fn_name. A 'file_line' and a 'fn_line' must appear
+# before any 'count_line's to give the context of the first 'count_line'=
.
+#=20
+# Each 'file_line' should be immediately followed by a 'fn_line'. "fi=3D=
"
+# 'file_lines' are used to switch filenames for inlined functions; "fe=3D=
"
+# 'file_lines' are similar, but are put at the end of a basic block in w=
hich
+# the file name hasn't been switched back to the original file name. (f=
i
+# and fe lines behave the same, they are only distinguished to help
+# debugging.) [Nb: "fi=3D" and "fe=3D" have not been produced by Cacheg=
rind for
+# some time, they are no longer necessary.]
+
+#-----------------------------------------------------------------------=
-----
# Performance improvements record, using cachegrind.out for cacheprof, d=
oing no
# source annotation (irrelevant ones removed):
# user tim=
e
@@ -57,6 +98,7 @@
#16. Finding count lengths by int((length-1)/3), not by
# commifying (halves the number of commify calls) 1.68s --=
> 1.47s
=20
+use warnings;
use strict;
=20
#-----------------------------------------------------------------------=
-----
@@ -187,19 +229,26 @@
@show_events =3D split(/,/, $1);
=20
# --sort=3DA,B,C
+ # Nb: You can specify thresholds individually, eg.
+ # --sort=3DA:99,B:95,C:90. These will override any --thre=
shold
+ # argument.
} elsif ($arg =3D~ /^--sort=3D(.*)$/) {
@sort_events =3D split(/,/, $1);
+ my $th_specified =3D 0;
foreach my $i (0 .. scalar @sort_events - 1) {
- if ($sort_events[$i] =3D~#/.*:(\d+)$/) {
- /.*:([\d\.]+)%?$/) {
+ if ($sort_events[$i] =3D~ /.*:([\d\.]+)%?$/) {
my $th =3D $1;
($th >=3D 0 && $th <=3D 100) or die($usage);
$sort_events[$i] =3D~ s/:.*//;
$thresholds[$i] =3D $th;
+ $th_specified =3D 1;
} else {
$thresholds[$i] =3D 0;
}
}
+ if (not $th_specified) {
+ @thresholds =3D ();
+ }
=20
# --threshold=3DX (tolerates a trailing '%')
} elsif ($arg =3D~ /^--threshold=3D([\d\.]+)%?$/) {
|