genhtml - Man Page

Generate HTML view from LCOV coverage data files

Synopsis

genhtml [-h|--help] [--version]

[-q|--quiet] [-v|--verbose] [--debug]
[-s|--show-details]
[-f|--frames]
[-b|--baseline-file] baseline-file
[-o|--output-directory output-directory]
[--header-title banner]
[--footer string]
[-t|--title title]
[-d|--description-file description-file]
[-k|--keep-descriptions] [-c|--css-file css-file]
[-p|--prefix prefix] [--no-prefix]
[--source-directory dirname]
[--no-source] [--num-spaces num] [--highlight]
[--legend] [--html-prolog prolog-file]
[--html-epilog epilog-file] [--html-extension extension]
[--html-gzip] [--sort] [--no-sort]
[--function-coverage] [--no-function-coverage]
[--branch-coverage] [--no-branch-coverage]
[--demangle-cpp [param]]
[--ignore-errors errors]
[--keep-going] [--config-file config-file] [--rc keyword=value]
[--precision num] [--missed]
[--suppress-aliases]
[--forget-test-names]
[--dark-mode]
[--baseline-file baseline-file]
[--baseline-title title]
[--baseline-date date]
[--current-date date]
[--diff-file diff-file]
[--annotate-script script]
[--criteria-script script]
[--version-script script]
[--checksum]
[--new-files-as-baseline]
[--elide-path-mismatch]
[--synthesize-missing]
[--date-bins day[,day,...]]
[--show-owners [all]]
[--show-noncode]
[--show-zero-columns]
[--show-navigation]
[--show-proportions]
[--simplified-colors]
[--hierarchical] [--flat]
[--filter filters]
[--include glob_pattern]
[--exclude glob_pattern]
[--erase-functions regexp_pattern]
[--substitute regexp_pattern]
[--omit-lines regexp_pattern]
[--parallel|-j [integer]]
[--memory integer_num_Mb]
[--tempdir dirname]
[--preserve]
[--save]
tracefile(s)

Description

genhtml creates an HTML view of coverage data tracefiles generated by the geninfo and lcov tools. Features include:

The basic concepts of differential coverage and date/owner binning are described in the paper found at https://arxiv.org/abs/2008.07947

Differential coverage

Differential coverage compares two versions of source code - the baseline and the current versions - and the coverage results for each to segment the code into categories.

To create a differential coverage report, genhtml requires

  1. a baseline-file specified via --baseline-file, and
  2. a patch file in unified format specified using --diff-file.

Note that while tracefile may be a list of filenames, baseline-file must be a single consolidated file.

