GENHTML(1)

๐Ÿ’… GENHTML โ€” the genhtml(1) page, LCOV edition ๐Ÿ‘‘

okay bestie, sit down, hydrate, and let me tell you about genhtml โ€” it lives in the LCOV manual, and it's genuinely one of the most extra tools in the coverage game. ๐Ÿซถ

๐ŸŒธ NAME ๐ŸŒธ

genhtml โ€” genhtml documentation

genhtml โ€” Generate HTML view from LCOV coverage data files - including differential coverage analysis, age and author binning, and various visualization options.

โœจ SYNOPSIS โœจ

no cap, the synopsis is a whole mood โ€” look at all these flags ๐Ÿ‘‡

    genhtml [ -h | --help ] [ --version ]
        [ -q | --quiet ]
        [ -v | --verbose ]
        [ --debug ] [ --validate ]
        [ -s | --show-details ]
        [ -f | --frames ]
        [ -b | --baseline-file baseline-file-pattern ]
        [ -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 ]
        [ --build-directory directory ]
        [ --source-directory dirname ]
        [ --no-source ] [ --no-html ]
        [ --num-spaces num ] [ --highlight ]
        [ --legend ] [ --html-prolog prolog-file ]
        [ --html-epilog epilog-file ] [ --html-extension extension ]
        [ --html-gzip ] [ --sort-tables ] [ --no-sort ]
        [ --function-coverage ] [ --no-function-coverage ]
        [ --branch-coverage ] [ --no-branch-coverage ]
        [ --mcdc-coverage ]
        [ --demangle-cpp [ param ] ]
        [ --msg-log [ log_file_name ] ]
        [ --ignore-errors errors ]
        [ --expect-message-count message_type=expr[,message_type=expr..] ]
        [ --keep-going ] [ --config-file config-file ]
        [ --profile [ profile-file ] ]
        [ --history-script callback ]
        [ --rc keyword = value ]
        [ --precision num ] [ --missed ]
        [ --merge-aliases ]
        [ --suppress-aliases ]
        [ --forget-test-names ]
        [ --dark-mode ]
        [ --baseline-title title ]
        [ --baseline-date date ]
        [ --current-date date ]
        [ --diff-file diff-file ]
        [ --annotate-script script ]
        [ --context-script script ]
        [ --criteria-script script ]
        [ --version-script script ]
        [ --resolve-script script ]
        [ --select-script script ]
        [ --simplify-script script ]
        [ --unreachable-script module ]
        [ --checksum ]
        [ --fail-under-branches percentage ]
        [ --fail-under-lines percentage ]
        [ --new-file-as-baseline ]
        [ --elide-path-mismatch ]
        [ --synthesize-missing ]
        [ --date-bins day[,day,...] ]
        [ --date-labels string[,string,...] ]
        [ --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 ]
        [ --sort-input ]
        [ --serialize serialize_output_file ]
    tracefile_pattern(s)

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So here's the tea: 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. Need the whole breakdown of the tracefile format? Peep geninfo(1) <file://../man/geninfo.1.html> โ€” it's all there. ๐Ÿ“–

Features include:

  • ๐Ÿ’– Differential coverage comparison against baseline coverage data
  • ๐ŸŽ€ Annotation of reports with date and owner information ("binning")

The basic concepts of differential coverage and date/owner binning are described in the paper found at https://arxiv.org/abs/2008.07947 โ€” yes, it's giving academic icon energy โœจ


๐Ÿ’– Differential coverage ๐Ÿ’–

Differential coverage is lowkey a glow-up comparison: it takes two versions of source code โ€” the baseline and the current versions โ€” plus the coverage results for each, and segments the code into categories. ๐Ÿงš

To create a differential coverage report, genhtml requires

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

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:

  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. fr fr, it's a whole team vibe. ๐Ÿ’…

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:

--annotate-script
--context-script
--criteria-script
--history-script
--resolve-script
--select-script
--simplify-script
--unreachable-script
--version-script

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

  1. If the callback script name ends in .pm then the script is assumed to be a Perl module.

A perl module may offer performance advantages over an external script, as it is compiled once and loaded into the interpreter and because it can load and maintain internal state. โšก

The module is expected to export a method new, which is called with the script name and the script parameters (if any) as arguments. It is expected to return an object which implements several standard methods:

$callback_obj = packagename ->new(perl_module_file, args);

๐ŸŒŸ version-script

$version = $callback_obj->extract_version($source_file_ename);

$match = $version->check_version($old_version, $new_version,
$source_file_name);

$match is expected to be 1 (true) if the version keys refer to the came file and 0 (false) otherwise.

$version is a string representing a unique identifier of the particular version of the file.

See example implementations *$|TOOL_NAME|_HOME/share/lcov/support-scripts/gitversion.pm and $|TOOL_NAME|_HOME/share/lcov/support-scripts/getp4version.pm.

๐ŸŒŸ annotate-script

($status, $array) =
$callback_obj->annotate($source_file_name);

where

$status โ€” is 0 if the command succeeded and nonzero otherwise. $status is interpreted in same way as the return code from system(..)

$array is a list of line data of the form:

[$text, $abbrev, $full_name, $when, $changelist].

and

  • $text is the source text from the corresponding line (without newline termination)
  • $abbrev is the "abbreviated author name" responsible for this line of code. This is the name that will be used in the various HTML tables. For example, for brevity/readability, you may want to strip the domain from developers who are inside your organization. If there is no associated author, then the value should be "NONE".

