LLVM-COV(1)
β¨ NAME β¨
llvm-cov β emit coverage information. Hii bestie, this is the LLVM-COV(1) page π and we're about to make coverage data make sense, no cap.
πΈ SYNOPSIS πΈ
Okay so the whole shape of it is:
llvm-cov command [args...]
π¦ DESCRIPTION π¦
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 π
These are the commands, periodt:
gcovshowreportexport
π GCOV COMMAND π
β¨ SYNOPSIS β¨
llvm-cov gcov [options] SOURCEFILE
π DESCRIPTION π
Okay so 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.) You should compile with debugging information (-g) and without optimization (-O0); otherwise, the coverage data cannot be accurately mapped back to the source code.
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.
Warning bestie: old .gcda files can sneak into your coverage counts if you leave them around, so clean them up if you don't want their contents included.
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β okay so 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).-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 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.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.-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,...]
[[-object BIN]] [SOURCES]
π DESCRIPTION π
Okay so llvm-cov show is THE one that goes line by line through your binaries BIN,... and shows you the coverage, using the profile data in PROFILE. And if you only care about some files? You can filter it down to just the stuff in SOURCES. Obsessed.
BIN can be an executable, an object file, a dynamic library, or an archive (thin or otherwise). All of the above, no cap.
Now, to actually use llvm-cov show, you need a program compiled with instrumentation so it emits profile and coverage data. To build one of those with clang, use the -fprofile-instr-generate and -fcoverage-mapping flags. And if you're linking with the clang driver, pls pls pls pass -fprofile-instr-generate to the link stage too, so the necessary runtime libraries actually get linked in. π«Ά
The coverage info lives inside the built executable or library itself β that's the thing you hand to llvm-cov show as a BIN argument. The profile data comes from justβ¦ running the instrumented program like normal. When it exits, it writes out a raw profile file, typically called default.profraw, and you convert that into something suitable for the PROFILE argument using the llvm-profdata merge tool. π
π OPTIONS π
-show-line-countsβ shows the execution counts for each line. Defaults totrue, unless some other-showoption is in play.-show-expansionsβ expands inclusions, like preprocessor macros or textual inclusions, inline in the display of the source file. Defaults tofalse.-show-instantiationsβ for source regions that get instantiated multiple times (looking at you, C++ templates π), show each instantiation separately and the combined summary. Defaults totrue.-show-regionsβ shows the execution counts for each region by drawing a caret that points at the character where the region starts. Defaults tofalse.-show-line-counts-or-regionsβ shows execution counts per line if there's only one region on that line, but shows the individual regions if there are several on the line. Defaults tofalse.-use-colorβ enable or disable color output. By default it's autodetected. π-arch=[*NAMES*]β give a list of architectures where the Nth entry lines up with the Nth specified binary. If the covered object is a universal binary, this picks which architecture to use. Heads up: it's an error to name an architecture that isn't 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-whitelist=<FILE>β show code coverage only for functions listed in the given file. Each line in the file should start withwhitelist_fun:, immediately followed by the name of the function to accept. That name can be a wildcard expression.-name-regex=<PATTERN>β show code coverage only for functions matching the given regular expression.-ignore-filename-regex=<PATTERN>β skip source code files whose file paths 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 doesn't exist, it gets 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 make reports way more human-readable. You can specify this option multiple times to feed 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β useNthreads to write file reports (only applicable when-output-diris specified). WhenN=0, llvm-cov auto-detects an appropriate number of threads to use. That's the default.-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 coverage data on one machine and then use llvm-cov on a different machine where you have the same files sitting at a different path. Main character problem-solving fr fr. π
π₯ REPORT COMMAND π₯
β¨ SYNOPSIS β¨
llvm-cov report [options] -instr-profile PROFILE BIN [-object BIN,...]
[[-object BIN]] [SOURCES]
π DESCRIPTION π
llvm-cov report gives you a summary of the coverage of the binaries BIN,... using the profile data PROFILE. And yep, it can optionally be filtered to only show coverage for the files listed in SOURCES.
BIN may be an executable, object file, dynamic library, or archive (thin or otherwise).
If you don't provide any source files, a summary line is printed for each file in the coverage data. If you do provide files, 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 look at 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. Heads up: 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. β οΈ-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.
π EXPORT COMMAND π
π SYNOPSIS π
llvm-cov export [options] -instr-profile PROFILE BIN [-object BIN,...]
[[-object BIN]] [SOURCES]
π« DESCRIPTION π«
llvm-cov export exports coverage data of the binaries BIN,... using the profile data PROFILE, in either JSON or lcov trace file format. Pick your fighter. π
When exporting JSON, the regions, functions, expansions, and summaries of the coverage data all get exported. When exporting an lcov trace file, the line-based coverage and summaries get exported.
The exported data can optionally be filtered to only export the coverage for the files listed in SOURCES.
For info on compiling programs for coverage and generating profile data, see SHOW COMMAND.
π§ OPTIONS π§
-arch=<name>β if the covered binary is a universal binary, select the architecture to use. Heads up: 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. β οΈ-format=<FORMAT>β use the specified output format. The supported formats are:"text"(JSON),"lcov".-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 produced by thellvm-cov reportcommand, but presented in JSON or lcov format rather than text.-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.-num-threads=N,-j=Nβ useNthreads to export coverage data. WhenN=0, llvm-cov auto-detects an appropriate number of threads to use. That's the default.
π AUTHOR π
Maintained by the LLVM Team (https://llvm.org/). Slay. π
πΈ COPYRIGHT πΈ
2003-2024, LLVM Project
okay bestie that's the whole page, go forth and cover some code π
β¨π¦ this was LLVM-COV(1), dated 2024-07-18 β ily, stan the LLVM Project π«Άπ
π¦ where this page comes from
- fedora 43: llvm11 11.1.0-14.fc41 Β· NCSA
- fedora 43: llvm11 11.1.0-14.fc41 Β· NCSA
- fedora 44: llvm11 11.1.0-14.fc41 Β· NCSA
- fedora 44: llvm11 11.1.0-14.fc41 Β· NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms