This file is indexed.

/usr/bin/verilator_coverage is in verilator 3.874-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#!/usr/bin/perl -w
######################################################################
#
# Copyright 2003-2015 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
######################################################################

require 5.006_001;
use warnings;
BEGIN {
    if ($ENV{DIRPROJECT} && $ENV{DIRPROJECT_PERL_BOOT}) {
	# Magic to allow author testing of perl packages in local directory
	require $ENV{DIRPROJECT}."/".$ENV{DIRPROJECT_PERL_BOOT};
    }
}

use Getopt::Long;
use FindBin qw($RealBin $RealScript);
use IO::File;
use Pod::Usage;
use Cwd qw(abs_path getcwd);

use strict;
use vars qw ($Debug @Opt_Verilator_Sw);

#######################################################################
#######################################################################
# main

autoflush STDOUT 1;
autoflush STDERR 1;

$Debug = 0;

# No arguments can't do anything useful.  Give help
if ($#ARGV < 0) {
    pod2usage(-exitstatus=>2, -verbose=>0);
}

# We sneak a look at the flags so we can do some pre-environment checks
# All flags will hit verilator...
foreach my $sw (@ARGV) {
    $sw = "'$sw'" if $sw =~ m![^---a-zA-Z0-9_/\\:.+]!;
    push @Opt_Verilator_Sw, $sw;
}

Getopt::Long::config ("no_auto_abbrev","pass_through");
if (! GetOptions (
	  # Major operating modes
	  "help"	=> \&usage,
	  "debug:s"	=> \&debug,
	  # "version!"	=> \&version,	# Also passthru'ed
	  # Additional parameters
	  "<>"		=> sub {},	# Ignored
    )) {
    pod2usage(-exitstatus=>2, -verbose=>0);
}

# Normal, non gdb
run (verilator_coverage_bin()
     ." ".join(' ',@Opt_Verilator_Sw));

#----------------------------------------------------------------------

sub usage {
    pod2usage(-verbose=>2, -exitval=>2, -output=>\*STDOUT);
}

sub debug {
    shift;
    my $level = shift;
    $Debug = $level||3;
}

#######################################################################
#######################################################################
# Builds

sub verilator_coverage_bin {
    my $bin = "";
    # Use VERILATOR_ROOT if defined, else assume verilator_bin is in the search path
    my $basename = ($ENV{VERILATOR_COVERAGE_BIN}
		    || "verilator_coverage_bin_dbg");
    if (defined($ENV{VERILATOR_ROOT})) {
	my $dir = $ENV{VERILATOR_ROOT};
	if (-x "$dir/bin/$basename") {  # From a "make install" into VERILATOR_ROOT
	    $bin = "$dir/bin/$basename";
	} else {
	    $bin = "$dir/$basename";  # From pointing to kit directory
	}
    } else {
	if (-x "$RealBin/$basename") {
	    $bin = "$RealBin/$basename";  # From path/to/verilator with verilator_bin installed
	} else {
	    $bin = $basename;  # Find in PATH
	}
	# Note we don't look under bin/$basename which would be right if running
	# in the kit dir. Running that would likely break, since
	# VERILATOR_ROOT wouldn't be set and Verilator won't find internal files.
    }
    return $bin;
}

#######################################################################
#######################################################################
# Utilities

sub run {
    # Run command, check errors
    my $command = shift;
    $! = undef;  # Cleanup -x
    print "\t$command\n" if $Debug>=3;
    system($command);
    my $status = $?;
    if ($status) {
	if ($! =~ /no such file or directory/i) {
	    warn "%Error: verilator_coverage: Misinstalled, or VERILATOR_ROOT might need to be in environment\n";
	}
	if ($Debug) {  # For easy rerunning
	    warn "%Error: export VERILATOR_ROOT=".($ENV{VERILATOR_ROOT}||"")."\n";
	    warn "%Error: $command\n";
	}
	if ($status & 127) {
	    if (($status & 127) == 8 || ($status & 127) == 11) { # SIGFPA or SIGSEGV
		warn "%Error: Verilator_coverage internal fault, sorry.\n" if !$Debug;
	    } elsif (($status & 127) == 6) {  # SIGABRT
		warn "%Error: Verilator_coverage aborted.\n" if !$Debug;
	    } else {
		warn "%Error: Verilator_coverage threw signal $status.\n" if !$Debug;
	    }
	}
	die "%Error: Command Failed $command\n";
    }
}