(this iconic page continues in part 2, bestie โ€” don't go anywhere ๐Ÿฆ‹โœจ)

  • $full_name โ€” the โ€œfull author nameโ€ that shows up in annotation tooltips, iykyk ๐Ÿ’…. Check the genhtml_annotate_tooltip entry in lcovrc(5). Heads up: $fullname may be undef if the full name and abbreviated names are the same.
  • $when โ€” the timestamp for the most recent edit of that line. It can be "NONE" if thereโ€™s no associated time.
  • $changelist โ€” the commit identifier for the most recent change to this line, or "NONE" if there isnโ€™t one.

See example implementations $|TOOL_NAME|_HOME/share/lcov/support-scripts/gitblame.pm and $|TOOL_NAME|_HOME/share/lcov/support-scripts/p4annotate.pm.


context-script ๐Ÿซถ

$hash = $callback_obj->context();

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 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 $|TOOL_NAME|_HOME/share/lcov/support-scripts/context.pm.


criteria-script ๐ŸŽฏ

($status, $array) = $callback_obj->check_criteria($obj_name,
$type, $json);

where

  • $obj_name โ€” the source file or directory name, or โ€œtopโ€ of the object whose coverage criteria is being checked.
  • $type โ€” the object type: either "file", "directory", or "top".
  • $json โ€” the coverage data associated with this object, in JSON format โ€” see below.
  • $status โ€” the return status of the operation, interpreted the same way as the annotate callback status, described above.
  • $array โ€” a reference to a possibly empty list of strings which will be reported by genhtml. The strings are expected to explain why the coverage criteria failed.

See example implementations $|TOOL_NAME|_HOME/share/lcov/support-scripts/criteria.pm.


history-script โณ

$cpu_seconds = $callback_obj->history($element_name)

where $cpu_seconds is the predicted time taken to process $element_name, or undef if there is no prediction/the element is unknown.

See the sample implementation scripts/history.pm, which uses the --profile data generated by a previous genhtml execution to predict the time required this time.

The prediction may improve load balancing โ€” and thus improve overall runtime performance (i.e., because we wonโ€™t be waiting for some โ€œlong poleโ€ task to complete while all other threads are idle).


resolve-script ๐Ÿงš

$newpath = $callback_obj->resolve($source_file_name)

where $newpath is the correct path to the indicated source file, or undef if the source file is not found by the callback.


simplify-script โœจ

$new_func_name = $callback_obj->simplify($orig_func_name)

where $new_func_name is the function name which will appear in the function detail table, and $orig_func_name is the (possibly demangled) function name found in the coverage DB.

Note that the modified name is only used in the โ€œfunction detailโ€ table and does not modify information in the coverage DB.


unreachable-script ๐Ÿ’€

$data_changed = $callback_obj->exclude($type, $source,
$summary, $testdata);

where $data_changed is non-zero if coverage data was changed in the callback, $type is either โ€œbranchโ€ or โ€œmcdcโ€, $source is a โ€œReadCurrentSourceโ€ object, $summary is the coverage summary across all testcases, and $testdata is the per-testcase coverage data.

See the sample implementation .../scripts/unreach.pm for a simple example callback which uses source code annotations to indicate branch expressions and/or MC/DC conditions which are excluded. See the comment at the top of the file for script usage directions.

More sophisticated unreachability analysis is easy to visualize. For example, one could use reachability data from the compiler or another tool, rather than relying on user annotation.

โš ๏ธ Note that the --unreachable-script callback must be a Perl module. Unlike the other callbacks, generic scripts are not supported.

  1. The option may be specified as a single split_char separated string which is divided into words (see lcovrc(5)), or as a list of arguments. The resulting command line is passed to a shell interpreter to be executed. The command line 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.

Note that module callbacks must be called via the โ€˜listโ€™ method: they cannot be called as an executable with a space-separated set of arguments.

For convenience: your callback module may need to implement its own โ€˜split_charโ€™ so that you can pass multiple parameters to your callback without interacting with genhtmlโ€™s split mechanism.

  1. If an option is specified multiple times, then the parameters are not split, but are simply concatenated to form the command line โ€” see the examples, below.

For simplicity and ease of understanding: your command line should pass all arguments individually, or all as a comma-separated list โ€” not a mix of the two.

  1. 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 arg0 ...

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:

/bin/script.sh arg0 *source_file_name*

Similarly

genhtml --annotate-script /bin/myMoodule.pm
        --annotate-script arg0 --annotate-script arg1 ...

or

genhtml --annotate-script /bin/myMoodule.pm,arg0,arg1 ...

result in genhtml executing

$annotateCallback = myModule->new(arg0, arg1);

to initialize the class object โ€” arg0 and arg1 passed as strings โ€” and then to execute

($status, $arrayRef) = $annotateCallback(*source_file_name*);

to retrieve the annotation information.

In contrast, the command

genhtml --annotate-script /bin/myMoodule.pm
        --annotate-script arg0,arg1 ...

would result in genhtml initializing the callback object via

$annotateCallback = myModule->new("arg0,arg1");

where "arg0,arg1" is passed as single comma-separated string.

Similarly, the command

genhtml --annotate-script /bin/myMoodule.pm,arg0
        --annotate-script arg1 ...

would very likely result in an error when genhtml tries to find a script called /bin/mymodule.pm,arg0.

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:

  • the class object associated with the module will be initialized once (in the parent process)
  • The callback will occur in the child process (possibly simultaneously with other child processes).

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.

๐Ÿซถ CALLBACKS AND PARALLEL EXECUTION ๐Ÿซถ

okay so this part is giving advanced bestie energy ๐Ÿ’… because when callbacks need to record data โ€” like for error reporting or action summaries when stuff is running in parallel โ€” genhtml (and lcov and geninfo too, fr fr) can call certain optional callback methods:

  • $callback->start() โ€” this one gets called when the child process begins execution. use it to capture initial state, like setting the count of events in this child to zero ๐ŸŽ€. this method is optional.
  • my $data = $callback->save() โ€” gets called when processing is complete, just before the child process exits ๐Ÿ˜ญ. the scalar $data returned by your $callback->save() method $callback->restore() method when the child process is reaped.
  • $callback->restore($data) โ€” called in the parent process when the child is reaped ๐Ÿงš. $data is the data that was returned when your $callback->save() method was called in the child. (serialization/deserialization has happened under the covers, don't worry about it โœจ)
  • $callback->finalize() โ€” called in the parent process when all calculations are complete and the parent setting up to report final results ๐Ÿ‘‘. this method is optional.

note that, unlike the other callback methods described in this section, finalize() is called in both parallel and serial execution contexts ๐Ÿฆ‹.

also note that your callback must implement $callback->restore() if it implements $callback->save(). $callback->start() and $callback->finalize() are optional โ€” if they are implemented, then they will be called ๐Ÿ’–.

these methods are available only for callbacks implemented a perl modules. if you callback is implemented as an executable script (say) โ€” then you are free to implement parent/child data passing however you prefer ๐Ÿ˜Œ.

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, 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) ๐Ÿ˜ค. no wiggle room, bestie.

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_existence_before_callback configuration option to tell the tool to check that the file exists before calling the --version-script or --annotate-script callback. see lcovrc(5) for details ๐Ÿ‘‘

Additional options ๐Ÿ’œ

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 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 lcovrc(5) for details.


โœจ OPTIONS โœจ

in general, (almost) all genhtml options can also be specified in your personal, group, project, or site configuration file โ€” see lcovrc(5) for details ๐Ÿ’….

  • -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 ๐Ÿ› ๏ธ.
  • --validate โ€” check the generated HTML to verify that there are no dead hyperlinks and no unused files in the output directory โœ…. the checks can also be enabled by setting environment variable LCOV_VALIDATE = 1. this option is primarily intended for use by developers who modify the HTML report.
  • --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.

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:

genhtml_hierarchical = 1

or

genhtml_flat_view = 1

see lcovrc(5) 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>).

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 .i --show-navigation 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.

  • -s, --show-details โ€” generate detailed directory view ๐Ÿ“Š. when this option is enabled, genhtml generates two versions of each source file file entry in the corresponding summary table:
    • one containing the standard information plus a link to a "detailed" version, and
    • a second which contains the number of coverpoints in the hit by each testcase.

