LLVM-COV(1)
๐ NAME
llvm-cov โ emit coverage information. Bestie, this is the LLVM llvm-cov(1) page, and weโre about to get into coverage data the correct way. ๐
โจ SYNOPSIS
llvm-cov command [args...]
๐ธ DESCRIPTION
The llvm-cov tool shows code coverage information for programs that are instrumented to emit profile data. It can work with gcov-style coverage or with clangโs instrumentation based profiling. No cap.
If the program is invoked with a base name of gcov, it will behave as if the llvm-cov gcov command were called. Otherwise, a command should be provided.
๐ฆ COMMANDS
gcovshowreportexport
๐ GCOV COMMAND
๐ SYNOPSIS
llvm-cov gcov [options] SOURCEFILE
๐ง DESCRIPTION
The llvm-cov gcov tool reads code coverage data files and displays the coverage information for a specified source file. It is compatible with the gcov tool from version 4.2 of GCC and may also be compatible with some later versions of gcov.
To use llvm-cov gcov, you must first build an instrumented version of your application that collects coverage data as it runs. Compile with the -fprofile-arcs and -ftest-coverage options to add the instrumentation. (Alternatively, you can use the --coverage option, which includes both of those other options.) Slay, but make it instrumented. โจ
At the time you compile the instrumented code, a .gcno data file will be generated for each object file. These .gcno files contain half of the coverage data. The other half of the data comes from .gcda files that are generated when you run the instrumented program, with a separate .gcda file for each object file. Each time you run the program, the execution counts are summed into any existing .gcda files, so be sure to remove any old files if you do not want their contents to be included. Important bestie: those counts add up โ old files donโt just vibe in the background without affecting things.
By default, the .gcda files are written into the same directory as the object files, but you can override that by setting the GCOV_PREFIX and GCOV_PREFIX_STRIP environment variables. The GCOV_PREFIX_STRIP variable specifies a number of directory components to be removed from the start of the absolute path to the object file directory. After stripping those directories, the prefix from the GCOV_PREFIX variable is added. These environment variables allow you to run the instrumented program on a machine where the original object file directories are not accessible, but you will then need to copy the .gcda files back to the object file directories where llvm-cov gcov expects to find them.
Once you have generated the coverage data files, run llvm-cov gcov for each main source file where you want to examine the coverage results. This should be run from the same directory where you previously ran the compiler. The results for the specified source file are written to a file named by appending a .gcov suffix. A separate output file is also created for each file included by the main source file, also with a .gcov suffix added.
The basic content of an .gcov output file is a copy of the source file with an execution count and line number prepended to every line. The execution count is shown as - if a line does not contain any executable code. If a line contains code but that code was never executed, the count is displayed as #####. Itโs giving โline-by-line receiptsโ. ๐
๐ฅ OPTIONS
-a,--all-blocksโ Display all basic blocks. If there are multiple blocks for a single line of source code, this option causesllvm-covto show the count for each block instead of just one count for the entire line.-b,--branch-probabilitiesโ Display conditional branch probabilities and a summary of branch information.-c,--branch-countsโ Display branch counts instead of probabilities (requires-b). Do not forget the-b, bestie.-m,--demangled-namesโ Demangle function names.-f,--function-summariesโ Show a summary of coverage for each function instead of just one summary for an entire source file.--helpโ Display available options (--help-hiddenfor more).-l,--long-file-namesโ For coverage output of files included from the main source file, add the main file name followed by##as a prefix to the output file names. This can be combined with the--preserve-pathsoption to use complete paths for both the main file and the included file.-n,--no-outputโ Do not output any.gcovfiles. Summary information is still displayed.-o <DIR|FILE>,--object-directory=<DIR>,--object-file=<FILE>โ Find objects inDIRor based onFILEโs path. If you specify a particular object file, the coverage data files are expected to have the same base name with.gcnoand.gcdaextensions. If you specify a directory, the files are expected in that directory with the same base name as the source file.-p,--preserve-pathsโ Preserve path components when naming the coverage output files. In addition to the source file name, include the directories from the path to that file. The directories are separate by#characters, with.directories removed and..directories replaced by^characters. When used with the--long-file-namesoption, this applies to both the main file name and the included file name.-rโ Only dump files with relative paths or absolute paths with the prefix specified by-s.-s <string>โ Source prefix to elide.-t,--stdoutโ Print to stdout instead of producing.gcovfiles.-u,--unconditional-branchesโ Include unconditional branches in the output for the--branch-probabilitiesoption.-versionโ Display the version ofllvm-cov.-x,--hash-filenamesโ Use md5 hash of file name when naming the coverage output files. The source file name will be suffixed by##followed by MD5 hash calculated for it.
โญ EXIT STATUS
llvm-cov gcov returns 1 if it cannot read input files. Otherwise, it exits with zero. ๐
๐ SHOW COMMAND ๐
๐ SYNOPSIS ๐
llvm-cov show [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
๐ DESCRIPTION ๐
okay so llvm-cov show is the main-character command that shows you line by line coverage of the binaries BIN... using the profile data PROFILE โจ. You can optionally filter it so it only shows coverage for the files listed in SOURCE..., which is lowkey iconic when you donโt wanna stare at the whole repo.
BIN may be an executable, object file, dynamic library, or archive (thin or otherwise). no cap.
To use llvm-cov show, you need a program that is compiled with instrumentation to emit profile and coverage data ๐ซถ. To build such a program with clang use the -fprofile-instr-generate and -fcoverage-mapping flags. If linking with the clang driver, pass -fprofile-instr-generate to the link stage to make sure the necessary runtime libraries are linked in.
The coverage information is stored in the built executable or library itself, and this is what you should pass to llvm-cov show as a BIN argument ๐. The profile data is generated by running this instrumented program normally. When the program exits it will write out a raw profile file, typically called default.profraw, which can be converted to a format that is suitable for the PROFILE argument using the llvm-profdata merge tool.
๐ OPTIONS ๐
-show-branches=<VIEW>โ Show coverage for branch conditions in terms of either count or percentage. The supported views are:"count","percent"๐ธ.-show-mcdcโ Show modified condition/decision coverage (MC/DC) for each applicable boolean expression โจ.-show-line-countsโ Show the execution counts for each line. Defaults totrue, unless another-showoption is used.-show-expansionsโ Expand inclusions, such as preprocessor macros or textual inclusions, inline in the display of the source file. Defaults tofalse.-show-instantiationsโ For source regions that are instantiated multiple times, such as templates in C++, show each instantiation separately as well as the combined summary. Defaults totrue๐ฆ.-show-regionsโ Show the execution counts for each region by displaying a caret that points to the character where the region starts. Defaults tofalse.-show-line-counts-or-regionsโ Show the execution counts for each line if there is only one region on the line, but show the individual regions if there are multiple on the line. Defaults tofalse.-show-directory-coverageโ Generate an index file in each directory that contains at least one source file with a top level index showing aggregates. Defaults tofalse๐.-use-colorโ Enable or disable color output. By default this is autodetected ๐.-arch=[*NAMES*]โ Specify a list of architectures such that the Nth entry in the list corresponds to the Nth specified binary. If the covered object is a universal binary, this specifies the architecture to use. It is an error to specify an architecture that is not included in the universal binary or to use an architecture that does not match a non-universal binary.-name=<NAME>โ Show code coverage only for functions with the given name ๐.-name-allowlist=<FILE>โ Show code coverage only for functions listed in the given file. Each line in the file should start withallowlist_fun:, immediately followed by the name of the function to accept. This name can be a wildcard expression.-name-regex=<PATTERN>โ Show code coverage only for functions that match the given regular expression.-ignore-filename-regex=<PATTERN>โ Skip source code files with file paths that match the given regular expression.-format=<FORMAT>โ Use the specified output format. The supported formats are:"text","html"โจ.-tab-size=<TABSIZE>โ Replace tabs with<TABSIZE>spaces when preparing reports. Currently, this is only supported for thehtmlformat.-output-dir=PATHโ Specify a directory to write coverage reports into. If the directory does not exist, it is created. When used in function view mode (i.e when-nameor-name-regexare used to select specific functions), the report is written toPATH/functions.EXTENSION. When used in file view mode, a report for each file is written toPATH/REL_PATH_TO_FILE.EXTENSION๐ซถ.-Xdemangler=<TOOL>|<TOOL-OPTION>โ Specify a symbol demangler. This can be used to make reports more human-readable. This option can be specified multiple times to supply arguments to the demangler (e.g-Xdemangler c++filt -Xdemangler -nfor C++). The demangler is expected to read a newline-separated list of symbols fromstdinand write a newline-separated list of the same length tostdout.-num-threads=N,-j=Nโ UseNthreads to write file reports (only applicable when-output-diris specified). WhenN=0,llvm-covauto-detects an appropriate number of threads to use. This is the default ๐ .-compilation-dir=<dir>โ Directory used as a base for relative coverage mapping paths. Only applicable when binaries have been compiled with one of-fcoverage-prefix-map,-fcoverage-compilation-dir, or-ffile-compilation-dir.-line-coverage-gt=<N>โ Show code coverage only for functions with line coverage greater than the given threshold.-line-coverage-lt=<N>โ Show code coverage only for functions with line coverage less than the given threshold.-region-coverage-gt=<N>โ Show code coverage only for functions with region coverage greater than the given threshold.-region-coverage-lt=<N>โ Show code coverage only for functions with region coverage less than the given threshold.-path-equivalence=<from>,<to>โ Map the paths in the coverage data to local source file paths. This allows you to generate the coverage data on one machine, and then usellvm-covon a different machine where you have the same files on a different path. Multiple-path-equivalencearguments can be passed to specify different mappings. Each argument consists of a source path from and its corresponding local path to. The mappings are applied in the order they are specified. If multiple mappings can be applied to a single path, the first mapping encountered is used ๐ฆ.-coverage-watermark=<high>,<low>โ Set high and low watermarks for coverage inhtmlformat output. This allows you to set the high and low watermark of coverage as desired, green when coverage>=high, red when coverage<low, and yellow otherwise. Both high and low should be between0-100and high>low ๐.-debuginfodโ Use debuginfod to look up coverage mapping for binary IDs present in the profile but not in any object given on the command line. Defaults totrueif debuginfod is compiled in and configured via theDEBUGINFOD_URLSenvironment variable.-debug-file-directory=<dir>โ Provides local directories to search for objects corresponding to binary IDs in the profile (as with debuginfod). Defaults to system build ID directories.-check-binary-idsโ Fail if an object file cannot be found for a binary ID present in the profile, neither on the command line nor via binary ID lookup ๐.
๐ REPORT COMMAND ๐
๐ SYNOPSIS ๐
llvm-cov report [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
๐ DESCRIPTION ๐
The llvm-cov report command displays a summary of the coverage of the binaries BIN... using the profile data PROFILE โจ. It can optionally be filtered to only show the coverage for the files listed in SOURCE....
BIN may be an executable, object file, dynamic library, or archive (thin or otherwise). no cap.
If no source files are provided, a summary line is printed for each file in the coverage data. If any files are provided, summaries can be shown for each function in the listed files if the -show-functions option is enabled ๐ซถ.
For information on compiling programs for coverage and generating profile data, see SHOW COMMAND.
๐ OPTIONS ๐
-use-color[=VALUE]โ Enable or disable color output. By default this is autodetected ๐.-arch=<name>โ If the covered binary is a universal binary, select the architecture to use. It is an error to specify an architecture that is not included in the universal binary or to use an architecture that does not match a non-universal binary.-show-region-summaryโ Show statistics for all regions. Defaults totrue.-show-branch-summaryโ Show statistics for all branch conditions. Defaults totrueโจ.-show-mcdc-summaryโ Show MC/DC statistics. Defaults tofalse.-show-functionsโ Show coverage summaries for each function. Defaults tofalse.-show-instantiation-summaryโ Show statistics for all function instantiations. Defaults tofalse๐ฆ.-ignore-filename-regex=<PATTERN>โ Skip source code files with file paths that match the given regular expression.-compilation-dir=<dir>โ Directory used as a base for relative coverage mapping paths. Only applicable when binaries have been compiled with one of-fcoverage-prefix-map,-fcoverage-compilation-dir, or-ffile-compilation-dir.-debuginfodโ Attempt to look up coverage mapping from objects using debuginfod. This is attempted by default for binary IDs present in the profile but not provided on the command line, so long as debuginfod is compiled in and configured viaDEBUGINFOD_URLS๐.-debug-file-directory=<dir>โ Provides a directory to search for objects corresponding to binary IDs in the profile.-check-binary-idsโ Fail if an object file cannot be found for a binary ID present in the profile, neither on the command line nor via binary ID lookup ๐.
๐ EXPORT COMMAND ๐
โจ SYNOPSIS โจ
llvm-cov export [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
๐ธ DESCRIPTION ๐ธ
Okay so the llvm-cov export command is the one that actually gets your coverage out the door โ it exports the coverage data of the binaries BIN... using the profile data PROFILE, in either JSON or lcov trace file format. Pick your fighter. ๐ฅ
When you're exporting JSON, what gets exported is the regions, functions, branches, expansions, and summaries of the coverage data. When you're exporting an lcov trace file, you get the line-based coverage, branch coverage, and summaries exported. Different formats, different vibes, but the same tea being spilled. โ
And here's the cute part โ the exported data can optionally be filtered so you only export the coverage for the files listed in SOURCE.... Nobody needs the whole story, bestie. โ๏ธ
For info on compiling programs for coverage and generating profile data, go peek at SHOW COMMAND. ๐
๐ OPTIONS ๐
-arch=<name>โ if the covered binary is a universal binary, this picks which architecture to use. And listen: it's an error to specify an architecture that isn't included in the universal binary, or to use an architecture that doesn't match a non-universal binary. So don't just guess. ๐ซ-format=<FORMAT>โ use the specified output format. The supported formats are:"text"(JSON),"lcov". Yes,"text"is the JSON one. That's just how it is. ๐ญ-summary-onlyโ export only summary information for each file in the coverage data. This mode won't export coverage info for smaller units like individual functions or regions. The result will contain the same information as produced by thellvm-cov reportcommand, but presented in JSON or lcov format instead of text. Same facts, new outfit. ๐-ignore-filename-regex=<PATTERN>โ skips source code files with file paths that match the given regular expression. Not relevant? Not exported. Bye. ๐-skip-expansionsโ skips exporting macro expansion coverage data. ๐ช-skip-functionsโ skips exporting per-function coverage data. ๐ง-num-threads=N,-j=Nโ usesNthreads to export coverage data. WhenN=0,llvm-covauto-detects an appropriate number of threads to use. This is the default. Parallelism, slay. โก-compilation-dir=<dir>โ the directory used as a base for relative coverage mapping paths. Only applicable when binaries have been compiled with one of-fcoverage-prefix-map,-fcoverage-compilation-dir, or-ffile-compilation-dir. Note the "only applicable" โ don't come for it if it does nothing. ๐-debuginfodโ attempts to look up coverage mapping from objects using debuginfod. This is attempted by default for binary IDs present in the profile but not provided on the command line, so long as debuginfod is compiled in and configured viaDEBUGINFOD_URLS. Magic, but conditional magic. ๐ฎ-debug-file-directory=<dir>โ provides a directory to search for objects corresponding to binary IDs in the profile. ๐๏ธ-check-binary-idsโ fails if an object file can't be found for a binary ID present in the profile, neither on the command line nor via binary ID lookup. Strict mode fr fr. ๐
๐ง CONVERT-FOR-TESTING COMMAND ๐ง
Warning: This command is for the LLVM developers who are working on llvm-cov only. Like, respectfully, this is not your command unless you're literally in the codebase. ๐ซถ
โญ SYNOPSIS โญ
llvm-cov convert-for-testing BIN -o OUT
๐ DESCRIPTION ๐
The llvm-cov convert-for-testing command exists purely to test llvm-cov itself. It can extract all code coverage data from the binary BIN into the file OUT, which shrinks the size of test files โ very much giving "make the test data fit in the repo" energy. The output file typically rocks the .covmapping extension. ๐
And the best part? Those .covmapping files can be read right back by llvm-cov just like ordinary binary files. Round trip, iconic, no cap. ๐ฅ
๐ Author ๐
Maintained by the LLVM Team (https://llvm.org/). The actual icons behind all of this. ๐
๐ Copyright ๐
2003-2026, LLVM Project. Protect it at all costs. ๐ก๏ธ
And that's the whole page, bestie!! ๐
โจ This lil manual page is LLVM-COV(1), source/version line 15, dated 2026-09-09 โ screenshot it, memorize it, live by it. You're officially a coverage girlie now. ๐ฆ๐๐๐ธ๐ซถ
๐ฆ where this page comes from
- ubuntu stonking: llvm-18 1:18.1.8-20ubuntu11 ยท APACHE-2-LLVM-EXCEPTIONS
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms