tcov(1)
NAME
tcov − construct test coverage analysis and statement-by-statement profile
SYNOPSIS
tcov sourcefile [ −a ] [-n]
DESCRIPTION
tcov produces a test coverage analysis and statement-by-statement profile of a C or other language program. When a program is compiled with the −xa option of the C compiler, or −a of another compiler, a corresponding file.d file is created. Each time the program is executed, test coverage information is accumulated in file.d.
tcov takes source files as arguments. It reads the corresponding file.d file and produces an annotated listing of the program with coverage data in file.tcov. Each straight-line segment of code (or each line if the −a option to tcov is specified) is prefixed with the number of times it has been executed; lines which have not been executed are prefixed with #####.
Note: the profile produced includes only the number of times each statement was executed, not execution times; to obtain times for routines use gprof(1) or prof(1).
OPTIONS
−a Display an execution count for each statement; if −a is not specified, an execution count is displayed only for the first statement of each straight-line segment of code.
−n Display table of the line numbers of the n most frequently executed statements and their execution counts.
EXAMPLES
The command:
example% cc -xa -o prog prog.c (Solaris 2.x)
compiles with the -xa option and produces a prog.d file in addition to the executable prog.
The command:
example% prog
executes the program prog and accumulates data in prog.d.
The command:
example% tcov prog.c
produces an annotated listing in file prog.tcov.
ENVIRONMENT
TCOVDIR
file.d and file.tcov are created in the directory specified by the TCOVDIR environment variable; if TCOVDIR has not been set, tcov creates the .tcov file in the current directory.
FILES
$TCOVDIR/file.d input test coverage data file
$TCOVDIR/file.tcov
output test coverage analysis listing file
bb_link.o entry and exit routines for test coverage analysis
SEE ALSO
acc(1) (Solaris 1.x) cc(1), (Solaris 2.x only), gprof(1), prof(1), exit(2)
DIAGNOSTICS
premature end of file
Issued for routines containing no statements.
NOTES
The count of basic blocks cannot exceed the value represented by an unsigned int.
tcov does not support files which contain #line or #file directives.
BUGS
The analyzed program must call exit(2) or return normally for the coverage information to be saved in the .d file.
SunOS 3.0.1 — Last change: 30 June 1994