* config/i386/i386.c (ix86_adjust_stack_and_probe_stack_clash): New.
[official-gcc.git] / gcc / doc / gcov.texi
blob706aa6cf0b0ce48bcff8aa8a3442ad8177cebe8f
1 @c Copyright (C) 1996-2017 Free Software Foundation, Inc.
2 @c This is part of the GCC manual.
3 @c For copying conditions, see the file gcc.texi.
5 @ignore
6 @c man begin COPYRIGHT
7 Copyright @copyright{} 1996-2017 Free Software Foundation, Inc.
9 Permission is granted to copy, distribute and/or modify this document
10 under the terms of the GNU Free Documentation License, Version 1.3 or
11 any later version published by the Free Software Foundation; with the
12 Invariant Sections being ``GNU General Public License'' and ``Funding
13 Free Software'', the Front-Cover texts being (a) (see below), and with
14 the Back-Cover Texts being (b) (see below).  A copy of the license is
15 included in the gfdl(7) man page.
17 (a) The FSF's Front-Cover Text is:
19      A GNU Manual
21 (b) The FSF's Back-Cover Text is:
23      You have freedom to copy and modify this GNU Manual, like GNU
24      software.  Copies published by the Free Software Foundation raise
25      funds for GNU development.
26 @c man end
27 @c Set file name and title for the man page.
28 @setfilename gcov
29 @settitle coverage testing tool
30 @end ignore
32 @node Gcov
33 @chapter @command{gcov}---a Test Coverage Program
35 @command{gcov} is a tool you can use in conjunction with GCC to
36 test code coverage in your programs.
38 @menu
39 * Gcov Intro::                  Introduction to gcov.
40 * Invoking Gcov::               How to use gcov.
41 * Gcov and Optimization::       Using gcov with GCC optimization.
42 * Gcov Data Files::             The files used by gcov.
43 * Cross-profiling::             Data file relocation.
44 @end menu
46 @node Gcov Intro
47 @section Introduction to @command{gcov}
48 @c man begin DESCRIPTION
50 @command{gcov} is a test coverage program.  Use it in concert with GCC
51 to analyze your programs to help create more efficient, faster running
52 code and to discover untested parts of your program.  You can use
53 @command{gcov} as a profiling tool to help discover where your
54 optimization efforts will best affect your code.  You can also use
55 @command{gcov} along with the other profiling tool, @command{gprof}, to
56 assess which parts of your code use the greatest amount of computing
57 time.
59 Profiling tools help you analyze your code's performance.  Using a
60 profiler such as @command{gcov} or @command{gprof}, you can find out some
61 basic performance statistics, such as:
63 @itemize @bullet
64 @item
65 how often each line of code executes
67 @item
68 what lines of code are actually executed
70 @item
71 how much computing time each section of code uses
72 @end itemize
74 Once you know these things about how your code works when compiled, you
75 can look at each module to see which modules should be optimized.
76 @command{gcov} helps you determine where to work on optimization.
78 Software developers also use coverage testing in concert with
79 testsuites, to make sure software is actually good enough for a release.
80 Testsuites can verify that a program works as expected; a coverage
81 program tests to see how much of the program is exercised by the
82 testsuite.  Developers can then determine what kinds of test cases need
83 to be added to the testsuites to create both better testing and a better
84 final product.
86 You should compile your code without optimization if you plan to use
87 @command{gcov} because the optimization, by combining some lines of code
88 into one function, may not give you as much information as you need to
89 look for `hot spots' where the code is using a great deal of computer
90 time.  Likewise, because @command{gcov} accumulates statistics by line (at
91 the lowest resolution), it works best with a programming style that
92 places only one statement on each line.  If you use complicated macros
93 that expand to loops or to other control structures, the statistics are
94 less helpful---they only report on the line where the macro call
95 appears.  If your complex macros behave like functions, you can replace
96 them with inline functions to solve this problem.
98 @command{gcov} creates a logfile called @file{@var{sourcefile}.gcov} which
99 indicates how many times each line of a source file @file{@var{sourcefile}.c}
100 has executed.  You can use these logfiles along with @command{gprof} to aid
101 in fine-tuning the performance of your programs.  @command{gprof} gives
102 timing information you can use along with the information you get from
103 @command{gcov}.
105 @command{gcov} works only on code compiled with GCC@.  It is not
106 compatible with any other profiling or test coverage mechanism.
108 @c man end
110 @node Invoking Gcov
111 @section Invoking @command{gcov}
113 @smallexample
114 gcov @r{[}@var{options}@r{]} @var{files}
115 @end smallexample
117 @command{gcov} accepts the following options:
119 @ignore
120 @c man begin SYNOPSIS
121 gcov [@option{-v}|@option{--version}] [@option{-h}|@option{--help}]
122      [@option{-a}|@option{--all-blocks}]
123      [@option{-b}|@option{--branch-probabilities}]
124      [@option{-c}|@option{--branch-counts}]
125      [@option{-d}|@option{--display-progress}]
126      [@option{-f}|@option{--function-summaries}]
127      [@option{-i}|@option{--intermediate-format}]
128      [@option{-l}|@option{--long-file-names}]
129      [@option{-m}|@option{--demangled-names}]
130      [@option{-n}|@option{--no-output}]
131      [@option{-o}|@option{--object-directory} @var{directory|file}]
132      [@option{-p}|@option{--preserve-paths}]
133      [@option{-r}|@option{--relative-only}]
134      [@option{-s}|@option{--source-prefix} @var{directory}]
135      [@option{-u}|@option{--unconditional-branches}]
136      [@option{-x}|@option{--hash-filenames}]
137      @var{files}
138 @c man end
139 @c man begin SEEALSO
140 gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entry for @file{gcc}.
141 @c man end
142 @end ignore
144 @c man begin OPTIONS
145 @table @gcctabopt
147 @item -a
148 @itemx --all-blocks
149 Write individual execution counts for every basic block.  Normally gcov
150 outputs execution counts only for the main blocks of a line.  With this
151 option you can determine if blocks within a single line are not being
152 executed.
154 @item -b
155 @itemx --branch-probabilities
156 Write branch frequencies to the output file, and write branch summary
157 info to the standard output.  This option allows you to see how often
158 each branch in your program was taken.  Unconditional branches will not
159 be shown, unless the @option{-u} option is given.
161 @item -c
162 @itemx --branch-counts
163 Write branch frequencies as the number of branches taken, rather than
164 the percentage of branches taken.
166 @item -d
167 @itemx --display-progress
168 Display the progress on the standard output.
170 @item -f
171 @itemx --function-summaries
172 Output summaries for each function in addition to the file level summary.
174 @item -h
175 @itemx --help
176 Display help about using @command{gcov} (on the standard output), and
177 exit without doing any further processing.
179 @item -i
180 @itemx --intermediate-format
181 Output gcov file in an easy-to-parse intermediate text format that can
182 be used by @command{lcov} or other tools. The output is a single
183 @file{.gcov} file per @file{.gcda} file. No source code is required.
185 The format of the intermediate @file{.gcov} file is plain text with
186 one entry per line
188 @smallexample
189 file:@var{source_file_name}
190 function:@var{line_number},@var{execution_count},@var{function_name}
191 lcount:@var{line number},@var{execution_count}
192 branch:@var{line_number},@var{branch_coverage_type}
194 Where the @var{branch_coverage_type} is
195    notexec (Branch not executed)
196    taken (Branch executed and taken)
197    nottaken (Branch executed, but not taken)
199 There can be multiple @var{file} entries in an intermediate gcov
200 file. All entries following a @var{file} pertain to that source file
201 until the next @var{file} entry.
202 @end smallexample
204 Here is a sample when @option{-i} is used in conjunction with @option{-b} option:
206 @smallexample
207 file:array.cc
208 function:11,1,_Z3sumRKSt6vectorIPiSaIS0_EE
209 function:22,1,main
210 lcount:11,1
211 lcount:12,1
212 lcount:14,1
213 branch:14,taken
214 lcount:26,1
215 branch:28,nottaken
216 @end smallexample
218 @item -l
219 @itemx --long-file-names
220 Create long file names for included source files.  For example, if the
221 header file @file{x.h} contains code, and was included in the file
222 @file{a.c}, then running @command{gcov} on the file @file{a.c} will
223 produce an output file called @file{a.c##x.h.gcov} instead of
224 @file{x.h.gcov}.  This can be useful if @file{x.h} is included in
225 multiple source files and you want to see the individual
226 contributions.  If you use the @samp{-p} option, both the including
227 and included file names will be complete path names.
229 @item -m
230 @itemx --demangled-names
231 Display demangled function names in output. The default is to show
232 mangled function names.
234 @item -n
235 @itemx --no-output
236 Do not create the @command{gcov} output file.
238 @item -o @var{directory|file}
239 @itemx --object-directory @var{directory}
240 @itemx --object-file @var{file}
241 Specify either the directory containing the gcov data files, or the
242 object path name.  The @file{.gcno}, and
243 @file{.gcda} data files are searched for using this option.  If a directory
244 is specified, the data files are in that directory and named after the
245 input file name, without its extension.  If a file is specified here,
246 the data files are named after that file, without its extension.
248 @item -p
249 @itemx --preserve-paths
250 Preserve complete path information in the names of generated
251 @file{.gcov} files.  Without this option, just the filename component is
252 used.  With this option, all directories are used, with @samp{/} characters
253 translated to @samp{#} characters, @file{.} directory components
254 removed and unremoveable @file{..}
255 components renamed to @samp{^}.  This is useful if sourcefiles are in several
256 different directories.
258 @item -r
259 @itemx --relative-only
260 Only output information about source files with a relative pathname
261 (after source prefix elision).  Absolute paths are usually system
262 header files and coverage of any inline functions therein is normally
263 uninteresting.
265 @item -s @var{directory}
266 @itemx --source-prefix @var{directory}
267 A prefix for source file names to remove when generating the output
268 coverage files.  This option is useful when building in a separate
269 directory, and the pathname to the source directory is not wanted when
270 determining the output file names.  Note that this prefix detection is
271 applied before determining whether the source file is absolute.
273 @item -u
274 @itemx --unconditional-branches
275 When branch probabilities are given, include those of unconditional branches.
276 Unconditional branches are normally not interesting.
278 @item -v
279 @itemx --version
280 Display the @command{gcov} version number (on the standard output),
281 and exit without doing any further processing.
283 @item -w
284 @itemx --verbose
285 Print verbose informations related to basic blocks and arcs.
287 @item -x
288 @itemx --hash-filenames
289 By default, gcov uses the full pathname of the source files to to create
290 an output filename.  This can lead to long filenames that can overflow
291 filesystem limits.  This option creates names of the form
292 @file{@var{source-file}##@var{md5}.gcov},
293 where the @var{source-file} component is the final filename part and
294 the @var{md5} component is calculated from the full mangled name that
295 would have been used otherwise.
297 @end table
299 @command{gcov} should be run with the current directory the same as that
300 when you invoked the compiler.  Otherwise it will not be able to locate
301 the source files.  @command{gcov} produces files called
302 @file{@var{mangledname}.gcov} in the current directory.  These contain
303 the coverage information of the source file they correspond to.
304 One @file{.gcov} file is produced for each source (or header) file
305 containing code,
306 which was compiled to produce the data files.  The @var{mangledname} part
307 of the output file name is usually simply the source file name, but can
308 be something more complicated if the @samp{-l} or @samp{-p} options are
309 given.  Refer to those options for details.
311 If you invoke @command{gcov} with multiple input files, the
312 contributions from each input file are summed.  Typically you would
313 invoke it with the same list of files as the final link of your executable.
315 The @file{.gcov} files contain the @samp{:} separated fields along with
316 program source code.  The format is
318 @smallexample
319 @var{execution_count}:@var{line_number}:@var{source line text}
320 @end smallexample
322 Additional block information may succeed each line, when requested by
323 command line option.  The @var{execution_count} is @samp{-} for lines
324 containing no code.  Unexecuted lines are marked @samp{#####} or
325 @samp{====}, depending on whether they are reachable by
326 non-exceptional paths or only exceptional paths such as C++ exception
327 handlers, respectively. Given @samp{-a} option, unexecuted blocks are
328 marked @samp{$$$$$} or @samp{%%%%%}, depending on whether a basic block
329 is reachable via non-exceptional or exceptional paths.
331 Some lines of information at the start have @var{line_number} of zero.
332 These preamble lines are of the form
334 @smallexample
335 -:0:@var{tag}:@var{value}
336 @end smallexample
338 The ordering and number of these preamble lines will be augmented as
339 @command{gcov} development progresses --- do not rely on them remaining
340 unchanged.  Use @var{tag} to locate a particular preamble line.
342 The additional block information is of the form
344 @smallexample
345 @var{tag} @var{information}
346 @end smallexample
348 The @var{information} is human readable, but designed to be simple
349 enough for machine parsing too.
351 When printing percentages, 0% and 100% are only printed when the values
352 are @emph{exactly} 0% and 100% respectively.  Other values which would
353 conventionally be rounded to 0% or 100% are instead printed as the
354 nearest non-boundary value.
356 When using @command{gcov}, you must first compile your program with two
357 special GCC options: @samp{-fprofile-arcs -ftest-coverage}.
358 This tells the compiler to generate additional information needed by
359 gcov (basically a flow graph of the program) and also includes
360 additional code in the object files for generating the extra profiling
361 information needed by gcov.  These additional files are placed in the
362 directory where the object file is located.
364 Running the program will cause profile output to be generated.  For each
365 source file compiled with @option{-fprofile-arcs}, an accompanying
366 @file{.gcda} file will be placed in the object file directory.
368 Running @command{gcov} with your program's source file names as arguments
369 will now produce a listing of the code along with frequency of execution
370 for each line.  For example, if your program is called @file{tmp.c}, this
371 is what you see when you use the basic @command{gcov} facility:
373 @smallexample
374 $ gcc -fprofile-arcs -ftest-coverage tmp.c
375 $ a.out
376 $ gcov tmp.c
377 File 'tmp.c'
378 Lines executed:90.00% of 10
379 Creating 'tmp.c.gcov'
380 @end smallexample
382 The file @file{tmp.c.gcov} contains output from @command{gcov}.
383 Here is a sample:
385 @smallexample
386         -:    0:Source:tmp.c
387         -:    0:Graph:tmp.gcno
388         -:    0:Data:tmp.gcda
389         -:    0:Runs:1
390         -:    0:Programs:1
391         -:    1:#include <stdio.h>
392         -:    2:
393         -:    3:int main (void)
394         1:    4:@{
395         1:    5:  int i, total;
396         -:    6:
397         1:    7:  total = 0;
398         -:    8:
399        11:    9:  for (i = 0; i < 10; i++)
400        10:   10:    total += i;
401         -:   11:
402         1:   12:  if (total != 45)
403     #####:   13:    printf ("Failure\n");
404         -:   14:  else
405         1:   15:    printf ("Success\n");
406         1:   16:  return 0;
407         -:   17:@}
408 @end smallexample
410 When you use the @option{-a} option, you will get individual block
411 counts, and the output looks like this:
413 @smallexample
414         -:    0:Source:tmp.c
415         -:    0:Graph:tmp.gcno
416         -:    0:Data:tmp.gcda
417         -:    0:Runs:1
418         -:    0:Programs:1
419         -:    1:#include <stdio.h>
420         -:    2:
421         -:    3:int main (void)
422         1:    4:@{
423         1:    4-block  0
424         1:    5:  int i, total;
425         -:    6:
426         1:    7:  total = 0;
427         -:    8:
428        11:    9:  for (i = 0; i < 10; i++)
429        11:    9-block  0
430        10:   10:    total += i;
431        10:   10-block  0
432         -:   11:
433         1:   12:  if (total != 45)
434         1:   12-block  0
435     #####:   13:    printf ("Failure\n");
436     $$$$$:   13-block  0
437         -:   14:  else
438         1:   15:    printf ("Success\n");
439         1:   15-block  0
440         1:   16:  return 0;
441         1:   16-block  0
442         -:   17:@}
443 @end smallexample
445 In this mode, each basic block is only shown on one line -- the last
446 line of the block.  A multi-line block will only contribute to the
447 execution count of that last line, and other lines will not be shown
448 to contain code, unless previous blocks end on those lines.
449 The total execution count of a line is shown and subsequent lines show
450 the execution counts for individual blocks that end on that line.  After each
451 block, the branch and call counts of the block will be shown, if the
452 @option{-b} option is given.
454 Because of the way GCC instruments calls, a call count can be shown
455 after a line with no individual blocks.
456 As you can see, line 13 contains a basic block that was not executed.
458 @need 450
459 When you use the @option{-b} option, your output looks like this:
461 @smallexample
462 $ gcov -b tmp.c
463 File 'tmp.c'
464 Lines executed:90.00% of 10
465 Branches executed:80.00% of 5
466 Taken at least once:80.00% of 5
467 Calls executed:50.00% of 2
468 Creating 'tmp.c.gcov'
469 @end smallexample
471 Here is a sample of a resulting @file{tmp.c.gcov} file:
473 @smallexample
474         -:    0:Source:tmp.c
475         -:    0:Graph:tmp.gcno
476         -:    0:Data:tmp.gcda
477         -:    0:Runs:1
478         -:    0:Programs:1
479         -:    1:#include <stdio.h>
480         -:    2:
481         -:    3:int main (void)
482 function main called 1 returned 1 blocks executed 75%
483         1:    4:@{
484         1:    5:  int i, total;
485         -:    6:
486         1:    7:  total = 0;
487         -:    8:
488        11:    9:  for (i = 0; i < 10; i++)
489 branch  0 taken 91% (fallthrough)
490 branch  1 taken 9%
491        10:   10:    total += i;
492         -:   11:
493         1:   12:  if (total != 45)
494 branch  0 taken 0% (fallthrough)
495 branch  1 taken 100%
496     #####:   13:    printf ("Failure\n");
497 call    0 never executed
498         -:   14:  else
499         1:   15:    printf ("Success\n");
500 call    0 called 1 returned 100%
501         1:   16:  return 0;
502         -:   17:@}
503 @end smallexample
505 For each function, a line is printed showing how many times the function
506 is called, how many times it returns and what percentage of the
507 function's blocks were executed.
509 For each basic block, a line is printed after the last line of the basic
510 block describing the branch or call that ends the basic block.  There can
511 be multiple branches and calls listed for a single source line if there
512 are multiple basic blocks that end on that line.  In this case, the
513 branches and calls are each given a number.  There is no simple way to map
514 these branches and calls back to source constructs.  In general, though,
515 the lowest numbered branch or call will correspond to the leftmost construct
516 on the source line.
518 For a branch, if it was executed at least once, then a percentage
519 indicating the number of times the branch was taken divided by the
520 number of times the branch was executed will be printed.  Otherwise, the
521 message ``never executed'' is printed.
523 For a call, if it was executed at least once, then a percentage
524 indicating the number of times the call returned divided by the number
525 of times the call was executed will be printed.  This will usually be
526 100%, but may be less for functions that call @code{exit} or @code{longjmp},
527 and thus may not return every time they are called.
529 The execution counts are cumulative.  If the example program were
530 executed again without removing the @file{.gcda} file, the count for the
531 number of times each line in the source was executed would be added to
532 the results of the previous run(s).  This is potentially useful in
533 several ways.  For example, it could be used to accumulate data over a
534 number of program runs as part of a test verification suite, or to
535 provide more accurate long-term information over a large number of
536 program runs.
538 The data in the @file{.gcda} files is saved immediately before the program
539 exits.  For each source file compiled with @option{-fprofile-arcs}, the
540 profiling code first attempts to read in an existing @file{.gcda} file; if
541 the file doesn't match the executable (differing number of basic block
542 counts) it will ignore the contents of the file.  It then adds in the
543 new execution counts and finally writes the data to the file.
545 @node Gcov and Optimization
546 @section Using @command{gcov} with GCC Optimization
548 If you plan to use @command{gcov} to help optimize your code, you must
549 first compile your program with two special GCC options:
550 @samp{-fprofile-arcs -ftest-coverage}.  Aside from that, you can use any
551 other GCC options; but if you want to prove that every single line
552 in your program was executed, you should not compile with optimization
553 at the same time.  On some machines the optimizer can eliminate some
554 simple code lines by combining them with other lines.  For example, code
555 like this:
557 @smallexample
558 if (a != b)
559   c = 1;
560 else
561   c = 0;
562 @end smallexample
564 @noindent
565 can be compiled into one instruction on some machines.  In this case,
566 there is no way for @command{gcov} to calculate separate execution counts
567 for each line because there isn't separate code for each line.  Hence
568 the @command{gcov} output looks like this if you compiled the program with
569 optimization:
571 @smallexample
572       100:   12:if (a != b)
573       100:   13:  c = 1;
574       100:   14:else
575       100:   15:  c = 0;
576 @end smallexample
578 The output shows that this block of code, combined by optimization,
579 executed 100 times.  In one sense this result is correct, because there
580 was only one instruction representing all four of these lines.  However,
581 the output does not indicate how many times the result was 0 and how
582 many times the result was 1.
584 Inlineable functions can create unexpected line counts.  Line counts are
585 shown for the source code of the inlineable function, but what is shown
586 depends on where the function is inlined, or if it is not inlined at all.
588 If the function is not inlined, the compiler must emit an out of line
589 copy of the function, in any object file that needs it.  If
590 @file{fileA.o} and @file{fileB.o} both contain out of line bodies of a
591 particular inlineable function, they will also both contain coverage
592 counts for that function.  When @file{fileA.o} and @file{fileB.o} are
593 linked together, the linker will, on many systems, select one of those
594 out of line bodies for all calls to that function, and remove or ignore
595 the other.  Unfortunately, it will not remove the coverage counters for
596 the unused function body.  Hence when instrumented, all but one use of
597 that function will show zero counts.
599 If the function is inlined in several places, the block structure in
600 each location might not be the same.  For instance, a condition might
601 now be calculable at compile time in some instances.  Because the
602 coverage of all the uses of the inline function will be shown for the
603 same source lines, the line counts themselves might seem inconsistent.
605 Long-running applications can use the @code{__gcov_reset} and @code{__gcov_dump}
606 facilities to restrict profile collection to the program region of
607 interest. Calling @code{__gcov_reset(void)} will clear all profile counters
608 to zero, and calling @code{__gcov_dump(void)} will cause the profile information
609 collected at that point to be dumped to @file{.gcda} output files.
610 Instrumented applications use a static destructor with priority 99
611 to invoke the @code{__gcov_dump} function. Thus @code{__gcov_dump}
612 is executed after all user defined static destructors,
613 as well as handlers registered with @code{atexit}.
615 @c man end
617 @node Gcov Data Files
618 @section Brief Description of @command{gcov} Data Files
620 @command{gcov} uses two files for profiling.  The names of these files
621 are derived from the original @emph{object} file by substituting the
622 file suffix with either @file{.gcno}, or @file{.gcda}.  The files
623 contain coverage and profile data stored in a platform-independent format.
624 The @file{.gcno} files are placed in the same directory as the object
625 file.  By default, the @file{.gcda} files are also stored in the same
626 directory as the object file, but the GCC @option{-fprofile-dir} option
627 may be used to store the @file{.gcda} files in a separate directory.
629 The @file{.gcno} notes file is generated when the source file is compiled
630 with the GCC @option{-ftest-coverage} option.  It contains information to
631 reconstruct the basic block graphs and assign source line numbers to
632 blocks.
634 The @file{.gcda} count data file is generated when a program containing
635 object files built with the GCC @option{-fprofile-arcs} option is executed.
636 A separate @file{.gcda} file is created for each object file compiled with
637 this option.  It contains arc transition counts, value profile counts, and
638 some summary information.
640 The full details of the file format is specified in @file{gcov-io.h},
641 and functions provided in that header file should be used to access the
642 coverage files.
644 @node Cross-profiling
645 @section Data File Relocation to Support Cross-Profiling
647 Running the program will cause profile output to be generated.  For each
648 source file compiled with @option{-fprofile-arcs}, an accompanying @file{.gcda}
649 file will be placed in the object file directory. That implicitly requires
650 running the program on the same system as it was built or having the same
651 absolute directory structure on the target system. The program will try
652 to create the needed directory structure, if it is not already present.
654 To support cross-profiling, a program compiled with @option{-fprofile-arcs}
655 can relocate the data files based on two environment variables:
657 @itemize @bullet
658 @item
659 GCOV_PREFIX contains the prefix to add to the absolute paths
660 in the object file. Prefix can be absolute, or relative.  The
661 default is no prefix.
663 @item
664 GCOV_PREFIX_STRIP indicates the how many initial directory names to strip off
665 the hardwired absolute paths. Default value is 0.
667 @emph{Note:} If GCOV_PREFIX_STRIP is set without GCOV_PREFIX is undefined,
668  then a relative path is made out of the hardwired absolute paths.
669 @end itemize
671 For example, if the object file @file{/user/build/foo.o} was built with
672 @option{-fprofile-arcs}, the final executable will try to create the data file
673 @file{/user/build/foo.gcda} when running on the target system.  This will
674 fail if the corresponding directory does not exist and it is unable to create
675 it.  This can be overcome by, for example, setting the environment as
676 @samp{GCOV_PREFIX=/target/run} and @samp{GCOV_PREFIX_STRIP=1}.  Such a
677 setting will name the data file @file{/target/run/build/foo.gcda}.
679 You must move the data files to the expected directory tree in order to
680 use them for profile directed optimizations (@option{-fprofile-use}), or to
681 use the @command{gcov} tool.