LLVM-COV(1)

πŸ“¦ version 23.1.3, in centos-stream 9

✨ 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 🌈

  • gcov
  • show
  • report
  • export

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 causes llvm-cov to 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-hidden for 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-paths option 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 .gcov files. 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 in DIR or based on FILE's path. If you specify a particular object file, the coverage data files are expected to have the same base name with .gcno and .gcda extensions. 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-names option, 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 .gcov files. Terminal direct, no files. ⭐
  • -u, --unconditional-branches β€” include unconditional branches in the output for the --branch-probabilities option. Unconditional branches also deserve to be seen. πŸ’…
  • -version β€” display the version of llvm-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 to true, unless another -show option 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 to false. 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 to true. 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 to false. 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 to false. 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 to false. 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 with allowlist_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 the html format. 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 -name or -name-regex are used to select specific functions), the report is written to PATH/functions.EXTENSION. When used in file view mode, a report for each file is written to PATH/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 -n for 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 β€” use N threads to write file reports (only applicable when -output-dir is specified). When N=0, llvm-cov auto-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 use llvm-cov on a different machine where you have the same files on a different path. Multiple -path-equivalence arguments 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 in html format 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 to true if debuginfod is compiled in and configured via the DEBUGINFOD_URLS environment 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-profile with -instr-profile unless 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 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 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 via DEBUGINFOD_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 the llvm-cov report command, 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": false alongside executed vectors). by default, only executed MC/DC test vectors are exported. 🧚
  • -num-threads=N, -j=N β€” use N threads to export coverage data. when N=0, llvm-cov auto-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 via DEBUGINFOD_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. πŸ’–

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