3 ##--------------------------------------------------------------------##
4 ##--- Cachegrind's annotator. cg_annotate.in ---##
5 ##--------------------------------------------------------------------##
7 # This file is part of Cachegrind, a Valgrind tool for cache
10 # Copyright (C) 2002-2005 Nicholas Nethercote
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation; either version 2 of the
16 # License, or (at your option) any later version.
18 # This program is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 # The GNU General Public License is contained in the file COPYING.
30 #----------------------------------------------------------------------------
31 # The file format is simple, basically printing the cost centre for every
32 # source line, grouped by files and functions. The details are in
33 # Cachegrind's manual.
35 #----------------------------------------------------------------------------
36 # Performance improvements record, using cachegrind.out for cacheprof, doing no
37 # source annotation (irrelevant ones removed):
39 # 1. turned off warnings in add_hash_a_to_b() 3.81 --> 3.48s
40 # [now add_array_a_to_b()]
41 # 6. make line_to_CC() return a ref instead of a hash 3.01 --> 2.77s
43 #10. changed file format to avoid file/fn name repetition 2.40s
44 # (not sure why higher; maybe due to new '.' entries?)
45 #11. changed file format to drop unnecessary end-line "."s 2.36s
46 # (shrunk file by about 37%)
47 #12. switched from hash CCs to array CCs 1.61s
48 #13. only adding b[i] to a[i] if b[i] defined (was doing it if
49 # either a[i] or b[i] was defined, but if b[i] was undefined
50 # it just added 0) 1.48s
51 #14. Stopped converting "." entries to undef and then back 1.16s
52 #15. Using foreach $i (x..y) instead of for ($i = 0...) in
53 # add_array_a_to_b() 1.11s
55 # Auto-annotating primes:
56 #16. Finding count lengths by int((length-1)/3), not by
57 # commifying (halves the number of commify calls) 1.68s --> 1.47s
62 #----------------------------------------------------------------------------
63 # Overview: the running example in the comments is for:
67 #----------------------------------------------------------------------------
69 #----------------------------------------------------------------------------
70 # Global variables, main data structures
71 #----------------------------------------------------------------------------
72 # CCs are arrays, the counts corresponding to @events, with 'undef'
73 # representing '.'. This makes things fast (faster than using hashes for CCs)
74 # but we have to use @sort_order and @show_order below to handle the --sort and
75 # --show options, which is a bit tricky.
76 #----------------------------------------------------------------------------
78 # Total counts for summary (an array reference).
81 # Totals for each function, for overall summary.
82 # hash(filename:fn_name => CC array)
85 # Individual CCs, organised by filename and line_num for easy annotation.
86 # hash(filename => hash(line_num => CC array))
89 # Files chosen for annotation on the command line.
90 # key = basename (trimmed of any directory), value = full filename
93 # Generic description string.
96 # Command line of profiled program.
99 # Events in input file, eg. (A,B,C,D)
102 # Events to show, from command line, eg. (C,A,D)
105 # Map from @show_events indices to @events indices, eg. (2,0,3). Gives the
106 # order in which we must traverse @events in order to show the @show_events,
107 # eg. (@events[$show_order[1]], @events[$show_order[2]]...) = @show_events.
108 # (Might help to think of it like a hash (0 => 2, 1 => 0, 2 => 3).)
111 # Print out the function totals sorted by these events, eg. (D,C).
114 # Map from @sort_events indices to @events indices, eg. (3,2). Same idea as
118 # Thresholds, one for each sort event (or default to 1 if no sort events
119 # specified). We print out functions and do auto-annotations until we've
120 # handled this proportion of all the events thresholded.
123 my $default_threshold = 0.1;
125 my $single_threshold = $default_threshold;
127 # If on, automatically annotates all files that are involved in getting over
128 # all the threshold counts.
129 my $auto_annotate = 0;
131 # Number of lines to show around each annotated line.
134 # Directories in which to look for annotation files.
135 my @include_dirs = ("");
138 my $input_file = undef;
141 my $version = "@VERSION@";
145 usage: cg_annotate [options] cachegrind-out-file [source-files...]
147 options for the user, with defaults in [ ], are:
148 -h --help show this message
149 --version show version
150 --show=A,B,C only show figures for events A,B,C [all]
151 --sort=A,B,C sort columns by events A,B,C [event column order]
152 --threshold=<0--20> a function is shown if it accounts for more than x% of
153 the counts of the primary sort event [$default_threshold]
154 --auto=yes|no annotate all source files containing functions
155 that helped reach the event count threshold [no]
156 --context=N print N lines of context before and after
158 -I<d> --include=<d> add <d> to list of directories to search for
161 cg_annotate is Copyright (C) 2002-2007 Nicholas Nethercote.
162 and licensed under the GNU General Public License, version 2.
163 Bug reports, feedback, admiration, abuse, etc, to: njn\@valgrind.org.
168 # Used in various places of output.
169 my $fancy = '-' x 80 . "\n";
174 return ($y == 0 ? 0 : $x / $y);
177 #-----------------------------------------------------------------------------
178 # Argument and option handling
179 #-----------------------------------------------------------------------------
180 sub process_cmd_line()
182 for my $arg (@ARGV) {
188 if ($arg =~ /^--version$/) {
189 die("cg_annotate-$version\n");
192 } elsif ($arg =~ /^--show=(.*)$/) {
193 @show_events = split(/,/, $1);
196 # Nb: You can specify thresholds individually, eg.
197 # --sort=A:99,B:95,C:90. These will override any --threshold
199 } elsif ($arg =~ /^--sort=(.*)$/) {
200 @sort_events = split(/,/, $1);
201 my $th_specified = 0;
202 foreach my $i (0 .. scalar @sort_events - 1) {
203 if ($sort_events[$i] =~ /.*:([\d\.]+)%?$/) {
205 ($th >= 0 && $th <= 100) or die($usage);
206 $sort_events[$i] =~ s/:.*//;
207 $thresholds[$i] = $th;
213 if (not $th_specified) {
217 # --threshold=X (tolerates a trailing '%')
218 } elsif ($arg =~ /^--threshold=([\d\.]+)%?$/) {
219 $single_threshold = $1;
220 ($1 >= 0 && $1 <= 20) or die($usage);
223 } elsif ($arg =~ /^--auto=yes$/) {
225 } elsif ($arg =~ /^--auto=no$/) {
229 } elsif ($arg =~ /^--context=([\d\.]+)$/) {
235 # We don't handle "-I name" -- there can be no space.
236 } elsif ($arg =~ /^-I$/) {
237 die("Sorry, no space is allowed after a -I flag\n");
239 # --include=A,B,C. Allow -I=name for backwards compatibility.
240 } elsif ($arg =~ /^(-I=|-I|--include=)(.*)$/) {
242 $inc =~ s|/$||; # trim trailing '/'
243 push(@include_dirs, "$inc/");
245 } else { # -h and --help fall under this case
249 # Argument handling -- annotation file checking and selection.
250 # Stick filenames into a hash for quick 'n easy lookup throughout.
252 if (not defined $input_file) {
253 # First non-option argument is the output file.
256 # Subsequent non-option arguments are source files.
258 foreach my $include_dir (@include_dirs) {
259 if (-r $include_dir . $arg) {
263 $readable or die("File $arg not found in any of: @include_dirs\n");
264 $user_ann_files{$arg} = 1;
269 # Must have chosen an input file
270 if (not defined $input_file) {
275 #-----------------------------------------------------------------------------
276 # Reading of input file
277 #-----------------------------------------------------------------------------
281 return ($x > $y ? $x : $y);
284 # Add the two arrays; any '.' entries are ignored. Two tricky things:
285 # 1. If $a2->[$i] is undefined, it defaults to 0 which is what we want; we turn
286 # off warnings to allow this. This makes things about 10% faster than
287 # checking for definedness ourselves.
288 # 2. We don't add an undefined count or a ".", even though it's value is 0,
289 # because we don't want to make an $a2->[$i] that is undef become 0
291 sub add_array_a_to_b ($$)
295 my $n = max(scalar @$a1, scalar @$a2);
297 foreach my $i (0 .. $n-1) {
298 $a2->[$i] += $a1->[$i] if (defined $a1->[$i] && "." ne $a1->[$i]);
303 # Add each event count to the CC array. '.' counts become undef, as do
304 # missing entries (implicitly).
307 my @CC = (split /\s+/, $_[0]);
308 (@CC <= @events) or die("Line $.: too many event counts\n");
312 sub read_input_file()
314 open(INPUTFILE, "< $input_file")
315 || die "Cannot open $input_file for reading\n";
317 # Read "desc:" lines.
319 while ($line = <INPUTFILE>) {
320 if ($line =~ s/desc:\s+//) {
327 # Read "cmd:" line (Nb: will already be in $line from "desc:" loop above).
328 ($line =~ s/^cmd:\s+//) or die("Line $.: missing command line\n");
330 chomp($cmd); # Remove newline
332 # Read "events:" line. We make a temporary hash in which the Nth event's
333 # value is N, which is useful for handling --show/--sort options below.
335 (defined $line && $line =~ s/^events:\s+//)
336 or die("Line $.: missing events line\n");
337 @events = split(/\s+/, $line);
340 foreach my $event (@events) {
341 $events{$event} = $n;
345 # If no --show arg give, default to showing all events in the file.
346 # If --show option is used, check all specified events appeared in the
347 # "events:" line. Then initialise @show_order.
349 foreach my $show_event (@show_events) {
350 (defined $events{$show_event}) or
351 die("--show event `$show_event' did not appear in input\n");
354 @show_events = @events;
356 foreach my $show_event (@show_events) {
357 push(@show_order, $events{$show_event});
360 # Do as for --show, but if no --sort arg given, default to sorting by
361 # column order (ie. first column event is primary sort key, 2nd column is
364 foreach my $sort_event (@sort_events) {
365 (defined $events{$sort_event}) or
366 die("--sort event `$sort_event' did not appear in input\n");
369 @sort_events = @events;
371 foreach my $sort_event (@sort_events) {
372 push(@sort_order, $events{$sort_event});
375 # If multiple threshold args weren't given via --sort, stick in the single
376 # threshold (either from --threshold if used, or the default otherwise) for
377 # the primary sort event, and 0% for the rest.
378 if (not @thresholds) {
379 foreach my $e (@sort_order) {
380 push(@thresholds, 100);
382 $thresholds[0] = $single_threshold;
386 my $currFileFuncName;
389 my $currFileCCs = {}; # hash(line_num => CC)
391 # Read body of input file.
392 while (<INPUTFILE>) {
393 s/#.*$//; # remove comments
394 if (s/^(-?\d+)\s+//) {
396 my $CC = line_to_CC($_);
397 defined($currFuncCC) || die;
398 add_array_a_to_b($CC, $currFuncCC);
400 # If currFileName is selected, add CC to currFileName list. We look for
401 # full filename matches; or, if auto-annotating, we have to
402 # remember everything -- we won't know until the end what's needed.
403 defined($currFileCCs) || die;
404 if ($auto_annotate || defined $user_ann_files{$currFileName}) {
405 my $currLineCC = $currFileCCs->{$lineNum};
406 if (not defined $currLineCC) {
408 $currFileCCs->{$lineNum} = $currLineCC;
410 add_array_a_to_b($CC, $currLineCC);
413 } elsif (s/^fn=(.*)$//) {
414 $currFileFuncName = "$currFileName:$1";
415 $currFuncCC = $fn_totals{$currFileFuncName};
416 if (not defined $currFuncCC) {
418 $fn_totals{$currFileFuncName} = $currFuncCC;
421 } elsif (s/^fl=(.*)$//) {
423 $currFileCCs = $allCCs{$currFileName};
424 if (not defined $currFileCCs) {
426 $allCCs{$currFileName} = $currFileCCs;
428 # Assume that a "fn=" line is followed by a "fl=" line.
429 $currFileFuncName = undef;
431 } elsif (s/^\s*$//) {
434 } elsif (s/^summary:\s+//) {
435 $summary_CC = line_to_CC($_);
436 (scalar(@$summary_CC) == @events)
437 or die("Line $.: summary event and total event mismatch\n");
440 warn("WARNING: line $. malformed, ignoring\n");
444 # Check if summary line was present
445 if (not defined $summary_CC) {
446 die("missing final summary line, aborting\n");
452 #-----------------------------------------------------------------------------
454 #-----------------------------------------------------------------------------
459 print("Command: $cmd\n");
460 print("Data file: $input_file\n");
461 print("Events recorded: @events\n");
462 print("Events shown: @show_events\n");
463 print("Event sort order: @sort_events\n");
464 print("Thresholds: @thresholds\n");
466 my @include_dirs2 = @include_dirs; # copy @include_dirs
467 shift(@include_dirs2); # remove "" entry, which is always the first
468 unshift(@include_dirs2, "") if (0 == @include_dirs2);
469 my $include_dir = shift(@include_dirs2);
470 print("Include dirs: $include_dir\n");
471 foreach my $include_dir (@include_dirs2) {
472 print(" $include_dir\n");
475 my @user_ann_files = keys %user_ann_files;
476 unshift(@user_ann_files, "") if (0 == @user_ann_files);
477 my $user_ann_file = shift(@user_ann_files);
478 print("User annotated: $user_ann_file\n");
479 foreach $user_ann_file (@user_ann_files) {
480 print(" $user_ann_file\n");
483 my $is_on = ($auto_annotate ? "on" : "off");
484 print("Auto-annotation: $is_on\n");
488 #-----------------------------------------------------------------------------
489 # Print summary and sorted function totals
490 #-----------------------------------------------------------------------------
495 # Iterate through sort events (eg. 3,2); return result if two are different
496 foreach my $i (@sort_order) {
500 $x = -1 unless defined $x;
501 $y = -1 unless defined $y;
503 my $cmp = abs($y) <=> abs($x); # reverse sort of absolute size
508 # Exhausted events, equal
514 1 while ($val =~ s/^(-?\d+)(\d{3})/$1,$2/);
518 # Because the counts can get very big, and we don't want to waste screen space
519 # and make lines too long, we compute exactly how wide each column needs to be
520 # by finding the widest entry for each one.
521 sub compute_CC_col_widths (@)
524 my $CC_col_widths = [];
526 # Initialise with minimum widths (from event names)
527 foreach my $event (@events) {
528 push(@$CC_col_widths, length($event));
531 # Find maximum width count for each column. @CC_col_width positions
532 # correspond to @CC positions.
533 foreach my $CC (@CCs) {
534 foreach my $i (0 .. scalar(@$CC)-1) {
535 if (defined $CC->[$i]) {
536 # Find length, accounting for commas that will be added
537 my $length = length $CC->[$i];
538 my $clength = $length + int(($length - 1) / 3);
539 $CC_col_widths->[$i] = max($CC_col_widths->[$i], $clength);
543 return $CC_col_widths;
546 # Print the CC with each column's size dictated by $CC_col_widths.
549 my ($CC, $CC_col_widths) = @_;
551 foreach my $i (@show_order) {
552 my $count = (defined $CC->[$i] ? commify($CC->[$i]) : ".");
553 my $space = ' ' x ($CC_col_widths->[$i] - length($count));
554 print("$space$count ");
560 my ($CC_col_widths) = @_;
562 foreach my $i (@show_order) {
563 my $event = $events[$i];
564 my $event_width = length($event);
565 my $col_width = $CC_col_widths->[$i];
566 my $space = ' ' x ($col_width - $event_width);
567 print("$space$event ");
571 # Prints summary and function totals (with separate column widths, so that
572 # function names aren't pushed over unnecessarily by huge summary figures).
573 # Also returns a hash containing all the files that are involved in getting the
574 # events count above the thresholds (ie. all the interesting ones).
575 sub print_summary_and_fn_totals ()
577 my @fn_fullnames = keys %fn_totals;
579 # Work out the size of each column for printing (summary and functions
581 my $summary_CC_col_widths = compute_CC_col_widths($summary_CC);
582 my $fn_CC_col_widths = compute_CC_col_widths(values %fn_totals);
584 # Header and counts for summary
586 print_events($summary_CC_col_widths);
589 print_CC($summary_CC, $summary_CC_col_widths);
590 print(" PROGRAM TOTALS\n");
593 # Header for functions
595 print_events($fn_CC_col_widths);
596 print(" file:function\n");
599 # Sort function names into order dictated by --sort option.
600 @fn_fullnames = sort {
601 mycmp($fn_totals{$a}, $fn_totals{$b})
606 (scalar @sort_order == scalar @thresholds) or
607 die("sort_order length != thresholds length:\n",
608 " @sort_order\n @thresholds\n");
610 my $threshold_files = {};
611 # @curr_totals has the same shape as @sort_order and @thresholds
612 my @curr_totals = ();
613 foreach my $e (@thresholds) {
614 push(@curr_totals, 0);
617 # Print functions, stopping when the threshold has been reached.
618 foreach my $fn_name (@fn_fullnames) {
620 my $fn_CC = $fn_totals{$fn_name};
622 # Stop when we've reached all the thresholds
623 my $any_thresholds_exceeded = 0;
624 foreach my $i (0 .. scalar @thresholds - 1) {
625 my $prop = safe_div(abs($fn_CC->[$sort_order[$i]] * 100),
626 abs($summary_CC->[$sort_order[$i]]));
627 $any_thresholds_exceeded ||= ($prop >= $thresholds[$i]);
629 last if not $any_thresholds_exceeded;
631 # Print function results
632 print_CC($fn_CC, $fn_CC_col_widths);
633 print(" $fn_name\n");
635 # Update the threshold counts
636 my $filename = $fn_name;
637 $filename =~ s/:.+$//; # remove function name
638 $threshold_files->{$filename} = 1;
639 foreach my $i (0 .. scalar @sort_order - 1) {
640 $curr_totals[$i] += $fn_CC->[$sort_order[$i]]
641 if (defined $fn_CC->[$sort_order[$i]]);
646 return $threshold_files;
649 #-----------------------------------------------------------------------------
650 # Annotate selected files
651 #-----------------------------------------------------------------------------
653 # Issue a warning that the source file is more recent than the input file.
654 sub warning_on_src_more_recent_than_inputfile ($)
656 my $src_file = $_[0];
659 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
660 @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@
661 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
662 @ Source file '$src_file' is more recent than input file '$input_file'.
663 @ Annotations may not be correct.
664 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
671 # If there is information about lines not in the file, issue a warning
672 # explaining possible causes.
673 sub warning_on_nonexistent_lines ($$$)
675 my ($src_more_recent_than_inputfile, $src_file, $excess_line_nums) = @_;
676 my $cause_and_solution;
678 if ($src_more_recent_than_inputfile) {
679 $cause_and_solution = <<END
680 @@ cause: '$src_file' has changed since information was gathered.
681 @@ If so, a warning will have already been issued about this.
682 @@ solution: Recompile program and rerun under "valgrind --cachesim=yes" to
683 @@ gather new information.
685 # We suppress warnings about .h files
686 } elsif ($src_file =~ /\.h$/) {
687 $cause_and_solution = <<END
688 @@ cause: bug in the Valgrind's debug info reader that screws up with .h
690 @@ solution: none, sorry
693 $cause_and_solution = <<END
694 @@ cause: not sure, sorry
699 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
700 @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@ WARNING @@
701 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
703 @@ Information recorded about lines past the end of '$src_file'.
705 @@ Probable cause and solution:
706 $cause_and_solution@@
707 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
713 sub annotate_ann_files($)
715 my ($threshold_files) = @_;
718 my @unfound_auto_annotate_files;
719 my $printed_totals_CC = [];
721 # If auto-annotating, add interesting files (but not "???")
722 if ($auto_annotate) {
723 delete $threshold_files->{"???"};
724 %all_ann_files = (%user_ann_files, %$threshold_files)
726 %all_ann_files = %user_ann_files;
729 # Track if we did any annotations.
730 my $did_annotations = 0;
733 foreach my $src_file (keys %all_ann_files) {
735 my $opened_file = "";
736 my $full_file_name = "";
737 # Nb: include_dirs already includes "", so it works in the case
738 # where the filename has the full path.
739 foreach my $include_dir (@include_dirs) {
740 my $try_name = $include_dir . $src_file;
741 if (open(INPUTFILE, "< $try_name")) {
742 $opened_file = $try_name;
743 $full_file_name = ($include_dir eq ""
745 : "$include_dir + $src_file");
750 if (not $opened_file) {
751 # Failed to open the file. If chosen on the command line, die.
752 # If arose from auto-annotation, print a little message.
753 if (defined $user_ann_files{$src_file}) {
754 die("File $src_file not opened in any of: @include_dirs\n");
757 push(@unfound_auto_annotate_files, $src_file);
761 # File header (distinguish between user- and auto-selected files).
764 (defined $user_ann_files{$src_file} ? "User" : "Auto");
765 print("-- $ann_type-annotated source: $full_file_name\n");
769 my $src_file_CCs = $allCCs{$src_file};
770 if (!defined $src_file_CCs) {
771 print(" No information has been collected for $src_file\n\n");
775 $did_annotations = 1;
777 # Numeric, not lexicographic sort!
778 my @line_nums = sort {$a <=> $b} keys %$src_file_CCs;
780 # If $src_file more recent than cachegrind.out, issue warning
781 my $src_more_recent_than_inputfile = 0;
782 if ((stat $opened_file)[9] > (stat $input_file)[9]) {
783 $src_more_recent_than_inputfile = 1;
784 warning_on_src_more_recent_than_inputfile($src_file);
787 # Work out the size of each column for printing
788 my $CC_col_widths = compute_CC_col_widths(values %$src_file_CCs);
791 print_events($CC_col_widths);
794 # Shift out 0 if it's in the line numbers (from unknown entries,
795 # likely due to bugs in Valgrind's stabs debug info reader)
796 shift(@line_nums) if (0 == $line_nums[0]);
798 # Finds interesting line ranges -- all lines with a CC, and all
799 # lines within $context lines of a line with a CC.
802 for (my $i = 0; $i < $n; $i++) {
803 push(@pairs, $line_nums[$i] - $context); # lower marker
805 $line_nums[$i] + 2*$context >= $line_nums[$i+1]) {
808 push(@pairs, $line_nums[$i] + $context); # upper marker
811 # Annotate chosen lines, tracking total counts of lines printed
812 $pairs[0] = 1 if ($pairs[0] < 1);
814 my $low = shift @pairs;
815 my $high = shift @pairs;
816 while ($. < $low-1) {
817 my $tmp = <INPUTFILE>;
818 last unless (defined $tmp); # hack to detect EOF
821 # Print line number, unless start of file
822 print("-- line $low " . '-' x 40 . "\n") if ($low != 1);
823 while (($. < $high) && ($src_line = <INPUTFILE>)) {
824 if (defined $line_nums[0] && $. == $line_nums[0]) {
825 print_CC($src_file_CCs->{$.}, $CC_col_widths);
826 add_array_a_to_b($src_file_CCs->{$.},
831 print_CC( [], $CC_col_widths);
836 # Print line number, unless EOF
838 print("-- line $high " . '-' x 40 . "\n");
844 # If there was info on lines past the end of the file...
846 foreach my $line_num (@line_nums) {
847 print_CC($src_file_CCs->{$line_num}, $CC_col_widths);
848 print(" <bogus line $line_num>\n");
851 warning_on_nonexistent_lines($src_more_recent_than_inputfile,
852 $src_file, \@line_nums);
856 # Print summary of counts attributed to file but not to any
857 # particular line (due to incomplete debug info).
858 if ($src_file_CCs->{0}) {
859 print_CC($src_file_CCs->{0}, $CC_col_widths);
860 print(" <counts for unidentified lines in $src_file>\n\n");
867 # Print list of unfound auto-annotate selected files.
868 if (@unfound_auto_annotate_files) {
870 print("The following files chosen for auto-annotation could not be found:\n");
872 foreach my $f (@unfound_auto_annotate_files) {
878 # If we did any annotating, print what proportion of events were covered by
879 # annotated lines above.
880 if ($did_annotations) {
881 my $percent_printed_CC;
882 foreach (my $i = 0; $i < @$summary_CC; $i++) {
883 $percent_printed_CC->[$i] =
885 100 * safe_div(abs($printed_totals_CC->[$i]),
886 abs($summary_CC->[$i])));
888 my $pp_CC_col_widths = compute_CC_col_widths($percent_printed_CC);
890 print_events($pp_CC_col_widths);
893 print_CC($percent_printed_CC, $pp_CC_col_widths);
894 print(" percentage of events annotated\n\n");
898 #----------------------------------------------------------------------------
900 #----------------------------------------------------------------------------
904 my $threshold_files = print_summary_and_fn_totals();
905 annotate_ann_files($threshold_files);
907 ##--------------------------------------------------------------------##
908 ##--- end cg_annotate.in ---##
909 ##--------------------------------------------------------------------##