1 llvm-cov - emit coverage information 2 ==================================== 3 4 SYNOPSIS 5 -------- 6 7 :program:`llvm-cov` [options] SOURCEFILE 8 9 DESCRIPTION 10 ----------- 11 12 The :program:`llvm-cov` tool reads code coverage data files and displays the 13 coverage information for a specified source file. It is compatible with the 14 ``gcov`` tool from version 4.2 of ``GCC`` and may also be compatible with 15 some later versions of ``gcov``. 16 17 To use llvm-cov, you must first build an instrumented version of your 18 application that collects coverage data as it runs. Compile with the 19 ``-fprofile-arcs`` and ``-ftest-coverage`` options to add the 20 instrumentation. (Alternatively, you can use the ``--coverage`` option, which 21 includes both of those other options.) You should compile with debugging 22 information (``-g``) and without optimization (``-O0``); otherwise, the 23 coverage data cannot be accurately mapped back to the source code. 24 25 At the time you compile the instrumented code, a ``.gcno`` data file will be 26 generated for each object file. These ``.gcno`` files contain half of the 27 coverage data. The other half of the data comes from ``.gcda`` files that are 28 generated when you run the instrumented program, with a separate ``.gcda`` 29 file for each object file. Each time you run the program, the execution counts 30 are summed into any existing ``.gcda`` files, so be sure to remove any old 31 files if you do not want their contents to be included. 32 33 By default, the ``.gcda`` files are written into the same directory as the 34 object files, but you can override that by setting the ``GCOV_PREFIX`` and 35 ``GCOV_PREFIX_STRIP`` environment variables. The ``GCOV_PREFIX_STRIP`` 36 variable specifies a number of directory components to be removed from the 37 start of the absolute path to the object file directory. After stripping those 38 directories, the prefix from the ``GCOV_PREFIX`` variable is added. These 39 environment variables allow you to run the instrumented program on a machine 40 where the original object file directories are not accessible, but you will 41 then need to copy the ``.gcda`` files back to the object file directories 42 where llvm-cov expects to find them. 43 44 Once you have generated the coverage data files, run llvm-cov for each main 45 source file where you want to examine the coverage results. This should be run 46 from the same directory where you previously ran the compiler. The results for 47 the specified source file are written to a file named by appending a ``.gcov`` 48 suffix. A separate output file is also created for each file included by the 49 main source file, also with a ``.gcov`` suffix added. 50 51 The basic content of an llvm-cov output file is a copy of the source file with 52 an execution count and line number prepended to every line. The execution 53 count is shown as ``-`` if a line does not contain any executable code. If 54 a line contains code but that code was never executed, the count is displayed 55 as ``#####``. 56 57 58 OPTIONS 59 ------- 60 61 .. option:: -a, --all-blocks 62 63 Display all basic blocks. If there are multiple blocks for a single line of 64 source code, this option causes llvm-cov to show the count for each block 65 instead of just one count for the entire line. 66 67 .. option:: -b, --branch-probabilities 68 69 Display conditional branch probabilities and a summary of branch information. 70 71 .. option:: -c, --branch-counts 72 73 Display branch counts instead of probabilities (requires -b). 74 75 .. option:: -f, --function-summaries 76 77 Show a summary of coverage for each function instead of just one summary for 78 an entire source file. 79 80 .. option:: --help 81 82 Display available options (--help-hidden for more). 83 84 .. option:: -l, --long-file-names 85 86 For coverage output of files included from the main source file, add the 87 main file name followed by ``##`` as a prefix to the output file names. This 88 can be combined with the --preserve-paths option to use complete paths for 89 both the main file and the included file. 90 91 .. option:: -n, --no-output 92 93 Do not output any ``.gcov`` files. Summary information is still 94 displayed. 95 96 .. option:: -o=<DIR|FILE>, --object-directory=<DIR>, --object-file=<FILE> 97 98 Find objects in DIR or based on FILE's path. If you specify a particular 99 object file, the coverage data files are expected to have the same base name 100 with ``.gcno`` and ``.gcda`` extensions. If you specify a directory, the 101 files are expected in that directory with the same base name as the source 102 file. 103 104 .. option:: -p, --preserve-paths 105 106 Preserve path components when naming the coverage output files. In addition 107 to the source file name, include the directories from the path to that 108 file. The directories are separate by ``#`` characters, with ``.`` directories 109 removed and ``..`` directories replaced by ``^`` characters. When used with 110 the --long-file-names option, this applies to both the main file name and the 111 included file name. 112 113 .. option:: -u, --unconditional-branches 114 115 Include unconditional branches in the output for the --branch-probabilities 116 option. 117 118 .. option:: -version 119 120 Display the version of llvm-cov. 121 122 EXIT STATUS 123 ----------- 124 125 :program:`llvm-cov` returns 1 if it cannot read input files. Otherwise, it 126 exits with zero. 127 128