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
- one or more baseline-files specified via
--baseline-file, and - 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:
- 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#ifdefstatement. - Source code changes: a line can be unchanged, added (
+ =>), or removed (=> -). Note that the diff-file format used bygenhtmlreports 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:
- If the callback script name ends in
.pmthen 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
$textis the source text from the corresponding line (without newline termination)$abbrevis 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 thegenhtml_annotate_tooltipentry inlcovrc(5). Heads up:$fullnamemay beundefif 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.
- The option may be specified as a single
split_charseparated string which is divided into words (seelcovrc(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.
- 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.
- 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$datareturned 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 ๐ง.$datais 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--quietflag.-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 variableLCOV_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:
- top-level: table of all directories,
- directory: table of source files in a directory, and
- 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:
- top-level: table of all project source files, and
- 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 theGD.pmPerl 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,genhtmlgenerates 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 ๐ญ.
-bbaseline-file-pattern,--baseline-filebaseline-file-pattern โ use data in the files found from glob pattern baseline-file-pattern as coverage baseline ๐งฑ.--baseline-filemay 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-titletitle โ uses title as the descriptive label text for the source of coverage baseline data ๐--baseline-datedate โ 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-datedate โ 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-filediff-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--filtersection, below), then those filters will be applied to the baseline coverage data (see the--baseline-filesection, 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-scriptcallback 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-scriptscript โ 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 yourP4USER,P4CLIENT, orP4PORTenvironment 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
NONEif this file is not checked in to your revision control system.- genhtml counts the file as not 'successfully annotated' if commit_id is
NONEand as 'successfully annotated' otherwise ๐
- genhtml counts the file as not 'successfully annotated' if commit_id is
- 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
gitblamecallback script for an example.) ๐
- 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
- For backward compatibility with existing annotate-script implementations, two author_data formats are supported:
- 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-scriptscript โ 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 executableadditional_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 datatypeโ 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 databin_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 brancheshitโ defines the number of hit lines, functions, or branchescategoryโ 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-scriptscript โ 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:
- 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.
- 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-scriptscript โ 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--substitutepatterns and searching the--source-directorylist. This option is equivalent to theresolve_scriptconfig file option. Seelcovrc(5)for details.--select-scriptcallback โ 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-scriptcallback โ 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 amoduleto 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 theunreachable_scriptconfig file option. Peeplcovrc(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 tellgenhtmlto exit with a status of1if the total branch coverage is less thanpercentage. That's it, that's the whole vibe. Seelcov(1)for more details. ๐ฅ--fail-under-lines percentageโ same deal but for lines, bestie: tellgenhtmlto exit with a status of1if the total line coverage is less thanpercentage. Seelcov(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-dateoption).
--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'
.infofiles, and - the basename of the path in the
.infofile 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-binsoption 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 yourSOURCE_DATE_EPOCHenvironment variable, if set). If--date-binsisn'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 thegenhtml_date_binsconfig file option. Seelcovrc(5). ๐
This argument has no effect if there's no source-annotation-script.
--date-labels string[,string,โฆ]โ the--date-labelsoption 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 nosource-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 ๐ญ.--excludepattern โ pattern is a glob-match pattern of filenames to exclude from the report. Files which do NOT match will be included. See thelcovman page for details โจ.--includepattern โ pattern is a glob-match pattern of filenames to include in processing. Files which do not match get excluded from the report. See thelcovman page for details โจ.--erase-functionsregexp โ 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-cppoption 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).
--substituteregexp_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.infofile don't match your source layout and so the source code just... isn't found ๐ญ. See thelcovman 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-linesregexp_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 ๐
--memoryinteger โ specify the maximum amount of memory to use during parallel processing, in Mb. Effectively, the process will notfork()if this limit would be exceeded. Default is0(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.
--filterfilters โ 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-coverageis 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 agcovartifact 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 byllvm-covwhen 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 theno_exception_branchsection oflcovrc(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 abranchcoverpoint 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 theLCOV_EXCL_START/LCOV_EXCL_STOP/LCOV_EXCL_LINEandLCOV_UNREACHABLE_START/LCOV_UNREACHABLE_STOP/LCOV_UNREACHABLE_LINEdirectives you wrote in your source text to the coverpoints found in the current and baseline.infofiles. This one is a whole lifesaver when the source code wasn't found duringlcov --capture โฆbut is accessible now. ๐branch_regionโ apply theLCOV_EXCL_BR_START/LCOV_EXCL_BR_STOP/LCOV_EXCL_BR_LINEdirectives found in the source text to the coverpoints in the current and baseline.infofiles. Basically the same vibe as theregionoption above โ but it only touches branch coverpoints. โจfunctionโ combine data for every "unique" function that's defined at the same file/line.geninfo/gcovseem 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-directoryoutput-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,--titletitle โ 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-titleBANNER โ 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. ๐ธ
--footerFOOTER โ 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-filedescription-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-filecss-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-directorydirname โ 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-filedata. 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-directorydirname โ 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,--prefixprefix โ 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-spacesspaces โ 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-prologprolog-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 locatingcss-files).
This option can also be configured permanently using the configuration file option genhtml_html_prolog.
--html-epilogepilog-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-extensionextension โ 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.htaccessfile 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 toSTDERR) ๐ If log_file_name is not specified, then default location is used.--ignore-errorserrors โ 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-scriptreturned 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.infofile 'BRDA' entry) does not follow expected integer sequence.callback:โ Annotate, version, or criteria script error.category:โ Line number categorizations are incorrect in the.infofile, 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 withparallel, 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 themax_message_countvariable. Seelcovrc(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-filedoesn't contain any differences at all. That might be totally fine โ like if there were no source code changes betweenbaselineandcurrent(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 theexcessive_count_thresholdsection inlcovrc(5)(file://../man/lcovrc.5.html) for the details.forkโ couldn't create a child process during--parallelexecution.
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.infofile โ 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-filedata isn't consistent with the coverage data โ for instance, an 'inserted' line has baseline coverage data. These are likely caused by inconsistent handling in thediffdata compared to thebaselineandcurrentcoverage data (e.g. using different source versions to collect the data but incorrectly annotating those differences), or by inconsistent treatment in theannotatescript. Consider using a--version-scriptto 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.
- Files have been moved, or the repository history presented by
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).
- (backward compatible LCOV format) function execution count record (
- branch expression (3rd field in the
.infofileBRDAentry) 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--parallelflag 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-filefile 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.infofile 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 theretain_unreachable_coverpoints_if_executedconfiguration parameter. Seelcovrc(5)(file://../man/lcovrc.5.html) and the "Exclusion markers" section ofgeninfo(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.findencountered an unreadable directory).version:โ the--version-scriptcomparison 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-countmessage_type:expr[,message_type:expr] โ givegenhtmla 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;%Cgets 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 thestop_on_errorlcovrcoption. Seelcovrc(5) <file://../man/lcovrc.5.html>for more details.--config-fileconfig-file โ specify a configuration file to use. Seelcovrc(5) <file://../man/lcovrc.5.html>for details of the file format and options. Also see theconfig_fileentry 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 namedgenhtml.jsonin 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-scriptscript โ 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).
--rckeyword = 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 ๐
--precisionnum โ 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;genhtmluses 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.infofile โ 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 ๐ซถ
--tempdirdirname โ write temporary and intermediate data under the indicated directory. Default is the platform temporary directory:$TMPDIR,$TEMPor$TMPif 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โ copyunified-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 thesort_inputsection inlcovrc(5) <file://../man/lcovrc.5.html>. Consistency is a whole aesthetic ๐--serializefile_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-filethat creates a unified diff file via Perforce ๐ฆscripts/gitdiffโ a sample script for use with--diff-filethat 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-scriptthat provides annotation data via Perforce ๐scripts/gitblame.pmโ a sample script written as a Perl module for use with--annotate-scriptthat 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-scriptthat 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-scriptthat 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-scriptthat obtains version IDs via Perforce ๐ฆscripts/P4version.pmโ a perl module with similar functionality togetp4versionbut higher performance ๐ฅscripts/get_signatureโ a sample script for use with--version-scriptthat usesmd5hashas version IDs ๐scripts/gitversion.pmโ a perl module with for use with--version-scriptwhich retrieves version IDs from git ๐ธscripts/batchGitVersion.pmโ a perl module with similar functionality togitversion.pmbut 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
lcov(1)<file://../man/lcov.1.html>lcovrc(5)<file://../man/lcovrc.5.html>geninfo(1)<file://../man/geninfo.1.html>llvm2lcov(1)<file://../man/llvm2lcov.1.html>perl2lcov(1)<file://../man/perl2lcov.1.html>py2lcov(1)<file://../man/py2lcov.1.html>gendesc(1)<file://../man/gendesc.1.html>gcov(1)<file://../man/gcov.1.html>
https://github.com/linux-test-project/lcov ๐
๐ Copyright
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
- arch rolling: lcov 2.6-1 ยท GPL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms