| genhtml(1) | User Manuals | genhtml(1) |
genhtml - Generate HTML view from LCOV coverage data files
genhtml [-h|--help] [--version]
genhtml creates an HTML view of coverage data found in
tracefiles geninfo and lcov tools which are found from
glob-match pattern(s) tracefile_pattern.
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 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
Both tracefile_pattern and baseline-file are treated as glob patterns which match one or more files.
The difference in coverage between the set of tracefiles and baseline-files is classified line-by-line into categories based on changes in 2 aspects:
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):
LBC
UIC
UBC
GBC
GIC
GNC
CBC
EUB
ECB
DUB
Note: Because these lines are not represented in the current source version, they are only represented in the classification summary table.
DCB
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 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).
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:
See example implementations $LCOV_HOME/share/lcov/support-scripts/gitversion.pm and $LCOV_HOME/share/lcov/support-scripts/getp4version.pm.
where
and
See example implementations $LCOV_HOME/share/lcov/support-scripts/gitblame.pm and $LCOV_HOME/share/lcov/support-scripts/p4annotate.pm.
where $hash is a reference to a hash of key/value pairs which are meaningful to you. This data is stored in the profile database. See the 'profile' section in man lcovrc(5) for more information.
If your callback is not a perl module - for example, is a shellscript - then it should return a string such that the first word on each line is the key and the remainder is the associated data. If a key is repeated, then the corresponding data strings are concatenated, separated by newline.
If you want to record only system information, then a shell callback is likely sufficient. If you want to record any tool-specific/internal information, then you will need to implement a perl module so that your callback will be able to access the information. Note that the constructor of your context-script callback (or of any callback) can perform any additional actions which are required - for example, to write additional files, to query or set tool-specific information, etc. For example, the example implementation, below, has an option to append comments to the generated .info file.
See the example implementation $LCOV_HOME/share/lcov/support-scripts/context.pm.
where
See example implementations $LCOV_HOME/share/lcov/support-scripts/criteria.pm.
where $newpath is the correct path to the indicated source file or undef if the source file is not found by the callback.
Example:
results in the same callback as
genhtml --annotate-script "/bin/script.sh arg0" ...
or
genhtml --annotate-script /bin/script.sh,arg0 ...
Note that the first form is preferred.
The resulting genhtml callback executes the command line:
Similarly
or
genhtml --annotate-script /bin/myMoodule.pm,arg0,arg1
result in genhtml executing
to initialize the class object - arg0 and arg1 passed as strings - and then to execute
to retrieve the annotation information.
In contrast, the command
Similarly, the command
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.
In particular, if your callback is implemented via a perl module:
As a result: if your callback needs to pass data back to the parent, you will need to arrange a communication mechanism to do so.
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, as well as to verify that the same source code was used to capture coverage information which is going to be merged and to verify that the source version used for filtering operations is compatible with the version used to generate the 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 and --resolve-script options for a mechanism to adjust extracted paths so they match your source and/or revision control layout.
You can use the check_exisitence_before_callback configuration option to tell the tool to check that the file exists before calling the --version-script or --annotate-script callback. See man lcovrc(5) for details.
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.
or type-specific limits:
See man lcovrc(5) 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.
By default, genhtml reports will include both line and function coverage data. Neither branch or MC/DC data is displayed by default; you can use the --branch-coverage and --mcdc-coverage options to enable branch or MC/DC coverage, respectively - or you can permanently enable branch coverage by adding the appropriate settings to your personal, group, or site lcov configuration file. See the branch_coverage and mcdc_coverage sections of man lcovrc(5) for details.
In general, (almost) all genhtml options can also be specified in your personal, group, project, or site configuration file - see man lcovrc(5) for details.
-h
--help
Decreased verbosity will suppress 'progress' messages for example - while error and warning messages will continue to be printed.
The default HTML report is 3 levels:
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:
The 'flat' view can reduce the number of clicks required to
navigate around the coverage report - but is unwieldy except for rather
small projects consisting of only a few source files. It can be useful in
'code review' mode, even for very large projects (see the
--select-script option).
Most large projects follow a rational directory structure - which favors the
'hierarchical' report format. Teams responsible for a particular module can
focus on a specific subdirectory or set of subdirectories.
Only one of options --flat or --hierarchical can be specified at the same time.
These options can also be persistently set via the lcovrc configuration file using either:
or
See man lcovrc(5) for details.
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).
This option can also be controlled from the genhtml_frames entry of the lcovrc file.
Please note that there is a bug in firefox and in chrome, such that enabling frames will disable hyperlinks from the 'directory' level summary table entry to the first line in the corresponding file in the particular category - e.g., to the first 'MIS' line (vanilla coverage report - see the option, below), to the first 'UNC' branch (differential coverage report), etc. Hyperlinks from the summary table at the top of the 'source detail' page are not affected.
When this option is enabled, genhtml generates two versions of each source file file entry in the corresponding summary table:
The corresponding summary table is found on the 'directory' page of the default 3-level genthm report, or on the top-level page of the 'flat' report (see genhtml --flat ... ), or on the parent directory page of the 'hierarchical' report (see genhtml --hierarchical ... ).
Note that this option may significantly increase memory consumption.
--baseline-file may be specified multiple times - for example, if you have multiple trace data files for each of several test suites and you do not want to go through the additional step of merging all of them into a single aggregated data file.
The coverage data files specified by baseline-file-pattern is read and used as the baseline for classifying the change in coverage represented by the coverage counts in tracefile-patterns. If baseline-file-pattern is a directory, then genhtml will search the directory for all files ending in '.info'. See the info_file_extension section in man(5) lcovrc for how to change this pattern.
In general, you should specify a diff file in unified diff format via --diff-file when you specify a --baseline-file-pattern. 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.
Note:
It is almost always a better idea to filter at capture or aggregate time - not at report generation.
A suitable diff-file can be generated using the command:
or using the "p4udiff" or "gitdiff" sample scripts that are provided as part of this package in the following locations:
and
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:
in the p4diff/gitdiff output as this knowledge will help to suppress spurious 'path mismatch' warnings. See the --elide-path-mismatch and --build-directory entries, below.
In general, you will specify --baseline-file when you specify --diff-file. The baseline_files are used to compute coverage differences ( e.g. gains and losses) between the baseline and current, where the diff_file is used to compute code changes: source text is identical between 'baseline' and 'current'. If you specify baseline_files but no diff_file, the tool will assume that there are no code changes between baseline and current. If you specify a diff_file but no baseline_files, the tool will assume that there is no baseline coverage data (no baseline code was covered); as result unchanged code ( i.e., which does not appear in the diff_file will be categorized as eiher GIC (covered) or UIC (not covered) while new or changed code will be categorized as either GNC or UNC.
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. Annotation data is also used to populate a 'tooltip' which appears when the mouse hovers over the associated source code. See the genhtml_annotate_tooltip entry in man lcovrc(5) for details.
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.
genhtml will emit an error if you have specified an annotation script but no files are successfully annotated (see below). This can happen, for example, if your P4USER, P4CLIENT, or P4PORT environment variables are not set correctly - e.g. if the Jenkins user who generates coverage reports is not the same and the user who checked out the code and owns the sandbox.
Sample annotation scripts for Perforce ("p4annotate") and git ("gitblame") are provided as part of this package in the following locations:
and
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:
where
additional_parameters
source_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:
where
author_data
date
source_code
The script should return 0 (zero) if processing was successful and non-zero if it encountered an error.
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:
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:
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:
See man lcovrc(5) 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:
where
additional_parameters
name
type
coverage_data
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
bin_type
bin_id
found
hit
category
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 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.
If your .info (coverage data) file does not contain version information - for example, because it was generated by a tool which did not support versioning - then you can use the compute_file_version = 1 config file option to generate the data afterward. A convenient way to do this might be to use lcov --add-tracefile to read the original file, insert version information, and write out the result. See man lcovrc(5) for more details.
Sample scripts for Perforce ("getp4version"), git ("gitversion") and using an md5 hash ("get_signature") are provided as part of this package in the following locations:
and
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
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
source_file_name
source_file_id
info_file_id
It should return non-zero if the IDs do not match.
--resolve-script script
--select-script callback
This option is equivalent to the select_script config file option. See man lcovrc(5) for details.
--checksum
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.
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:
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:
See the --diff-file and --build-directory entries for a discussion of how to avoid spurious warnings and/or incorrect matches.
When generating annotated file content, genhtml assumes that the source was written 'now' (so age is zero), the author is no.body and the commit ID is synthesized. These names and ages will appear in your HTML reports.
This option is equivalent config file genhtml_synthesize_missing parameter; see man lcovrc(5) for details.
This argument has no effect if there is no source-annotation-script .
One possible use of this option is to use release names in the tables - i.e., to indicate the release in which each particular line first appeared.
This option is equivalent to the genhtml_date_labels config file option. See man lcovrc(5).
This argument has no effect if there is no source-annotation-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.
This option is equivalent config file genhtml_show_owner_table parameter; see man lcovrc(5) for details.
The lcovrc controls owner_table_entries and truncate_owner_table can be used to improve readability by limiting the number of authors who are displayed in the table when the author number is large. For example, if your configuration is:
owner_table_entries = 5
truncate_owner_table = top,directory
then the owner table displayed at the top- and directory-levels will be truncated while the table shown at the 'file' level will display the full list.
See man lcovrc(5) for details.
This option is equivalent config file genhtml_show_noncode_owners parameter; see man lcovrc(5) for details.
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.
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.
See the --frames description above for a description of a browser bug which disables these hyperlinks in certain conditions.
Navigation hyperlinks are always enabled in differential coveage report.
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 compiler version which is new enough to support function begin/end line reports or that you configure the tool to derive the required data - see the derive_function_end_line discussion in man lcovrc(5).
--erase-functions regexp
Note that this option requires that you use a compiler version which is new enough to support function begin/end line reports or that you configure the tool to derive the required data - see the derive_function_end_line discussion in man lcovrc(5).
Note that the substitution patterns are applied to the --diff-file entries as well as the baseline and current .info files.
--omit-lines regexp_pattern
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.
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.
The configuration file memory_percentage option provided another way to set the maximum memory consumption. See man lcovrc (5) for details.
Note that certain filters apply only to C/C++ source files. genhtml associates the file extension ('.c', '.vhd', etc. ) with its source language. See the c_file_extentions and rtl_file_extensions sections of man lcovrc(5) for a description of the default associations and how they can be changed.
Note that filters are applied to both 'branch' and 'MC/DC' coverpoints, where appropriate: if a particular filter would remove some branch, then it will also remove corresponding MC/DC coverpoints - for example, --filter branch will remove MC/DC coverpoints if there is no conditional expression on the corresponding line, and --filter branch_region will remove both branch and MC/DC coverpoints in the marked region.
Most filters need the source code; filters are not applied if the source file is not available. Similarly, for each source file, if the version recorded in the coverage data (the '.info' file) does not match the version found on the filesystem, then a version error is reported. If the version error is ignored, then filtering is not applied to the mismatched file. See the --version-script for more information.
filters can be a comma-separated list of the following keywords:
See also man lcovrc(5) - 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 man lcovrc(5) for a way to remove all identified exception branches.
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.
Note that the trivial filter requires function end line information - and so requires that you use a compiler version which is new enough to support begin/end line reports ( e.g., gcc/9 or newer) or that you enable lcov/genhtml/geninfo to derive the information:
In man lcovrc(5), 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. Also see the lcov_filter_parallel and lcov_filter_chunk_size settings, which may improve CPU performance if the number of files to process is very large.
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.
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.
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 is written to the footer portion of each generated HTML page. The default simply identifies the LCOV tool version used to generate the report.
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:
Valid test case names can consist of letters, numbers and the underscore character ('_').
-k
--keep-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.
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.
Look in dirname for file paths which appear in tracefile - possibly after substitutions have been applied - which are soft links. Both the original file path and the path to the linked file will resolve to the same --diff-file entry.
This option can be specified multiple times, to add more directories to the search path.
For relative source file paths e.g. paths found in tracefile, or in diff-file - possibly after substitutions have been applied - 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.
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.
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.
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.
Use this switch if you want some artifact of coverage report generation - e.g., the coverage criteria check or the serialized coverage DB, etc. - but do not need the coverage report HTML itself.
Default value is 8.
This option can also be configured permanently using the configuration file option genhtml_num_spaces.
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.
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.
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.
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.
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
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.
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.
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 compiler version which report both begin and end line of functions ( e.g., gcc/9 and newer), functions are considered 'new' if any of their source lines have changed. With older compiler versions, functions are considered 'new' if the function signature has changed or if the entire function is new.
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 branch_coverage.
--mcdc-coverage
MC/DC data display is disabled by default.
MC/DC coverage is supported for GCC versions 14.2 and higher, or
LLVM 18.1 and higher.
See llvm2lcov --help for details on MC/DC data capture in LLVM.
When MC/DC display is enabled, each overview page will contain the number of MC/DC expressions found and hit per file or directory - two senses per expression - together with the resulting coverage rate. In addition, each source code view will contain an extra column which lists all expressions and condition senses of a line with indications of whether the condition was sensitized or not. Conditions are shown in the following format:
Note that branch and MC/DC coverage are identical if the condition is a simple expression - e.g.,
Note that, where appropriate, filters are applied to both 'branch' and 'MC/DC' coverpoints: if a particular filter would remove some branch, then it will also remove corresponding MC/DC coverpoints. See the --filter section, above.
This option can also be configured permanently using the configuration file option mcdc_coverage. See man lcovrc(5) .
Note that MC/DC coverpoints are defined differently by GCC and LLVM.
That is: the testcase must sensitize both values in order to be
marked covered by LLVM, whereas GCC will independently mark each.
Consequently: in LLVM-generated lcov reports, either both 'true' and
'false' sensitizations will be covered, or neither will be.
See the examples in tesctcase .../tests/lcov/mcdc.
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 parameter 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
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:
If the error is ignored, the offending record is skipped.
Note that negative counts may be caused by a known GCC bug - see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080
and try compiling with "-fprofile-update=atomic". You will need to recompile, re-run your tests, and re-capture coverage data.
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.
Note that certain error messages are caused by issues that you probably cannot fix by yourself - for example, bugs in your tool chain which result in inconsistent coverage DB data (see above). In those cases, after reviewing the messages you may want to exclude the offending code or the entire offending file, or you may simply ignore the messages - either by converting to warning or suppressing entirely. Another alternative is to tell genhtml about the number of messages you expect - so that it can warn you if something changes such that the count differs, such that you know to review the messages again. See the --expect-message-count flag, below.
Also see 'man lcovrc(5)
For example:
Multiple constraints can be specified using a comma-separated list or by using the option multiple times.
This flag is equivalent to the expect_message_count configuration option. See man lcovrc(5) for more details on the expression syntax and how expressions are interpreted. The number of messages of the particular type is substituted into the expression before it is evaluated.
--keep-going
This command line option corresponds to the stop_on_error lcovrc option. See man lcovrc(5) for more details.
--config-file config-file
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.
--profile [ profile-data-file ]
--rc keyword=value
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 man lcovrc(5) for a list of available keywords and their meaning.
--precision num
Default value is 1.
This option can also be configured permanently using the configuration file option genhtml_precision.
--merge-aliases
This parameter an be configured via the configuration file merge_function_aliases option. See man(5) lcovrc.
--suppress-aliases
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 if --filter function has been applied to the coverage DB.
This parameter an be configured via the configuration file merge_function_aliases option. See man(5) lcovrc.
--forget-test-names
This option can also be configured permanently using the configuration file option forget_testcase_names.
--missed
Use this option to change overview pages to show the count of lines, functions, branches, or MC/DC expressions 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
The idea is to reduce eye strain due to viewing dark text on a bright screen - particularly at night.
--tempdir dirname
--preserve
--save
Keeping copies of the input data files may help to debug any issues or to regenerate report files later.
--serialize file_name
The file is in Perl "Storable" format.
Note that this option may significantly increase genhtml memory requirements, as a great deal of data must be retained.
/etc/lcovrc
~/.lcovrc
Sample --diff-file data creation scripts:
/usr/share/lcov//support-scripts/p4udiff
/usr/share/lcov//support-scripts/gitdiff
Sample --annotate-script callback Perl modules:
/usr/share/lcov//support-scripts/gitblame.pm
Sample --criteria-script callback Perl modules:
/usr/share/lcov//support-scripts/criteria.pm
/usr/share/lcov//support-scripts/threshold.pm
Sample --version-script callback Perl modules and scripts:
/usr/share/lcov//support-scripts/getp4version
/usr/share/lcov//support-scripts/P4version.pm
/usr/share/lcov//support-scripts/get_signature
/usr/share/lcov//support-scripts/gitversion.pm
/usr/share/lcov//support-scripts/batchGitVersion.pm
Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com>
Henry Cox <henry.cox@mediatek.com>
lcov(1), lcovrc(5), geninfo(1), genpng(1), gendesc(1), gcov(1)
https://github.com/linux-test-project/lcov
| LCOV 2.0 | 2025-04-03 |