note that missed coverpoints are not shown in the per-testcase table entry data ๐Ÿ™ˆ.

the corresponding summary table is found on the 'directory' page of the default 3-level genhtml 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 ๐Ÿ˜ญ.

  • -b baseline-file-pattern, --baseline-file baseline-file-pattern โ€” use data in the files found from glob pattern baseline-file-pattern as coverage baseline ๐Ÿงฑ. --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 ๐ŸŒธ.

Okay so the coverage data files that baseline-file-pattern points at get read in and used as the baseline for classifying the change in coverage that the coverage counts in tracefile-patterns represent, bestie. And if baseline-file-pattern is a directory, genhtml will search that directory for all files ending in .info. Want to change that pattern? Check the info_file_extension section in man(5) lcovrc ๐Ÿ’…

Lowkey important: 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 just assumes there are no source differences between 'baseline' and 'current'. Like 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 โ€” uses 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 you don't pass this argument, the default is to use the creation time of the first file matched by baseline-file-pattern as the baseline date. Got multiple baseline files? Then the creation date of the first file is the one that gets used, no cap ๐Ÿซถ
  • --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-pattern and tracefile(s).
Note: ๐Ÿ“Œ - if filters are applied during the creation of a differential coverage report (see the --filter section, below), then those filters will be applied to the baseline coverage data (see the --baseline-file section, above) as well as to the current coverage data. It is important that the diff-file accurately reflect all source code changes so that the baseline coverage data can be correctly filtered ๐Ÿ˜ญ - Best practice is to use a --version-script callback to verify that source versions match before source-based filtering is applied ๐Ÿ’…

It is almost always a better idea to filter at capture or aggregate time โ€” not at report generation. Genuinely, listen to the manpage on this one.

A suitable "universal diff" input file for the --diff-file option can be generated using either the "p4udiff" or "gitdiff" sample scripts that are provided as part of this package, or by using revision control commands directly ๐Ÿ”ฅ

The "p4udiff" or "gitdiff" sample scripts are found in:

scripts/p4udiff

and

scripts/gitdiff

These scripts simply 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.

p4udiff accepts either a changelist ID or the literal string "sandbox"; "sandbox" indicates that there are modified files which have not been checked in. See gitdiff --help and p4udiff --help for more information ๐Ÿ‘‘

It is useful to note unchanged files denoted by lines of the form:

diff [optional header strings]
=== file_path

in the p4diff/gitdiff output, because 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 either GIC (covered) or UIC (not covered) while new or changed code will be categorized as either GNC or UNC ๐ŸŒˆ

  • --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. 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 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:

scripts/p4annotate

and

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 ๐ŸŽ€

Both sample scripts accept a number of options โ€” --cache, --verify, -b (or --ignore-whitespace) and --log โ€” which may be passed after the script name in the script,args form described in Script conventions above. See the Callback Scripts section of the LCOV documentation for details ๐Ÿ‘‘

๐Ÿงš Creating your own script ๐Ÿงš

When creating your own script, please first see Script considerations above for general calling conventions and script requirements, bestie ๐Ÿ™

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_data | date | source_code

where

  • commit_id is an ID identifying the last change to the line or NONE if this file is not checked in to your revision control system.
    • genhtml counts the file as not 'successfully annotated' if commit_id is NONE and as 'successfully annotated' otherwise ๐Ÿ‘€
  • author_data identifies the author of the last change.
    • For backward compatibility with existing annotate-script implementations, two author_data formats are supported:
      • string: the string used as both the 'abbreviated name' (used as 'owner' name in HTML output and callbacks) and as 'full name' (used in tooltip callbacks)
      • abbrev_string;full_name: the author_data string contains both an 'abbreviated name' and a 'full name' โ€” separated by a semicolon character (;).
        • This is useful when generating coverage reports for opensource software components where there are many 'External' contributors who you do not want to distinguish in 'owner' summary tables but you still want to know who the actual author was. (See the gitblame callback script for an example.) ๐Ÿ’–
  • 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:

scripts/criteria

The sample script checks that top-level line coverage meets the criteria UNC + LBC + UIC == 0 โ€” like, added code and newly activated code must be tested ๐Ÿ’…, and existing tested code must not become untested. Periodt.

As another example, you can absolutely cook up 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 you desire, bestie. Similarly, criteria may include branch and function coverage metrics. Iconic.

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 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:

script [additional_parameters] "name " " type" "coverage_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"
  • coverage_data โ€” is either a coverage data hash or a JSON representation of coverage data hash of the corresponding source code object. If the callback is a Perl module, then the it is passes a hash object โ€” otherwise, it is passed a JSON representation of that 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

  • 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.

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 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:

scripts/getp4version
scripts/gitversion

and

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.

  1. Compare source file version IDs
script --compare version_id_1 version_id_2 source_file_name

where

  • "version_id_1" โ€” is one of the two version IDs to compare
  • "version_id_2" โ€” is the other
  • "source_file_name" โ€” is the source code file name

One ID is the version ID found in the corresponding .info file and the other is the ID returned by calling script source_file_name โ€” but which of the two is passed first depends on the caller, so the comparison should not depend on the order ๐Ÿ™ˆ. Note that either ID can be the empty string, when only one of the two is known. The sample scripts provided with this package show the expected argument handling.

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

The arguments are passed to the script as separate arguments, without an intervening shell ๐Ÿš. A version ID or file name containing a space or a shell metacharacter therefore arrives as it was written.

Note that here โ€” unlike every other callback, whose answer is what it writes to stdout โ€” the exit status is the answer: a non-zero status means "the IDs do not match", and nothing else. A script which exits non-zero to report a problem of its own, such as a usage error or an unreachable server, is reporting a version mismatch. genhtml can tell that the script could not be executed at all, or that it was killed by a signal โ€” both are reported as an ignorable callback error โ€” but it cannot tell a non-zero exit status apart from an answer. โš ๏ธ
  • --resolve-script script โ€” use script to find the file path for some source file which which appears in an input data file if the file is not found after applying --substitute patterns and searching the --source-directory list. This option is equivalent to the resolve_script config file option. See lcovrc(5) for details.
  • --select-script callback โ€” use callback to decide whether a particular source line is interesting and should be included in the output data/generated report or not ๐Ÿ’–.

This option is equivalent to the select_script config file option. See lcovrc(5) for details.

  • --simplify-script callback โ€” use callback to shorten/simplify long demangled C++ function and template names to make the function detail table more compact and readable โ€” for example, to remove nested namespace names โœจ.

Note that the simplifications affect only the display and not the actual names stored in the coverage DB. In particular, the DB name (not the simplified name) is the one used to match --erase-function patterns ๐Ÿ‘‘.


  • --unreachable-script module โ€” okay bestie, this one lets you hand over a module to decide whether specific branch expressions and/or MC/DC conditions should get yeeted from the coverage report. It's giving the exact same energy as the unreachable_script config file option. Peep lcovrc(5) for the deets.

Heads up though: "module" has got to be a Perl module. No exceptions, no cap.

Also go read the โ€“unreachable-script discussion in the "Script conventions" section up above, plus the "Exclusion markers" section in geninfo(1). โœจ

  • --checksum โ€” this one's the vibe check for your source: should we compare the checksum stored in the tracefile against the checksum we compute from the actual source code? ๐Ÿ‘€

Checksum verification is disabled by default, jsyk.

When you turn it on, a checksum gets computed for every single source code line and then compared to the checksum found in the 'current' tracefile. Why? To help prevent any attempt to display source code that isn't identical to the code used to generate the coverage data. Basically it's an anti-catfish filter for your source files. ๐Ÿ’…

Ngl, this option is somewhat subsumed by the --version-script option โ€” which does something similar, but at the 'whole file' level. iykyk.

  • --fail-under-branches percentage โ€” use this to tell genhtml to exit with a status of 1 if the total branch coverage is less than percentage. That's it, that's the whole vibe. See lcov(1) for more details. ๐Ÿ”ฅ
  • --fail-under-lines percentage โ€” same deal but for lines, bestie: tell genhtml to exit with a status of 1 if the total line coverage is less than percentage. See lcov(1) for the full tea.
  • --new-file-as-baseline โ€” okay so 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 hasn't changed, their coverpoints get categorized as "included code": GIC or UIC.

But here's the plot twist ๐Ÿ˜ญ โ€” if the configuration of the coverage job was recently changed to instrument additional files, then all the un-exercised coverpoints in those files are gonna fall into the GIC category, which may cause certain coverage criteria checks to fail. Not the moment.

When you specify this option, genhtml pretends that the baseline data for the file is the same as the current data โ€” so coverpoints get categorized as CBC or UBC, which do not trigger the coverage criteria check. Slay.

Please note (fr fr): 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 โ€” so 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 aren't identical, then categorization may end up incorrect or just plain strange. ๐Ÿ™ˆ

When paths don't match, genhtml will produce "path" error messages to tell you about the mismatches.

If mismatches happen, the best solution is to fix the incorrect entries in the .info and/or unified-diff-file files. But if fixing those entries isn't 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 and --build-directory entries for a discussion of how to avoid spurious warnings and/or incorrect matches. ๐Ÿซถ

  • --synthesize-missing โ€” generate (fake) file content if the source file doesn't exist. This option can be used to work around otherwise fatal annotation errors. ๐Ÿ’€

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 โ€” so yeah, everyone's gonna see the fake ones.

This option is equivalent to the config file genhtml_synthesize_missing parameter; see lcovrc(5) for details.

  • --date-bins day[,day,โ€ฆ] โ€” the --date-bins option specifies age boundaries (cutpoints) for date-binning classification. Each age element is expected to be an integer number of days prior to today (or prior to your SOURCE_DATE_EPOCH environment variable, if set). If --date-bins isn't 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 option is equivalent to the genhtml_date_bins config file option. See lcovrc(5). ๐ŸŽ€

This argument has no effect if there's no source-annotation-script.

  • --date-labels string[,string,โ€ฆ] โ€” the --date-labels option specifies labels used for the 'date-bin' table entries in the HTML report. The number of labels should be one greater than the number of cutpoints. If not specified, the default is to use label strings which specify the [from ..to) range of ages held by the corresponding bin. โœจ

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. Cute, right?

This option is equivalent to the genhtml_date_labels config file option. See lcovrc(5).

This argument has no effect if there's no source-annotation-script.

  • --show-owners [ all ] โ€” if you use --show-owners, each coverage report header report contains 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 shows 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 responsible for non-code lines (e.g., comments) are not shown. This option does nothing if --annotate-script isn't used โ€” it needs revision control information provided by calling the script. No annotation script, no owner table, periodt.

Please note: if the all option isn't specified, the summary table will contain "Total" rows for all date/owner bins which aren't empty โ€” but there will be no secondary "File/Directory" entries for elements which have no "missed" coverpoints.

This option is equivalent to the config file genhtml_show_owner_table parameter; see 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 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 lcovrc(5) for details.

  • --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 you use --show-noncode, then the source code view will show annotations for both code and non-code lines. This argument has no effect if there's no source-annotation-script.

This option is equivalent to the config file genhtml_show_noncode_owners parameter; see lcovrc(5) for details.

  • --show-zero-columns โ€” by default, columns whose entries are all zero get removed (not shown) in the summary table at the top of each HTML page. If you use --show-zero-columns, then those columns will be shown. โœจ

When columns are retained, 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, 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. So like, pick your fighter. ๐Ÿฆ‹

  • --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 for non-differential reports.)

If you use --show-navigation, 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. Literally a glow-up for your workflow. ๐ŸŒธ

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 coverage report.

  • --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. Main character functions only, honestly.

This feature is disabled by default. Heads up tho โ€” it literally requires that you use a compiler version new enough to support function begin/end line reports, OR that you configure the tool to derive the required data itself (peep the derive_function_end_line discussion in lcovrc(5) ๐Ÿซถ).

  • --simplified-colors โ€” okay so by default every differential category gets its own unique color in the source code detail view, right? With this flag, only two colors get used: one for covered code and another for uncovered code. Simple, clean, minimal. But watch out โ€” ECB and EUB code is neither covered nor uncovered, so it may be kinda hard to tell apart in the source code view, since it'll 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 get 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 ๐Ÿ‘€.

Heads up again: 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 lcovrc(5).

  • --substitute regexp_pattern โ€” applies the Perl regexp regexp_pattern to source file names found during processing. Super useful when some file paths in the baseline or current .info file don't match your source layout and so the source code just... isn't found ๐Ÿ˜ญ. See the lcov man page for more details.

Note that the substitution patterns are applied to the --diff-file entries as well as the baseline and current .info files.

Patterns are applied after the directory separator in a name has been translated to this platform's, so a pattern which is to match input captured on the other platform gets written with the separator used here โ€” e.g., --substitute 's#^C:/##' to remove a Windows drive letter. See cross_platform_read in lcovrc(5) ๐Ÿฆ‹.

  • --omit-lines regexp_pattern โ€” exclude coverage data from lines whose content matches regexp.

