]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/clang/llvm-cov/llvm-cov.1
MFV r344088 (libarchive):
[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" "2018-08-02" "7" "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 \-ignore\-filename\-regex=<PATTERN>
275 Skip source code files with file paths that match the given regular expression.
276 .UNINDENT
277 .INDENT 0.0
278 .TP
279 .B \-format=<FORMAT>
280 Use the specified output format. The supported formats are: "text", "html".
281 .UNINDENT
282 .INDENT 0.0
283 .TP
284 .B \-tab\-size=<TABSIZE>
285 Replace tabs with <TABSIZE> spaces when preparing reports. Currently, this is
286 only supported for the html format.
287 .UNINDENT
288 .INDENT 0.0
289 .TP
290 .B \-output\-dir=PATH
291 Specify a directory to write coverage reports into. If the directory does not
292 exist, it is created. When used in function view mode (i.e when \-name or
293 \-name\-regex are used to select specific functions), the report is written to
294 PATH/functions.EXTENSION. When used in file view mode, a report for each file
295 is written to PATH/REL_PATH_TO_FILE.EXTENSION.
296 .UNINDENT
297 .INDENT 0.0
298 .TP
299 .B \-Xdemangler=<TOOL>|<TOOL\-OPTION>
300 Specify a symbol demangler. This can be used to make reports more
301 human\-readable. This option can be specified multiple times to supply
302 arguments to the demangler (e.g \fI\-Xdemangler c++filt \-Xdemangler \-n\fP for C++).
303 The demangler is expected to read a newline\-separated list of symbols from
304 stdin and write a newline\-separated list of the same length to stdout.
305 .UNINDENT
306 .INDENT 0.0
307 .TP
308 .B \-num\-threads=N, \-j=N
309 Use N threads to write file reports (only applicable when \-output\-dir is
310 specified). When N=0, llvm\-cov auto\-detects an appropriate number of threads to
311 use. This is the default.
312 .UNINDENT
313 .INDENT 0.0
314 .TP
315 .B \-line\-coverage\-gt=<N>
316 Show code coverage only for functions with line coverage greater than the
317 given threshold.
318 .UNINDENT
319 .INDENT 0.0
320 .TP
321 .B \-line\-coverage\-lt=<N>
322 Show code coverage only for functions with line coverage less than the given
323 threshold.
324 .UNINDENT
325 .INDENT 0.0
326 .TP
327 .B \-region\-coverage\-gt=<N>
328 Show code coverage only for functions with region coverage greater than the
329 given threshold.
330 .UNINDENT
331 .INDENT 0.0
332 .TP
333 .B \-region\-coverage\-lt=<N>
334 Show code coverage only for functions with region coverage less than the given
335 threshold.
336 .UNINDENT
337 .INDENT 0.0
338 .TP
339 .B \-path\-equivalence=<from>,<to>
340 Map the paths in the coverage data to local source file paths. This allows you
341 to generate the coverage data on one machine, and then use llvm\-cov on a
342 different machine where you have the same files on a different path.
343 .UNINDENT
344 .SH REPORT COMMAND
345 .SS SYNOPSIS
346 .sp
347 \fBllvm\-cov report\fP [\fIoptions\fP] \-instr\-profile \fIPROFILE\fP \fIBIN\fP [\fI\-object BIN,...\fP] [[\fI\-object BIN\fP]] [\fISOURCES\fP]
348 .SS DESCRIPTION
349 .sp
350 The \fBllvm\-cov report\fP command displays a summary of the coverage of
351 the binaries \fIBIN\fP,... using the profile data \fIPROFILE\fP\&. It can optionally be
352 filtered to only show the coverage for the files listed in \fISOURCES\fP\&.
353 .sp
354 If no source files are provided, a summary line is printed for each file in the
355 coverage data. If any files are provided, summaries can be shown for each
356 function in the listed files if the \fB\-show\-functions\fP option is enabled.
357 .sp
358 For information on compiling programs for coverage and generating profile data,
359 see \fI\%SHOW COMMAND\fP\&.
360 .SS OPTIONS
361 .INDENT 0.0
362 .TP
363 .B \-use\-color[=VALUE]
364 Enable or disable color output. By default this is autodetected.
365 .UNINDENT
366 .INDENT 0.0
367 .TP
368 .B \-arch=<name>
369 If the covered binary is a universal binary, select the architecture to use.
370 It is an error to specify an architecture that is not included in the
371 universal binary or to use an architecture that does not match a
372 non\-universal binary.
373 .UNINDENT
374 .INDENT 0.0
375 .TP
376 .B \-show\-functions
377 Show coverage summaries for each function. Defaults to false.
378 .UNINDENT
379 .INDENT 0.0
380 .TP
381 .B \-show\-instantiation\-summary
382 Show statistics for all function instantiations. Defaults to false.
383 .UNINDENT
384 .INDENT 0.0
385 .TP
386 .B \-ignore\-filename\-regex=<PATTERN>
387 Skip source code files with file paths that match the given regular expression.
388 .UNINDENT
389 .SH EXPORT COMMAND
390 .SS SYNOPSIS
391 .sp
392 \fBllvm\-cov export\fP [\fIoptions\fP] \-instr\-profile \fIPROFILE\fP \fIBIN\fP [\fI\-object BIN,...\fP] [[\fI\-object BIN\fP]] [\fISOURCES\fP]
393 .SS DESCRIPTION
394 .sp
395 The \fBllvm\-cov export\fP command exports regions, functions, expansions,
396 and summaries of the coverage of the binaries \fIBIN\fP,... using the profile data
397 \fIPROFILE\fP as JSON. It can optionally be filtered to only export the coverage
398 for the files listed in \fISOURCES\fP\&.
399 .sp
400 For information on compiling programs for coverage and generating profile data,
401 see \fI\%SHOW COMMAND\fP\&.
402 .SS OPTIONS
403 .INDENT 0.0
404 .TP
405 .B \-arch=<name>
406 If the covered binary is a universal binary, select the architecture to use.
407 It is an error to specify an architecture that is not included in the
408 universal binary or to use an architecture that does not match a
409 non\-universal binary.
410 .UNINDENT
411 .INDENT 0.0
412 .TP
413 .B \-summary\-only
414 Export only summary information for each file in the coverage data. This mode
415 will not export coverage information for smaller units such as individual
416 functions or regions. The result will be the same as produced by :program:
417 \fIllvm\-cov report\fP command, but presented in JSON format rather than text.
418 .UNINDENT
419 .INDENT 0.0
420 .TP
421 .B \-ignore\-filename\-regex=<PATTERN>
422 Skip source code files with file paths that match the given regular expression.
423 .UNINDENT
424 .SH AUTHOR
425 Maintained by The LLVM Team (http://llvm.org/).
426 .SH COPYRIGHT
427 2003-2018, LLVM Project
428 .\" Generated by docutils manpage writer.
429 .