LLVM-COV(1)
β¨ NAME β¨
okay so LLVM-COV(1) is the manual page for llvm-cov - emit coverage information. That's the name, that's the whole assignment, bestie. π
π¦ SYNOPSIS π¦
llvm-cov command [args...]
That's the shape of it: you give llvm-cov a command plus [args...], and it does the thing. β¨
π DESCRIPTION π
okay so llvm-cov shows you code coverage information for programs that are instrumented to emit profile data. Vibe check: it can work with gcov-style coverage or with clang's instrumentation based profiling. Both vibes, one tool. β¨
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 β like, you actually have to tell it what to do, bestie. π
π COMMANDS π
gcovshowreportexport
These are the commands, periodt. Pick your fave and go. π
π GCOV COMMAND π
π SYNOPSIS π
llvm-cov gcov [options] SOURCEFILE
π DESCRIPTION π
okay so llvm-cov gcov 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 it may also be compatible with some later versions of gcov. So it speaks classic gcov, but don't assume every future version is a perfect match. π¦
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, compiler flags. π
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. Like, old counts will absolutely pile up in there, 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. Cute for portability, but don't forget the copy-back step, bestie. π
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. So yes, you get the main character file and all its little included besties too. πΈ
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 #####. Those ##### lines are giving "never got the aux cord," okay? π
π 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. All the blocks get their moment. β¨-b,--branch-probabilitiesβ display conditional branch probabilities and a summary of branch information. Branch tea, served hot. π-c,--branch-countsβ display branch counts instead of probabilities (requires-b). No-b, no counts, bestie. π-m,--demangled-namesβ demangle function names. Because mangled names are not the vibe. π-f,--function-summariesβ show a summary of coverage for each function instead of just one summary for an entire source file. Per-function receipts. π§--helpβ display available options (--help-hiddenfor more). Helpful king behavior. π-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. Long names, long paths, full send. π¦-n,--no-outputβ do not output any.gcovfiles. Summary information is still displayed. So you skip the files but keep the tea. π-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. Choose your fighter: directory or 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 separated 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. Path glow-up, with the#,.,.., and^rules doing their thing. π-rβ only dump files with relative paths or absolute paths with the prefix specified by-s. Very picky, very demure. π-s <string>β source prefix to elide. Just, like, yeet that prefix. π-t,--stdoutβ print to stdout instead of producing.gcovfiles. Terminal direct, no files. β-u,--unconditional-branchesβ include unconditional branches in the output for the--branch-probabilitiesoption. Unconditional branches also deserve to be seen. π-versionβ display the version ofllvm-cov. Version check, iconic. β-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. Hash it and go. π₯
β EXIT STATUS β
llvm-cov gcov returns 1 if it cannot read input files. Otherwise, it exits with zero. So: can't read? 1. Otherwise? 0. No cap. π
β¨ SHOW COMMAND β¨
okay so this is the part where llvm-cov puts on its main-character glasses and shows you line-by-line coverage. Itβs giving βreceipts for your codeβ π
.
SYNOPSIS
llvm-cov show [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
DESCRIPTION
The llvm-cov show command shows line by line 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.... Slay, selective reporting, we love to see it π.
BIN may be an executable, object file, dynamic library, or archive (thin or otherwise). Versatile icon behavior, 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. This is literally the setup lore, bestie π§.
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. Raw glow-up pipeline, periodt β¨.
π OPTIONS π
-show-branches=<VIEW>β show coverage for branch conditions in terms of either count or percentage. The supported views are:"count","percent". Pick your fighter π .-show-mcdcβ show modified condition/decision coverage (MC/DC) for each applicable boolean expression. Fancy logic coverage, weβre obsessed.-show-mcdc-non-executed-vectorsβ when showing MC/DC details, also list test vectors that were not executed (for example in a Not executed section after the executed vectors). By default, only executed test vectors are shown. Giving you the unseen footage π.-show-line-countsβ show the execution counts for each line. Defaults totrue, unless another-showoption is used. My beloved default behavior π«Ά.-show-expansionsβ expand inclusions, such as preprocessor macros or textual inclusions, inline in the display of the source file. Defaults tofalse. Open the curtains on expansions π.-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. All the versions, plus the group chat summary π.-show-regionsβ show the execution counts for each region by displaying a caret that points to the character where the region starts. Defaults tofalse. Tiny caret, big information energy β¨.-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. Adaptive queen πΈ.-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. Folder-level lore unlocked ποΈ.-use-colorβ enable or disable color output. By default this is autodetected. Colors are literally the vibe check π.-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. Architecture matching is not a drill, bestie.-name=<NAME>β show code coverage only for functions with the given name. Targeted coverage, iykyk π―.-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. Allowlist behavior, wildcard slay π .-name-regex=<PATTERN>β show code coverage only for functions that match the given regular expression. Regex girlies rise π§.-ignore-filename-regex=<PATTERN>β skip source code files with file paths that match the given regular expression. Not today, matching paths π.-include-filename-regex=<PATTERN>β only include source code files with file paths that match the given regular expression. Keep the matching files, drop the rest.-format=<FORMAT>β use the specified output format. The supported formats are:"text","html". Choose your aesthetic β¨.-tab-size=<TABSIZE>β replace tabs with<TABSIZE>spaces when preparing reports. Currently, this is only supported for thehtmlformat. Tab-to-spaces glow-up, but only in HTML π.-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. Directory output pipeline, very organized, very demure π.-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. Demangling for readability, we love a communication queen π«Ά.-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. Multithreaded and mysterious, iconic π₯.-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. Path base behavior, very βwhere are my files actuallyβ π .-line-coverage-gt=<N>β show code coverage only for functions with line coverage greater than the given threshold. Filter by line coverage, we stan a threshold π.-line-coverage-lt=<N>β show code coverage only for functions with line coverage less than the given threshold. Low-coverage spotlight, no shame πΈ.-region-coverage-gt=<N>β show code coverage only for functions with region coverage greater than the given threshold. Region coverage filter, very precise π.-region-coverage-lt=<N>β show code coverage only for functions with region coverage less than the given threshold. Region coverage under-the-threshold check β¨.-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. Path mapping, but make it ordered π§.-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 between 0-100 and high > low. Color-coded coverage feelings, literally π.-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. Remote lookup behavior, very resourceful π .-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. Local search spot, very cozy π.-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 behavior, no missing binaries allowed π.-empty-profileβ display the baseline coverage of the binaries with all zero execution counts. Mutually exclusive with-instr-profile.
mutually exclusive means exactly what it sounds like, bestie: do not pair-empty-profilewith-instr-profileunless you want drama π.
π REPORT COMMAND π
β¨ SYNOPSIS β¨
llvm-cov report [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
π DESCRIPTION π
okay so the llvm-cov report command is literally the vibe check for your coverage β it shows a summary of the coverage of the binaries BIN... using the profile data PROFILE. You can also filter it down to only show coverage for the files you list in SOURCE... if that's what you're into. π
BIN can be an executable, object file, dynamic library, or archive (thin or otherwise) β so basically whatever you've got, she's not picky. π«Ά
If you don't hand it any source files, you get a summary line printed for each file in the coverage data. And if you do provide files, summaries can be shown for each function in those listed files β but only if the -show-functions option is enabled. iykyk. β¨
For information on compiling programs for coverage and generating profile data, see SHOW COMMAND. (already covered bestie, go look π)
πΈ OPTIONS πΈ
-use-color[=VALUE]β turn color output on or off. by default this is autodetected, so it just knows. π¨-arch=<name>β if the covered binary is a universal binary, this picks the architecture to use. and like, 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. no cap, she will not tolerate that. π-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 whose file paths match the given regular expression. bye felicia π-compilation-dir=<dir>β directory used as a base for relative coverage mapping paths. this only applies when binaries have been compiled with one of-fcoverage-prefix-map,-fcoverage-compilation-dir, or-ffile-compilation-dir. β-debuginfodβ try 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>β gives a directory to search for objects corresponding to binary IDs in the profile.-check-binary-idsβ fail 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. it's giving strict bestie energy. π-empty-profileβ display the baseline coverage of the binaries with all zero execution counts. mutually exclusive with-instr-profileβ you literally cannot have both, pick a lane. π
π¦ EXPORT COMMAND π¦
β¨ SYNOPSIS β¨
llvm-cov export [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
π DESCRIPTION π
llvm-cov export exports coverage data of the binaries BIN... using the profile data PROFILE, in either JSON or lcov trace file format. two formats, both iconic. π
When exporting JSON, the regions, functions, branches, expansions, and summaries of the coverage data get exported. When exporting an lcov trace file, the line-based coverage, branch coverage, and summaries get exported. slay, everything accounted for. β¨
The exported data can optionally be filtered to only export coverage for the files listed in SOURCE... β your call, bestie.
For information on compiling programs for coverage and generating profile data, see SHOW COMMAND. (yeah yeah, same note, it's important ok π)
πΈ OPTIONS πΈ
-arch=<name>β if the covered binary is a universal binary, select the architecture to use. 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. same rule as report, she's consistent. π-format=<FORMAT>β use the specified output format. the supported formats are:"text"(JSON) and"lcov". yes,"text"means JSON, that's just how it is, don't @ me. π-summary-onlyβ export only summary information for each file in the coverage data. this mode will not export coverage info for smaller units like individual functions or regions. the result contains the same info as produced by thellvm-cov reportcommand, but presented in JSON or lcov format rather than text. cute lil remix. π-ignore-filename-regex=<PATTERN>β skip source code files with file paths that match the given regular expression.-skip-expansionsβ skip exporting macro expansion coverage data.-skip-functionsβ skip exporting per-function coverage data.-show-mcdc-non-executed-vectorsβ when MC/DC data is present in the export, include test vectors that were not executed (for JSON, these appear with"executed": falsealongside executed vectors). by default, only executed MC/DC test vectors are exported. π§-num-threads=N,-j=Nβ useNthreads to export coverage data. whenN=0,llvm-covauto-detects an appropriate number of threads to use, and that's the default. parallel queen. β‘-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. 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 can't be found for a binary ID present in the profile, neither on the command line nor via binary ID lookup. π₯-empty-profileβ export the baseline coverage of the binaries with all zero execution counts. mutually exclusive with-instr-profile. again. pick one. π
π CONVERT-FOR-TESTING COMMAND π
β οΈ WARNING: this command is for the LLVM developers who are working on llvm-cov only. like, respectfully, this one isn't for you unless you're on the team. π
β¨ SYNOPSIS β¨
llvm-cov convert-for-testing BIN -o OUT
π DESCRIPTION π
llvm-cov convert-for-testing serves the purpose of testing llvm-cov itself. it can extract all code coverage data from the binary BIN into the file OUT, which reduces the size of test files. the output file typically bears the .covmapping extension. π¦
and the best part? the .covmapping files can be read back by llvm-cov just like ordinary binary files. round-trip slay. β¨
π AUTHOR π
Maintained by the LLVM Team (https://llvm.org/). they're the main characters fr fr. π
π COPYRIGHT π
2003-2026, LLVM Project
that's the whole page bestie, you made it to the end!! ππ this one's from the LLVM-COV(1) manual, page 23, dated 2026-10-06. go forth and get that coverage, you're gonna ate. πΈπ¦β¨
π¦ where this page comes from
- centos-stream 9: llvm 23.1.3-1.el9 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- centos-stream 9: llvm 23.1.3-1.el9 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms