]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/clang/llvm-cov/llvm-cov.1
MFV r310622:
[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" "2016-03-03" "3.8" "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 .UNINDENT
56 .SH GCOV COMMAND
57 .SS SYNOPSIS
58 .sp
59 \fBllvm\-cov gcov\fP [\fIoptions\fP] \fISOURCEFILE\fP
60 .SS DESCRIPTION
61 .sp
62 The \fBllvm\-cov gcov\fP tool reads code coverage data files and displays
63 the coverage information for a specified source file. It is compatible with the
64 \fBgcov\fP tool from version 4.2 of \fBGCC\fP and may also be compatible with some
65 later versions of \fBgcov\fP\&.
66 .sp
67 To use \fBllvm\-cov gcov\fP, you must first build an instrumented version
68 of your application that collects coverage data as it runs. Compile with the
69 \fB\-fprofile\-arcs\fP and \fB\-ftest\-coverage\fP options to add the
70 instrumentation. (Alternatively, you can use the \fB\-\-coverage\fP option, which
71 includes both of those other options.) You should compile with debugging
72 information (\fB\-g\fP) and without optimization (\fB\-O0\fP); otherwise, the
73 coverage data cannot be accurately mapped back to the source code.
74 .sp
75 At the time you compile the instrumented code, a \fB\&.gcno\fP data file will be
76 generated for each object file. These \fB\&.gcno\fP files contain half of the
77 coverage data. The other half of the data comes from \fB\&.gcda\fP files that are
78 generated when you run the instrumented program, with a separate \fB\&.gcda\fP
79 file for each object file. Each time you run the program, the execution counts
80 are summed into any existing \fB\&.gcda\fP files, so be sure to remove any old
81 files if you do not want their contents to be included.
82 .sp
83 By default, the \fB\&.gcda\fP files are written into the same directory as the
84 object files, but you can override that by setting the \fBGCOV_PREFIX\fP and
85 \fBGCOV_PREFIX_STRIP\fP environment variables. The \fBGCOV_PREFIX_STRIP\fP
86 variable specifies a number of directory components to be removed from the
87 start of the absolute path to the object file directory. After stripping those
88 directories, the prefix from the \fBGCOV_PREFIX\fP variable is added. These
89 environment variables allow you to run the instrumented program on a machine
90 where the original object file directories are not accessible, but you will
91 then need to copy the \fB\&.gcda\fP files back to the object file directories
92 where \fBllvm\-cov gcov\fP expects to find them.
93 .sp
94 Once you have generated the coverage data files, run \fBllvm\-cov gcov\fP
95 for each main source file where you want to examine the coverage results. This
96 should be run from the same directory where you previously ran the
97 compiler. The results for the specified source file are written to a file named
98 by appending a \fB\&.gcov\fP suffix. A separate output file is also created for
99 each file included by the main source file, also with a \fB\&.gcov\fP suffix added.
100 .sp
101 The basic content of an \fB\&.gcov\fP output file is a copy of the source file with
102 an execution count and line number prepended to every line. The execution
103 count is shown as \fB\-\fP if a line does not contain any executable code. If
104 a line contains code but that code was never executed, the count is displayed
105 as \fB#####\fP\&.
106 .SS OPTIONS
107 .INDENT 0.0
108 .TP
109 .B \-a, \-\-all\-blocks
110 Display all basic blocks. If there are multiple blocks for a single line of
111 source code, this option causes llvm\-cov to show the count for each block
112 instead of just one count for the entire line.
113 .UNINDENT
114 .INDENT 0.0
115 .TP
116 .B \-b, \-\-branch\-probabilities
117 Display conditional branch probabilities and a summary of branch information.
118 .UNINDENT
119 .INDENT 0.0
120 .TP
121 .B \-c, \-\-branch\-counts
122 Display branch counts instead of probabilities (requires \-b).
123 .UNINDENT
124 .INDENT 0.0
125 .TP
126 .B \-f, \-\-function\-summaries
127 Show a summary of coverage for each function instead of just one summary for
128 an entire source file.
129 .UNINDENT
130 .INDENT 0.0
131 .TP
132 .B \-\-help
133 Display available options (\-\-help\-hidden for more).
134 .UNINDENT
135 .INDENT 0.0
136 .TP
137 .B \-l, \-\-long\-file\-names
138 For coverage output of files included from the main source file, add the
139 main file name followed by \fB##\fP as a prefix to the output file names. This
140 can be combined with the \-\-preserve\-paths option to use complete paths for
141 both the main file and the included file.
142 .UNINDENT
143 .INDENT 0.0
144 .TP
145 .B \-n, \-\-no\-output
146 Do not output any \fB\&.gcov\fP files. Summary information is still
147 displayed.
148 .UNINDENT
149 .INDENT 0.0
150 .TP
151 .B \-o=<DIR|FILE>, \-\-object\-directory=<DIR>, \-\-object\-file=<FILE>
152 Find objects in DIR or based on FILE\(aqs path. If you specify a particular
153 object file, the coverage data files are expected to have the same base name
154 with \fB\&.gcno\fP and \fB\&.gcda\fP extensions. If you specify a directory, the
155 files are expected in that directory with the same base name as the source
156 file.
157 .UNINDENT
158 .INDENT 0.0
159 .TP
160 .B \-p, \-\-preserve\-paths
161 Preserve path components when naming the coverage output files. In addition
162 to the source file name, include the directories from the path to that
163 file. The directories are separate by \fB#\fP characters, with \fB\&.\fP directories
164 removed and \fB\&..\fP directories replaced by \fB^\fP characters. When used with
165 the \-\-long\-file\-names option, this applies to both the main file name and the
166 included file name.
167 .UNINDENT
168 .INDENT 0.0
169 .TP
170 .B \-u, \-\-unconditional\-branches
171 Include unconditional branches in the output for the \-\-branch\-probabilities
172 option.
173 .UNINDENT
174 .INDENT 0.0
175 .TP
176 .B \-version
177 Display the version of llvm\-cov.
178 .UNINDENT
179 .SS EXIT STATUS
180 .sp
181 \fBllvm\-cov gcov\fP returns 1 if it cannot read input files.  Otherwise,
182 it exits with zero.
183 .SH SHOW COMMAND
184 .SS SYNOPSIS
185 .sp
186 \fBllvm\-cov show\fP [\fIoptions\fP] \-instr\-profile \fIPROFILE\fP \fIBIN\fP [\fISOURCES\fP]
187 .SS DESCRIPTION
188 .sp
189 The \fBllvm\-cov show\fP command shows line by line coverage of a binary
190 \fIBIN\fP using the profile data \fIPROFILE\fP\&. It can optionally be filtered to only
191 show the coverage for the files listed in \fISOURCES\fP\&.
192 .sp
193 To use \fBllvm\-cov show\fP, you need a program that is compiled with
194 instrumentation to emit profile and coverage data. To build such a program with
195 \fBclang\fP use the \fB\-fprofile\-instr\-generate\fP and \fB\-fcoverage\-mapping\fP
196 flags. If linking with the \fBclang\fP driver, pass \fB\-fprofile\-instr\-generate\fP
197 to the link stage to make sure the necessary runtime libraries are linked in.
198 .sp
199 The coverage information is stored in the built executable or library itself,
200 and this is what you should pass to \fBllvm\-cov show\fP as the \fIBIN\fP
201 argument. The profile data is generated by running this instrumented program
202 normally. When the program exits it will write out a raw profile file,
203 typically called \fBdefault.profraw\fP, which can be converted to a format that
204 is suitable for the \fIPROFILE\fP argument using the \fBllvm\-profdata merge\fP
205 tool.
206 .SS OPTIONS
207 .INDENT 0.0
208 .TP
209 .B \-show\-line\-counts
210 Show the execution counts for each line. This is enabled by default, unless
211 another \fB\-show\fP option is used.
212 .UNINDENT
213 .INDENT 0.0
214 .TP
215 .B \-show\-expansions
216 Expand inclusions, such as preprocessor macros or textual inclusions, inline
217 in the display of the source file.
218 .UNINDENT
219 .INDENT 0.0
220 .TP
221 .B \-show\-instantiations
222 For source regions that are instantiated multiple times, such as templates in
223 \fBC++\fP, show each instantiation separately as well as the combined summary.
224 .UNINDENT
225 .INDENT 0.0
226 .TP
227 .B \-show\-regions
228 Show the execution counts for each region by displaying a caret that points to
229 the character where the region starts.
230 .UNINDENT
231 .INDENT 0.0
232 .TP
233 .B \-show\-line\-counts\-or\-regions
234 Show the execution counts for each line if there is only one region on the
235 line, but show the individual regions if there are multiple on the line.
236 .UNINDENT
237 .INDENT 0.0
238 .TP
239 .B \-use\-color[=VALUE]
240 Enable or disable color output. By default this is autodetected.
241 .UNINDENT
242 .INDENT 0.0
243 .TP
244 .B \-arch=<name>
245 If the covered binary is a universal binary, select the architecture to use.
246 It is an error to specify an architecture that is not included in the
247 universal binary or to use an architecture that does not match a
248 non\-universal binary.
249 .UNINDENT
250 .INDENT 0.0
251 .TP
252 .B \-name=<NAME>
253 Show code coverage only for functions with the given name.
254 .UNINDENT
255 .INDENT 0.0
256 .TP
257 .B \-name\-regex=<PATTERN>
258 Show code coverage only for functions that match the given regular expression.
259 .UNINDENT
260 .INDENT 0.0
261 .TP
262 .B \-line\-coverage\-gt=<N>
263 Show code coverage only for functions with line coverage greater than the
264 given threshold.
265 .UNINDENT
266 .INDENT 0.0
267 .TP
268 .B \-line\-coverage\-lt=<N>
269 Show code coverage only for functions with line coverage less than the given
270 threshold.
271 .UNINDENT
272 .INDENT 0.0
273 .TP
274 .B \-region\-coverage\-gt=<N>
275 Show code coverage only for functions with region coverage greater than the
276 given threshold.
277 .UNINDENT
278 .INDENT 0.0
279 .TP
280 .B \-region\-coverage\-lt=<N>
281 Show code coverage only for functions with region coverage less than the given
282 threshold.
283 .UNINDENT
284 .SH REPORT COMMAND
285 .SS SYNOPSIS
286 .sp
287 \fBllvm\-cov report\fP [\fIoptions\fP] \-instr\-profile \fIPROFILE\fP \fIBIN\fP [\fISOURCES\fP]
288 .SS DESCRIPTION
289 .sp
290 The \fBllvm\-cov report\fP command displays a summary of the coverage of a
291 binary \fIBIN\fP using the profile data \fIPROFILE\fP\&. It can optionally be filtered to
292 only show the coverage for the files listed in \fISOURCES\fP\&.
293 .sp
294 If no source files are provided, a summary line is printed for each file in the
295 coverage data. If any files are provided, summaries are shown for each function
296 in the listed files instead.
297 .sp
298 For information on compiling programs for coverage and generating profile data,
299 see \fI\%SHOW COMMAND\fP\&.
300 .SS OPTIONS
301 .INDENT 0.0
302 .TP
303 .B \-use\-color[=VALUE]
304 Enable or disable color output. By default this is autodetected.
305 .UNINDENT
306 .INDENT 0.0
307 .TP
308 .B \-arch=<name>
309 If the covered binary is a universal binary, select the architecture to use.
310 It is an error to specify an architecture that is not included in the
311 universal binary or to use an architecture that does not match a
312 non\-universal binary.
313 .UNINDENT
314 .SH AUTHOR
315 Maintained by The LLVM Team (http://llvm.org/).
316 .SH COPYRIGHT
317 2003-2016, LLVM Project
318 .\" Generated by docutils manpage writer.
319 .