The difference in coverage between tracefile and baseline-file is classified line-by-line into categories based on changes in 2 aspects:

  1. Test coverage results: a line of code can be tested (1), untested (0), or unused (#). An unused line is a source code line that has no associated coverage data, for example due to a disabled #ifdef statement.
  2. Source code changes: a line can be unchanged, added (+ =>), or removed (=> -). Note that the diff-file format used by genhtml reports changes in lines as removal of old line and addition of new line.

Below are the resulting 12 categories, sorted by priority (assuming that untested code is more interesting than tested code, and new code is more interesting than old code):

UNC

Uncovered New Code (+ => 0): newly added code is not tested.

LBC

Lost Baseline Coverage (1 => 0): unchanged code is no longer tested.

UIC

Uncovered Included Code (# => 0): previously unused code is untested.

UBC

Uncovered Baseline Code (0 => 0): unchanged code was untested before, is untested now.

GBC

Gained Baseline Coverage (0 => 1): unchanged code is tested now.

GIC

Gained Included Coverage (# => 1): previously unused code is tested now.

GNC

Gained New Coverage (+ => 1): newly added code is tested.

CBC

Covered Baseline Code (1 => 1): unchanged code was tested before and is still tested.

EUB

Excluded Uncovered Baseline (0 => #): previously untested code is unused now.

ECB

Excluded Covered Baseline (1 => #): previously tested code is unused now.

DUB

Deleted Uncovered Baseline (0 => -): previously untested code has been deleted.

Note: Because these lines are not represented in the current source version, they are only represented in the classification summary table.

DCB

Deleted Covered Baseline (1 => -): previously tested code has been deleted.

Note: Because these lines are not represented in the current source version, they are only represented in the classification summary table.

The differential coverage report colorizes categorized regions in the source code view using unique colors for each.  You can use the --simplified-colors option to instead use one color for 'covered' code and another for 'uncovered'.

Date and owner binning

Date binning annotates coverage reports with age-of-last-change information to distinguish recently added or modified code which has not been tested from older, presumed stable code which is also not tested. Owner binning adds annotation identifying the author of changes.

Both age and ownership reporting can be used to enhance team efforts to maintain good coverage discipline by spotlighting coverage shortfalls in recently modified code, even in the absence of baseline coverage data.

To enable date and owner binning, the --annotate-script option must be used to specify a script that provides source code line age and ownership information.

For each source line, age is the interval since the most recent modification date and the owner is the user identity responsible for the most recent change to that line.

Line coverage overall totals and counts for each of the 12 classification categories are collected for each of the specified age ranges (see the --date-bins option, below).

Script conventions

Some genhtml options expect the name of an external script or tool as argument. These scripts are then run as part of the associated function. This includes the following options:

While each script performs a separate function there are some common aspects in the way these options are handled:

1.

If an option is specified only once, the argument specifies the full command line that genhtml passes to a shell interpreter to run the script. This includes the script path followed by optional additional parameters separated by spaces. Care must be taken to provide proper quoting if script path or any parameter contains spaces or shell special characters.

2.

If an option is specified multiple times, the first invocation specifies the script path and any further invocation specifies one additional parameter. In this case, genhtml takes care of quoting of spaces contained in script location and additional parameters.

3.

genhtml passes any additional parameters specified via option arguments between the script path and the parameters required by the script's function.

Example:

genhtml --annotate-script /bin/script.sh
       --annotate-script "full"

results in genhtml executing the following command line:

/bin/script.sh "full" source_file_name

Note that multiple instances of each script may execute simultaneously if the --parallel option was specified. Therefore each script must either be reentrant or should arrange for its own synchronization, if necessary.

Additional considerations

If the --criteria-script option is used, genhtml will use the referenced script to determine whether your coverage criteria have been met - and will return a non-zero status and print a message if the criteria are not met.

The --version-script option is used to verify that the same/compatible source code versions are displayed as were used to capture coverage data.

HTML output files are created in the current working directory unless the --output-directory option is used. If tracefile or baseline-file ends with ".gz", it is assumed to be GZIP-compressed and the gunzip tool will be used to decompress it transparently.

Note that all source code files have to be present and readable at the exact file system location they were compiled, and all path references in the input data ".info" and "diff" files must match exactly (i.e., exact string match).

Further, the --version-script, --annotate-script, and --criteria-script scripts use the same path strings. However, see the --substitute option for a mechanism to adjust extracted paths so they match your source and/or revision control layout.

Use option --diff-file to supply a unified diff file that represents the changes to the source code files between the version used to compile and capture the baseline trace files, and the version used to compile and capture the current trace files.

Use option --css-file to modify layout and colors of the generated HTML output. Files are marked in different colors depending on the associated coverage rate.

By default, the coverage limits for low, medium and high coverage are set to 0-75%, 75-90% and 90-100% percent respectively. To change these values, use configuration file options.

genhtml_hi_limit and genhtml_med_limit

or type-specific limits:

genhtml_line_hi_limit and genhtml_line_med_limit
genhtml_branch_hi_limit and genhtml_branch_med_limit
genhtml_function_hi_limit and genhtml_function_med_limit

See the lcovrc man page for details.

Also note that when displaying percentages, 0% and 100% are only printed when the values are exactly 0% and 100% respectively. Other values which would conventionally be rounded to 0% or 100% are instead printed as nearest non-boundary value. This behavior is in accordance with that of the gcov(1) tool.

Options

-h
--help

Print a short help text, then exit.

--version

Print version number, then exit.

-v
--verbose

Increment informational message verbosity.  This is mainly used for script and/or flow debugging - e.g., to figure out which data files are found, where. Also see the --quiet flag.

-q
--quiet

Decrement informational message verbosity.

Decreased verbosity will suppress 'progress' messages for example - while error and warning messages will continue to be printed.

--debug

Increment 'debug messages' verbosity.  This is useful primarily to developers who want to enhance the lcov tool suite.

--flat
--hierarchical

Use the specified HTML report hierarchy layout.

The default HTML report is 3 levels:

1. top-level: table of all directories,

2. directory: table of source files in a directory, and

3. source file detail: annotated source code.

Option --hierarchical produces a multilevel report which follows the directory structure of the source code (similar to the file tool in Microsoft Windows).

Option --flat produces a two-level HTML report:

1. top-level: table of all project source files, and

2. source file detail: annotated source code.

Only one of options --flat and --hierarchical can be specified at the same time.

These options can also be persistently set via the lcovrc configuration file using either:

genhtml_hierarchical = 1

or

genhtml_flat_view = 1

See the lcovrc man page for details.

-f
--frames

Use HTML frames for source code view.

If enabled, a frameset is created for each source code file, providing an overview of the source code as a "clickable" image. Note that this option will slow down output creation noticeably because each source code character has to be inspected once. Note also that the GD.pm Perl module has to be installed for this option to work (it may be obtained from http://www.cpan.org).

-s
--show-details

Generate detailed directory view.

When this option is enabled, genhtml generates two versions of each file view. One containing the standard information plus a link to a "detailed" version. The latter additionally contains information about which test case covered how many lines of each source file.

-b baseline-file
--baseline-file baseline-file

Use data in baseline-file as coverage baseline.

The coverage data file specified by baseline-file is read and used as the baseline for classifying the change in coverage represented by the coverage counts in tracefile.

In general, you should specify a diff file in unified diff format via --diff-file when you specify a --baseline-file. Without a diff file, genhtml will assume that there are no source differences between 'baseline' and 'current'.  (For example:  this might be used to find incremental changes caused by the addition of more testcases, or to compare coverage results between gcc versions, or between gcc and llvm.)

--baseline-title title

Use title as the descriptive label text for the source of coverage baseline data.

--baseline-date date

Use date as the collection date in text format for the coverage baseline data. If this argument is not specified, the default is to use the creation time of the baseline-file as the baseline date.

--current-date date

Use date as the collection date in text format for the coverage baseline data. If this argument is not specified, the default is to use the creation time of the current tracefile.

--diff-file diff-file

Use the diff-file as the definition for source file changes between the sample points for baseline-file and tracefile(s).

A suitable diff-file can be generated using the command:

git diff --relative <SHA_base> <SHA_current>

or using the "p4udiff" or "gitdiff" sample scripts that are provided as part of this package in the following locations:

/usr/share/lcov/support-scripts/p4udiff

and

/usr/share/lcov/support-scripts/gitdiff

p4udiff accepts either a changelist ID or the literal string "sandbox"; "sandbox" indicates that there are modified files which have not been checked in.

These scripts post-process the 'p4' or 'git' output to (optionally) remove files that are not of interest and to explicitly note files which have not changed.  It is useful to note unchanged files denoted by lines of the form:

diff [optional header strings]
=== file_path

in the p4diff/gitdiff output as this knowledge will help to suppress spurious 'path mismatch' warnings.  See the --elide-path-mismatch option, below.

Note that you must specify --baseline-file when you specify --diff-file. Both are needed for differential coverage categorization.

Conversely, if you specify a --baseline-file without a --diff-file, then genhtml will assume that there are no source code changes:  source text is identical between 'baseline' and 'current'.

--annotate-script script

Use script to get source code annotation data.

Use this option to specify an external tool or command line that genhtml can use to obtain source code annotation data such as age and author of the last change for each source code line.

This option also instructs genhtml to add a summary table to the HTML report header that shows counts in the various coverage categories, associated with each date bin. In addition, each source code line will show age and owner information.

The specified script is expected to obtain age and ownership information for each source code line from the revision management system and to output this information in the format described below.

If the annotate script fails and annotation errors are ignored via --ignore-errors, then genhtml will try to load the source file normally.  If the file is not present or not readable, and the --synthesize-missing flag is specified, then genhtml will synthesize fake data for the file.

Sample annotation scripts for Perforce ("p4annotate") and git ("gitblame") are provided as part of this package in the following locations:

/usr/share/lcov/support-scripts/p4annotate

and

/usr/share/lcov/support-scripts/gitblame

Note that these scripts generate annotations from the file version checked in to the repository - not the locally modified file in the build directory.  If you need annotations for locally modified files, you can shelve your changes in P4, or check them in to a local branch in git.

Creating your own script

When creating your own script, please first see Script considerations above for general calling conventions and script requirements.

script is called by genhtml with the following command line:

script [additional_parameters]  source_file_name

where

script

is the script executable

additional_parameters

includes any optional parameters specified (see Script conventions above)

source_file_name

is the source code file name

The script executable should output a line to the standard output stream in the following format for each line in file source_file_name:

commit_id|author_id|date|source_code

where

commit_id

is an ID identifying the last change to the line

author_id

identifies the author of the last change

date

is the data of last change in W3CDTF format (<YYYY>-<MM>-<DD>T<hh>:<mm>:<ss><TZD>)

source_code

is the line's source code

The script should return 0 (zero) if processing was successful and non-zero if it encountered an error.

--criteria-script script

Use script to test for coverage acceptance criteria.

Use this option to specify an external tool or command line that genhtml can use to determine if coverage results meet custom acceptance criteria. Criteria checking results are shown in the standard output log of genhtml. If at least one check fails, genhtml will exit with a non-zero exit code after completing its processing.

A sample coverage criteria script is provided as part of this package in the following location:

/usr/share/lcov/support-scripts/criteria

The sample script checks that top-level line coverage meets the criteria "UNC + LBC + UIC == 0" (added code and newly activated code must be tested, and existing tested code must not become untested).

As another example, it is possible to create scripts that mimic the lcov --fail-under-lines feature by checking that the ratio of exercised lines to total lines ("(GNC + GIC + CBC) / (GNC + GIC + CBC + UNC + UIC + UBC)") is greater than the threshold - either only at the top level, in every directory, or wherever desired. Similarly, criteria may include branch and function coverage metrics.

By default the criteria script is called for all source code hierarchy levels, i.e.: top-level, directory, and file-level. The criteria_callback_levels configuration file option can be used to limit the hierarchy levels to any combination of 'top', 'directory', or 'file' levels.

Example:

genhtml --rc criteria_callback_levels=directory,top ...

You can increase the amount of data passed to the criteria script using configuration file option criteria_callback_data. By default, only total counts are included. Specifying "date" adds per date-bin counts, "owner" adds per owner-bin counts.

Example:

genhtml --rc criteria_callback_data=date,owner ...

See the lcovrc man page for more details.

Creating your own script

When creating your own script, please first see Script considerations above for general calling conventions and script requirements.

script is run with the following command line for each source code file, leaf-directory, and top-level coverage results:

script [additional_parameters]  name   type json_data

where

script

is the script executable

additional_parameters

includes any optional parameters specified (see Script conventions above)

name

is the name of the object for which coverage criteria should be checked, that is either the source code file name, directory name, or "top" if the script is called for top-level data

type

is the type of source code object for which coverage criteria should be checked, that is one of "file", "directory", or "top"

json_data

is a JSON representation of coverage data for the corresponding source code object

The JSON data format is defined as follows:

{
 "<type>": {
   "found": <count>,
   "hit": <count>,
   "<category>": <count>,
   ...
 },
 "<bin_type>": {
   "<bin_id>" : {
     "found": <count>,
     "hit": <count>,
     "<category>": <count>,
     ...
   },
   ...
 },
 ...
}

where

type

specifies the type of coverage as one of "line", "function", or "branch"

bin_type

specifies the type of per-bin coverage as one of "line_age", "function_age", or "branch_age" for date-bin data, and "line_owners" or "branch_owners" for owner-bin data

bin_id

specifies the date-bin index for date-bin data, and owner ID for owner-bin data.

found

defines the number of found lines, functions, or branches

hit

defines the number of hit lines, functions, or branches

category

defines the number of lines, functions, or branches that fall in the specified category (see Differential coverage above)

Note that data is only reported for non-empty coverage types and bins.

The script should return 0 (zero) if the criteria are met and non-zero otherwise.

If desired, it may print a single line output string which will be appended to the error log if the return status is non-zero.  Additionally, non-empty lines are appended to the genhtml standard output log.

--version-script script

Use script to get source code file version data.

Use this option to specify an external tool or command line that genhtml can use to obtain a source code file's version ID when generating HTML or applying source filters (see --filter option).

A version ID can be a file hash or commit ID from revision control. It is used to check the version of the source file which is loaded against the version which was used to generate coverage data (i.e., the file version seen by lcov/geninfo). It is important that source code versions match - otherwise inconsistent or confusing results may be produced.

Version mismatches typically happen when the tasks of capture, aggregation, and report generation are split between multiple jobs - e.g., when the same source code is used in multiple projects, a unified/global coverage report is required, and the projects accidentally use different revisions.

Sample scripts for Perforce ("getp4version") and using an md5 hash ("get_signature") are provided as part of this package in the following locations:

/usr/share/lcov/support-scripts/getp4version

and

/usr/share/lcov/support-scripts/get_signature

Note that you must use the same script/same mechanism to determine the file version when you extract, merge, and display coverage data - otherwise, you may see spurious mismatch reports.

Creating your own script

When creating your own script, please first see Script considerations above for general calling conventions and script requirements.

script is used both to generate and to compare the version ID to enable retaining history between calls or to do more complex processing to determine equivalence. It will be called by genhtml with either of the following command lines:

1. Determine source file version ID

script source_file_name

It should write the version ID of source_file_name to stdout and return a 0 exit status. If the file is not versioned, it should write an empty string and return a 0 exit status.

2. Compare source file version IDs

script --compare source_file_name source_file_id
                 info_file_id

where

source_file_name

is the source code file name

source_file_id

is the version ID returned by calling "script source_file_name"

info_file_id

is the version ID found in the corresponding .info file

It should return non-zero if the IDs do not match.

--checksum

Specify whether to compare stored tracefile checksum to checksum computed from the source code.

Checksum verification is disabled by default.

When checksum verification is enabled, a checksum will be computed for each source code line and compared to the checksum found in the 'current' tracefile. This will help to prevent attempts to display source code which is not identical to the code used to generate the coverage data.

Note that this option is somewhat subsumed by the --version-script option - which does something similar, but at the 'whole file' level.

--new-file-as-baseline

By default, when code is identified on source lines in the 'current' data which were not identified as code in the 'baseline' data, but the source text has not changed, their coverpoints are categorized as "included code": GIC or UIC.

However, if the configuration of the coverage job has been recently changed to instrument additional files, then all un-exercised coverpoints in those files will fall into the GIC category - which may cause certain coverage criteria checks to fail.

When this option is specified, genhtml pretends that the baseline data for the file is the same as the current data - so coverpoints are categorized as CBC or UBC which do not trigger the coverage criteria check.

Please note that coverpoints in the file are re-categorized only if:

  • There is no 'baseline' data for any coverpoint in this file, AND
  • The file pre-dates the baseline:  the oldest line in the file is older than the 'baseline' data file (or the value specified by the --baseline-date option).
--elide-path-mismatch

Differential categorization uses file pathnames to match coverage entries from the ".info" file with file difference entries in the unified-diff-file.  If the entries are not identical, then categorization may be incorrect or strange.

When paths do not match, genhtml will produce "path" error messages to tell you about the mismatches.

If mismatches occur, the best solution is to fix the incorrect entries in the .info and/or unified-diff-file files.  However, fixing these entries is not possible, then you can use this option to attempt to automatically work around them.

When this option is specified, genhtml will pretend that the unified-diff-file entry matches the .info file entries if:

  • the same path is found in both the 'baseline' and 'current' .info files, and
  • the basename of the path in the .info file and the path in the unified-diff-file are the same, and
  • there is only one unmatched unified-diff-file entry with that basename.

See the --diff-file discussion above for a discussion of how to avoid spurious warnings and/or incorrect matches.

--synthesize-missing

Generate (fake) file content if source file does not exist. This option can be used to work around otherwise fatal annotation errors.

--date-bins day[,day,...]

The --date-bins option is used to specify age boundaries (cutpoints) for date-binning classification.  If not specified, the default is to use 4 age ranges: less than 7 days, 7 to 30 days, 30 to 180 days, and more than 180 days. This argument has no effect if there is no source-annotation-script .

--show-owners [all]

If the --show-owners option is used, each coverage report header report contain a summary table, showing counts in the various coverage categories for everyone who appears in the revision control annotation as the most recent editor of the corresponding line.  If the optional argument 'all' is not specified, the table will show only users who are responsible for un-exercised code lines.  If the optional argument is specified, then users responsible for any code lines will appear.  In both cases, users who are responsible for non-code lines (e.g, comments) are not shown. This option does nothing if --annotate-script is not used; it needs revision control information provided by calling the script.

Please note: if the all option is not specified, the summary table will contain "Total" rows for all date/owner bins which are not empty - but there will be no secondary "File/Directory" entries for elements which have no "missed" coverpoints.

--show-noncode

By default, the source code detail view does not show owner or date annotations in the far-left column for non-code lines (e.g., comments). If the --show-noncode option is used, then the source code view will show annotations for both code and non-code lines. This argument has no effect if there is no source-annotation-script .

--show-zero-columns

By default, columns whose entries are all zero are removed (not shown) in the summary table at the top of each HTML page. If the --show-zero-columns option is used, then those columns will be shown.

When columns are retained, then all the tables have the same width/contain the same number of columns - which may be a benefit in some situations.

When columns are removed, then the tables are more compact and easier to read. This is especially true in relatively mature development environments, when there are very few un-exercised coverpoints in the project.

--show-navigation

By default, the summary table in the source code detail view does not contain hyperlinks from the number to the first line in the corresponding category ('Hit' or 'Missed') and from the current location to the next location in the current category, in non-differential coverage reports.  (This is the lcov 'legacy' view non-differential reports.)

If the --show-navigation option is used, then the source code summary table will be generated with navigation links. Hyperlinks are always generated for differential coverage reports.

This feature enables developers to find and understand coverage issues more quickly than they might otherwise, if they had to rely on scrolling.

--show-proportions

In the 'function coverage detail' table, also show the percentage of lines and branches within the function which are exercised.

This feature enables developers to focus attention on functions which have the largest effect on overall code coverage.

This feature is disabled by default. Note that this option requires that you use a gcc version which is new enough to support function begin/end line reports.

--simplified-colors

By default, each differential category is colorized uniquely in the source code detail view.  With this option, only two colors are used:  one for covered code and another for uncovered code.  Note that ECB and EUB code is neither covered nor uncovered - and so may be difficult to distinguish in the source code view, as they will be presented in normal background color.

--exclude pattern

pattern is a glob-match pattern of filenames to exclude from the report. Files which do NOT match will be included. See the lcov man page for details.

--include pattern

pattern is a glob-match pattern of filenames to include in processing. Files which do not match will be excluded from the report. See the lcov man page for details.

--erase-functions regexp

Exclude coverage data from lines which fall within a function whose name matches the supplied regexp.  Note that this is a mangled or demangled name, depending on whether the --demangle-cpp option is used or not.

Note that this option requires that you use a gcc version which is new enough to support function begin/end line reports.

--substitute regexp_pattern

Apply Perl regexp regexp_pattern to source file names found during processing.  This is useful when some file paths in the baseline or current .info file do not match your source layout and so the source code is not found. See the lcov man page for more details.

--omit-lines regexp_pattern

Exclude coverage data from lines whose content matches regexp.

Use this switch if you want to exclude line and branch coverage data for some particular constructs in your code (e.g., some complicated macro). See the lcov man page for details.

--parallel [ integer ]
-j [ integer ]

Specify parallelism to use during processing (maximum number of forked child processes).  If the optional integer parallelism parameter is zero or is missing, then use to use up the number of cores on the machine.  Default is not to use a single process (no parallelism).

--memory integer

Specify the maximum amount of memory to use during parallel processing, in Mb.  Effectively, the process will not fork() if this limit would be exceeded.  Default is 0 (zero) - which means that there is no limit.

This option may be useful if the compute farm environment imposes strict limits on resource utilization such that the job will be killed if it tries to use too many parallel children - but the user does not know a priori what the permissible maximum is.  This option enables the tool to use maximum parallelism - up to the limit imposed by the memory restriction.

--filter filters

Specify a list of coverpoint filters to apply to input data.

filters can be a comma-separated list of the following keywords:

branch: ignore branch counts for C/C++ source code lines which do not appear to contain conditionals.  These may be generated automatically by the compiler (e.g., from C++ exception handling) - and are not interesting to users. This option has no effect unless --branch-coverage is used.

See also the lcovrc man page - which describes several variables which affect branch filtering: filter_lookahead and filter_bitwise_conditional.

The most common use for branch filtering is to remove compiler-generated branches related to C++ exception handlers.  See the no_exception_branch' option in the lcovrc man page for a way to remove all identified exception branches.

brace: ignore line coverage counts on the closing brace of C/C++ code block, if the line contains only a closing brace and the preceding line has the same count or if the close brace has a zero count and either the preceding line has a non-zero count, or the close brace is not the body of a conditional.

These lines seem to appear and disappear in gcov output - and cause differential coverage to report bogus LBC and/or GIC and/or UIC counts.  Bogus LBC or UIC counts are a problem because an automated regression which uses pass criteria "LBC + UIC + UNC == 0" will fail.

blank: ignore lines which contain only whitespace (or whitespace + comments) whose 'hit' count is zero.  These appear to be a 'gcov' artifact related to compiler-generated code - such as exception handlers and destructor calls at the end of scope - and can confuse differential coverage criteria.

range: Ignore line and branch coverpoints on lines which are out-of range/whose line number is beyond the end of the source file.  These appear to be gcov artifacts caused by a macro instantiation on the last line of the file.

line: alias for "--filter brace,blank".

region: apply LCOV_EXCL_START/LCOV_EXCL_STOP directives found in source text to the coverpoints found in the current and baseline .info files. This option may be useful in cases that the source code was not found during 'lcov --capture ...' but is accessible now.

branch_region: apply LCOV_EXCL_BR_START/LCOV_EXCL_BR_STOP directives found in source text to the coverpoints found in the current and baseline .info files. This is similar to the 'region option, above - but applies to branch coverpoints only.

function: combine data for every "unique" function which is defined at the same file/line. geninfo/gcov seem to have a bug such that they create multiple entries for the same function. This feature also merges all instances of the same template function/template method.

trivial: remove trivial functions and associated coverpoints.  'Trivial' functions are whose body is empty/do not contain any statements.  Commonly, these include compiler-generated methods (e.g., default constructors and assignment operators) as well as static initialization wrappers, etc.

Note that this filter requires function end line information - and so requires that you use a gcc veraion which is new enough to support begin/end line reports:  gcc/9 or newer, or that you enable lcov/genhtml/geninfo to derive the information:

In the lcovrc man page, see the derive_function_end_line setting as well as the trivial_function_threshold setting.  The former is used to turn end line calculation on or off, and the latter to change the lookahead used to determine whether the function body is empty.

-o output-directory
--output-directory output-directory

Create files in output-directory.

Use this option to tell genhtml to write the resulting files to a directory other than the current one. If output-directory does not exist, it will be created.

It is advisable to use this option since depending on the project size, a lot of files and subdirectories may be created.

-t title
--title title

Display title in header table of all pages.

title is written to the "Test:"-field in the header table at the top of each generated HTML page to identify the context in which a particular output was created. By default, this is the name of the 'current; tracefile.

A common use is to specify a test run name, or a version control system identifier (perforce changelist or git SHA, for example) that indicates the code level that was tested.

--header-title BANNER

Display BANNER in header of all pages.

BANNER is written to the header portion of each generated HTML page. By default, this simply identifies this as an LCOV (differential) coverage report.

A common use is to specify the name of the project or project branch and the Jenkins build ID.

--footer FOOTER

Display FOOTER in footer of all pages.

FOOTER is written to the footer portion of each generated HTML page. The default simply identifies the LCOV tool version used to generate the report.

-d description-file
--description-file description-file

Read test case descriptions from description-file.

All test case descriptions found in description-file and referenced in the input data file are read and written to an extra page which is then incorporated into the HTML output.

The file format of description-file is:

for each test case:

TN:<testname>
TD:<test description>

Valid test case names can consist of letters, numbers and the underscore character ('_').

-k
--keep-descriptions

Do not remove unused test descriptions.

Keep descriptions found in the description file even if the coverage data indicates that the associated test case did not cover any lines of code.

This option can also be configured permanently using the configuration file option genhtml_keep_descriptions.

-c css-file
--css-file css-file

Use external style sheet file css-file.

Using this option, an extra .css file may be specified which will replace the default one. This may be helpful if the default colors make your eyes want to jump out of their sockets :)

This option can also be configured permanently using the configuration file option genhtml_css_file.

--source-directory dirname

Add 'dirname' to the list of places to look for source files.

For relative paths listed in tracefile, genhtml will first look for the path from 'cwd' (where genhtml was invoked) and then from each alternate directory name in the order specified. The first location matching location is used.

This option can be specified multiple times, to add more directories to the source search path.

-p prefix
--prefix prefix

Remove prefix from all directory names.

Because lists containing long filenames are difficult to read, there is a mechanism implemented that will automatically try to shorten all directory names on the overview page beginning with a common prefix. By default, this is done using an algorithm that tries to find the prefix which, when applied, will minimize the resulting sum of characters of all directory names.

Use this option to specify the prefix to be removed by yourself.

--no-prefix

Do not remove prefix from directory names.

This switch will completely disable the prefix mechanism described in the previous section.

This option can also be configured permanently using the configuration file option genhtml_no_prefix.

--no-source

Do not create source code view.

Use this switch if you don't want to get a source code view for each file.

This option can also be configured permanently using the configuration file option genhtml_no_source.

--num-spaces spaces

Replace tabs in source view with num spaces.

Default value is 8.

This option can also be configured permanently using the configuration file option genhtml_num_spaces.

--highlight

Highlight lines with converted-only coverage data.

Use this option in conjunction with the --diff option of lcov to highlight those lines which were only covered in data sets which were converted from previous source code versions.

This option can also be configured permanently using the configuration file option genhtml_highlight.

--legend

Include color legend in HTML output.

Use this option to include a legend explaining the meaning of color coding in the resulting HTML output.

This option can also be configured permanently using the configuration file option genhtml_legend.

--html-prolog prolog-file

Read customized HTML prolog from prolog-file.

Use this option to replace the default HTML prolog (the initial part of the HTML source code leading up to and including the <body> tag) with the contents of prolog-file. Within the prolog text, the following words will be replaced when a page is generated:

@pagetitle@
The title of the page.

@basedir@
A relative path leading to the base directory (e.g., for locating css-files).

This option can also be configured permanently using the configuration file option genhtml_html_prolog.

--html-epilog epilog-file

Read customized HTML epilog from epilog-file.

Use this option to replace the default HTML epilog (the final part of the HTML source including </body>) with the contents of epilog-file.

Within the epilog text, the following words will be replaced when a page is generated:

@basedir@
A relative path leading to the base directory (e.g., for locating css-files).

This option can also be configured permanently using the configuration file option genhtml_html_epilog.

--html-extension extension

Use customized filename extension for generated HTML pages.

This option is useful in situations where different filename extensions are required to render the resulting pages correctly (e.g., php). Note that a '.' will be inserted between the filename and the extension specified by this option.

This option can also be configured permanently using the configuration file option genhtml_html_extension.

--html-gzip

Compress all generated html files with gzip and add a .htaccess file specifying gzip-encoding in the root output directory.

Use this option if you want to save space on your webserver. Requires a webserver with .htaccess support and a browser with support for gzip compressed html.

This option can also be configured permanently using the configuration file option genhtml_html_gzip.

--sort
--no-sort

Specify whether to include sorted views of file and directory overviews.

Use --sort to include sorted views or --no-sort to not include them. Sorted views are enabled by default.

When sorted views are enabled, each overview page will contain links to views of that page sorted by coverage rate.

This option can also be configured permanently using the configuration file option genhtml_sort.

--function-coverage
--no-function-coverage

Specify whether to display function coverage summaries in HTML output.

Use --function-coverage to enable function coverage summaries or --no-function-coverage to disable it. Function coverage summaries are enabled by default.

This option can also be configured permanently using the configuration file option genhtml_function_coverage.

When function coverage summaries are enabled, each overview page will contain the number of functions found and hit per file or directory, together with the resulting coverage rate. In addition, each source code view will contain a link to a page which lists all functions found in that file plus the respective call count for those functions. The function coverage page groups the data for every alias of each function, sorted by name or execution count.  The representative name of the group of functions is the shorted (i.e., containing the fewest characters).

If using differential coverage and a sufficiently recent gcc version which report both begin and end line of functions (gcc/9 and newer), functions are considered 'new' if any of their source lines have changed. With older gcc versions, functions are considered 'new' if the function signature has changed or if the entire function is new.

--branch-coverage
--no-branch-coverage

Specify whether to display branch coverage data in HTML output.

Use --branch-coverage to enable branch coverage display or --no-branch-coverage to disable it. Branch coverage data display is disabled by default.

When branch coverage display is enabled, each overview page will contain the number of branches found and hit per file or directory, together with the resulting coverage rate. In addition, each source code view will contain an extra column which lists all branches of a line with indications of whether the branch was taken or not. Branches are shown in the following format:

' + ': Branch was taken at least once
' - ': Branch was not taken
' # ': The basic block containing the branch was never executed

Note that it might not always be possible to relate branches to the corresponding source code statements: during compilation, GCC might shuffle branches around or eliminate some of them to generate better code.

This option can also be configured permanently using the configuration file option genhtml_branch_coverage.

--demangle-cpp [param]

Specify whether to demangle C++ function names.

Use this option if you want to convert C++ internal function names to human readable format for display on the HTML function overview page.

If called with no parameters, genhtml will use c++filt for demangling.  This requires that the c++filt tool is installed (see c++filt(1)).

If param is specified, it is treated as th tool to call to demangle source code. The --demangle-cpp option can be used multiple times to specify the demangling tool and a set of command line options that are passed to the tool - similar to how the gcc -Xlinker paramter works.  In that case, you callback will be executed as: | demangle_param0 demangle_param1 ... Note that the demangle tool is called as a pipe and is expected to read from stdin and write to stdout.

--ignore-errors errors

Specify a list of errors after which to continue processing.

Use this option to specify a list of error classes after which genhtml should continue processing with a warning message instead of aborting. To suppress the warning message, specify the error class twice.

errors can be a comma-separated list of the following keywords:

annotate: --annotate-script returned non-zero exit status - likely a file path or related error.  HTML source code display will not be correct and ownership/date information may be missing.

branch: Branch ID (2nd field in the .info file 'BRDA' entry) does not follow expected integer sequence.

callback: Annotate, version, or criteria script error.

category: Line number categorizations are incorrect in the .info file, so branch coverage line number turns out to not be an executable source line.

count: An excessive number of messages of some class has been reported - subsequent messages of that type will be suppressed. The limit can be controlled by the 'max_message_count' variable. See the lcovrc man page.

corrupt: Corrupt/unreadable coverage data file found.

deprecated: You are using a deprecated option. This option will be removed in an upcoming release - so you should change your scripts now.

empty: The patch file specified by the --diff-file argument does not contain any differences.  This may be OK if there were no source code changes between 'baseline' and 'current' (e.g., the only change was to modify a Makefile) - or may indicate an unsupported file format.

format: Unexpected syntax found in .info file.

inconsistent: Files have been moved or repository history presented by --diff-file data is not consistent with coverage data; for example, an 'inserted' line has baseline coverage data.  These issues are likely to be caused by inconsistent handling in the 'diff' and 'annotate' scripts.

mismatch: Inconsistent entries found in trace file:

  • branch expression (3rd field in the .info file 'BRDA' entry) of merge data does not match, or
  • function execution count (FNDA:...) but no function declaration (FN:...).

negative: negative 'hit' count found.

Note that negative counts may be caused by a known GCC bug - see

and try compiling with "-fprofile-update=atomic". You will need to recompile, re-run your tests, and re-capture coverage data.

package: A required perl package is not installed on your system.  In some cases, it is possible to ignore this message and continue - however, certain features will be disabled in that case.

parallel: Various types of errors related to parallelism - e.g., child process died due to some error.   If you see an error related to parallel execution, it may be a good idea to remove the --parallel flag and try again.

path: File name found in --diff-file file but does not appear in either baseline or current trace data.  These may be mapping issues - different pathname in the tracefile vs. the diff file.

source: The source code file for a data set could not be found.

unmapped: Coverage data for a particular line cannot be found, possibly because the source code was not found, or because the line number mapping in the .info file is wrong.

This can happen if the source file used in HTML generation is not the same as the file used to generate the coverage data - for example, lines have been added or removed.

unsupported: The requested feature is not supported for this tool configuration.  For example, function begin/end line range exclusions use some GCOV features that are not available in older GCC releases.

unused: The include/exclude/erase/substitute/omit pattern did not match any file pathnames.

version: --version-script comparison returned non-zero mismatch indication.  It likely that the version of the file which was used in coverage data extraction is different than the source version which was found.  File annotations may be incorrect.

Also see 'man lcovrc' for a discussion of the 'max_message_count' parameter which can be used to control the number of warnings which are emitted before all subsequent messages are suppressed.  This can be used to reduce log file volume.

--keep-going

Do not stop if error occurs: attempt to generate a result, however flawed.

This command line option corresponds to the stop_on_error lcovrc option.  See the lcovrc man page for more details.

--config-file config-file

Specify a configuration file to use. See the lcovrc man page for details of the file format and options.

When this option is specified, neither the system-wide configuration file /etc/lcovrc, nor the per-user configuration file ~/.lcovrc is read.

This option may be useful when there is a need to run several instances of genhtml with different configuration file options in parallel.

Note that this option must be specified in full - abbreviations are not supported.

--rc keyword=value

Override a configuration directive.

Use this option to specify a keyword=value statement which overrides the corresponding configuration statement in the lcovrc configuration file. You can specify this option more than once to override multiple configuration statements. See lcovrc(5) for a list of available keywords and their meaning.

--precision num

Show coverage rates with num number of digits after the decimal point.

Default value is 1.

This option can also be configured permanently using the configuration file option genhtml_precision.

--suppress-aliases

Suppress list of aliases in function detail table.

Functions whose file/line is the same are considered to be aliases; genthml uses the shortest name in the list of aliases (fewest characters) as the leader.

The number of aliases can be large, for example due to instantiated templates - which can make function coverage results difficult to read.  This option removes the list of aliases, making it easier to focus on the overall function coverage number, which is likely more interesting.

Note that this option has an effect only when --filter function is applied.

This option can also be configured permanently using the configuration file option suppress_function_aliases.

--forget-test-names

If non-zero, ignore testcase names in .info file - i.e., treat all coverage data as if it came from the same testcase. This may improve performance and reduce memory consumption if user does not need per-testcase coverage summary in coverage reports.

This option can also be configured permanently using the configuration file option forget_testcase_names.

--missed

Show counts of missed lines, functions, or branches.

Use this option to change overview pages to show the count of lines, functions, or branches that were not hit. These counts are represented by negative numbers.

When specified together with --sort, file and directory views will be sorted by missed counts.

This option can also be configured permanently using the configuration file option genhtml_missed.

--dark-mode

Use a light-display-on-dark-background color scheme rather than the default dark-display-on-light-background.

The idea is to reduce eye strain due to viewing dark text on a bright screen - particularly at night.

--tempdir dirname

Write temporary and intermediate data to indicated directory.  Default is "/tmp".

--preserve

Preserve intermediate data files generated by various steps in the tool - e.g., for debugging.  By default, these files are deleted.

--save

Copy unified-diff-file, baseline_trace_file, and tracefile(s) to output-directory.

Keeping copies of the input data files may help to debug any issues or to regenerate report files later.

Files

/etc/lcovrc

The system-wide configuration file.

~/.lcovrc

The per-user configuration file.

/usr/share/lcov/support-scripts/p4udiff

Sample script for use with --diff-file that creates a unified diff file via Perforce.

/usr/share/lcov/support-scripts/gitdiff

Sample script for use with --diff-file that creates a unified diff file via git.

/usr/share/lcov/support-scripts/p4annotate

Sample script for use with --annotate-script that provides annotation data via Perforce.

/usr/share/lcov/support-scripts/gitblame

Sample script for use with --annotate-script that provides annotation data via git.

/usr/share/lcov/support-scripts/criteria

Sample script for use with --criteria-script that implements a check for "UNC + LBC + UIC == 0".

/usr/share/lcov/support-scripts/getp4version

Sample script for use with --version-script that obtains version IDs via Perforce.

/usr/share/lcov/support-scripts/get_signature

Sample script for use with --version-script that uses md5hash as version IDs.

Authors

Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com>

Henry Cox <henry.cox@mediatek.com>

Differential coverage and date/owner binning, filtering, error management, parallel execution sections,

See Also

lcov(1), lcovrc(5), geninfo(1), genpng(1), gendesc(1), gcov(1)

https://github.com/linux-test-project/lcov

Referenced By

gendesc(1), geninfo(1), genpng(1), lcov(1), lcovrc(5).

LCOV 2.0 2024-01-25 User Manuals