]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/clang/llvm-cov/llvm-cov.1
MFV r339640,339641,339644:
[FreeBSD/FreeBSD.git] / usr.bin / clang / llvm-cov / llvm-cov.1
1 .\" $FreeBSD$
2 .\" Man page generated from reStructuredText.
3 .
4 .TH "LLVM-COV" "1" "2017-12-24" "6" "LLVM"
5 .SH NAME
6 llvm-cov \- emit coverage information
7 .
8 .nr rst2man-indent-level 0
9 .
10 .de1 rstReportMargin
11 \\$1 \\n[an-margin]
12 level \\n[rst2man-indent-level]
13 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
14 -
15 \\n[rst2man-indent0]
16 \\n[rst2man-indent1]
17 \\n[rst2man-indent2]
18 ..
19 .de1 INDENT
20 .\" .rstReportMargin pre:
21 . RS \\$1
22 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
23 . nr rst2man-indent-level +1
24 .\" .rstReportMargin post:
25 ..
26 .de UNINDENT
27 . RE
28 .\" indent \\n[an-margin]
29 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
30 .nr rst2man-indent-level -1
31 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
32 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
33 ..
34 .SH SYNOPSIS
35 .sp
36 \fBllvm\-cov\fP \fIcommand\fP [\fIargs...\fP]
37 .SH DESCRIPTION
38 .sp
39 The \fBllvm\-cov\fP tool shows code coverage information for
40 programs that are instrumented to emit profile data. It can be used to
41 work with \fBgcov\fP\-style coverage or with \fBclang\fP\(aqs instrumentation
42 based profiling.
43 .sp
44 If the program is invoked with a base name of \fBgcov\fP, it will behave as if
45 the \fBllvm\-cov gcov\fP command were called. Otherwise, a command should
46 be provided.
47 .SH COMMANDS
48 .INDENT 0.0
49 .IP \(bu 2
50 \fI\%gcov\fP
51 .IP \(bu 2
52 \fI\%show\fP
53 .IP \(bu 2
54 \fI\%report\fP
55 .IP \(bu 2
56 \fI\%export\fP
57 .UNINDENT
58 .SH GCOV COMMAND
59 .SS SYNOPSIS
60 .sp
61 \fBllvm\-cov gcov\fP [\fIoptions\fP] \fISOURCEFILE\fP
62 .SS DESCRIPTION
63 .sp
64 The \fBllvm\-cov gcov\fP tool reads code coverage data files and displays
65 the coverage information for a specified source file. It is compatible with the
66 \fBgcov\fP tool from version 4.2 of \fBGCC\fP and may also be compatible with some
67 later versions of \fBgcov\fP\&.
68 .sp
69 To use \fBllvm\-cov gcov\fP, you must first build an instrumented version
70 of your application that collects coverage data as it runs. Compile with the
71 \fB\-fprofile\-arcs\fP and \fB\-ftest\-coverage\fP options to add the
72 instrumentation. (Alternatively, you can use the \fB\-\-coverage\fP option, which
73 includes both of those other options.) You should compile with debugging
74 information (\fB\-g\fP) and without optimization (\fB\-O0\fP); otherwise, the
75 coverage data cannot be accurately mapped back to the source code.
76 .sp
77 At the time you compile the instrumented code, a \fB\&.gcno\fP data file will be
78 generated for each object file. These \fB\&.gcno\fP files contain half of the
79 coverage data. The other half of the data comes from \fB\&.gcda\fP files that are
80 generated when you run the instrumented program, with a separate \fB\&.gcda\fP
81 file for each object file. Each time you run the program, the execution counts
82 are summed into any existing \fB\&.gcda\fP files, so be sure to remove any old
83 files if you do not want their contents to be included.
84 .sp
85 By default, the \fB\&.gcda\fP files are written into the same directory as the
86 object files, but you can override that by setting the \fBGCOV_PREFIX\fP and
87 \fBGCOV_PREFIX_STRIP\fP environment variables. The \fBGCOV_PREFIX_STRIP\fP
88 variable specifies a number of directory components to be removed from the
89 start of the absolute path to the object file directory. After stripping those
90 directories, the prefix from the \fBGCOV_PREFIX\fP variable is added. These
91 environment variables allow you to run the instrumented program on a machine
92 where the original object file directories are not accessible, but you will
93 then need to copy the \fB\&.gcda\fP files back to the object file directories
94 where \fBllvm\-cov gcov\fP expects to find them.
95 .sp
96 Once you have generated the coverage data files, run \fBllvm\-cov gcov\fP
97 for each main source file where you want to examine the coverage results. This
98 should be run from the same directory where you previously ran the
99 compiler. The results for the specified source file are written to a file named
100 by appending a \fB\&.gcov\fP suffix. A separate output file is also created for
101 each file included by the main source file, also with a \fB\&.gcov\fP suffix added.
102 .sp
103 The basic content of an \fB\&.gcov\fP output file is a copy of the source file with
104 an execution count and line number prepended to every line. The execution
105 count is shown as \fB\-\fP if a line does not contain any executable code. If
106 a line contains code but that code was never executed, the count is displayed
107 as \fB#####\fP\&.
108 .SS OPTIONS
109 .INDENT 0.0
110 .TP
111 .B \-a, \-\-all\-blocks
112 Display all basic blocks. If there are multiple blocks for a single line of
113 source code, this option causes llvm\-cov to show the count for each block
114 instead of just one count for the entire line.
115 .UNINDENT
116 .INDENT 0.0
117 .TP
118 .B \-b, \-\-branch\-probabilities
119 Display conditional branch probabilities and a summary of branch information.
120 .UNINDENT
121 .INDENT 0.0
122 .TP
123 .B \-c, \-\-branch\-counts
124 Display branch counts instead of probabilities (requires \-b).
125 .UNINDENT
126 .INDENT 0.0
127 .TP
128 .B \-f, \-\-function\-summaries
129 Show a summary of coverage for each function instead of just one summary for
130 an entire source file.
131 .UNINDENT
132 .INDENT 0.0
133 .TP
134 .B \-\-help
135 Display available options (\-\-help\-hidden for more).
136 .UNINDENT
137 .INDENT 0.0
138 .TP
139 .B \-l, \-\-long\-file\-names
140 For coverage output of files included from the main source file, add the
141 main file name followed by \fB##\fP as a prefix to the output file names. This
142 can be combined with the \-\-preserve\-paths option to use complete paths for
143 both the main file and the included file.
144 .UNINDENT
145 .INDENT 0.0
146 .TP
147 .B \-n, \-\-no\-output
148 Do not output any \fB\&.gcov\fP files. Summary information is still
149 displayed.
150 .UNINDENT
151 .INDENT 0.0
152 .TP
153 .B \-o=<DIR|FILE>, \-\-object\-directory=<DIR>, \-\-object\-file=<FILE>
154 Find objects in DIR or based on FILE\(aqs path. If you specify a particular
155 object file, the coverage data files are expected to have the same base name
156 with \fB\&.gcno\fP and \fB\&.gcda\fP extensions. If you specify a directory, the
157 files are expected in that directory with the same base name as the source
158 file.
159 .UNINDENT
160 .INDENT 0.0
161 .TP
162 .B \-p, \-\-preserve\-paths
163 Preserve path components when naming the coverage output files. In addition
164 to the source file name, include the directories from the path to that
165 file. The directories are separate by \fB#\fP characters, with \fB\&.\fP directories
166 removed and \fB\&..\fP directories replaced by \fB^\fP characters. When used with
167 the \-\-long\-file\-names option, this applies to both the main file name and the
168 included file name.
169 .UNINDENT
170 .INDENT 0.0
171 .TP
172 .B \-u, \-\-unconditional\-branches
173 Include unconditional branches in the output for the \-\-branch\-probabilities
174 option.
175 .UNINDENT
176 .INDENT 0.0
177 .TP
178 .B \-version
179 Display the version of llvm\-cov.
180 .UNINDENT
181 .SS EXIT STATUS
182 .sp
183 \fBllvm\-cov gcov\fP returns 1 if it cannot read input files.  Otherwise,
184 it exits with zero.
185 .SH SHOW COMMAND
186 .SS SYNOPSIS
187 .sp
188 \fBllvm\-cov show\fP [\fIoptions\fP] \-instr\-profile \fIPROFILE\fP \fIBIN\fP [\fI\-object BIN,...\fP] [[\fI\-object BIN\fP]] [\fISOURCES\fP]
189 .SS DESCRIPTION
190 .sp
191 The \fBllvm\-cov show\fP command shows line by line coverage of the
192 binaries \fIBIN\fP,...  using the profile data \fIPROFILE\fP\&. It can optionally be
193 filtered to only show the coverage for the files listed in \fISOURCES\fP\&.
194 .sp
195 To use \fBllvm\-cov show\fP, you need a program that is compiled with
196 instrumentation to emit profile and coverage data. To build such a program with
197 \fBclang\fP use the \fB\-fprofile\-instr\-generate\fP and \fB\-fcoverage\-mapping\fP
198 flags. If linking with the \fBclang\fP driver, pass \fB\-fprofile\-instr\-generate\fP
199 to the link stage to make sure the necessary runtime libraries are linked in.
200 .sp
201 The coverage information is stored in the built executable or library itself,
202 and this is what you should pass to \fBllvm\-cov show\fP as a \fIBIN\fP
203 argument. The profile data is generated by running this instrumented program
204 normally. When the program exits it will write out a raw profile file,
205 typically called \fBdefault.profraw\fP, which can be converted to a format that
206 is suitable for the \fIPROFILE\fP argument using the \fBllvm\-profdata merge\fP
207 tool.
208 .SS OPTIONS
209 .INDENT 0.0
210 .TP
211 .B \-show\-line\-counts
212 Show the execution counts for each line. Defaults to true, unless another
213 \fB\-show\fP option is used.
214 .UNINDENT
215 .INDENT 0.0
216 .TP
217 .B \-show\-expansions
218 Expand inclusions, such as preprocessor macros or textual inclusions, inline
219 in the display of the source file. Defaults to false.
220 .UNINDENT
221 .INDENT 0.0
222 .TP
223 .B \-show\-instantiations
224 For source regions that are instantiated multiple times, such as templates in
225 \fBC++\fP, show each instantiation separately as well as the combined summary.
226 Defaults to true.
227 .UNINDENT
228 .INDENT 0.0
229 .TP
230 .B \-show\-regions
231 Show the execution counts for each region by displaying a caret that points to
232 the character where the region starts. Defaults to false.
233 .UNINDENT
234 .INDENT 0.0
235 .TP
236 .B \-show\-line\-counts\-or\-regions
237 Show the execution counts for each line if there is only one region on the
238 line, but show the individual regions if there are multiple on the line.
239 Defaults to false.
240 .UNINDENT
241 .INDENT 0.0
242 .TP
243 .B \-use\-color
244 Enable or disable color output. By default this is autodetected.
245 .UNINDENT
246 .INDENT 0.0
247 .TP
248 .B \-arch=[*NAMES*]
249 Specify a list of architectures such that the Nth entry in the list
250 corresponds to the Nth specified binary. If the covered object is a universal
251 binary, this specifies the architecture to use. It is an error to specify an
252 architecture that is not included in the universal binary or to use an
253 architecture that does not match a non\-universal binary.
254 .UNINDENT
255 .INDENT 0.0
256 .TP
257 .B \-name=<NAME>
258 Show code coverage only for functions with the given name.
259 .UNINDENT
260 .INDENT 0.0
261 .TP
262 .B \-name\-whitelist=<FILE>
263 Show code coverage only for functions listed in the given file. Each line in
264 the file should start with \fIwhitelist_fun:\fP, immediately followed by the name
265 of the function to accept. This name can be a wildcard expression.
266 .UNINDENT
267 .INDENT 0.0
268 .TP
269 .B \-name\-regex=<PATTERN>
270 Show code coverage only for functions that match the given regular expression.
271 .UNINDENT
272 .INDENT 0.0
273 .TP
274 .B \-format=<FORMAT>
275 Use the specified output format. The supported formats are: "text", "html".
276 .UNINDENT
277 .INDENT 0.0
278 .TP
279 .B \-tab\-size=<TABSIZE>
280 Replace tabs with <TABSIZE> spaces when preparing reports. Currently, this is
281 only supported for the html format.
282 .UNINDENT
283 .INDENT 0.0
284 .TP
285 .B \-output\-dir=PATH
286 Specify a directory to write coverage reports into. If the directory does not
287 exist, it is created. When used in function view mode (i.e when \-name or
288 \-name\-regex are used to select specific functions), the report is written to
289 PATH/functions.EXTENSION. When used in file view mode, a report for each file
290 is written to PATH/REL_PATH_TO_FILE.EXTENSION.
291 .UNINDENT
292 .INDENT 0.0
293 .TP
294 .B \-Xdemangler=<TOOL>|<TOOL\-OPTION>
295 Specify a symbol demangler. This can be used to make reports more
296 human\-readable. This option can be specified multiple times to supply
297 arguments to the demangler (e.g \fI\-Xdemangler c++filt \-Xdemangler \-n\fP for C++).
298 The demangler is expected to read a newline\-separated list of symbols from
299 stdin and write a newline\-separated list of the same length to stdout.
300 .UNINDENT
301 .INDENT 0.0
302 .TP
303 .B \-num\-threads=N, \-j=N
304 Use N threads to write file reports (only applicable when \-output\-dir is
305 specified). When N=0, llvm\-cov auto\-detects an appropriate number of threads to
306 use. This is the default.
307 .UNINDENT
308 .INDENT 0.0
309 .TP
310 .B \-line\-coverage\-gt=<N>
311 Show code coverage only for functions with line coverage greater than the
312 given threshold.
313 .UNINDENT
314 .INDENT 0.0
315 .TP
316 .B \-line\-coverage\-lt=<N>
317 Show code coverage only for functions with line coverage less than the given
318 threshold.
319 .UNINDENT
320 .INDENT 0.0
321 .TP
322 .B \-region\-coverage\-gt=<N>
323 Show code coverage only for functions with region coverage greater than the
324 given threshold.
325 .UNINDENT
326 .INDENT 0.0
327 .TP
328 .B \-region\-coverage\-lt=<N>
329 Show code coverage only for functions with region coverage less than the given
330 threshold.
331 .UNINDENT
332 .INDENT 0.0
333 .TP
334 .B \-path\-equivalence=<from>,<to>
335 Map the paths in the coverage data to local source file paths. This allows you
336 to generate the coverage data on one machine, and then use llvm\-cov on a
337 different machine where you have the same files on a different path.
338 .UNINDENT
339 .SH REPORT COMMAND
340 .SS SYNOPSIS
341 .sp
342 \fBllvm\-cov report\fP [\fIoptions\fP] \-instr\-profile \fIPROFILE\fP \fIBIN\fP [\fI\-object BIN,...\fP] [[\fI\-object BIN\fP]] [\fISOURCES\fP]
343 .SS DESCRIPTION
344 .sp
345 The \fBllvm\-cov report\fP command displays a summary of the coverage of
346 the binaries \fIBIN\fP,... using the profile data \fIPROFILE\fP\&. It can optionally be
347 filtered to only show the coverage for the files listed in \fISOURCES\fP\&.
348 .sp
349 If no source files are provided, a summary line is printed for each file in the
350 coverage data. If any files are provided, summaries are shown for each function
351 in the listed files instead.
352 .sp
353 For information on compiling programs for coverage and generating profile data,
354 see \fI\%SHOW COMMAND\fP\&.
355 .SS OPTIONS
356 .INDENT 0.0
357 .TP
358 .B \-use\-color[=VALUE]
359 Enable or disable color output. By default this is autodetected.
360 .UNINDENT
361 .INDENT 0.0
362 .TP
363 .B \-arch=<name>
364 If the covered binary is a universal binary, select the architecture to use.
365 It is an error to specify an architecture that is not included in the
366 universal binary or to use an architecture that does not match a
367 non\-universal binary.
368 .UNINDENT
369 .INDENT 0.0
370 .TP
371 .B \-show\-functions
372 Show coverage summaries for each function. Defaults to false.
373 .UNINDENT
374 .INDENT 0.0
375 .TP
376 .B \-show\-instantiation\-summary
377 Show statistics for all function instantiations. Defaults to false.
378 .UNINDENT
379 .SH EXPORT COMMAND
380 .SS SYNOPSIS
381 .sp
382 \fBllvm\-cov export\fP [\fIoptions\fP] \-instr\-profile \fIPROFILE\fP \fIBIN\fP [\fI\-object BIN,...\fP] [[\fI\-object BIN\fP]]
383 .SS DESCRIPTION
384 .sp
385 The \fBllvm\-cov export\fP command exports regions, functions, expansions,
386 and summaries of the coverage of the binaries \fIBIN\fP,... using the profile data
387 \fIPROFILE\fP as JSON.
388 .sp
389 For information on compiling programs for coverage and generating profile data,
390 see \fI\%SHOW COMMAND\fP\&.
391 .SS OPTIONS
392 .INDENT 0.0
393 .TP
394 .B \-arch=<name>
395 If the covered binary is a universal binary, select the architecture to use.
396 It is an error to specify an architecture that is not included in the
397 universal binary or to use an architecture that does not match a
398 non\-universal binary.
399 .UNINDENT
400 .INDENT 0.0
401 .TP
402 .B \-summary\-only
403 Export only summary information for each file in the coverage data. This mode
404 will not export coverage information for smaller units such as individual
405 functions or regions. The result will be the same as produced by :program:
406 \fIllvm\-cov report\fP command, but presented in JSON format rather than text.
407 .UNINDENT
408 .SH AUTHOR
409 Maintained by The LLVM Team (http://llvm.org/).
410 .SH COPYRIGHT
411 2003-2017, LLVM Project
412 .\" Generated by docutils manpage writer.
413 .