LCOV(1)
okay bestie, welcome to the lcov(1) page β manual name LCOV β and we're about to make coverage data make sense π
β¨
πΈ NAME πΈ
lcov β lcov documentation.
πΈ NAME, again (yes, it's literally the section name, bestie) πΈ
lcov β Capture and manipulate coverage data from lcov tracefiles or gcov.
π¦ SYNOPSIS π¦
Bestie, here's the whole menu of ways to run lcov. First up: capture a coverage data tracefile from compiler-generated data. The lcov tracefile (the β.infoβ file) format is described in geninfo(1) (file://../man/geninfo.1.html).
lcov -c | --capture
[ -d | --directory *directory* ]
[ -k | --kernel-directory *directory* ]
[ -o | --output-file *tracefile* ]
[ -t | --test-name *testname* ]
[ -b | --base-directory *directory* ]
[ --build-directory *directory* ]
[ --source-directory *directory* ]
[ -i | --initial ]
[ --all ]
[ --gcov-tool *tool* ]
[ --branch-coverage ]
[ --mcdc-coverage ]
[ --demangle-cpp [ *param* ] ]
[ --checksum ]
[ --no-checksum ]
[ --no-recursion ]
[ -f | --follow ]
[ --sort-input ]
[ --compat-libtool ]
[ --no-compat-libtool ]
[ --msg-log [ *log_file_name* ] ]
[ --ignore-errors *errors* ]
[ --expect-message-count *message_type=expr[,message_type=expr..]* ]
[ --preserve ]
[ --to-package *package* ]
[ --from-package *package* ]
[ --no-markers ]
[ --external ]
[ --no-external ]
[ --compat *mode*\ =on|off|auto]
[ --context-script *script_file* ]
[ --criteria-script *script_file* ]
[ --history-script *callback* ]
[ --resolve-script *script_file* ]
[ --version-script *script_file* ]
[ --unreachable-script *callback* ]
[ --comment *comment_string* ]
[ --large-file *regexp* ]
Generate a tracefile from compiler-generated data with all counter values set to zero β a little reset moment, no cap:
lcov -z | --zerocounters
[ -d | --directory *directory* ]
[ --no-recursion ]
[ -f | --follow ]
Show the coverage counts recorded in previously generated tracefiles:
lcov -l | --list *tracefile*
[ --list-full-path ]
[ --no-list-full-path ]
Aggregate multiple coverage tracefiles into one:
lcov -a | --add-tracefile *tracefile_patterns*
[ -o | --output-file *tracefile* ]
[ --prune-tests ]
[ --forget-test-names ]
[ --map-functions ]
[ --branch-coverage ]
[ --mcdc-coverage ]
[ --checksum ]
[ --no-checksum ]
[ --sort-input ]
Depending on your use model, it may not be necessary to create aggregate coverage data files. For example, if your regression tests are split into multiple suites, you may want to keep separate suite data and to compare both per-suite and aggregate results over time. genhtml allows you specify tracefiles via one or more glob patterns β which enables you generate aggregate reports without explicitly generating aggregated trace files. See the genhtml man page.
Generate a new tracefile from an existing tracefile, keeping only data from files matching the pattern:
lcov -e | --extract *tracefile pattern*
[ -o | --output-file *tracefile* ]
[ --checksum ]
[ --no-checksum ]
Generate a new tracefile from an existing tracefile, removing data from files matching the pattern:
lcov -r | --remove *tracefile pattern*
[ -o | --output-file *tracefile* ]
[ --checksum ]
[ --no-checksum ]
Generate a new tracefile from existing tracefiles by performing set operations on coverage data β math but make it coverage π :
lcov --intersect *rh_glob_pattern*
[ -o | --output-file *tracefile* ]
lh_glob_pattern
The output will reflect:
(union of files matching lh_glob_patterns) intersect (union of files
matching rh_glob_patterns)
such that coverpoints found in both sets are merged (summed) whereas coverpoints found in only one set are dropped. Note that branch blocks are defined to be the same if and only if their block ID and the associated branch expressions list are identical. Functions are defined to be the same if their name and location are identical.
lcov --subtract *rh_glob_pattern*
[ -o | --output-file *tracefile* ]
lh_glob_pattern
The output will reflect:
(union of files matching lh_glob_patterns) subtract (union of files
matching rh_glob_patterns)
such that coverpoints found only in the set on the left will be retained and all others are dropped.
Summarize tracefile content:
lcov --summary *tracefile*
Print version or help message and exit:
lcov [ -h | --help ]
[ --version ]
Common lcov options β supported by all the above use cases, bestie:
lcov [ --keep-going ]
[ --filter *type* ]
[ -q | --quiet ]
[ -v | --verbose ]
[ --comment *comment_string* ]
[ --debug ]
[ --parallel | -j [*integer*] ]
[ --memory *integer_num_Mb* ]
[ --tempdir *dirname* ]
[ --branch-coverage ]
[ --mcdc-coverage ]
[ --config-file *config-file* ]
[ --rc *keyword*\ =\ *value* ]
[ --profile [ *profile-file* ] ]
[ --include *glob_pattern* ]
[ --exclude *glob_pattern* ]
[ --erase-functions *regexp_pattern* ]
[ --substitute *regexp_pattern* ]
[ --omit-lines *regexp_pattern* ]
[ --fail-under-branches *percentage* ]
[ --fail-under-lines *percentage* ]
π DESCRIPTION π
lcov is a graphical front-end for GCC's coverage testing tool gcov. It collects line, function and branch coverage data for multiple source files and creates HTML pages containing the source code annotated with coverage information. It also adds overview pages for easy navigation within the file structure.
Use lcov to collect coverage data and genhtml to create HTML pages. Coverage data can either be collected from the currently running Linux kernel or from a user space application. To do this, you have to complete the following preparation steps:
- For Linux kernel coverage: Follow the setup instructions for the gcov-kernel infrastructure:
https://docs.kernel.org/dev-tools/gcov.html - For user space application coverage: Compile the application with GCC using the options
-fprofile-arcsand-ftest-coverageor--coverage.
Please note that this man page refers to the output format of lcov as β.info fileβ or βtracefileβ and that the output of GCOV is called β.da fileβ.
Also note that when printing 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 (file://../man/gcov.1.html).
By default, lcov and related tools generate and collect line and function coverage data. Branch data is not collected or displayed by default; all tools support the --branch-coverage and --mcdc-coverage options to enable branch and 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 man lcovrc(5) (file://../man/lcovrc.5.html) for details.
β¨ OPTIONS β¨
In general, (almost) all lcov options can also be specified in a configuration file β see man lcovrc(5) (file://../man/lcovrc.5.html) for details.
-atracefile_patterns,--add-tracefiletracefile_patterns β Add contents of all files matching glob pattern tracefile_patterns. Specify several tracefiles using the-aswitch to combine the coverage data contained in these files by adding up execution counts for matching test and filename combinations. The result of the add operation will be written to stdout or the tracefile specified with-o. Only one of-z,-c,-a,-e,-r,-lor--summarymay be specified at a time.-bdirectory,--base-directorydirectory β Use directory as base directory for relative paths. Use this option to specify the base directory of a build-environment whenlcovproduces error messages like:ERROR: could not read source file /home/user/project/subdir1/subdir2/subdir1/subdir2/file.c. In this example, use/home/user/projectas base directory. This option is required when usinglcovon projects built with libtool or similar build environments that work with a base directory, i.e. environments, where the current working directory when invoking the compiler is not the same directory in which the source code file is located. Note that this option will not work in environments where multiple base directories are used. In that case use configuration file settinggeninfo_auto_base=1(see manlcovrc(5)(file://../man/lcovrc.5.html)).--build-directorybuild_directory β search for.gcnodata files from build_directory rather than adjacent to the corresponding.gcdafile. See mangeninfo(1)(file://../man/geninfo.1.html) for details.--source-directorydirname β Add β*dirname*β to the list of places to look for source files. For relative source file paths listed in e.g. paths found in tracefile, or found ingcovoutput during--captureβ possibly after substitutions have been applied βlcovwill first look for the path from βcwdβ (wheregenhtmlwas invoked) and then from each alternate directory name in the order specified. The first location matching location is used. This option can be specified multiple times, to add more directories to the source search path.-c,--captureβ Capture runtime coverage data. By default captures the current kernel execution counts and writes the resulting coverage data to the standard output. Use the--directoryoption to capture counts for a user space program. The result of the capture operation will be written to stdout or the tracefile specified with-o. When combined with the--allflag, both runtime and compile-time coverage will be extracted in one step. See the description of the--initialflag, below. See mangeninfo(1)(file://../man/geninfo.1.html) for more details about the capture process and available options and parameters.
Okay so first up: if your project is big, you can make that capture go brrr with the --parallel option. π¨ How the work gets batched across those forked children β and how a large compilation unit gets its own child process so it doesnβt serialize the tail of the run β is controlled by these entries in lcovrc(5): geninfo_chunk_size, geninfo_dedicate_segment_size, dedicate_segment_threshold, and dedicate_segment_line_estimate. Also peep the --large-file option below, bestie β it handles the related-but-distinct problem of a single file whose memory footprint could exhaust available memory during parallel processing. π
β οΈ Real talk: only one of-z,-c,-a,-e,-r,-l,--diffor--summarymay be specified at a time.
--branch-coverageβ Collect and/or retain branch coverage data. β¨ This is literally equivalent to using the option--rc branch_coverage=1; the option was added to better match thegenhtmlinterface.--mcdc-coverageβ Collect and retain MC/DC data. This is equivalent to using the option--rc mcdc_coverage=1. MC/DC coverage is supported for GCC versions 14.2 and higher, or LLVM 18.1 and higher. Seellvm2lcov --helpfor details on MC/DC data capture in LLVM. See the MC/DC section ofman genhtml(1)for more details.--checksum,--no-checksumβ Specify whether to generate checksum data when writing tracefiles and/or to verify matching checksums when combining trace files. Use--checksumto enable checksum generation or--no-checksumto disable it. Checksum generation is disabled by default. When checksum generation is enabled, a checksum will be generated for each source code line and stored along with the coverage data. This checksum will be used to prevent attempts to combine coverage data from different source code versions. If you donβt work with different source code versions, disable this option to speed up coverage data processing and to reduce the size of tracefiles. Note that this option is somewhat subsumed by the--version-scriptoption β which does something similar, but at the βwhole fileβ level. π--compat mode=value*[,*mode=value,β¦]β Set compatibility mode. Use--compatto specify thatlcovshould enable one or more compatibility modes when capturing coverage data. You can provide a comma-separated list ofmode=valuepairs to specify the values for multiple modes.
Valid values are:
onβ Enable compatibility mode.offβ Disable compatibility mode.autoβ Apply auto-detection to determine if compatibility mode is required. Note that auto-detection is not available for all compatibility modes.
If no value is specified, βonβ is assumed as default value.
Valid modes are:
libtoolβ Enable this mode if you are capturing coverage data for a project that was built using the libtool mechanism. See also--compat-libtool. The default value for this setting is βonβ.hammerβ Enable this mode if you are capturing coverage data for a project that was built using a version of GCC 3.3 that contains a modification (hammer patch) of later GCC versions. You can identify a modified GCC 3.3 by checking the build directory of your project for files ending in the extension β.bbgβ. Unmodified versions of GCC 3.3 name these files β.bbβ. The default value for this setting is βautoβ.split_crcβ Enable this mode if you are capturing coverage data for a project that was built using a version of GCC 4.6 that contains a modification (split function checksums) of later GCC versions. Typical error messages when runninglcovon coverage data produced by such GCC versions are βout of memoryβ and βreached unexpected end of fileβ. The default value for this setting is βautoβ.
--compat-libtool,--no-compat-libtoolβ Specify whether to enable libtool compatibility mode. Use--compat-libtoolto enable libtool compatibility mode or--no-compat-libtoolto disable it. The libtool compatibility mode is enabled by default. When libtool compatibility mode is enabled,lcovwill assume that the source code relating to a.dafile located in a directory named β.libsβ can be found in its parent directory. If you have directories named β.libsβ in your build environment but donβt use libtool, disable this option to prevent problems when capturing coverage data. π«Ά--config-fileconfig-file β Specify a configuration file to use. Seeman lcovrc(5)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~/.lcovrcis read. This option may be useful when there is a need to run several instances oflcovwith different configuration file options in parallel. Note that this option must be specified in full β abbreviations are not supported. π«--profile[profile-data-file] β Tell the tool to keep track of performance and other configuration data. If the optional profile-data-file is not specified, then the profile data is written to a file named with the same basename as the--output-filename, with suffix β.jsonβ appended. Profile data is useful if you are trying to optimize thelcovimplementation (see$LCOV_ROOT/share/lcov/support-scripts/spreadsheet.py), and can also enable faster--parallelexecution (see the β--history-scriptβ section of this man page). π₯--history-scriptcallback β Use callback to predict current runtime cost using observed cost from prior execution. Seeman genhtml(1)for more information.
β οΈ Again for the people in the back: only one of-z,-c,-a,-e,-r,-l,--diffor--summarymay be specified at a time.
-ddirectory,--directorydirectory β Use.dafiles in directory instead of kernel. If you want to work on coverage data for a user space program, use this option to specify the location where the program was compiled (thatβs where the counter files ending with.dawill be stored). Note that you may specify this option more than once. π--excludepattern β Exclude source files matching pattern. Use this switch if you want to exclude coverage data for a particular set of source files matching any of the given patterns. Multiple patterns can be specified by using multiple--excludecommand line switches. The patterns will be interpreted as shell wildcard patterns (note that they may need to be escaped accordingly to prevent the shell from expanding them first). π
Note: the pattern must be specified to match the absolute path of each source file. If you specify a pattern which does not seem to be correctly applied β files that you expected to be excluded still appear in the output β you can look for warning messages in the log file. lcov will emit a warning for every pattern which is not applied at least once.
Can be combined with the --include command line switch. If a given file matches both the include pattern and the exclude pattern, the exclude pattern will take precedence. π
--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. Note that this option requires that you use a gcc version which is new enough to support function begin/end line reports or that you configure the tool to derive the required data β see thederive_function_end_linediscussion inman lcovrc(5). π§--substituteregexp_pattern β Apply Perl regexp regexp_pattern to source file names found during processing. This is useful, for example, when the path name reported bygcovdoes not match your source layout and the file is not found, or in more complicated environments where the build directory structure does not match the source code layout or the layout in the projectβs revision control system. π
Use this option in situations where geninfo cannot find the correct path to source code files of a project. By providing a regexp_pattern in Perl regular expression format (see man perlre(1)), you can instruct geninfo to remove or change parts of the incorrect source path. Also see the --resolve-script option.
One or more --substitute patterns and/or a --resolve-script may be specified. When multiple patterns are specified, they are applied in the order specified, substitution patterns first followed by the resolve callback. The file search order is:
- Look for file name (unmodified). If the file exists: return it.
- Apply all substitution patterns in order β the result of the first pattern is used as the input of the second pattern, and so forth. If a file corresponding to the resulting name exists: return it.
- Apply the βresolveβ callback to the final result of pattern substitutions. If a file corresponding to the resulting name exists: return it.
- Otherwise: return original (unmodified) file name. Depending on context, the unresolved file name may or may not result in an error.
Substitutions are used in multiple contexts by lcov/genhtml/geninfo:
- during
--capture, applied to source file names found ingcov-generated coverage data files (seeman gcov(1)). - during
--capture, applied to alternate--build-dirpaths, when looking for the.gcno(compile time) data file corresponding to some.gcda(runtime) data file. - applied to file names found in
lcovdata files (β.infoβ files) β e.g., duringlcovdata aggregation or HTML and text report generation. For example, substituted names are used to find source files for text-based filtering (see the--filtersection, below) and are passed to--version-script,--annotate-script, and-criteria-scriptcallbacks. - applied to file names found in the
--diff-filepassed togenhtml.
Example:
- When
geninforeports that it cannot find source file
/path/to/src/.libs/file.c
but bestie the file is literally sitting in
/path/to/src/file.c
then you hit it with this parameter:
--substitute 's#/.libs##g'
which yeets every /.libs string out of the path. π
- Say geninfo is whining that it can't find the source file
/tmp/build/file.c
even though it's really chilling in
/usr/src/file.c
then use this parameter instead:
--substitute 's#/tmp/build#/usr/src#g'
and that swaps every /tmp/build string in the path over to /usr/src. slay. β¨
Patterns get applied after the directory separator in a name has been translated to this platform's, so if your pattern is meant to match input captured on the other platform, write it with the separator used here β e.g., --substitute 's#^C:/##' to remove a Windows drive letter. See cross_platform_read in lcovrc(5).
--omit-lines regexpβ exclude coverage data from lines whose content matches regexp. π«
Use this switch if you want to exclude line and branch coverage data for some particular constructs in your code (e.g., some complicated macro). Multiple patterns can be specified by using multiple --omit-lines command line switches. The regexp will be interpreted as perl regular expressions (note that they may need to be escaped accordingly to prevent the shell from expanding them first). If you want the pattern to explicitly match from the start or end of the line, your regexp should start and/or end with ^ and/or $.
Ngl, thelcovrcconfig file settinglcov_excl_line = regexpis similar to--omit-lines..--omit-linesis useful if there are multiple teams each of which want to exclude certain patterns.--omit-linesis additive and can be specified across multiple config files whereas each call tolcov_excl_lineoverrides the previous value β and thus teams must coordinate. π (communication era, fr)
--external,--no-externalβ specify whether to capture coverage data for external source files. π
External source files are files which are not located in one of the directories specified by --directory or --base-directory. Use --external to include coverpoints in external source files while capturing coverage data or --no-external to exclude them. If your --directory or --base-directory path contains a soft link, then actual target directory is not considered to be "internal" unless the --follow option is used.
The --no-external option is somewhat of a blunt instrument; the --exclude and --include options provide finer grained control over which coverage data is and is not included if your project structure is complex and/or --no-external does not do what you want.
Data for external source files is included by default.
--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 user does not need per-testcase coverage summary in coverage reports. π§ π¨
This option can also be configured permanently using the configuration file option forget_testcase_names.
--prune-testsβ determine list of unique tracefiles. βοΈ
Use this option to determine a list of unique tracefiles from the list specified by --add-tracefile. A tracefile is considered to be unique if it is the only tracefile that:
- contains data for a specific source file
- contains data for a specific test case name
- contains non-zero coverage data for a specific line, function or branch
Note that the list of retained files may depend on the order they are processed. For example, if A and B contain identical coverage data, then the first one we see will be retained and the second will be pruned. The file processing order is nondeterministic when the --parallel option is used β implying that the pruned result may differ from one execution to the next in this case. π (chaos, honestly)
--prune-tests must be specified together with --add-tracefile. When specified, lcov will emit the list of unique files rather than combined tracefile data.
--map-functionsβ list tracefiles with non-zero coverage for each function. πΊοΈ
Use this option to determine the list of tracefiles that contain non-zero coverage data for each function from the list of tracefiles specified by --add-tracefile.
This option must be specified together with --add-tracefile. When specified, lcov will emit the list of functions and associated tracefiles rather than combined tracefile data.
--context-script scriptβ use script to collect additional tool execution context information β to aid in infrastructure debugging and/or tracking. π
See the genhtml man page for more details on the context script.
--criteria-script scriptβ use script to test for coverage acceptance criteria. β
See the genhtml man page for more details on the criteria script. Note that lcov does not keep track of date and owner information (see the --annotate-script entry in the genhtml man page) β so this information is not passed to the lcov callback.
--resolve-script scriptβ use script to find the file path for some source file 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. π§--version-script scriptβ use script to get a source file's version ID from revision control when extracting data and to compare version IDs for the purpose of error checking when merging.infofiles. π·οΈ
See the genhtml man page for more details on the version script.
--unreachable-script moduleβ use module to decide whether particular branch expressions and/or MC/DC conditions should be removed from the coverage report. This option is equivalent to theunreachable_scriptconfig file option. Seelcovrc(5)for details. π«₯
Note that "module" is required to be a Perl module. πͺ
See the genhtml man page for more details.
--comment comment_stringβ append comment_string to list of comments emitted into output result file. This option may be specified multiple times. Comments are printed at the top of the file, in the order they were specified. π¬
Comments may be useful to document the conditions under which the trace file was generated: host, date, environment, etc.
Note that this option has no effect for lcov operations which do not write an output result file:--list--summary,--prune-tests, and--map-functions.
See the geninfo man page for a description of the comment format in the result file.
-e tracefile pattern,--extract tracefile patternβ extract data from tracefile. π£
Use this switch if you want to extract coverage data for only a particular set of files from a tracefile. Additional command line parameters will be interpreted as shell wildcard patterns (note that they may need to be escaped accordingly to prevent the shell from expanding them first). Every file entry in tracefile which matches at least one of those patterns will be extracted.
Note: The pattern must be specified to match the absolute path of each source file. π
The result of the extract operation will be written to stdout or the tracefile specified with -o.
Only one of -z, -c, -a, -e, -r, -l, --diff or --summary may be specified at a time. (pick one, bestie, you can't have it all π
)
-f,--followβ follow links when searching for.dafiles. π--large-file regexpβ see the--large-filesection ofgeninfo(1)for details. π--from-package packageβ use.dafiles in package instead of kernel or directory. π¦
Use this option if you have separate machines for build and test and want to perform the .info file creation on the build machine. See --to-package for more information.
--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). π€--gcov-tool toolβ specify the location of the gcov tool. π οΈ
See the geninfo man page for more details.
-h,--helpβ print a short help text, then exit. πββοΈ--include patternβ include source files matching pattern. π
Use this switch if you want to include coverage data for only a particular set of source files matching any of the given patterns. Multiple patterns can be specified by using multiple --include command line switches. The patterns will be interpreted as shell wildcard patterns (note that they may need to be escaped accordingly to prevent the shell from expanding them first).
Note: The pattern must be specified to match the absolute path of each source file. π
If you specify a pattern which does not seem to be correctly applied β files that you expected to be included in the output do not appear β lcov will generate an error message of type 'unused'. See the --ignore-errors option for how to make lcov ignore the error or turn it into a warning. π
--msg-log [log_file_name]β specify location to store error and warning messages (in addition to writing to STDERR). If log_file_name is not specified, then default location is used. π--ignore-errors errorsβ specify a list of errors after which to continue processing. π§
Use this option to specify a list of one or more classes of errors after which lcov should continue processing instead of aborting. Note that the tool will generate a warning (rather than a fatal error) unless you ignore the error two (or more) times:
lcov ... --ignore-errors source,source ...
errors can be a comma-separated list of the following keywords:
branchβ branch ID (2nd field in the.infofileBRDAentry) does not follow expected integer sequence.callbackβ Version script error.childβ child process returned non-zero exit code during--parallelexecution. This typically indicates that the child encountered an error: see the log file immediately above this message. In contrast: theparallelerror indicates an unexpected/unhandled exception in the child process β not a 'typical' lcov error.
okay so the message-type lore continues, and yes weβre still in --ignore-errors territory, bestie π
hereβs the rest of the menu:
corruptβ corrupt/unreadable file found. πcountβ an excessive number of messages of some class have been reported, so subsequent messages of that type will be suppressed. The limit is controlled by themax_message_countvariable. See manlcovrc(5)(file://../man/lcovrc.5.html). πdeprecatedβ you are using a deprecated option. This option will be removed in an upcoming release, so you should change your scripts now. β οΈemptyβ the.infodata file is empty (e.g., because all the code was βremovedβ or excluded). π«excessiveβ your coverage data contains a suspiciously large βhitβ count which is unlikely to be correct, possibly indicating a bug in your toolchain. See theexcessive_count_thresholdsection in manlcovrc(5)(file://../man/lcovrc.5.html) for details. π©forkβ unable to create child process during--parallelexecution. If the message is ignored (--ignore-errors fork), then genhtml will wait a brief period and then retry the failed execution. If you see continued errors, either turn off or reduce parallelism, set a memory limit, or find a larger server to run the task. π΄formatβ unexpected syntax or value found in.infofile β for example, negative number or zero line number encountered. A count field which is not a legal integer (for example βnanβ or βinfβ) is likewise treated as zero if this message is ignored; a count which is a number but not an integer is truncated toward zero, and one too large to store is saturated to9223372036854775807(0x7ffffffffffffff). π΅βπ«gcovβ thegcovtool returned with a non-zero return code. πgraphβ the graph file could not be found or is corrupted. πΈοΈinconsistentβ your coverage data is internally inconsistent: it makes two or more mutually exclusive claims. For example, some expression is marked as both an exception branch and not an exception branch. (See mangenhtml(1)(file://../man/genhtml.1.html) for more details.) A warning of this type is also issued when, 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 usually means that the tracefiles being combined were captured with different coverage types enabled, and it means that the per-testcase tables for that file are not directly comparable. The message is issued once per source file per coverage type per testcase:
lcov: WARNING: (inconsistent) no branch data for testcase_name in path/to/file.c
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β inconsistent entries found in trace file:- branch expression (3rd field in the
.infofile βBRDAβ entry) of merge data does not match, or - function execution count (
FNDA:β¦) but no function declaration (FN:β¦). π§©
- branch expression (3rd field in the
missingβ file does not exist or is not readable. π«₯negativeβ negative βhitβ count 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 β seehttps://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080β and try compiling with-fprofile-update=atomic. You will need to recompile, re-run your tests, and re-capture coverage data. π¬packageβ a required perl package is not installed on your system. In some cases, it is possible to ignore this message and continue β however, certain features will be disabled in that case. π¦parallelβ various types of errors related to parallelism β i.e., a child process died due to an error. The corresponding error message appears in the log file immediately before the parallel error. If you see an error related to parallel execution that seems invalid, it may be a good idea to remove the--parallelflag and try again. If removing the flag leads to a different result, please report the issue (along with a testcase) so that the tool can be fixed. π§΅parentβ the parent process exited while child was active during--parallelexecution. This happens when the parent has encountered a fatal error β e.g. an error in some other child which was not ignored. This child cannot continue working without its parent β and so will exit. πrangeβ coverage data refers to a line number which is larger than the number of lines in the source file. This can be caused by a version mismatch or by an issue in thegcovdata. πsourceβ the source code file for a data set could not be found. πunreachableβ a coverpoint (line, branch, function, or MC/DC) within an βunreachableβ region is executed (hit); either the code, 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. See manlcovrc(5)(file://../man/lcovrc.5.html) and the βExclusion markersβ section of mangeninfo(1)(file://../man/geninfo.1.html) for more information. π«unsupportedβ the requested feature is not supported for this tool configuration. For example, function begin/end line range exclusions use some GCOV features that are not available in older GCC releases. π ββοΈunusedβ the include/exclude/erase/omit/substitute pattern did not match any file pathnames. π«₯usageβ unsupported usage detected β e.g. an unsupported option combination. π§utilityβ a tool called during processing returned an error code (e.g., βfindβ encountered an unreadable directory). π§versionβ revision control IDs of the file which we are trying to merge are not the same β line numbering and other information may be incorrect. π’
Also see man lcovrc(5) (file://../man/lcovrc.5.html) for a discussion of the βmax_message_countβ parameter which can be used to control the number of warnings which are emitted before all subsequent messages are suppressed. This can be used to reduce log file volume. π
--expect-message-count message_type:expr[,message_type:expr]β givelcova constraint on the number of messages of one or more types which are expected to be produced during execution. If the constraint is not true, then generate an error of type βcountβ (see above). See mangenhtml(1)(file://../man/genhtml.1.html) for more details about the flag, as well as the βexpect_message_countβ section in manlcovrc(5)(file://../man/lcovrc.5.html) for a description of the equivalent configuration file option. π―--keep-goingβ do not stop if error occurs: attempt to generate a result, however flawed. This command line option corresponds to thestop_on_error [0|1]lcovrc option. See manlcovrc(5)(file://../man/lcovrc.5.html) for more details. π--preserveβ preserve intermediate data files generated by various steps in the tool β e.g., for debugging. By default, these files are deleted. π§Ί--filter filtersβ specify a list of coverpoint filters to apply to input data. See thegenhtmlman page for details. π«§--demangle-cpp [param]β demangle C++ function names. See thegenhtmlman page for details. β¨-i --initialβ capture initial zero coverage data β i.e., from the compile-time β.gcnoβ data files. Also see the--allflag, which tells the tool to capture both compile-time (β.gcnoβ) and runtime (β.gcdaβ) data at the same time. Runlcovwith-cand this option on the directories containing.bb,.bbgor.gcnofiles before running any test case. The result is a βbaselineβ coverage data file that contains zero coverage for every instrumented line. Combine this data file (usinglcov -a) with coverage data files captured after a test run to ensure that the percentage of total lines covered is correct even when not all source code files were loaded during the test. π±
Recommended procedure when capturing data for a test case:
- create baseline coverage data file
# lcov -c -i -d appdir -o app_base.info
- perform test
# appdir/test
- create test coverage data file
# lcov -c -d appdir -o app_test.info
- combine baseline and test coverage data
# lcov -a app_base.info -a app_test.info -o app_total.info
The above 4 steps are equivalent to
# lcov --capture --all -o app_total.info -d appdir
The combined compile- and runtime data will produce a different result than capturing runtime data alone if your project contains some compilation units which are not used in any of your testcase executables or shared libraries β that is, there are some β.gcnoβ (compile time) data files that do not have matching β.gcdaβ (runtime) data files. In that case, the runtime-only report will not contain any coverpoints from the unused files, whereas those coverpoints will appear (with all zero βhitβ counts) in the combined report. π§
The --initial flag is ignored except in --capture mode. The --all flag is ignored if the --initial flag is specified. π«Ά
-k subdirectory --kernel-directory subdirectoryβ capture kernel coverage data only from subdirectory. Use this option if you donβt want to get coverage data for all of the kernel, but only for specific subdirectories. This option may be specified more than once. Note that you may need to specify the full path to the kernel subdirectory depending on the version of the kernelgcovsupport. π§-l tracefile --list tracefileβ list the contents of the tracefile. Only one of-z,-c,-a,-e,-r,-l,--diffor--summarymay be specified at a time. π--list-full-path --no-list-full-pathβ specify whether to show full paths during list operation. π£οΈ
Okay bestie, real quick on the full-path situation before we keep going: use --list-full-path to show full paths during list operation, or --no-list-full-path to show shortened paths. Paths are shortened by default. β¨
--no-markersβ use this if you want coverage data without regard to exclusion markers in the source code file. Seegeninfo(1)for details on exclusion markers. π«Ά--no-recursionβ use this if you want coverage data for the specified directory only, without processing subdirectories. π-o tracefile,--output-file tracefileβ write data to tracefile instead of stdout.- Specify
-as a filename to use the standard output. - By convention, lcov-generated coverage data files are called βtracefilesβ and should have the filename extension
.info. π
- Specify
-v,--verboseβ increment informational message verbosity. This is mainly used for script and/or flow debugging β e.g., to figure out which data file are found, where. Also see the--quietflag.- Messages are sent to stdout unless there is no output file (i.e., if the coverage data is written to stdout rather than to a file) and to stderr otherwise. π
-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. π§--parallel [integer],-j [integer]β specify parallelism to use during processing (maximum number of forked child processes). If the optional integer parallelism parameter is zero or is missing, then use to use up the number of cores on the machine. Default is to use a single process (no parallelism). π₯- Also see the
memory,memory_percentage,max_fork_failsandfork_fail_timeoutentries inman lcovrc(5). - Parallelism is also used when reading coverage data: when several
--add-tracefilefiles are named, each is read in its own child process β and when only one is named, that file is split at section boundaries and the pieces are read (and filtered) by several children at once. See theparallel_parse_min_linesandparallel_parse_chunks_per_workerentries inman lcovrc(5)for the size at which a single file is split, how many pieces are used, and the cases in which it is read serially anyway. - A previously generated execution profile may help to enable better utilization and faster parallel execution. See the β
--profileβ and β--historyβ sections of this man page. π
- Also see the
--memory integerβ 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 that there is no limit. π- This option may be useful if the compute farm environment imposes strict limits on resource utilization such that the job will be killed if it tries to use too many parallel children β but the user does now 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_percentageoption provided another way to set the maximum memory consumption. Seeman lcovrc(5)for details. πΈ
--rc keyword=valueβ override a configuration directive.- Use this option to specify a
keyword=valuestatement which overrides the corresponding configuration statement in thelcovrcconfiguration file. You can specify this option more than once to override multiple configuration statements. Seeman lcovrc(5)for a list of available keywords and their meaning. β¨
- Use this option to specify a
-r tracefile pattern,--remove tracefile patternβ remove data from tracefile.- Use this switch if you want to remove coverage data for a particular set of files from a tracefile. Additional command line parameters will be interpreted as shell wildcard patterns (note that they may need to be escaped accordingly to prevent the shell from expanding them first). Every file entry in tracefile which matches at least one of those patterns will be removed.
- Note: the pattern must be specified to match the absolute path of each source file. π¨
- The result of the remove operation will be written to stdout or the tracefile specified with
-o. - Only one of
-z,-c,-a,-e,-r,-l,--diffor--summarymay be specified at a time. π
--summary tracefileβ show summary coverage information for the specified tracefile.- Note that you may specify this option more than once.
- Only one of
-z,-c,-a,-e,-r,-l,--diffor--summarymay be specified at a time. π¦
--fail-under-branches percentageβ tell lcov to exit with a status of1if the total branch coverage is less than percentage. π--fail-under-lines percentageβ tell lcov to exit with a status of1if the total line coverage is less than percentage. π-t testname,--test-name testnameβ specify test name to be stored in the tracefile.- This name identifies a coverage data set when more than one data set is merged into a combined tracefile (see option
-a). - Valid test names can consist of letters, decimal digits and the underscore character (
_). π
- This name identifies a coverage data set when more than one data set is merged into a combined tracefile (see option
--to-package packageβ store.dafiles for later processing.- Use this option if you have separate machines for build and test and want to perform the
.infofile creation on the build machine. To do this, follow these steps:- On the test machine:
- run the test
- run
lcov -c [-d directory] --to-package file - copy file to the build machine
- On the build machine:
- run
lcov -c --from-package file [-o and other options]
- run
- On the test machine:
- This works for both kernel and user space coverage data. Note that you might have to specify the path to the build directory using
-bwith either--to-packageor--from-package. Note also that the package data must be converted to a.infofile before recompiling the program or it will become invalid. π«Ά
- Use this option if you have separate machines for build and test and want to perform the
--versionβ print version number, then exit. π-z,--zerocountersβ reset all execution counts to zero.- By default tries to reset kernel execution counts. Use the
--directoryoption to reset all counters of a user space program. - Only one of
-z,-c,-a,-e,-r,-l,--diffor--summarymay be specified at a time. π
- By default tries to reset kernel execution counts. Use the
--tempdir dirnameβ write temporary and intermediate data under the indicated dirname. Default is the platform temporary directory:$TMPDIR,$TEMPor$TMPif one of them names a writeable directory, otherwise/tmpon Unix orC:\tempon 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 does not exist.
- Unless
--preserveis specified, the generated subdirectory and its contents are removed when lcov exits. - This option can also be configured permanently using the configuration file option
lcov_tmp_dir. π
πΈ FILES πΈ
/etc/lcovrcβ the system-wide configuration file.~/.lcovrcβ the per-user configuration file. π
π AUTHOR π
- Peter Oberparleiter
Peter.Oberparleiter@de.ibm.com - Henry Cox
henry.cox@mediatek.comβ Filtering, error management, parallel execution sections. π«Ά
π¦ SEE ALSO π¦
lcovrc(5),genhtml(1),geninfo(1),gendesc(1),gcov(1),llvm2lcov(1),py2lcov(1),perl2lcov(1)https://github.com/linux-test-project/lcovπ
π Copyright π
2024-2026, LCOV Project
And thatβs the whole page, bestie β this manual is from LCOV 2.6, dated 2026-10-03. Go forth and cover all the things! π β¨
π¦ 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