Gather code coverage data (GNU)


gcov_variant [options] sourcefile

Runs on:



The gcov_variant depends on the target platform, as follows:

Target platform: gcov_variant:
ARM ntoarm-gcov
MIPS ntomips-gcov
PowerPC ntoppc-gcov
SH4 ntosh-gcov
x86 ntox86-gcov
-b or --branch-probabilities
Write branch frequencies to the output file and branch summary info to standard output. This lets you see how often each branch was taken.
-c or --branch-counts
Write branch frequencies as the number of branches taken instead of the percentage of branches taken.
-f or --function-summaries
Output summaries for each function in addition to the file level summary.
-h or --help
Display gcov command-line options and exit.
-l or --long-file-names
Create long file names for included source files.

For example, if x.h was included in a.c, then running gcov -l on a.c will produce a.c##x.h.gcov instead of x.h.gcov. This can be useful if x.h is included in multiple source files.

-n or --no-output
Don't create the output file.
-o directory|file or --object-directory directory, --object-file file
Specify the directory containing the gcov data files or the object path name.

The gcov utility searches for the .bb, .bbg, and .da data files using this option. If a directory is specified, the data files are in that directory and named after the source file name without its extension. If a file is specified, the data files are named after that file without its extension. If this option isn't specified, it defaults to the current directory.

-p or --preserve-paths
Preserve complete path information in the names of generated .gcov files.

Without -p only the filename component is used. With -p, all directories are used, with / characters translated to # characters, . directory components removed and .. components renamed to ^. This is useful if source files are in several different directories.

The -p option also affects the -l option.

-v or --version
Display the gcov version number on the standard output and exit.


The gcov utility produces code coverage data for an application compiled with the -Wc,-fprofile-argcs -Wc,-ftest-coverage options to qcc (or the -fprofile-arcs -ftest-coverage options to gcc). This data is interpreted visually for you by the Code Coverage perspective in the QNX Momentics IDE.

For detailed documentation about gcov, see the gcc documentation on the GNU website at http://www.gnu.org/.

Exit status:

not 0
An error occurred.

Contributing author:


See also:

gcc, qcc