Lably
Skip to content

Gcov

Software coverage tool

  • 8 min read
  • 4 chapters

Related on Lably

Through Computer program, Graphical user interface and HTML

The gcov utility gives information on how often a program executes segments of code. It produces a copy of the source file, annotated with execution frequencies. The gcov utility does not produce any time-based data and works only on code compiled with the GCC suite. The manual claims that it is not compatible with any other profiling or test coverage mechanism, but it works with LLVM-generated files too.

Description

gcov produces a test coverage analysis of a specially instrumented program. The options -fprofile-arcs -ftest-coverage should be used to compile the program for coverage analysis (first option to record branch statistics and second to save line execution count); -fprofile-arcs should also be used to link the program. After running such program will create several files with ".bb" ".bbg" and ".da" extensions (suffixes), which can be analysed by gcov. It takes source files as command-line arguments and produces an annotated source listing. Each line of source code is prefixed with the number of times it has been executed; lines that have not been executed are prefixed with "#####".

gcov creates a logfile called sourcefile.gcov which indicates how many times each line of a source file sourcefile.c has executed. This annotated source file can be used with gprof, another profiling tool, to extract timing information about the program.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and communication

Source and licence. Adapted from the Wikipedia article “Gcov” (this version, 2026-05-01) by its contributors, shared under CC BY-SA 4.0. Lablypedia has left out its tables, references and most pictures, and linked it to other Lablypedia articles.