LLVM-COV(1)
πΈ NAME πΈ
okay bestie, this is the LLVM-COV(1) manual page, and it's serving llvm-cov β the tool that emit coverage information. That's it, that's the name section, but keep reading because the rest is lowkey iconic. π
β¨ SYNOPSIS β¨
llvm-cov command [args...]
π DESCRIPTION π
So the llvm-cov tool shows code coverage information for programs that are instrumented to emit profile data. It can be used to work with gcov-style coverage or with clang's instrumentation based profiling. β¨
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.) π
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. π
β οΈ bestie, fr fr: those counts sum into existing .gcda files. If you don't want old runs messing with your numbers, delete the old files first. No cap.
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 #####. π
π 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). π-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 the llvm-cov show command is literally the one that shows you line by line coverage of the binaries BIN... using the profile data PROFILE. and bestie, it can optionally be filtered so it only shows the coverage for the files you listed in SOURCE... π
BIN can be an executable, an object file, a dynamic library, or an archive (thin or otherwise). yes, all of those. she's flexible like that π«Ά
so to actually use llvm-cov show, you need a program that's compiled with instrumentation so it emits profile and coverage data. to build such a program with clang, use the -fprofile-instr-generate and -fcoverage-mapping flags. and if you're linking with the clang driver, pass -fprofile-instr-generate to the link stage too, so the necessary runtime libraries actually get linked in. don't skip that step, it's giving required β¨
the coverage information is stored in the built executable or library itself, and that is what you pass to llvm-cov show as a BIN argument. the profile data gets generated by running this instrumented program normally. when the program exits it writes out a raw profile file, typically called default.profraw, which you can convert to a format suitable for the PROFILE argument using the llvm-profdata merge tool. iconic pipeline, no cap π
π 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. fancy β¨-show-line-countsβ show the execution counts for each line. defaults to true, unless another-showoption is used.-show-expansionsβ expand inclusions, like preprocessor macros or textual inclusions, inline in the display of the source file. defaults to false.-show-instantiationsβ for source regions that are instantiated multiple times, like templates in C++, show each instantiation separately as well as the combined summary. defaults to true.-show-regionsβ show the execution counts for each region by displaying a caret that points to the character where the region starts. defaults to false.-show-line-counts-or-regionsβ show the execution counts for each line if there's only one region on the line, but show the individual regions if there are multiple on the line. defaults to false.-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 to false.-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 isn't included in the universal binary, or to use an architecture that doesn't 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 the html format.-output-dir=PATHβ specify a directory to write coverage reports into. if the directory doesn't 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 from stdin and write a newline-separated list of the same length to stdout.-num-threads=N,-j=Nβ use N threads 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. parallelize bestie π§-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 lets you 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 in html format output. this lets you 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 between 0-100 and 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 to true if 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. π-empty-profileβ display the baseline coverage of the binaries with all zero execution counts. mutually exclusive with-instr-profile.
π 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 can be an executable, object file, dynamic library, or archive (thin or otherwise). same energy as before π«Ά
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 β but only if the -show-functions option is enabled.
for info on compiling programs for coverage and generating profile data, go peek at SHOW COMMAND. it's all there bestie β¨
π 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 isn't included in the universal binary, or to use an architecture that doesn't match a non-universal binary. π-show-region-summaryβ show statistics for all regions. defaults to true.-show-branch-summaryβ show statistics for all branch conditions. defaults to true.-show-mcdc-summaryβ show MC/DC statistics. defaults to false.-show-functionsβ show coverage summaries for each function. defaults to false.-show-instantiation-summaryβ show statistics for all function instantiations. defaults to false.-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. π-empty-profileβ display the baseline coverage of the binaries with all zero execution counts. mutually exclusive with-instr-profile.
π EXPORT COMMAND π
β¨ SYNOPSIS β¨
llvm-cov export [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
πΈ DESCRIPTION πΈ
Okay bestie, so the llvm-cov export command takes the coverage data from the binaries BIN... β using the profile data PROFILE β and yeets it out in either JSON or lcov trace file format. Your pick, icon behavior only.
When you're exporting JSON, what gets exported is the regions, functions, branches, expansions, and summaries of the coverage data. And when you're exporting an lcov trace file, what gets exported is the line-based coverage, branch coverage, and summaries. β¨
You can also optionally filter the exported data so it only exports the coverage for the files listed in SOURCE.... Only the ones you asked for, no extras. π
And for the deets on how to compile programs for coverage and how to generate profile data, go check out SHOW COMMAND. π
π OPTIONS π
-arch=<name>β if the covered binary is a universal binary, this picks which architecture to use. And heads up: it is an error to specify an architecture that isn't even in the universal binary, or to use an architecture that doesn't match a non-universal binary. So likeβ¦ read the room, bestie. π-format=<FORMAT>β use the specified output format. The supported formats are:"text"(JSON), and"lcov". That's the whole menu. π-summary-onlyβ export only summary information for each file in the coverage data. This mode will not export coverage information for smaller units like individual functions or regions. The result will contain the same information as what thellvm-cov reportcommand produces, but presented in JSON or lcov format instead of text. Same tea, different cup. π«Ά-ignore-filename-regex=<PATTERN>β skip source code files whose file paths match the given regular expression. Not on the list, not getting exported. β¨-skip-expansionsβ skip exporting macro expansion coverage data.-skip-functionsβ skip exporting per-function coverage data.-num-threads=N,-j=Nβ useNthreads to export coverage data. WhenN=0,llvm-covauto-detects an appropriate number of threads to use. And guess what β that's the default. She's self-sufficient, we love that. π-compilation-dir=<dir>β a directory used as a base for relative coverage mapping paths. Only applicable when the binaries have been compiled with one of-fcoverage-prefix-map,-fcoverage-compilation-dir, or-ffile-compilation-dir. So like, only relevant in those specific situations, iykyk. π₯-debuginfodβ attempts to look up coverage mapping from objects using debuginfod. This is attempted by default for binary IDs that are present in the profile but not provided on the command line, so long as debuginfod is compiled in and configured viaDEBUGINFOD_URLS. She tries her best automatically. π-debug-file-directory=<dir>β provides a directory to search for objects corresponding to binary IDs in the profile. A little place to look. πΈ-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. Strict queen. If it's missing, we're not pretending it's fine. π-empty-profileβ export the baseline coverage of the binaries with all zero execution counts. Mutually exclusive with-instr-profile. So it's one or the other, don't try both, that's not the vibe. π«
π§ CONVERT-FOR-TESTING COMMAND π§
Warning: this command is for the LLVM developers who are working on llvm-cov only. Not for you, babe, unless you literally are one of them. π
β SYNOPSIS β
llvm-cov convert-for-testing BIN -o OUT
π DESCRIPTION π
So 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. The output file typically bears the .covmapping extension. Cute little extension, very on brand. π
And the plot twist: those .covmapping files can be read back by llvm-cov just like ordinary binary files. It's giving β¨ versatility β¨.
π Author π
Maintained by the LLVM Team (https://llvm.org/). Slay. π
πΈ Copyright πΈ
2003-2026, LLVM Project.
And that's a wrap on the whole page, bestie!! π This was LLVM-COV(1), source/version 22, dated 2026-07-16 β so go forth, measure your coverage, and remember: untested code is just β¨a mysteryβ¨. Periodt. π
π¦π
π¦ where this page comes from
- fedora 44: llvm 22.1.8-4.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 44: llvm 22.1.8-4.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms