GCOV parser

GCOV json output

Starting with gcc-14 the gcov tool can generate a zipped JSON representation of the coverage data. Only version 2 of the intermediate format is supported. The version generated by your installation can be checked with the command gcov --version.

If an unsupported version is generated gcovr is falling back to the GCOV text output.

GCOV text output

Until gcc-13 or if the json output format is unsupported the gcov text output is parsed. The behavior of this parser was informed by the following sources:

Error handling

By default the parser raises an exception on unrecognized gcov output.

There are several known issues with the files generated by gcov which can be handled by --gcov-ignore-parse-errors which are described here. If no value is given to the option the value all is used the whole gcov file is ignored if the output is not recognized.

Negative hit counts

A bug in gcov can produce negative hit values (see gcov comment_negative_hits) which are not accepted by default. This behavior can be changed by using the value --gcov-ignore-parse-errors=negative_hits.warn or --gcov-ignore-parse-errors=negative_hits.warn_once_per_file. The first form warns on every line with a negative value the second one only once per processed file and adds a summary with the overall issues in the file.

Suspicious hit counts

A bug in gcov can produce very high hit values (see gcov issue_suspicious_hits) which are not accepted by default. A suspicious value is assumed if the counter is 2^32 or greater. This behavior can be changed by using the value --gcov-ignore-parse-errors=suspicious_hits.warn or --gcov-ignore-parse-errors=suspicious_hits.warn_once_per_file. The first form warns on every line with a suspicious value the second one only once per processed file and adds a summary with the overall issues in the file.