1GCOV(1)                               GNU                              GCOV(1)
2
3
4

NAME

6       gcov - coverage testing tool
7

SYNOPSIS

9       gcov [-v|--version] [-h|--help]
10            [-a|--all-blocks]
11            [-b|--branch-probabilities]
12            [-c|--branch-counts]
13            [-d|--display-progress]
14            [-f|--function-summaries]
15            [-i|--json-format]
16            [-j|--human-readable]
17            [-k|--use-colors]
18            [-l|--long-file-names]
19            [-m|--demangled-names]
20            [-n|--no-output]
21            [-o|--object-directory directory|file]
22            [-p|--preserve-paths]
23            [-q|--use-hotness-colors]
24            [-r|--relative-only]
25            [-s|--source-prefix directory]
26            [-t|--stdout]
27            [-u|--unconditional-branches]
28            [-x|--hash-filenames]
29            files
30

DESCRIPTION

32       gcov is a test coverage program.  Use it in concert with GCC to analyze
33       your programs to help create more efficient, faster running code and to
34       discover untested parts of your program.  You can use gcov as a
35       profiling tool to help discover where your optimization efforts will
36       best affect your code.  You can also use gcov along with the other
37       profiling tool, gprof, to assess which parts of your code use the
38       greatest amount of computing time.
39
40       Profiling tools help you analyze your code's performance.  Using a
41       profiler such as gcov or gprof, you can find out some basic performance
42       statistics, such as:
43
44       *   how often each line of code executes
45
46       *   what lines of code are actually executed
47
48       *   how much computing time each section of code uses
49
50       Once you know these things about how your code works when compiled, you
51       can look at each module to see which modules should be optimized.  gcov
52       helps you determine where to work on optimization.
53
54       Software developers also use coverage testing in concert with
55       testsuites, to make sure software is actually good enough for a
56       release.  Testsuites can verify that a program works as expected; a
57       coverage program tests to see how much of the program is exercised by
58       the testsuite.  Developers can then determine what kinds of test cases
59       need to be added to the testsuites to create both better testing and a
60       better final product.
61
62       You should compile your code without optimization if you plan to use
63       gcov because the optimization, by combining some lines of code into one
64       function, may not give you as much information as you need to look for
65       `hot spots' where the code is using a great deal of computer time.
66       Likewise, because gcov accumulates statistics by line (at the lowest
67       resolution), it works best with a programming style that places only
68       one statement on each line.  If you use complicated macros that expand
69       to loops or to other control structures, the statistics are less
70       helpful---they only report on the line where the macro call appears.
71       If your complex macros behave like functions, you can replace them with
72       inline functions to solve this problem.
73
74       gcov creates a logfile called sourcefile.gcov which indicates how many
75       times each line of a source file sourcefile.c has executed.  You can
76       use these logfiles along with gprof to aid in fine-tuning the
77       performance of your programs.  gprof gives timing information you can
78       use along with the information you get from gcov.
79
80       gcov works only on code compiled with GCC.  It is not compatible with
81       any other profiling or test coverage mechanism.
82

OPTIONS

84       -a
85       --all-blocks
86           Write individual execution counts for every basic block.  Normally
87           gcov outputs execution counts only for the main blocks of a line.
88           With this option you can determine if blocks within a single line
89           are not being executed.
90
91       -b
92       --branch-probabilities
93           Write branch frequencies to the output file, and write branch
94           summary info to the standard output.  This option allows you to see
95           how often each branch in your program was taken.  Unconditional
96           branches will not be shown, unless the -u option is given.
97
98       -c
99       --branch-counts
100           Write branch frequencies as the number of branches taken, rather
101           than the percentage of branches taken.
102
103       -d
104       --display-progress
105           Display the progress on the standard output.
106
107       -f
108       --function-summaries
109           Output summaries for each function in addition to the file level
110           summary.
111
112       -h
113       --help
114           Display help about using gcov (on the standard output), and exit
115           without doing any further processing.
116
117       -i
118       --json-format
119           Output gcov file in an easy-to-parse JSON intermediate format which
120           does not require source code for generation.  The JSON file is
121           compressed with gzip compression algorithm and the files have
122           .gcov.json.gz extension.
123
124           Structure of the JSON is following:
125
126                   {
127                     "current_working_directory": <current_working_directory>,
128                     "data_file": <data_file>,
129                     "format_version": <format_version>,
130                     "gcc_version": <gcc_version>
131                     "files": [<file>]
132                   }
133
134           Fields of the root element have following semantics:
135
136           *   current_working_directory: working directory where a
137               compilation unit was compiled
138
139           *   data_file: name of the data file (GCDA)
140
141           *   format_version: semantic version of the format
142
143           *   gcc_version: version of the GCC compiler
144
145           Each file has the following form:
146
147                   {
148                     "file": <file_name>,
149                     "functions": [<function>],
150                     "lines": [<line>]
151                   }
152
153           Fields of the file element have following semantics:
154
155           *   file_name: name of the source file
156
157           Each function has the following form:
158
159                   {
160                     "blocks": <blocks>,
161                     "blocks_executed": <blocks_executed>,
162                     "demangled_name": "<demangled_name>,
163                     "end_column": <end_column>,
164                     "end_line": <end_line>,
165                     "execution_count": <execution_count>,
166                     "name": <name>,
167                     "start_column": <start_column>
168                     "start_line": <start_line>
169                   }
170
171           Fields of the function element have following semantics:
172
173           *   blocks: number of blocks that are in the function
174
175           *   blocks_executed: number of executed blocks of the function
176
177           *   demangled_name: demangled name of the function
178
179           *   end_column: column in the source file where the function ends
180
181           *   end_line: line in the source file where the function ends
182
183           *   execution_count: number of executions of the function
184
185           *   name: name of the function
186
187           *   start_column: column in the source file where the function
188               begins
189
190           *   start_line: line in the source file where the function begins
191
192           Note that line numbers and column numbers number from 1.  In the
193           current implementation, start_line and start_column do not include
194           any template parameters and the leading return type but that this
195           is likely to be fixed in the future.
196
197           Each line has the following form:
198
199                   {
200                     "branches": [<branch>],
201                     "count": <count>,
202                     "line_number": <line_number>,
203                     "unexecuted_block": <unexecuted_block>
204                     "function_name": <function_name>,
205                   }
206
207           Branches are present only with -b option.  Fields of the line
208           element have following semantics:
209
210           *   count: number of executions of the line
211
212           *   line_number: line number
213
214           *   unexecuted_block: flag whether the line contains an unexecuted
215               block (not all statements on the line are executed)
216
217           *   function_name: a name of a function this line belongs to (for a
218               line with an inlined statements can be not set)
219
220           Each branch has the following form:
221
222                   {
223                     "count": <count>,
224                     "fallthrough": <fallthrough>,
225                     "throw": <throw>
226                   }
227
228           Fields of the branch element have following semantics:
229
230           *   count: number of executions of the branch
231
232           *   fallthrough: true when the branch is a fall through branch
233
234           *   throw: true when the branch is an exceptional branch
235
236       -j
237       --human-readable
238           Write counts in human readable format (like 24.6k).
239
240       -k
241       --use-colors
242           Use colors for lines of code that have zero coverage.  We use red
243           color for non-exceptional lines and cyan for exceptional.  Same
244           colors are used for basic blocks with -a option.
245
246       -l
247       --long-file-names
248           Create long file names for included source files.  For example, if
249           the header file x.h contains code, and was included in the file
250           a.c, then running gcov on the file a.c will produce an output file
251           called a.c##x.h.gcov instead of x.h.gcov.  This can be useful if
252           x.h is included in multiple source files and you want to see the
253           individual contributions.  If you use the -p option, both the
254           including and included file names will be complete path names.
255
256       -m
257       --demangled-names
258           Display demangled function names in output. The default is to show
259           mangled function names.
260
261       -n
262       --no-output
263           Do not create the gcov output file.
264
265       -o directory|file
266       --object-directory directory
267       --object-file file
268           Specify either the directory containing the gcov data files, or the
269           object path name.  The .gcno, and .gcda data files are searched for
270           using this option.  If a directory is specified, the data files are
271           in that directory and named after the input file name, without its
272           extension.  If a file is specified here, the data files are named
273           after that file, without its extension.
274
275       -p
276       --preserve-paths
277           Preserve complete path information in the names of generated .gcov
278           files.  Without this option, just the filename component is used.
279           With this option, all directories are used, with / characters
280           translated to # characters, . directory components removed and
281           unremoveable ..  components renamed to ^.  This is useful if
282           sourcefiles are in several different directories.
283
284       -q
285       --use-hotness-colors
286           Emit perf-like colored output for hot lines.  Legend of the color
287           scale is printed at the very beginning of the output file.
288
289       -r
290       --relative-only
291           Only output information about source files with a relative pathname
292           (after source prefix elision).  Absolute paths are usually system
293           header files and coverage of any inline functions therein is
294           normally uninteresting.
295
296       -s directory
297       --source-prefix directory
298           A prefix for source file names to remove when generating the output
299           coverage files.  This option is useful when building in a separate
300           directory, and the pathname to the source directory is not wanted
301           when determining the output file names.  Note that this prefix
302           detection is applied before determining whether the source file is
303           absolute.
304
305       -t
306       --stdout
307           Output to standard output instead of output files.
308
309       -u
310       --unconditional-branches
311           When branch probabilities are given, include those of unconditional
312           branches.  Unconditional branches are normally not interesting.
313
314       -v
315       --version
316           Display the gcov version number (on the standard output), and exit
317           without doing any further processing.
318
319       -w
320       --verbose
321           Print verbose informations related to basic blocks and arcs.
322
323       -x
324       --hash-filenames
325           When using --preserve-paths, gcov uses the full pathname of the
326           source files to create an output filename.  This can lead to long
327           filenames that can overflow filesystem limits.  This option creates
328           names of the form source-file##md5.gcov, where the source-file
329           component is the final filename part and the md5 component is
330           calculated from the full mangled name that would have been used
331           otherwise.  The option is an alternative to the --preserve-paths on
332           systems which have a filesystem limit.
333
334       gcov should be run with the current directory the same as that when you
335       invoked the compiler.  Otherwise it will not be able to locate the
336       source files.  gcov produces files called mangledname.gcov in the
337       current directory.  These contain the coverage information of the
338       source file they correspond to.  One .gcov file is produced for each
339       source (or header) file containing code, which was compiled to produce
340       the data files.  The mangledname part of the output file name is
341       usually simply the source file name, but can be something more
342       complicated if the -l or -p options are given.  Refer to those options
343       for details.
344
345       If you invoke gcov with multiple input files, the contributions from
346       each input file are summed.  Typically you would invoke it with the
347       same list of files as the final link of your executable.
348
349       The .gcov files contain the : separated fields along with program
350       source code.  The format is
351
352               <execution_count>:<line_number>:<source line text>
353
354       Additional block information may succeed each line, when requested by
355       command line option.  The execution_count is - for lines containing no
356       code.  Unexecuted lines are marked ##### or =====, depending on whether
357       they are reachable by non-exceptional paths or only exceptional paths
358       such as C++ exception handlers, respectively. Given the -a option,
359       unexecuted blocks are marked $$$$$ or %%%%%, depending on whether a
360       basic block is reachable via non-exceptional or exceptional paths.
361       Executed basic blocks having a statement with zero execution_count end
362       with * character and are colored with magenta color with the -k option.
363       This functionality is not supported in Ada.
364
365       Note that GCC can completely remove the bodies of functions that are
366       not needed -- for instance if they are inlined everywhere.  Such
367       functions are marked with -, which can be confusing.  Use the
368       -fkeep-inline-functions and -fkeep-static-functions options to retain
369       these functions and allow gcov to properly show their execution_count.
370
371       Some lines of information at the start have line_number of zero.  These
372       preamble lines are of the form
373
374               -:0:<tag>:<value>
375
376       The ordering and number of these preamble lines will be augmented as
377       gcov development progresses --- do not rely on them remaining
378       unchanged.  Use tag to locate a particular preamble line.
379
380       The additional block information is of the form
381
382               <tag> <information>
383
384       The information is human readable, but designed to be simple enough for
385       machine parsing too.
386
387       When printing percentages, 0% and 100% are only printed when the values
388       are exactly 0% and 100% respectively.  Other values which would
389       conventionally be rounded to 0% or 100% are instead printed as the
390       nearest non-boundary value.
391
392       When using gcov, you must first compile your program with a special GCC
393       option --coverage.  This tells the compiler to generate additional
394       information needed by gcov (basically a flow graph of the program) and
395       also includes additional code in the object files for generating the
396       extra profiling information needed by gcov.  These additional files are
397       placed in the directory where the object file is located.
398
399       Running the program will cause profile output to be generated.  For
400       each source file compiled with -fprofile-arcs, an accompanying .gcda
401       file will be placed in the object file directory.
402
403       Running gcov with your program's source file names as arguments will
404       now produce a listing of the code along with frequency of execution for
405       each line.  For example, if your program is called tmp.cpp, this is
406       what you see when you use the basic gcov facility:
407
408               $ g++ --coverage tmp.cpp
409               $ a.out
410               $ gcov tmp.cpp -m
411               File 'tmp.cpp'
412               Lines executed:92.86% of 14
413               Creating 'tmp.cpp.gcov'
414
415       The file tmp.cpp.gcov contains output from gcov.  Here is a sample:
416
417                       -:    0:Source:tmp.cpp
418                       -:    0:Working directory:/home/gcc/testcase
419                       -:    0:Graph:tmp.gcno
420                       -:    0:Data:tmp.gcda
421                       -:    0:Runs:1
422                       -:    0:Programs:1
423                       -:    1:#include <stdio.h>
424                       -:    2:
425                       -:    3:template<class T>
426                       -:    4:class Foo
427                       -:    5:{
428                       -:    6:  public:
429                      1*:    7:  Foo(): b (1000) {}
430               ------------------
431               Foo<char>::Foo():
432                   #####:    7:  Foo(): b (1000) {}
433               ------------------
434               Foo<int>::Foo():
435                       1:    7:  Foo(): b (1000) {}
436               ------------------
437                      2*:    8:  void inc () { b++; }
438               ------------------
439               Foo<char>::inc():
440                   #####:    8:  void inc () { b++; }
441               ------------------
442               Foo<int>::inc():
443                       2:    8:  void inc () { b++; }
444               ------------------
445                       -:    9:
446                       -:   10:  private:
447                       -:   11:  int b;
448                       -:   12:};
449                       -:   13:
450                       -:   14:template class Foo<int>;
451                       -:   15:template class Foo<char>;
452                       -:   16:
453                       -:   17:int
454                       1:   18:main (void)
455                       -:   19:{
456                       -:   20:  int i, total;
457                       1:   21:  Foo<int> counter;
458                       -:   22:
459                       1:   23:  counter.inc();
460                       1:   24:  counter.inc();
461                       1:   25:  total = 0;
462                       -:   26:
463                      11:   27:  for (i = 0; i < 10; i++)
464                      10:   28:    total += i;
465                       -:   29:
466                      1*:   30:  int v = total > 100 ? 1 : 2;
467                       -:   31:
468                       1:   32:  if (total != 45)
469                   #####:   33:    printf ("Failure\n");
470                       -:   34:  else
471                       1:   35:    printf ("Success\n");
472                       1:   36:  return 0;
473                       -:   37:}
474
475       Note that line 7 is shown in the report multiple times.  First
476       occurrence presents total number of execution of the line and the next
477       two belong to instances of class Foo constructors.  As you can also
478       see, line 30 contains some unexecuted basic blocks and thus execution
479       count has asterisk symbol.
480
481       When you use the -a option, you will get individual block counts, and
482       the output looks like this:
483
484                       -:    0:Source:tmp.cpp
485                       -:    0:Working directory:/home/gcc/testcase
486                       -:    0:Graph:tmp.gcno
487                       -:    0:Data:tmp.gcda
488                       -:    0:Runs:1
489                       -:    0:Programs:1
490                       -:    1:#include <stdio.h>
491                       -:    2:
492                       -:    3:template<class T>
493                       -:    4:class Foo
494                       -:    5:{
495                       -:    6:  public:
496                      1*:    7:  Foo(): b (1000) {}
497               ------------------
498               Foo<char>::Foo():
499                   #####:    7:  Foo(): b (1000) {}
500               ------------------
501               Foo<int>::Foo():
502                       1:    7:  Foo(): b (1000) {}
503               ------------------
504                      2*:    8:  void inc () { b++; }
505               ------------------
506               Foo<char>::inc():
507                   #####:    8:  void inc () { b++; }
508               ------------------
509               Foo<int>::inc():
510                       2:    8:  void inc () { b++; }
511               ------------------
512                       -:    9:
513                       -:   10:  private:
514                       -:   11:  int b;
515                       -:   12:};
516                       -:   13:
517                       -:   14:template class Foo<int>;
518                       -:   15:template class Foo<char>;
519                       -:   16:
520                       -:   17:int
521                       1:   18:main (void)
522                       -:   19:{
523                       -:   20:  int i, total;
524                       1:   21:  Foo<int> counter;
525                       1:   21-block  0
526                       -:   22:
527                       1:   23:  counter.inc();
528                       1:   23-block  0
529                       1:   24:  counter.inc();
530                       1:   24-block  0
531                       1:   25:  total = 0;
532                       -:   26:
533                      11:   27:  for (i = 0; i < 10; i++)
534                       1:   27-block  0
535                      11:   27-block  1
536                      10:   28:    total += i;
537                      10:   28-block  0
538                       -:   29:
539                      1*:   30:  int v = total > 100 ? 1 : 2;
540                       1:   30-block  0
541                   %%%%%:   30-block  1
542                       1:   30-block  2
543                       -:   31:
544                       1:   32:  if (total != 45)
545                       1:   32-block  0
546                   #####:   33:    printf ("Failure\n");
547                   %%%%%:   33-block  0
548                       -:   34:  else
549                       1:   35:    printf ("Success\n");
550                       1:   35-block  0
551                       1:   36:  return 0;
552                       1:   36-block  0
553                       -:   37:}
554
555       In this mode, each basic block is only shown on one line -- the last
556       line of the block.  A multi-line block will only contribute to the
557       execution count of that last line, and other lines will not be shown to
558       contain code, unless previous blocks end on those lines.  The total
559       execution count of a line is shown and subsequent lines show the
560       execution counts for individual blocks that end on that line.  After
561       each block, the branch and call counts of the block will be shown, if
562       the -b option is given.
563
564       Because of the way GCC instruments calls, a call count can be shown
565       after a line with no individual blocks.  As you can see, line 33
566       contains a basic block that was not executed.
567
568       When you use the -b option, your output looks like this:
569
570                       -:    0:Source:tmp.cpp
571                       -:    0:Working directory:/home/gcc/testcase
572                       -:    0:Graph:tmp.gcno
573                       -:    0:Data:tmp.gcda
574                       -:    0:Runs:1
575                       -:    0:Programs:1
576                       -:    1:#include <stdio.h>
577                       -:    2:
578                       -:    3:template<class T>
579                       -:    4:class Foo
580                       -:    5:{
581                       -:    6:  public:
582                      1*:    7:  Foo(): b (1000) {}
583               ------------------
584               Foo<char>::Foo():
585               function Foo<char>::Foo() called 0 returned 0% blocks executed 0%
586                   #####:    7:  Foo(): b (1000) {}
587               ------------------
588               Foo<int>::Foo():
589               function Foo<int>::Foo() called 1 returned 100% blocks executed 100%
590                       1:    7:  Foo(): b (1000) {}
591               ------------------
592                      2*:    8:  void inc () { b++; }
593               ------------------
594               Foo<char>::inc():
595               function Foo<char>::inc() called 0 returned 0% blocks executed 0%
596                   #####:    8:  void inc () { b++; }
597               ------------------
598               Foo<int>::inc():
599               function Foo<int>::inc() called 2 returned 100% blocks executed 100%
600                       2:    8:  void inc () { b++; }
601               ------------------
602                       -:    9:
603                       -:   10:  private:
604                       -:   11:  int b;
605                       -:   12:};
606                       -:   13:
607                       -:   14:template class Foo<int>;
608                       -:   15:template class Foo<char>;
609                       -:   16:
610                       -:   17:int
611               function main called 1 returned 100% blocks executed 81%
612                       1:   18:main (void)
613                       -:   19:{
614                       -:   20:  int i, total;
615                       1:   21:  Foo<int> counter;
616               call    0 returned 100%
617               branch  1 taken 100% (fallthrough)
618               branch  2 taken 0% (throw)
619                       -:   22:
620                       1:   23:  counter.inc();
621               call    0 returned 100%
622               branch  1 taken 100% (fallthrough)
623               branch  2 taken 0% (throw)
624                       1:   24:  counter.inc();
625               call    0 returned 100%
626               branch  1 taken 100% (fallthrough)
627               branch  2 taken 0% (throw)
628                       1:   25:  total = 0;
629                       -:   26:
630                      11:   27:  for (i = 0; i < 10; i++)
631               branch  0 taken 91% (fallthrough)
632               branch  1 taken 9%
633                      10:   28:    total += i;
634                       -:   29:
635                      1*:   30:  int v = total > 100 ? 1 : 2;
636               branch  0 taken 0% (fallthrough)
637               branch  1 taken 100%
638                       -:   31:
639                       1:   32:  if (total != 45)
640               branch  0 taken 0% (fallthrough)
641               branch  1 taken 100%
642                   #####:   33:    printf ("Failure\n");
643               call    0 never executed
644               branch  1 never executed
645               branch  2 never executed
646                       -:   34:  else
647                       1:   35:    printf ("Success\n");
648               call    0 returned 100%
649               branch  1 taken 100% (fallthrough)
650               branch  2 taken 0% (throw)
651                       1:   36:  return 0;
652                       -:   37:}
653
654       For each function, a line is printed showing how many times the
655       function is called, how many times it returns and what percentage of
656       the function's blocks were executed.
657
658       For each basic block, a line is printed after the last line of the
659       basic block describing the branch or call that ends the basic block.
660       There can be multiple branches and calls listed for a single source
661       line if there are multiple basic blocks that end on that line.  In this
662       case, the branches and calls are each given a number.  There is no
663       simple way to map these branches and calls back to source constructs.
664       In general, though, the lowest numbered branch or call will correspond
665       to the leftmost construct on the source line.
666
667       For a branch, if it was executed at least once, then a percentage
668       indicating the number of times the branch was taken divided by the
669       number of times the branch was executed will be printed.  Otherwise,
670       the message "never executed" is printed.
671
672       For a call, if it was executed at least once, then a percentage
673       indicating the number of times the call returned divided by the number
674       of times the call was executed will be printed.  This will usually be
675       100%, but may be less for functions that call "exit" or "longjmp", and
676       thus may not return every time they are called.
677
678       The execution counts are cumulative.  If the example program were
679       executed again without removing the .gcda file, the count for the
680       number of times each line in the source was executed would be added to
681       the results of the previous run(s).  This is potentially useful in
682       several ways.  For example, it could be used to accumulate data over a
683       number of program runs as part of a test verification suite, or to
684       provide more accurate long-term information over a large number of
685       program runs.
686
687       The data in the .gcda files is saved immediately before the program
688       exits.  For each source file compiled with -fprofile-arcs, the
689       profiling code first attempts to read in an existing .gcda file; if the
690       file doesn't match the executable (differing number of basic block
691       counts) it will ignore the contents of the file.  It then adds in the
692       new execution counts and finally writes the data to the file.
693
694   Using gcov with GCC Optimization
695       If you plan to use gcov to help optimize your code, you must first
696       compile your program with a special GCC option --coverage.  Aside from
697       that, you can use any other GCC options; but if you want to prove that
698       every single line in your program was executed, you should not compile
699       with optimization at the same time.  On some machines the optimizer can
700       eliminate some simple code lines by combining them with other lines.
701       For example, code like this:
702
703               if (a != b)
704                 c = 1;
705               else
706                 c = 0;
707
708       can be compiled into one instruction on some machines.  In this case,
709       there is no way for gcov to calculate separate execution counts for
710       each line because there isn't separate code for each line.  Hence the
711       gcov output looks like this if you compiled the program with
712       optimization:
713
714                     100:   12:if (a != b)
715                     100:   13:  c = 1;
716                     100:   14:else
717                     100:   15:  c = 0;
718
719       The output shows that this block of code, combined by optimization,
720       executed 100 times.  In one sense this result is correct, because there
721       was only one instruction representing all four of these lines.
722       However, the output does not indicate how many times the result was 0
723       and how many times the result was 1.
724
725       Inlineable functions can create unexpected line counts.  Line counts
726       are shown for the source code of the inlineable function, but what is
727       shown depends on where the function is inlined, or if it is not inlined
728       at all.
729
730       If the function is not inlined, the compiler must emit an out of line
731       copy of the function, in any object file that needs it.  If fileA.o and
732       fileB.o both contain out of line bodies of a particular inlineable
733       function, they will also both contain coverage counts for that
734       function.  When fileA.o and fileB.o are linked together, the linker
735       will, on many systems, select one of those out of line bodies for all
736       calls to that function, and remove or ignore the other.  Unfortunately,
737       it will not remove the coverage counters for the unused function body.
738       Hence when instrumented, all but one use of that function will show
739       zero counts.
740
741       If the function is inlined in several places, the block structure in
742       each location might not be the same.  For instance, a condition might
743       now be calculable at compile time in some instances.  Because the
744       coverage of all the uses of the inline function will be shown for the
745       same source lines, the line counts themselves might seem inconsistent.
746
747       Long-running applications can use the "__gcov_reset" and "__gcov_dump"
748       facilities to restrict profile collection to the program region of
749       interest. Calling "__gcov_reset(void)" will clear all profile counters
750       to zero, and calling "__gcov_dump(void)" will cause the profile
751       information collected at that point to be dumped to .gcda output files.
752       Instrumented applications use a static destructor with priority 99 to
753       invoke the "__gcov_dump" function. Thus "__gcov_dump" is executed after
754       all user defined static destructors, as well as handlers registered
755       with "atexit".  If an executable loads a dynamic shared object via
756       dlopen functionality, -Wl,--dynamic-list-data is needed to dump all
757       profile data.
758
759       Profiling run-time library reports various errors related to profile
760       manipulation and profile saving.  Errors are printed into standard
761       error output or GCOV_ERROR_FILE file, if environment variable is used.
762       In order to terminate immediately after an errors occurs set
763       GCOV_EXIT_AT_ERROR environment variable.  That can help users to find
764       profile clashing which leads to a misleading profile.
765

SEE ALSO

767       gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entry for gcc.
768
770       Copyright (c) 1996-2020 Free Software Foundation, Inc.
771
772       Permission is granted to copy, distribute and/or modify this document
773       under the terms of the GNU Free Documentation License, Version 1.3 or
774       any later version published by the Free Software Foundation; with the
775       Invariant Sections being "GNU General Public License" and "Funding Free
776       Software", the Front-Cover texts being (a) (see below), and with the
777       Back-Cover Texts being (b) (see below).  A copy of the license is
778       included in the gfdl(7) man page.
779
780       (a) The FSF's Front-Cover Text is:
781
782            A GNU Manual
783
784       (b) The FSF's Back-Cover Text is:
785
786            You have freedom to copy and modify this GNU Manual, like GNU
787            software.  Copies published by the Free Software Foundation raise
788            funds for GNU development.
789
790
791
792gcc-10.2.1                        2020-07-23                           GCOV(1)
Impressum