comparison gcc/doc/gcov.texi @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 @c Copyright (C) 1996-2017 Free Software Foundation, Inc. 1 @c Copyright (C) 1996-2018 Free Software Foundation, Inc.
2 @c This is part of the GCC manual. 2 @c This is part of the GCC manual.
3 @c For copying conditions, see the file gcc.texi. 3 @c For copying conditions, see the file gcc.texi.
4 4
5 @ignore 5 @ignore
6 @c man begin COPYRIGHT 6 @c man begin COPYRIGHT
7 Copyright @copyright{} 1996-2017 Free Software Foundation, Inc. 7 Copyright @copyright{} 1996-2018 Free Software Foundation, Inc.
8 8
9 Permission is granted to copy, distribute and/or modify this document 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 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 11 any later version published by the Free Software Foundation; with the
12 Invariant Sections being ``GNU General Public License'' and ``Funding 12 Invariant Sections being ``GNU General Public License'' and ``Funding
123 [@option{-b}|@option{--branch-probabilities}] 123 [@option{-b}|@option{--branch-probabilities}]
124 [@option{-c}|@option{--branch-counts}] 124 [@option{-c}|@option{--branch-counts}]
125 [@option{-d}|@option{--display-progress}] 125 [@option{-d}|@option{--display-progress}]
126 [@option{-f}|@option{--function-summaries}] 126 [@option{-f}|@option{--function-summaries}]
127 [@option{-i}|@option{--intermediate-format}] 127 [@option{-i}|@option{--intermediate-format}]
128 [@option{-j}|@option{--human-readable}]
129 [@option{-k}|@option{--use-colors}]
128 [@option{-l}|@option{--long-file-names}] 130 [@option{-l}|@option{--long-file-names}]
129 [@option{-m}|@option{--demangled-names}] 131 [@option{-m}|@option{--demangled-names}]
130 [@option{-n}|@option{--no-output}] 132 [@option{-n}|@option{--no-output}]
131 [@option{-o}|@option{--object-directory} @var{directory|file}] 133 [@option{-o}|@option{--object-directory} @var{directory|file}]
132 [@option{-p}|@option{--preserve-paths}] 134 [@option{-p}|@option{--preserve-paths}]
135 [@option{-q}|@option{--use-hotness-colors}]
133 [@option{-r}|@option{--relative-only}] 136 [@option{-r}|@option{--relative-only}]
134 [@option{-s}|@option{--source-prefix} @var{directory}] 137 [@option{-s}|@option{--source-prefix} @var{directory}]
138 [@option{-t}|@option{--stdout}]
135 [@option{-u}|@option{--unconditional-branches}] 139 [@option{-u}|@option{--unconditional-branches}]
136 [@option{-x}|@option{--hash-filenames}] 140 [@option{-x}|@option{--hash-filenames}]
137 @var{files} 141 @var{files}
138 @c man end 142 @c man end
139 @c man begin SEEALSO 143 @c man begin SEEALSO
184 188
185 The format of the intermediate @file{.gcov} file is plain text with 189 The format of the intermediate @file{.gcov} file is plain text with
186 one entry per line 190 one entry per line
187 191
188 @smallexample 192 @smallexample
193 version:@var{gcc_version}
194 cwd:@var{working_directory}
189 file:@var{source_file_name} 195 file:@var{source_file_name}
190 function:@var{line_number},@var{execution_count},@var{function_name} 196 function:@var{start_line_number},@var{end_line_number},@var{execution_count},@var{function_name}
191 lcount:@var{line number},@var{execution_count} 197 lcount:@var{line number},@var{execution_count},@var{has_unexecuted_block}
192 branch:@var{line_number},@var{branch_coverage_type} 198 branch:@var{line_number},@var{branch_coverage_type}
193 199
194 Where the @var{branch_coverage_type} is 200 Where the @var{branch_coverage_type} is
195 notexec (Branch not executed) 201 notexec (Branch not executed)
196 taken (Branch executed and taken) 202 taken (Branch executed and taken)
197 nottaken (Branch executed, but not taken) 203 nottaken (Branch executed, but not taken)
204 @end smallexample
198 205
199 There can be multiple @var{file} entries in an intermediate gcov 206 There can be multiple @var{file} entries in an intermediate gcov
200 file. All entries following a @var{file} pertain to that source file 207 file. All entries following a @var{file} pertain to that source file
201 until the next @var{file} entry. 208 until the next @var{file} entry. If there are multiple functions that
202 @end smallexample 209 start on a single line, then corresponding lcount is repeated multiple
210 times.
203 211
204 Here is a sample when @option{-i} is used in conjunction with @option{-b} option: 212 Here is a sample when @option{-i} is used in conjunction with @option{-b} option:
205 213
206 @smallexample 214 @smallexample
207 file:array.cc 215 version: 8.1.0 20180103
208 function:11,1,_Z3sumRKSt6vectorIPiSaIS0_EE 216 cwd:/home/gcc/testcase
209 function:22,1,main 217 file:tmp.cpp
210 lcount:11,1 218 function:7,7,0,_ZN3FooIcEC2Ev
211 lcount:12,1 219 function:7,7,1,_ZN3FooIiEC2Ev
212 lcount:14,1 220 function:8,8,0,_ZN3FooIcE3incEv
213 branch:14,taken 221 function:8,8,2,_ZN3FooIiE3incEv
214 lcount:26,1 222 function:18,37,1,main
215 branch:28,nottaken 223 lcount:7,0,1
216 @end smallexample 224 lcount:7,1,0
225 lcount:8,0,1
226 lcount:8,2,0
227 lcount:18,1,0
228 lcount:21,1,0
229 branch:21,taken
230 branch:21,nottaken
231 lcount:23,1,0
232 branch:23,taken
233 branch:23,nottaken
234 lcount:24,1,0
235 branch:24,taken
236 branch:24,nottaken
237 lcount:25,1,0
238 lcount:27,11,0
239 branch:27,taken
240 branch:27,taken
241 lcount:28,10,0
242 lcount:30,1,1
243 branch:30,nottaken
244 branch:30,taken
245 lcount:32,1,0
246 branch:32,nottaken
247 branch:32,taken
248 lcount:33,0,1
249 branch:33,notexec
250 branch:33,notexec
251 lcount:35,1,0
252 branch:35,taken
253 branch:35,nottaken
254 lcount:36,1,0
255 @end smallexample
256
257 @item -j
258 @itemx --human-readable
259 Write counts in human readable format (like 24.6k).
260
261 @item -k
262 @itemx --use-colors
263
264 Use colors for lines of code that have zero coverage. We use red color for
265 non-exceptional lines and cyan for exceptional. Same colors are used for
266 basic blocks with @option{-a} option.
217 267
218 @item -l 268 @item -l
219 @itemx --long-file-names 269 @itemx --long-file-names
220 Create long file names for included source files. For example, if the 270 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 271 header file @file{x.h} contains code, and was included in the file
253 translated to @samp{#} characters, @file{.} directory components 303 translated to @samp{#} characters, @file{.} directory components
254 removed and unremoveable @file{..} 304 removed and unremoveable @file{..}
255 components renamed to @samp{^}. This is useful if sourcefiles are in several 305 components renamed to @samp{^}. This is useful if sourcefiles are in several
256 different directories. 306 different directories.
257 307
308 @item -q
309 @itemx --use-hotness-colors
310
311 Emit perf-like colored output for hot lines. Legend of the color scale
312 is printed at the very beginning of the output file.
313
258 @item -r 314 @item -r
259 @itemx --relative-only 315 @itemx --relative-only
260 Only output information about source files with a relative pathname 316 Only output information about source files with a relative pathname
261 (after source prefix elision). Absolute paths are usually system 317 (after source prefix elision). Absolute paths are usually system
262 header files and coverage of any inline functions therein is normally 318 header files and coverage of any inline functions therein is normally
268 coverage files. This option is useful when building in a separate 324 coverage files. This option is useful when building in a separate
269 directory, and the pathname to the source directory is not wanted when 325 directory, and the pathname to the source directory is not wanted when
270 determining the output file names. Note that this prefix detection is 326 determining the output file names. Note that this prefix detection is
271 applied before determining whether the source file is absolute. 327 applied before determining whether the source file is absolute.
272 328
329 @item -t
330 @itemx --stdout
331 Output to standard output instead of output files.
332
273 @item -u 333 @item -u
274 @itemx --unconditional-branches 334 @itemx --unconditional-branches
275 When branch probabilities are given, include those of unconditional branches. 335 When branch probabilities are given, include those of unconditional branches.
276 Unconditional branches are normally not interesting. 336 Unconditional branches are normally not interesting.
277 337
284 @itemx --verbose 344 @itemx --verbose
285 Print verbose informations related to basic blocks and arcs. 345 Print verbose informations related to basic blocks and arcs.
286 346
287 @item -x 347 @item -x
288 @itemx --hash-filenames 348 @itemx --hash-filenames
289 By default, gcov uses the full pathname of the source files to to create 349 By default, gcov uses the full pathname of the source files to create
290 an output filename. This can lead to long filenames that can overflow 350 an output filename. This can lead to long filenames that can overflow
291 filesystem limits. This option creates names of the form 351 filesystem limits. This option creates names of the form
292 @file{@var{source-file}##@var{md5}.gcov}, 352 @file{@var{source-file}##@var{md5}.gcov},
293 where the @var{source-file} component is the final filename part and 353 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 354 the @var{md5} component is calculated from the full mangled name that
320 @end smallexample 380 @end smallexample
321 381
322 Additional block information may succeed each line, when requested by 382 Additional block information may succeed each line, when requested by
323 command line option. The @var{execution_count} is @samp{-} for lines 383 command line option. The @var{execution_count} is @samp{-} for lines
324 containing no code. Unexecuted lines are marked @samp{#####} or 384 containing no code. Unexecuted lines are marked @samp{#####} or
325 @samp{====}, depending on whether they are reachable by 385 @samp{=====}, depending on whether they are reachable by
326 non-exceptional paths or only exceptional paths such as C++ exception 386 non-exceptional paths or only exceptional paths such as C++ exception
327 handlers, respectively. Given @samp{-a} option, unexecuted blocks are 387 handlers, respectively. Given the @samp{-a} option, unexecuted blocks are
328 marked @samp{$$$$$} or @samp{%%%%%}, depending on whether a basic block 388 marked @samp{$$$$$} or @samp{%%%%%}, depending on whether a basic block
329 is reachable via non-exceptional or exceptional paths. 389 is reachable via non-exceptional or exceptional paths.
390 Executed basic blocks having a statement with zero @var{execution_count}
391 end with @samp{*} character and are colored with magenta color with
392 the @option{-k} option. This functionality is not supported in Ada.
393
394 Note that GCC can completely remove the bodies of functions that are
395 not needed -- for instance if they are inlined everywhere. Such functions
396 are marked with @samp{-}, which can be confusing.
397 Use the @option{-fkeep-inline-functions} and @option{-fkeep-static-functions}
398 options to retain these functions and
399 allow gcov to properly show their @var{execution_count}.
330 400
331 Some lines of information at the start have @var{line_number} of zero. 401 Some lines of information at the start have @var{line_number} of zero.
332 These preamble lines are of the form 402 These preamble lines are of the form
333 403
334 @smallexample 404 @smallexample
365 source file compiled with @option{-fprofile-arcs}, an accompanying 435 source file compiled with @option{-fprofile-arcs}, an accompanying
366 @file{.gcda} file will be placed in the object file directory. 436 @file{.gcda} file will be placed in the object file directory.
367 437
368 Running @command{gcov} with your program's source file names as arguments 438 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 439 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 440 for each line. For example, if your program is called @file{tmp.cpp}, this
371 is what you see when you use the basic @command{gcov} facility: 441 is what you see when you use the basic @command{gcov} facility:
372 442
373 @smallexample 443 @smallexample
374 $ gcc -fprofile-arcs -ftest-coverage tmp.c 444 $ g++ -fprofile-arcs -ftest-coverage tmp.cpp
375 $ a.out 445 $ a.out
376 $ gcov tmp.c 446 $ gcov tmp.cpp -m
377 File 'tmp.c' 447 File 'tmp.cpp'
378 Lines executed:90.00% of 10 448 Lines executed:92.86% of 14
379 Creating 'tmp.c.gcov' 449 Creating 'tmp.cpp.gcov'
380 @end smallexample 450 @end smallexample
381 451
382 The file @file{tmp.c.gcov} contains output from @command{gcov}. 452 The file @file{tmp.cpp.gcov} contains output from @command{gcov}.
383 Here is a sample: 453 Here is a sample:
384 454
385 @smallexample 455 @smallexample
386 -: 0:Source:tmp.c 456 -: 0:Source:tmp.cpp
457 -: 0:Working directory:/home/gcc/testcase
387 -: 0:Graph:tmp.gcno 458 -: 0:Graph:tmp.gcno
388 -: 0:Data:tmp.gcda 459 -: 0:Data:tmp.gcda
389 -: 0:Runs:1 460 -: 0:Runs:1
390 -: 0:Programs:1 461 -: 0:Programs:1
391 -: 1:#include <stdio.h> 462 -: 1:#include <stdio.h>
392 -: 2: 463 -: 2:
393 -: 3:int main (void) 464 -: 3:template<class T>
394 1: 4:@{ 465 -: 4:class Foo
395 1: 5: int i, total; 466 -: 5:@{
396 -: 6: 467 -: 6: public:
397 1: 7: total = 0; 468 1*: 7: Foo(): b (1000) @{@}
398 -: 8: 469 ------------------
399 11: 9: for (i = 0; i < 10; i++) 470 Foo<char>::Foo():
400 10: 10: total += i; 471 #####: 7: Foo(): b (1000) @{@}
401 -: 11: 472 ------------------
402 1: 12: if (total != 45) 473 Foo<int>::Foo():
403 #####: 13: printf ("Failure\n"); 474 1: 7: Foo(): b (1000) @{@}
404 -: 14: else 475 ------------------
405 1: 15: printf ("Success\n"); 476 2*: 8: void inc () @{ b++; @}
406 1: 16: return 0; 477 ------------------
407 -: 17:@} 478 Foo<char>::inc():
408 @end smallexample 479 #####: 8: void inc () @{ b++; @}
480 ------------------
481 Foo<int>::inc():
482 2: 8: void inc () @{ b++; @}
483 ------------------
484 -: 9:
485 -: 10: private:
486 -: 11: int b;
487 -: 12:@};
488 -: 13:
489 -: 14:template class Foo<int>;
490 -: 15:template class Foo<char>;
491 -: 16:
492 -: 17:int
493 1: 18:main (void)
494 -: 19:@{
495 -: 20: int i, total;
496 1: 21: Foo<int> counter;
497 -: 22:
498 1: 23: counter.inc();
499 1: 24: counter.inc();
500 1: 25: total = 0;
501 -: 26:
502 11: 27: for (i = 0; i < 10; i++)
503 10: 28: total += i;
504 -: 29:
505 1*: 30: int v = total > 100 ? 1 : 2;
506 -: 31:
507 1: 32: if (total != 45)
508 #####: 33: printf ("Failure\n");
509 -: 34: else
510 1: 35: printf ("Success\n");
511 1: 36: return 0;
512 -: 37:@}
513 @end smallexample
514
515 Note that line 7 is shown in the report multiple times. First occurrence
516 presents total number of execution of the line and the next two belong
517 to instances of class Foo constructors. As you can also see, line 30 contains
518 some unexecuted basic blocks and thus execution count has asterisk symbol.
409 519
410 When you use the @option{-a} option, you will get individual block 520 When you use the @option{-a} option, you will get individual block
411 counts, and the output looks like this: 521 counts, and the output looks like this:
412 522
413 @smallexample 523 @smallexample
414 -: 0:Source:tmp.c 524 -: 0:Source:tmp.cpp
525 -: 0:Working directory:/home/gcc/testcase
415 -: 0:Graph:tmp.gcno 526 -: 0:Graph:tmp.gcno
416 -: 0:Data:tmp.gcda 527 -: 0:Data:tmp.gcda
417 -: 0:Runs:1 528 -: 0:Runs:1
418 -: 0:Programs:1 529 -: 0:Programs:1
419 -: 1:#include <stdio.h> 530 -: 1:#include <stdio.h>
420 -: 2: 531 -: 2:
421 -: 3:int main (void) 532 -: 3:template<class T>
422 1: 4:@{ 533 -: 4:class Foo
423 1: 4-block 0 534 -: 5:@{
424 1: 5: int i, total; 535 -: 6: public:
425 -: 6: 536 1*: 7: Foo(): b (1000) @{@}
426 1: 7: total = 0; 537 ------------------
427 -: 8: 538 Foo<char>::Foo():
428 11: 9: for (i = 0; i < 10; i++) 539 #####: 7: Foo(): b (1000) @{@}
429 11: 9-block 0 540 ------------------
430 10: 10: total += i; 541 Foo<int>::Foo():
431 10: 10-block 0 542 1: 7: Foo(): b (1000) @{@}
432 -: 11: 543 ------------------
433 1: 12: if (total != 45) 544 2*: 8: void inc () @{ b++; @}
434 1: 12-block 0 545 ------------------
435 #####: 13: printf ("Failure\n"); 546 Foo<char>::inc():
436 $$$$$: 13-block 0 547 #####: 8: void inc () @{ b++; @}
437 -: 14: else 548 ------------------
438 1: 15: printf ("Success\n"); 549 Foo<int>::inc():
439 1: 15-block 0 550 2: 8: void inc () @{ b++; @}
440 1: 16: return 0; 551 ------------------
441 1: 16-block 0 552 -: 9:
442 -: 17:@} 553 -: 10: private:
554 -: 11: int b;
555 -: 12:@};
556 -: 13:
557 -: 14:template class Foo<int>;
558 -: 15:template class Foo<char>;
559 -: 16:
560 -: 17:int
561 1: 18:main (void)
562 -: 19:@{
563 -: 20: int i, total;
564 1: 21: Foo<int> counter;
565 1: 21-block 0
566 -: 22:
567 1: 23: counter.inc();
568 1: 23-block 0
569 1: 24: counter.inc();
570 1: 24-block 0
571 1: 25: total = 0;
572 -: 26:
573 11: 27: for (i = 0; i < 10; i++)
574 1: 27-block 0
575 11: 27-block 1
576 10: 28: total += i;
577 10: 28-block 0
578 -: 29:
579 1*: 30: int v = total > 100 ? 1 : 2;
580 1: 30-block 0
581 %%%%%: 30-block 1
582 1: 30-block 2
583 -: 31:
584 1: 32: if (total != 45)
585 1: 32-block 0
586 #####: 33: printf ("Failure\n");
587 %%%%%: 33-block 0
588 -: 34: else
589 1: 35: printf ("Success\n");
590 1: 35-block 0
591 1: 36: return 0;
592 1: 36-block 0
593 -: 37:@}
443 @end smallexample 594 @end smallexample
444 595
445 In this mode, each basic block is only shown on one line -- the last 596 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 597 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 598 execution count of that last line, and other lines will not be shown
451 block, the branch and call counts of the block will be shown, if the 602 block, the branch and call counts of the block will be shown, if the
452 @option{-b} option is given. 603 @option{-b} option is given.
453 604
454 Because of the way GCC instruments calls, a call count can be shown 605 Because of the way GCC instruments calls, a call count can be shown
455 after a line with no individual blocks. 606 after a line with no individual blocks.
456 As you can see, line 13 contains a basic block that was not executed. 607 As you can see, line 33 contains a basic block that was not executed.
457 608
458 @need 450 609 @need 450
459 When you use the @option{-b} option, your output looks like this: 610 When you use the @option{-b} option, your output looks like this:
460 611
461 @smallexample 612 @smallexample
462 $ gcov -b tmp.c 613 -: 0:Source:tmp.cpp
463 File 'tmp.c' 614 -: 0:Working directory:/home/gcc/testcase
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
470
471 Here is a sample of a resulting @file{tmp.c.gcov} file:
472
473 @smallexample
474 -: 0:Source:tmp.c
475 -: 0:Graph:tmp.gcno 615 -: 0:Graph:tmp.gcno
476 -: 0:Data:tmp.gcda 616 -: 0:Data:tmp.gcda
477 -: 0:Runs:1 617 -: 0:Runs:1
478 -: 0:Programs:1 618 -: 0:Programs:1
479 -: 1:#include <stdio.h> 619 -: 1:#include <stdio.h>
480 -: 2: 620 -: 2:
481 -: 3:int main (void) 621 -: 3:template<class T>
482 function main called 1 returned 1 blocks executed 75% 622 -: 4:class Foo
483 1: 4:@{ 623 -: 5:@{
484 1: 5: int i, total; 624 -: 6: public:
485 -: 6: 625 1*: 7: Foo(): b (1000) @{@}
486 1: 7: total = 0; 626 ------------------
487 -: 8: 627 Foo<char>::Foo():
488 11: 9: for (i = 0; i < 10; i++) 628 function Foo<char>::Foo() called 0 returned 0% blocks executed 0%
629 #####: 7: Foo(): b (1000) @{@}
630 ------------------
631 Foo<int>::Foo():
632 function Foo<int>::Foo() called 1 returned 100% blocks executed 100%
633 1: 7: Foo(): b (1000) @{@}
634 ------------------
635 2*: 8: void inc () @{ b++; @}
636 ------------------
637 Foo<char>::inc():
638 function Foo<char>::inc() called 0 returned 0% blocks executed 0%
639 #####: 8: void inc () @{ b++; @}
640 ------------------
641 Foo<int>::inc():
642 function Foo<int>::inc() called 2 returned 100% blocks executed 100%
643 2: 8: void inc () @{ b++; @}
644 ------------------
645 -: 9:
646 -: 10: private:
647 -: 11: int b;
648 -: 12:@};
649 -: 13:
650 -: 14:template class Foo<int>;
651 -: 15:template class Foo<char>;
652 -: 16:
653 -: 17:int
654 function main called 1 returned 100% blocks executed 81%
655 1: 18:main (void)
656 -: 19:@{
657 -: 20: int i, total;
658 1: 21: Foo<int> counter;
659 call 0 returned 100%
660 branch 1 taken 100% (fallthrough)
661 branch 2 taken 0% (throw)
662 -: 22:
663 1: 23: counter.inc();
664 call 0 returned 100%
665 branch 1 taken 100% (fallthrough)
666 branch 2 taken 0% (throw)
667 1: 24: counter.inc();
668 call 0 returned 100%
669 branch 1 taken 100% (fallthrough)
670 branch 2 taken 0% (throw)
671 1: 25: total = 0;
672 -: 26:
673 11: 27: for (i = 0; i < 10; i++)
489 branch 0 taken 91% (fallthrough) 674 branch 0 taken 91% (fallthrough)
490 branch 1 taken 9% 675 branch 1 taken 9%
491 10: 10: total += i; 676 10: 28: total += i;
492 -: 11: 677 -: 29:
493 1: 12: if (total != 45) 678 1*: 30: int v = total > 100 ? 1 : 2;
494 branch 0 taken 0% (fallthrough) 679 branch 0 taken 0% (fallthrough)
495 branch 1 taken 100% 680 branch 1 taken 100%
496 #####: 13: printf ("Failure\n"); 681 -: 31:
682 1: 32: if (total != 45)
683 branch 0 taken 0% (fallthrough)
684 branch 1 taken 100%
685 #####: 33: printf ("Failure\n");
497 call 0 never executed 686 call 0 never executed
498 -: 14: else 687 branch 1 never executed
499 1: 15: printf ("Success\n"); 688 branch 2 never executed
500 call 0 called 1 returned 100% 689 -: 34: else
501 1: 16: return 0; 690 1: 35: printf ("Success\n");
502 -: 17:@} 691 call 0 returned 100%
692 branch 1 taken 100% (fallthrough)
693 branch 2 taken 0% (throw)
694 1: 36: return 0;
695 -: 37:@}
503 @end smallexample 696 @end smallexample
504 697
505 For each function, a line is printed showing how many times the function 698 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 699 is called, how many times it returns and what percentage of the
507 function's blocks were executed. 700 function's blocks were executed.
609 collected at that point to be dumped to @file{.gcda} output files. 802 collected at that point to be dumped to @file{.gcda} output files.
610 Instrumented applications use a static destructor with priority 99 803 Instrumented applications use a static destructor with priority 99
611 to invoke the @code{__gcov_dump} function. Thus @code{__gcov_dump} 804 to invoke the @code{__gcov_dump} function. Thus @code{__gcov_dump}
612 is executed after all user defined static destructors, 805 is executed after all user defined static destructors,
613 as well as handlers registered with @code{atexit}. 806 as well as handlers registered with @code{atexit}.
807 If an executable loads a dynamic shared object via dlopen functionality,
808 @option{-Wl,--dynamic-list-data} is needed to dump all profile data.
809
810 Profiling run-time library reports various errors related to profile
811 manipulation and profile saving. Errors are printed into standard error output
812 or @samp{GCOV_ERROR_FILE} file, if environment variable is used.
813 In order to terminate immediately after an errors occurs
814 set @samp{GCOV_EXIT_AT_ERROR} environment variable.
815 That can help users to find profile clashing which leads
816 to a misleading profile.
614 817
615 @c man end 818 @c man end
616 819
617 @node Gcov Data Files 820 @node Gcov Data Files
618 @section Brief Description of @command{gcov} Data Files 821 @section Brief Description of @command{gcov} Data Files
635 object files built with the GCC @option{-fprofile-arcs} option is executed. 838 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 839 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 840 this option. It contains arc transition counts, value profile counts, and
638 some summary information. 841 some summary information.
639 842
640 The full details of the file format is specified in @file{gcov-io.h}, 843 It is not recommended to access the coverage files directly.
641 and functions provided in that header file should be used to access the 844 Consumers should use the intermediate format that is provided
642 coverage files. 845 by @command{gcov} tool via @option{--intermediate-format} option.
643 846
644 @node Cross-profiling 847 @node Cross-profiling
645 @section Data File Relocation to Support Cross-Profiling 848 @section Data File Relocation to Support Cross-Profiling
646 849
647 Running the program will cause profile output to be generated. For each 850 Running the program will cause profile output to be generated. For each