#######################################################################
#######################################################################
package main;
__END__

=pod

=head1 NAME

verilator_coverage - Verilator coverage analyzer

=head1 SYNOPSIS

    verilator_coverage --help
    verilator_coverage --version

    verilator_coverage --annotate <obj>

    verilator_coverage  -write merged.dat -read <datafiles>...

Verilator_coverage processes Verilator coverage reports.

With --anotate, it reads the specified data file and generates annotated
source code with coverage metrics annotated.  If multiple coverage points
exist on the same line, additional lines will be inserted to report the
additional points.

Additional Verilog-standard arguments specify the search paths necessary to
find the source code that the coverage analysis was performed on.

To get correct coverage percentages, you may wish to read logs/coverage.pl
into Emacs and do a M-x keep-lines to include only those statistics of
interest.

For Verilog conditions that should never occur, you should add a $stop
statement.  This will remove the coverage during the next build.

=head1 ARGUMENTS

=over 4

=item I<filename>

Specify input data file, may be repeated to read multiple inputs.  If no
data file is specified, by default coverage.dat is read.

=item --annotate I<output_directory>

Sprcifies the directory name that source files with annotated coverage data
should be written to.

=item --annotate-all

Specifies all files should be shown.  By default, only those source files
which have low coverage are written to the output directory.

=item --annotate-min I<count>

Specifies the minimum occurrence count that should be flagged if the
coverage point does not include a specified threshold.  Defaults to 10.

=item --help

Displays this message and program version and exits.

=item --rank

Print an experimental report listing the relative importance of each test
in covering all of the coverage points.  The report shows "Covered" which
indicates the number of points that test covers; a test is considered to
cover a point if it has a bucket count of at least 1. The "rank" column has
a higher number t indicate the test is more important, and rank 0 means the
test does not need to be run to cover the points.  "RankPts" indicates the
number of coverage points this test will contribute to overall coverage if
all tests are run in the order of highest to lowest rank.

=item --unlink

When using --write to combine coverage data, unlink all input files after
the output has been created.

=item --version

Displays program version and exits.

=item --write I<filename>

Specifies the aggregate coverage results, summed across all the files,
should be written to the given filename.  This is useful in scripts to
combine many sequential runs into one master coverage file.

=back

=head1 VERILOG ARGUMENTS

The following arguments are compatible with GCC, VCS and most Verilog
programs.

=over 4

=item +libext+I<ext>+I<ext>...

Defines the extensions for Verilog files.

=item +define+I<var>+I<value>
=item -DI<var>=I<value>

Defines the given variable.

=item +incdir+I<dir>
=item -II<dir>

Specifies a directory for finding include files.

=item -f I<file>

Specifies a file containing additional command line arguments.

=item -y I<dir>

Specifies a module search directory.

=back

=head1 DISTRIBUTION

The latest version is available from L<http://www.veripool.org/>.

Copyright 2003-2015 by Wilson Snyder.  Verilator is free software; you can
redistribute it and/or modify the Verilator internals under the terms of
either the GNU Lesser General Public License Version 3 or the Perl Artistic
License Version 2.0.

=head1 AUTHORS

Wilson Snyder <wsnyder@wsnyder.org>

=head1 SEE ALSO

C<verilator>

L<verilator_coverage --help> which is the source for this document.

=cut

######################################################################