Use this switch when 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 (that's the maximum number of forked child processes, bestie). If the optional integer parallelism parameter is zero or is missing, then use up the number of cores on the machine. Default is to use a single process (no parallelism). Iconic.

Also see the memory, memory_percentage, max_fork_fails and fork_fail_timeout entries in lcovrc(5).

How work is batched across the forked children is controlled by the max_tasks_per_core, dedicate_segment_threshold and dedicate_segment_line_estimate entries in lcovrc(5) โ€” the latter two arrange for a predicted long-running file to be given its own child process and scheduled first, so it doesn't serialize the tail of the run ๐Ÿ”ฅ.

Parallelism is also used when reading the coverage data (.info) files named on the command line (and by --baseline-file): each file is read in its own child process โ€” and if only one file is named, then that file is split at section boundaries and the pieces are read (and filtered) by several children at once. See the parallel_parse_min_lines and parallel_parse_chunks_per_worker entries in lcovrc(5) for the size at which a single file is split, how many pieces are used, and the cases in which it's read serially anyway.

A previously generated execution profile may help to enable better utilization and faster parallel execution. See the --profile and --history-script sections of this man page ๐Ÿ‘‘

  • --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 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 doesn't 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.

  • --filter filters โ€” specify a list of coverpoint filters to apply to input data.

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_extensions and rtl_file_extensions sections of 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:

  • 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 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 lcovrc(5) for a way to remove all identified exception branches.

  • brace: ignore line coverage counts on the closing brace of a 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.

If the lcovrc option filter_blank_aggressive = 1 is enabled, then blank lines will be ignored whether their 'hit' count is zero or not. Aggressive filtering may be useful in LLVM-generated coverage data, which tends to include large numbers of such lines ๐ŸŒธ.

  • directive: ignore lines which look like C compiler directives: #ifdef, #include, #define, etc. These lines are sometimes included by llvm-cov when LLVM profile data is translated to LCOV format.
  • exception: exclude branches related to C++ exception handling from branch coverage. Whether C++ exception branches are identified and removed is dependent on your compiler/toolchain correctly marking them in the generated coverage data. See the no_exception_branch section of lcovrc(5).
  • initializer: exclude lines which appear to be part of a C++ std::initializer_list.
  • line: alias for --filter brace,blank.
  • mcdc: remove an MC/DC coverpoint which contains a single expression, if a branch coverpoint is present on the same line. Single-element MC/DC coverpoints are identical to the corresponding branch โ€” except in the case of compile-time expression evaluation, for example, in a template function.
  • orphan: remove branches which appear by themselves โ€” i.e., the branch has only one destination and so cannot be a conditional.

These occur most frequently as a result of exception branch filtering.

  • range โ€” ignore line and branch coverpoints on lines that are out of range / whose line number goes past the end of the source file. These are giving gcov artifact energy, lowkey โ€” they pop up because of a macro instantiation on the very last line of the file.
    • region โ€” apply the LCOV_EXCL_START/LCOV_EXCL_STOP/LCOV_EXCL_LINE and LCOV_UNREACHABLE_START/LCOV_UNREACHABLE_STOP/LCOV_UNREACHABLE_LINE directives you wrote in your source text to the coverpoints found in the current and baseline .info files. This one is a whole lifesaver when the source code wasn't found during lcov --capture โ€ฆ but is accessible now. ๐Ÿ’…
    • branch_region โ€” apply the LCOV_EXCL_BR_START/LCOV_EXCL_BR_STOP/LCOV_EXCL_BR_LINE directives found in the source text to the coverpoints in the current and baseline .info files. Basically the same vibe as the region option above โ€” but it only touches branch coverpoints. โœจ
    • function โ€” combine data for every "unique" function that's defined at the same file/line. geninfo/gcov seem to have a bug where they create multiple entries for the same function ๐Ÿ˜ญ and this feature also merges, like, all the instances of the same template function / template method. Slay.
    • trivial โ€” remove trivial functions and their associated coverpoints. "Trivial" means the function body is empty / contains zero statements. Commonly these are the compiler-generated ones (e.g., default constructors and assignment operators) plus static initialization wrappers, etc.

Fr fr, note that the trivial filter needs function end line info โ€” so you gotta use a compiler version new enough to support begin/end line reports (e.g., gcc/9 or newer), or let lcov/genhtml/geninfo derive it for you:

In lcovrc(5), peep the derive_function_end_line setting and also the trivial_function_threshold setting. The first one flips end line calculation on or off, and the second changes the lookahead used to figure out whether the function body is empty. Also check the lcov_filter_parallel and lcov_filter_chunk_size settings โ€” those can boost your CPU performance if the number of files to process is, like, very large. ๐Ÿ”ฅ


  • -o, --output-directory output-directory โ€” create files in output-directory.

Use this option to tell genhtml to write the resulting files into a directory that isn't the current one. If output-directory doesn't exist, bestie, it will be created for you. ๐Ÿ’–

Honestly it's advisable to use this option, because depending on the project size a lot of files and subdirectories may get created. Like. A lot.

  • -t, --title title โ€” display title in the header table of all pages.

title gets written into the "Test:" field in the header table at the top of each generated HTML page, so you know the context in which a particular output was created. By default this is the name of the current tracefile.

A super common use is to drop in a test run name, or a version control system identifier (perforce changelist or git SHA, for example) that tells you which code level was tested. ๐ŸŽ€

  • --header-title BANNER โ€” display BANNER in the header of all pages.

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

A common glow-up: specify the name of the project or project branch plus the Jenkins build ID. ๐ŸŒธ

  • --footer FOOTER โ€” display FOOTER in the footer of all pages.

FOOTER gets 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 โ€” read test case descriptions from description-file.

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

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.

Keeps the descriptions found in the description file even if the coverage data indicates that the associated test case didn't 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 โ€” use external style sheet file css-file.

With this option you can specify an extra .css file which replaces 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.

  • --build-directory dirname โ€” to support "linked build directory" structures, add dirname to the list of places to search for soft links to source files โ€” e.g., to handle the case where those links point to source files held in your revision control system and appear in the --diff-file data. In this use case, the paths in the coverage data very likely refer to the structure the compiler saw during the build โ€” so resolving them back to the corresponding revision-controlled source structure is likely to succeed. iykyk โœจ

Look in dirname for file paths that appear in the 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.

  • --source-directory dirname โ€” add dirname to the list of places to look for source files.

For relative source file paths โ€” e.g. paths found in the tracefile, or in the 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 matching location is the one used. ๐Ÿฆ‹

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

  • -p, --prefix prefix โ€” remove prefix from all directory names.

Because lists with long filenames are genuinely painful to read, there's a mechanism that automatically tries to shorten all directory names on the overview page that begin with a common prefix. By default it uses an algorithm that tries to find the prefix which, when applied, minimizes the resulting sum of characters of all the directory names. Math ate, tbh.

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

prefix may be written with either platform's directory separator. It's the leading part of a path, and it's compared to the name as that name is decomposed โ€” so --prefix C:\proj removes the same directories from Windows-captured names as --prefix /C:/proj does. See cross_platform_read in lcovrc(5).

  • --no-prefix โ€” do not remove prefix from directory names.

This switch completely disables the prefix mechanism from 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 a source code view for each file. ๐Ÿ™ˆ

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

  • --no-html โ€” do not create HTML report.

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 you don't actually need the coverage report HTML itself. Main character energy: all the data, no html.

  • --num-spaces spaces โ€” change the appearance of tabs in the source view according to spaces.

When set to 0, tabs and their behaviour will be the browser's default.

Negative values will set the rendered width in the source view to spaces spaces.

Positive values will replace tabs with spaces 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 together with the --diff option of lcov to highlight those lines which were only covered in data sets that 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 the color coding in the resulting HTML output. No more guessing what the colors mean, we love to see it.

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 get 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 โ€” okay so this one lets you read a customized HTML epilog from epilog-file ๐ŸŽ€

Use it to replace the default HTML epilog (that's the final part of the HTML source, including </body>, bestie) with the contents of epilog-file. Iconic, honestly.

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

  • @basedir@ โ€” a relative path leading to the base directory (like, for locating css-files ๐Ÿ’…).

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

  • --html-extension extension โ€” use a 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. Lowkey important, don't forget it.

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. Both of those, or it's giving broken page ๐Ÿ˜ญ

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

  • --sort-tables, --no-sort โ€” specify whether to include sorted views of file and directory overviews ๐Ÿ“Š

Use --sort-tables 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. Chef's kiss sorting fr fr.

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). Yes, that's what it says โ€” literally the shortest one wins ๐Ÿ‘‘

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. Periodt.

  • --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. Not me pointing that out twice, it's just important.

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. So like, don't come for genhtml when that happens ๐Ÿ™ˆ

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

  • --mcdc-coverage โ€” specify whether to display Modified Condition / Decision Coverage (MC/DC) data in HTML output ๐Ÿงš

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:

  • T: โ€” True sense of subexpression was sensitized: if this subexpression's value had been false, then the condition result would have been different.
  • t: โ€” True sense of subexpression was not sensitized: the condition result would not change if the subexpression value was different.
  • F: โ€” False sense of subexpression was sensitized: if this subexpression's value had been true, then the condition result would have been different.
  • f: โ€” False sense of subexpression was not sensitized: the condition result would not change if the subexpression value was different.

Note that branch and MC/DC coverage are identical if the condition is a simple expression - e.g.,

   if (enable) ...

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. No sneaky escapes, bestie ๐Ÿซถ

This option can also be configured permanently using the configuration file option mcdc_coverage. See lcovrc(5).

Note that MC/DC coverpoints are defined differently by GCC and LLVM. This is the part where you go "wait, what" โ€” same energy ๐Ÿ’€

  • GCC: evaluates the sensitivity of the condition to the 'true' and 'false' sense of each constituent (leaf) expression independently.

That is: it evaluates the question: does the result of the condition change if this constituent expression changed from true to false (termed the 'true' sense, above) or from false to true (termed the 'false' sense, above).

For example, the expression A || B is sensitive to A==true when B==false, but is not sensitive to A==true when B==true.

  • LLVM: records the subexpression as covered if and only if there is a pair of evaluations of the condition such that the condition was sensitized for both 'true' and 'false' values of the subexpression. This is defined as an independence pair in the LLVM documentation.

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. It's all-or-nothing energy ๐Ÿ˜ค

See the examples in testcase โ€ฆ/tests/lcov/mcdc.

  • --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. Because nobody wants to read mangled symbols, be so fr.

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. Pipes are so main character ๐ŸŽ€

  • --msg-log [ log_file_name ] โ€” specify location to store error and warning messages (in addition to writing to STDERR) ๐Ÿ“ If log_file_name is not specified, then default location is used.
  • --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. Yeah, twice โ€” that's the trick.

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.
  • child โ€” the child process came back with a non-zero exit code while you were running --parallel. That's basically code for "the child actually hit an error", so go read the log file immediately above this message ๐Ÿ’€. Not to be confused with parallel, which means the child threw something unexpected/unhandled โ€” not a 'typical' lcov-style oopsie.
  • count โ€” way too many messages of one class got reported, so the rest of that type are getting suppressed now. The limit is controlled by the max_message_count variable. See lcovrc(5) (file://../man/lcovrc.5.html).
  • corrupt โ€” found a corrupt/unreadable coverage data file. rip ๐Ÿซ 
  • deprecated โ€” you're using a deprecated option. It WILL be removed in an upcoming release, so change your scripts now, bestie.
  • empty โ€” the patch file you handed to --diff-file doesn't contain any differences at all. That might be totally fine โ€” like if there were no source code changes between baseline and current (e.g. the only change was to modify a Makefile) โ€” or it might mean the file format isn't supported.
  • excessive โ€” your coverage data has a suspiciously large 'hit' count that's unlikely to be correct, which possibly points to a bug in your toolchain. Check the excessive_count_threshold section in lcovrc(5) (file://../man/lcovrc.5.html) for the details.
  • fork โ€” couldn't create a child process during --parallel execution.

If the message is ignored (--ignore-errors fork), then genhtml waits a brief period and then retries the failed execution.

If you keep seeing errors, either turn off or reduce parallelism, set a memory limit, or find a larger server to run the task on ๐Ÿ”ฅ.

  • format โ€” unexpected syntax or value found in the .info file โ€” for example, a negative number or a zero line number.

A count field that isn't a legal integer (like nan or inf) is likewise treated as zero if this message is ignored; a count that's a number but not an integer is truncated toward zero, and one too large to store is clamped at 9223372036854775807.

  • inconsistent โ€” your coverage data is internally inconsistent: it's making two or more mutually exclusive claims. Example time:
    • Files have been moved, or the repository history presented by --diff-file data isn't consistent with the coverage data โ€” for instance, an 'inserted' line has baseline coverage data. These are likely caused by inconsistent handling in the diff data compared to the baseline and current coverage data (e.g. using different source versions to collect the data but incorrectly annotating those differences), or by inconsistent treatment in the annotate script. Consider using a --version-script to guard against version mismatches.
    • Two or more gcov data files or lcov ".info" files report different end lines for the same function. That's likely either a gcc/gcov bug or a source version mismatch.

In this context, if the "inconsistent" error is ignored, then the tool records the largest number as the function end line.

  • Two or more gcov data files or lcov ".info" files report different start lines for the same function. Again, likely a gcc/gcov bug or a source version mismatch.

In this context, if the "inconsistent" error is ignored, then the tool retains only the first function definition it saw.

  • Mismatched function declaration/alias records encountered:
    • (backward compatible LCOV format) function execution count record (FNDA) without a matching function declaration record (FN).
    • (enhanced LCOV format) function alias record (FNA) without a matching function declaration record (FLN).
  • branch expression (3rd field in the .info file BRDA entry) of merge data doesn't match.

If the error is ignored, the offending record is skipped.

  • After all input data has been merged, some source file has data for two or more testcases, but one of its coverage types has data for only some of them โ€” for example, both testcases have line coverage data for the file, but only one of them has branch data. This is usually a sign that the tracefiles you're combining were captured with different coverage types enabled, and it means the per-testcase tables for that file are not directly comparable. The message is issued once per source file per coverage type per testcase:
no branch data for testcase_name in path/to/file.c

This is a warning, and the data is used as-is โ€” no coverpoints are added or removed.

  • internal โ€” internal tool issue detected ๐Ÿ˜ญ. Please report this bug along with a testcase.
  • mismatch โ€” incorrect or inconsistent information found in the coverage data and/or the source code โ€” for example, the source code contains overlapping exclusion directives.
  • missing โ€” remove all coverpoints associated with source files that aren't found or aren't readable. This is equivalent to adding a --exclude <name> pattern for each file that isn't found.

If a --resolve-script callback is specified, then the file is considered missing if it's not locally visible AND the callback returns "" (empty string) or undef โ€” otherwise it's not missing.

  • negative โ€” a negative 'hit' count was found.

A negative count is not a legal value for any cover type, so if this message is ignored, the count is treated as zero.

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'll need to recompile, re-run your tests, and re-capture coverage data ๐Ÿ™ˆ.

  • package โ€” a required perl package isn't installed on your system. In some cases it's possible to ignore this message and carry on โ€” but certain features will be disabled in that case.
  • parallel โ€” various types of errors related to parallelism, i.e. a child process died because of an error. The corresponding error message shows up in the log file immediately before the parallel error. If you see an error about parallel execution that seems invalid, it might be a good idea to remove the --parallel flag and try again. If removing the flag gives you a different result, please report the issue (with a testcase!) so the tool can be fixed ๐Ÿซถ.
  • path โ€” a file name found in the --diff-file file doesn't appear in either the baseline or the current trace data. These may be mapping issues โ€” different pathname in the tracefile vs. the diff file.
  • range โ€” the coverage data refers to a line number that's larger than the number of lines in the source file. This can be caused by a version mismatch or by an issue in the gcov data.
  • source โ€” the source code file for a data set couldn't be found.
  • unmapped โ€” coverage data for a particular line can't be found, possibly because the source code wasn't found, or because the line number mapping in the .info file is wrong.

This can happen if the source file used in HTML generation isn't the same as the file used to generate the coverage data โ€” like, lines have been added or removed.

  • unreachable โ€” a coverpoint (line, branch, function, or MC/DC) inside an "unreachable" region got executed (hit); either the code, the directive placement, or both are wrong. If the error is ignored, the offending coverpoint is retained (not excluded) or not, depending on the value of the retain_unreachable_coverpoints_if_executed configuration parameter. See lcovrc(5) (file://../man/lcovrc.5.html) and the "Exclusion markers" section of geninfo(1) (file://../man/geninfo.1.html) for more info.
  • unsupported โ€” the requested feature isn't supported for this tool configuration. For example, function begin/end line range exclusions use some GCOV features that aren't available in older GCC releases ๐Ÿ’….
  • unused โ€” the include/exclude/erase/substitute/omit pattern didn't match any file pathnames.
  • usage โ€” unsupported usage detected โ€” e.g. an unsupported option combination.
  • utility โ€” a tool called during processing returned an error code (e.g. find encountered an unreadable directory).
  • version: โ€” the --version-script comparison came back with a non-zero mismatch indication, and ngl that's a red flag ๐Ÿšฉ. It likely means the version of the file used when the coverage data was extracted is different from the source version that got found. Translation: the file annotations may be incorrect, so don't fully trust the pretty numbers.

Okay so bestie, listen โ€” some of these error messages are caused by stuff you literally cannot fix yourself. Like, no cap. Example: bugs in your tool chain that produce inconsistent coverage DB data (the situation right up there โ˜๏ธ). In those cases, after you've actually read the messages, you've got options:

  • exclude the offending code or the entire offending file ๐Ÿซถ
  • or just ignore the messages โ€” either by converting them to warnings or suppressing them entirely

Another alternative? Tell genhtml how many messages you're expecting โ€” then it can warn you if something changes and the count differs, so you know it's time to review the messages again. That's the --expect-message-count flag, coming at you below ๐Ÿ‘‡

Also, peep lcovrc(5) <file://../man/lcovrc.5.html> for a whole discussion of the max_message_count parameter, which controls the number of warnings emitted before all subsequent messages get suppressed. Use it to keep your log file volume from becoming a whole vibe crisis. ๐Ÿ’…


  • --expect-message-count message_type:expr[,message_type:expr] โ€” give genhtml a constraint on how many messages of one or more types it should be producing during execution.

Heads up: the total includes _all_ messages of the given type โ€” even the ones that got suppressed. If the constraint isn't true, an error of type count (see above) gets generated. ๐Ÿ’€

message_type is one of the message mnemonics described above, and expr can be either:

  • an integer โ€” interpreted as "there should be exactly this many messages of the corresponding type", or
  • a Perl expression containing the substring %C; %C gets replaced with the total number of messages of the corresponding type and then evaluated. The constraint is met if the result is non-zero, and not met otherwise.

For example:

--expect-message-count inconsistent:5

says we expect exactly 5 messages of type inconsistent.

--expect-message-count inconsistent:%C==5

also says we expect exactly 5 messages of this type, just specified using expression syntax.

--expect-message-count 'inconsistent : %C > 6 && %C <= 10'

says we expect the number of messages to be in the range (6:10]. (Note that quoting may be necessary, to protect whitespace from interpretation by your shell, if you want to improve expression readability by adding spaces to your expression. Your shell is not your friend here, bestie ๐Ÿ˜ญ)

Multiple constraints can be specified using a comma-separated list, or by using the option multiple times. Slay. โœจ

This flag is equivalent to the expect_message_count configuration option. See lcovrc(5) <file://../man/lcovrc.5.html> 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's evaluated.

  • --keep-going โ€” do not stop if an error occurs: attempt to generate a result, however flawed. It's giving "we're finishing this report even if it's ugly" ๐Ÿ’€. This command line option corresponds to the stop_on_error lcovrc option. See lcovrc(5) <file://../man/lcovrc.5.html> for more details.
  • --config-file config-file โ€” specify a configuration file to use. See lcovrc(5) <file://../man/lcovrc.5.html> for details of the file format and options. Also see the config_file entry in the same man page for details on how to include one config file into another.

When this option is specified, neither the system-wide configuration file /etc/lcovrc, nor the per-user configuration file ~/.lcovrc is read. Iconic isolation behavior ๐ŸŽ€

This option may be useful when there's 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. (Yes, it's that kind of option ๐Ÿ™ˆ)

  • --profile [ profile-data-file ] โ€” tell the tool to keep track of performance and other configuration data. If the optional profile-data-file isn't specified, then the profile data is written to a file named genhtml.json in the output directory.

Profile data is useful if you're trying to optimize the lcov implementation (see $LCOV_ROOT/share/lcov/support-scripts/spreadsheet.py), and can also enable faster genhtml --parallel execution (see the "--history-script" section of this man page).

  • --history-script script โ€” tell the tool to use performance data from a prior job to predict resource usage by the current job. This may allow better segmentation, enabling more balanced workloads between parallel threads โ€” thus improving wall clock execution time. Highkey a glow-up for your build times ๐Ÿ”ฅ

A common source for the previous-profile-data-file is the profile data generated by a prior regression suite execution. See $LCOV_ROOT/share/lcov/example and $LCOV_ROOT/share/lcov/support-scripts/history.pm in the installed release (or .../example in the source repository).

  • --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) <file://../man/lcovrc.5.html> for a list of available keywords and their meaning. Go off, override everything ๐Ÿ’…

  • --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.

  • --merge-aliases โ€” functions whose file/line is the same are considered to be aliases; genhtml uses the shortest name in the list of aliases (fewest characters) as the leader. ๐Ÿ‘‘

This option counts each alias group as a single object โ€” so the function count will be the number of distinct function groups rather than the total number of aliases of all functions โ€” and displays them as groups in the function detail table.

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.

  • --suppress-aliases โ€” suppress the list of aliases in the function detail table.

Functions whose file/line is the same are considered to be aliases; genhtml 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. Fr fr, decluttering is self care ๐ŸŒธ

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 โ€” 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 the user doesn't need per-testcase coverage summary in coverage reports. Memory said "thank you" ๐Ÿงš

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

  • --missed โ€” show counts of missed lines, functions, branches, and MC/DC expressions.

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-tables, 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. Your retinas will thank you, bestie ๐Ÿซถ

  • --tempdir dirname โ€” write temporary and intermediate data under the indicated directory. Default is the platform temporary directory: $TMPDIR, $TEMP or $TMP if one of them names a writeable directory, otherwise "/tmp" on Unix or "C:\temp" on Windows.

A uniquely named subdirectory of dirname is created for the run, and the data is written there โ€” so several runs can share one dirname without colliding. dirname itself is created if it doesn't exist.

Unless --preserve is specified, the generated subdirectory and its contents are removed when genhtml exits.

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

  • --preserve โ€” preserve intermediate data files generated by various steps in the tool โ€” e.g., for debugging. By default, these files are deleted. Keep your little artifacts safe ๐ŸŽ€
  • --save โ€” copy unified-diff-file, baseline_trace_files, 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. Archive girly behavior and we respect it โœจ

  • --sort-input โ€” specify whether to sort file names before capture and/or aggregation. Sorting reduces certain types of processing order-dependent output differences. See the sort_input section in lcovrc(5) <file://../man/lcovrc.5.html>. Consistency is a whole aesthetic ๐Ÿ’…
  • --serialize file_name โ€” save coverage database to file_name.

Like, by default this file is in LCOV's XS binary format, bestie. But if the environment variable LCOV_PURE_PERL=1 is set, then genhtml will write the file in Perl "Storable" format instead. And these formats are not compatible with each other โ€” the way that it works is: if you serialize binary data, then you must deserialize binary data, and vice versa. No mixing, no matching, no "close enough" ๐Ÿ™ˆ

Heads up: this option may significantly increase genhtml memory requirements, because a great deal of data must be retained. So likeโ€ฆ maybe watch your RAM, babe ๐Ÿ’€

๐Ÿ—‚๏ธ FILES

  • /etc/lcovrc โ€” the system-wide configuration file โœจ
  • ~/.lcovrc โ€” the per-user configuration file ๐ŸŽ€

๐ŸŒˆ Sample --diff-file data creation scripts

  • scripts/p4udiff โ€” a sample script for use with --diff-file that creates a unified diff file via Perforce ๐Ÿฆ‹
  • scripts/gitdiff โ€” a sample script for use with --diff-file that creates a unified diff file via git ๐ŸŒธ

๐Ÿ’… Sample --annotate-script callback Perl modules

  • scripts/p4annotate.pm โ€” a sample script written as a Perl module for use with --annotate-script that provides annotation data via Perforce ๐Ÿ’œ
  • scripts/gitblame.pm โ€” a sample script written as a Perl module for use with --annotate-script that provides annotation data via git โญ

๐Ÿ”ฅ Sample --criteria-script callback Perl modules

  • scripts/criteria.pm โ€” a sample script written as a Perl module for use with --criteria-script that implements a check for "UNC + LBC + UIC == 0" ๐Ÿ‘‘
  • scripts/threshold.pm โ€” a sample script written as a Perl module to check for minimum acceptable line and/or branch and/or and/or MC/DC function coverage. For example, the

"genhtml --fail_under_lines 75 โ€ฆ"

feature can instead be realized by

"genhtml --criteria-script scripts/threshold.pm,--line,75 โ€ฆ"

๐Ÿงš Sample --simplify-script callback Perl module

  • scripts/simplify.pm โ€” a sample script written as Perl module for use with --simplify-script that implements regular expression substitutions for function name simplification โœจ

๐Ÿซถ Sample --version-script callback Perl modules and scripts

  • scripts/getp4version โ€” a sample script for use with --version-script that obtains version IDs via Perforce ๐Ÿฆ‹
  • scripts/P4version.pm โ€” a perl module with similar functionality to getp4version but higher performance ๐Ÿ”ฅ
  • scripts/get_signature โ€” a sample script for use with --version-script that uses md5hash as version IDs ๐Ÿ’…
  • scripts/gitversion.pm โ€” a perl module with for use with --version-script which retrieves version IDs from git ๐ŸŒธ
  • scripts/batchGitVersion.pm โ€” a perl module with similar functionality to gitversion.pm but higher performance โญ

๐Ÿ‘‘ 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

https://github.com/linux-test-project/lcov ๐Ÿ”—


2024-2026, LCOV Project


okay that's literally the whole page bestie, you ate that ๐Ÿ’…โœจ this iconic little number is GENHTML(1) from version 2.6, dated 2026-10-03 โ€” so like, go forth and generate those HTML coverage reports, no cap ๐ŸŽ€๐Ÿฆ‹๐ŸŒˆ

๐Ÿ“ฆ where this page comes from