gcov - display basic block profile / coverage data
gcov [-bflnv] [-o dir] source.c
The C compiler gcc(1) supports the command line options -fprofile-arcs
and -ftest-coverage. These options cause the compiler to insert instrumentation
into the object files it generates which measure how often each
basic block is executed; in addition, when compiling a file named (for
instance) source.c, in addition to generating the object file source.o,
the compiler also generates source.bb and source.bbg; these files
describe the control flow graph of the program.
When executed, the program will update execution counts for each basic
block in a file named source.da. This file will be created if it doesn't
exist. If the program is run multiple times, the execution counts will
reflect all runs of the program since the file was first created. The
gcov(1) program can then be used to display the collected data in humanreadable
form. When the command
gcov source.c
is run, a copy of the source file with execution counts prepended to each
line is created in source.c.gcov, and some summary statistics are printed
to standard output.
The following options are available:
-b Include information about branch frequencies in the output file
and on standard output.
-f Output function-level summaries in addition to a summary for the
whole source file.
-l Create longer unambiguous names when executable code in the
object comes from an included header file rather than the main
file. If, for example, source.c includes one or more header
files header.h which include instrumented code, the report for
this code will be put in source.c.header.h.gcov instead of the
default header.h.gcov.
-n Do not create output files (but still display summaries to standard
output).
-v Display the version number of gcov(1)
-o dir Find .bb, .bbg, and .da files in the directory dir.
gcc(1), gprof(1)
The `gcc' entry in info(1)
gcov appeared in NetBSD 1.4.
BSD March 13, 1999 BSD
[ Back ] |