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            [-j|--json-format]
16            [-H|--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       -j
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": "foo/bar",
128                     "data_file": "a.out",
129                     "format_version": "1",
130                     "gcc_version": "11.1.1 20210510"
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": "a.c",
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": 2,
161                     "blocks_executed": 2,
162                     "demangled_name": "foo",
163                     "end_column": 1,
164                     "end_line": 4,
165                     "execution_count": 1,
166                     "name": "foo",
167                     "start_column": 5,
168                     "start_line": 1
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": 2,
202                     "line_number": 15,
203                     "unexecuted_block": false,
204                     "function_name": "foo",
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": 11,
224                     "fallthrough": true,
225                     "throw": false
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       -H
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 -c
409               $ g++ --coverage tmp.o
410               $ a.out
411               $ gcov tmp.cpp -m
412               File 'tmp.cpp'
413               Lines executed:92.86% of 14
414               Creating 'tmp.cpp.gcov'
415
416       The file tmp.cpp.gcov contains output from gcov.  Here is a sample:
417
418                       -:    0:Source:tmp.cpp
419                       -:    0:Working directory:/home/gcc/testcase
420                       -:    0:Graph:tmp.gcno
421                       -:    0:Data:tmp.gcda
422                       -:    0:Runs:1
423                       -:    0:Programs:1
424                       -:    1:#include <stdio.h>
425                       -:    2:
426                       -:    3:template<class T>
427                       -:    4:class Foo
428                       -:    5:{
429                       -:    6:  public:
430                      1*:    7:  Foo(): b (1000) {}
431               ------------------
432               Foo<char>::Foo():
433                   #####:    7:  Foo(): b (1000) {}
434               ------------------
435               Foo<int>::Foo():
436                       1:    7:  Foo(): b (1000) {}
437               ------------------
438                      2*:    8:  void inc () { b++; }
439               ------------------
440               Foo<char>::inc():
441                   #####:    8:  void inc () { b++; }
442               ------------------
443               Foo<int>::inc():
444                       2:    8:  void inc () { b++; }
445               ------------------
446                       -:    9:
447                       -:   10:  private:
448                       -:   11:  int b;
449                       -:   12:};
450                       -:   13:
451                       -:   14:template class Foo<int>;
452                       -:   15:template class Foo<char>;
453                       -:   16:
454                       -:   17:int
455                       1:   18:main (void)
456                       -:   19:{
457                       -:   20:  int i, total;
458                       1:   21:  Foo<int> counter;
459                       -:   22:
460                       1:   23:  counter.inc();
461                       1:   24:  counter.inc();
462                       1:   25:  total = 0;
463                       -:   26:
464                      11:   27:  for (i = 0; i < 10; i++)
465                      10:   28:    total += i;
466                       -:   29:
467                      1*:   30:  int v = total > 100 ? 1 : 2;
468                       -:   31:
469                       1:   32:  if (total != 45)
470                   #####:   33:    printf ("Failure\n");
471                       -:   34:  else
472                       1:   35:    printf ("Success\n");
473                       1:   36:  return 0;
474                       -:   37:}
475
476       Note that line 7 is shown in the report multiple times.  First
477       occurrence presents total number of execution of the line and the next
478       two belong to instances of class Foo constructors.  As you can also
479       see, line 30 contains some unexecuted basic blocks and thus execution
480       count has asterisk symbol.
481
482       When you use the -a option, you will get individual block counts, and
483       the output looks like this:
484
485                       -:    0:Source:tmp.cpp
486                       -:    0:Working directory:/home/gcc/testcase
487                       -:    0:Graph:tmp.gcno
488                       -:    0:Data:tmp.gcda
489                       -:    0:Runs:1
490                       -:    0:Programs:1
491                       -:    1:#include <stdio.h>
492                       -:    2:
493                       -:    3:template<class T>
494                       -:    4:class Foo
495                       -:    5:{
496                       -:    6:  public:
497                      1*:    7:  Foo(): b (1000) {}
498               ------------------
499               Foo<char>::Foo():
500                   #####:    7:  Foo(): b (1000) {}
501               ------------------
502               Foo<int>::Foo():
503                       1:    7:  Foo(): b (1000) {}
504               ------------------
505                      2*:    8:  void inc () { b++; }
506               ------------------
507               Foo<char>::inc():
508                   #####:    8:  void inc () { b++; }
509               ------------------
510               Foo<int>::inc():
511                       2:    8:  void inc () { b++; }
512               ------------------
513                       -:    9:
514                       -:   10:  private:
515                       -:   11:  int b;
516                       -:   12:};
517                       -:   13:
518                       -:   14:template class Foo<int>;
519                       -:   15:template class Foo<char>;
520                       -:   16:
521                       -:   17:int
522                       1:   18:main (void)
523                       -:   19:{
524                       -:   20:  int i, total;
525                       1:   21:  Foo<int> counter;
526                       1:   21-block  0
527                       -:   22:
528                       1:   23:  counter.inc();
529                       1:   23-block  0
530                       1:   24:  counter.inc();
531                       1:   24-block  0
532                       1:   25:  total = 0;
533                       -:   26:
534                      11:   27:  for (i = 0; i < 10; i++)
535                       1:   27-block  0
536                      11:   27-block  1
537                      10:   28:    total += i;
538                      10:   28-block  0
539                       -:   29:
540                      1*:   30:  int v = total > 100 ? 1 : 2;
541                       1:   30-block  0
542                   %%%%%:   30-block  1
543                       1:   30-block  2
544                       -:   31:
545                       1:   32:  if (total != 45)
546                       1:   32-block  0
547                   #####:   33:    printf ("Failure\n");
548                   %%%%%:   33-block  0
549                       -:   34:  else
550                       1:   35:    printf ("Success\n");
551                       1:   35-block  0
552                       1:   36:  return 0;
553                       1:   36-block  0
554                       -:   37:}
555
556       In this mode, each basic block is only shown on one line -- the last
557       line of the block.  A multi-line block will only contribute to the
558       execution count of that last line, and other lines will not be shown to
559       contain code, unless previous blocks end on those lines.  The total
560       execution count of a line is shown and subsequent lines show the
561       execution counts for individual blocks that end on that line.  After
562       each block, the branch and call counts of the block will be shown, if
563       the -b option is given.
564
565       Because of the way GCC instruments calls, a call count can be shown
566       after a line with no individual blocks.  As you can see, line 33
567       contains a basic block that was not executed.
568
569       When you use the -b option, your output looks like this:
570
571                       -:    0:Source:tmp.cpp
572                       -:    0:Working directory:/home/gcc/testcase
573                       -:    0:Graph:tmp.gcno
574                       -:    0:Data:tmp.gcda
575                       -:    0:Runs:1
576                       -:    0:Programs:1
577                       -:    1:#include <stdio.h>
578                       -:    2:
579                       -:    3:template<class T>
580                       -:    4:class Foo
581                       -:    5:{
582                       -:    6:  public:
583                      1*:    7:  Foo(): b (1000) {}
584               ------------------
585               Foo<char>::Foo():
586               function Foo<char>::Foo() called 0 returned 0% blocks executed 0%
587                   #####:    7:  Foo(): b (1000) {}
588               ------------------
589               Foo<int>::Foo():
590               function Foo<int>::Foo() called 1 returned 100% blocks executed 100%
591                       1:    7:  Foo(): b (1000) {}
592               ------------------
593                      2*:    8:  void inc () { b++; }
594               ------------------
595               Foo<char>::inc():
596               function Foo<char>::inc() called 0 returned 0% blocks executed 0%
597                   #####:    8:  void inc () { b++; }
598               ------------------
599               Foo<int>::inc():
600               function Foo<int>::inc() called 2 returned 100% blocks executed 100%
601                       2:    8:  void inc () { b++; }
602               ------------------
603                       -:    9:
604                       -:   10:  private:
605                       -:   11:  int b;
606                       -:   12:};
607                       -:   13:
608                       -:   14:template class Foo<int>;
609                       -:   15:template class Foo<char>;
610                       -:   16:
611                       -:   17:int
612               function main called 1 returned 100% blocks executed 81%
613                       1:   18:main (void)
614                       -:   19:{
615                       -:   20:  int i, total;
616                       1:   21:  Foo<int> counter;
617               call    0 returned 100%
618               branch  1 taken 100% (fallthrough)
619               branch  2 taken 0% (throw)
620                       -:   22:
621                       1:   23:  counter.inc();
622               call    0 returned 100%
623               branch  1 taken 100% (fallthrough)
624               branch  2 taken 0% (throw)
625                       1:   24:  counter.inc();
626               call    0 returned 100%
627               branch  1 taken 100% (fallthrough)
628               branch  2 taken 0% (throw)
629                       1:   25:  total = 0;
630                       -:   26:
631                      11:   27:  for (i = 0; i < 10; i++)
632               branch  0 taken 91% (fallthrough)
633               branch  1 taken 9%
634                      10:   28:    total += i;
635                       -:   29:
636                      1*:   30:  int v = total > 100 ? 1 : 2;
637               branch  0 taken 0% (fallthrough)
638               branch  1 taken 100%
639                       -:   31:
640                       1:   32:  if (total != 45)
641               branch  0 taken 0% (fallthrough)
642               branch  1 taken 100%
643                   #####:   33:    printf ("Failure\n");
644               call    0 never executed
645               branch  1 never executed
646               branch  2 never executed
647                       -:   34:  else
648                       1:   35:    printf ("Success\n");
649               call    0 returned 100%
650               branch  1 taken 100% (fallthrough)
651               branch  2 taken 0% (throw)
652                       1:   36:  return 0;
653                       -:   37:}
654
655       For each function, a line is printed showing how many times the
656       function is called, how many times it returns and what percentage of
657       the function's blocks were executed.
658
659       For each basic block, a line is printed after the last line of the
660       basic block describing the branch or call that ends the basic block.
661       There can be multiple branches and calls listed for a single source
662       line if there are multiple basic blocks that end on that line.  In this
663       case, the branches and calls are each given a number.  There is no
664       simple way to map these branches and calls back to source constructs.
665       In general, though, the lowest numbered branch or call will correspond
666       to the leftmost construct on the source line.
667
668       For a branch, if it was executed at least once, then a percentage
669       indicating the number of times the branch was taken divided by the
670       number of times the branch was executed will be printed.  Otherwise,
671       the message "never executed" is printed.
672
673       For a call, if it was executed at least once, then a percentage
674       indicating the number of times the call returned divided by the number
675       of times the call was executed will be printed.  This will usually be
676       100%, but may be less for functions that call "exit" or "longjmp", and
677       thus may not return every time they are called.
678
679       The execution counts are cumulative.  If the example program were
680       executed again without removing the .gcda file, the count for the
681       number of times each line in the source was executed would be added to
682       the results of the previous run(s).  This is potentially useful in
683       several ways.  For example, it could be used to accumulate data over a
684       number of program runs as part of a test verification suite, or to
685       provide more accurate long-term information over a large number of
686       program runs.
687
688       The data in the .gcda files is saved immediately before the program
689       exits.  For each source file compiled with -fprofile-arcs, the
690       profiling code first attempts to read in an existing .gcda file; if the
691       file doesn't match the executable (differing number of basic block
692       counts) it will ignore the contents of the file.  It then adds in the
693       new execution counts and finally writes the data to the file.
694
695   Using gcov with GCC Optimization
696       If you plan to use gcov to help optimize your code, you must first
697       compile your program with a special GCC option --coverage.  Aside from
698       that, you can use any other GCC options; but if you want to prove that
699       every single line in your program was executed, you should not compile
700       with optimization at the same time.  On some machines the optimizer can
701       eliminate some simple code lines by combining them with other lines.
702       For example, code like this:
703
704               if (a != b)
705                 c = 1;
706               else
707                 c = 0;
708
709       can be compiled into one instruction on some machines.  In this case,
710       there is no way for gcov to calculate separate execution counts for
711       each line because there isn't separate code for each line.  Hence the
712       gcov output looks like this if you compiled the program with
713       optimization:
714
715                     100:   12:if (a != b)
716                     100:   13:  c = 1;
717                     100:   14:else
718                     100:   15:  c = 0;
719
720       The output shows that this block of code, combined by optimization,
721       executed 100 times.  In one sense this result is correct, because there
722       was only one instruction representing all four of these lines.
723       However, the output does not indicate how many times the result was 0
724       and how many times the result was 1.
725
726       Inlineable functions can create unexpected line counts.  Line counts
727       are shown for the source code of the inlineable function, but what is
728       shown depends on where the function is inlined, or if it is not inlined
729       at all.
730
731       If the function is not inlined, the compiler must emit an out of line
732       copy of the function, in any object file that needs it.  If fileA.o and
733       fileB.o both contain out of line bodies of a particular inlineable
734       function, they will also both contain coverage counts for that
735       function.  When fileA.o and fileB.o are linked together, the linker
736       will, on many systems, select one of those out of line bodies for all
737       calls to that function, and remove or ignore the other.  Unfortunately,
738       it will not remove the coverage counters for the unused function body.
739       Hence when instrumented, all but one use of that function will show
740       zero counts.
741
742       If the function is inlined in several places, the block structure in
743       each location might not be the same.  For instance, a condition might
744       now be calculable at compile time in some instances.  Because the
745       coverage of all the uses of the inline function will be shown for the
746       same source lines, the line counts themselves might seem inconsistent.
747
748       Long-running applications can use the "__gcov_reset" and "__gcov_dump"
749       facilities to restrict profile collection to the program region of
750       interest. Calling "__gcov_reset(void)" will clear all run-time profile
751       counters to zero, and calling "__gcov_dump(void)" will cause the
752       profile information collected at that point to be dumped to .gcda
753       output files.  Instrumented applications use a static destructor with
754       priority 99 to invoke the "__gcov_dump" function. Thus "__gcov_dump" is
755       executed after all user defined static destructors, as well as handlers
756       registered with "atexit".
757
758       If an executable loads a dynamic shared object via dlopen
759       functionality, -Wl,--dynamic-list-data is needed to dump all profile
760       data.
761
762       Profiling run-time library reports various errors related to profile
763       manipulation and profile saving.  Errors are printed into standard
764       error output or GCOV_ERROR_FILE file, if environment variable is used.
765       In order to terminate immediately after an errors occurs set
766       GCOV_EXIT_AT_ERROR environment variable.  That can help users to find
767       profile clashing which leads to a misleading profile.
768

SEE ALSO

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