annotate gcc/doc/gcov.texi @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1 @c Copyright (C) 1996-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 @c This is part of the GCC manual.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 @c For copying conditions, see the file gcc.texi.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 @ignore
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 @c man begin COPYRIGHT
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
7 Copyright @copyright{} 1996-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 Permission is granted to copy, distribute and/or modify this document
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
10 under the terms of the GNU Free Documentation License, Version 1.3 or
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 any later version published by the Free Software Foundation; with the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 Invariant Sections being ``GNU General Public License'' and ``Funding
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 Free Software'', the Front-Cover texts being (a) (see below), and with
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 the Back-Cover Texts being (b) (see below). A copy of the license is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 included in the gfdl(7) man page.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 (a) The FSF's Front-Cover Text is:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 A GNU Manual
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 (b) The FSF's Back-Cover Text is:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 You have freedom to copy and modify this GNU Manual, like GNU
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 software. Copies published by the Free Software Foundation raise
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 funds for GNU development.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 @c man end
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 @c Set file name and title for the man page.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 @setfilename gcov
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 @settitle coverage testing tool
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 @end ignore
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 @node Gcov
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 @chapter @command{gcov}---a Test Coverage Program
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 @command{gcov} is a tool you can use in conjunction with GCC to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 test code coverage in your programs.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 @menu
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 * Gcov Intro:: Introduction to gcov.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 * Invoking Gcov:: How to use gcov.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 * Gcov and Optimization:: Using gcov with GCC optimization.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 * Gcov Data Files:: The files used by gcov.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 * Cross-profiling:: Data file relocation.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 @end menu
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 @node Gcov Intro
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 @section Introduction to @command{gcov}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 @c man begin DESCRIPTION
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 @command{gcov} is a test coverage program. Use it in concert with GCC
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 to analyze your programs to help create more efficient, faster running
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 code and to discover untested parts of your program. You can use
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 @command{gcov} as a profiling tool to help discover where your
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 optimization efforts will best affect your code. You can also use
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 @command{gcov} along with the other profiling tool, @command{gprof}, to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 assess which parts of your code use the greatest amount of computing
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 time.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 Profiling tools help you analyze your code's performance. Using a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 profiler such as @command{gcov} or @command{gprof}, you can find out some
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 basic performance statistics, such as:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 @itemize @bullet
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 @item
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 how often each line of code executes
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 @item
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 what lines of code are actually executed
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 @item
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 how much computing time each section of code uses
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 @end itemize
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 Once you know these things about how your code works when compiled, you
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 can look at each module to see which modules should be optimized.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 @command{gcov} helps you determine where to work on optimization.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 Software developers also use coverage testing in concert with
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 testsuites, to make sure software is actually good enough for a release.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 Testsuites can verify that a program works as expected; a coverage
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 program tests to see how much of the program is exercised by the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 testsuite. Developers can then determine what kinds of test cases need
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 to be added to the testsuites to create both better testing and a better
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 final product.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 You should compile your code without optimization if you plan to use
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 @command{gcov} because the optimization, by combining some lines of code
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 into one function, may not give you as much information as you need to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 look for `hot spots' where the code is using a great deal of computer
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 time. Likewise, because @command{gcov} accumulates statistics by line (at
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 the lowest resolution), it works best with a programming style that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 places only one statement on each line. If you use complicated macros
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 that expand to loops or to other control structures, the statistics are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 less helpful---they only report on the line where the macro call
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 appears. If your complex macros behave like functions, you can replace
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 them with inline functions to solve this problem.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 @command{gcov} creates a logfile called @file{@var{sourcefile}.gcov} which
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 indicates how many times each line of a source file @file{@var{sourcefile}.c}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 has executed. You can use these logfiles along with @command{gprof} to aid
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 in fine-tuning the performance of your programs. @command{gprof} gives
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 timing information you can use along with the information you get from
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 @command{gcov}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 @command{gcov} works only on code compiled with GCC@. It is not
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 compatible with any other profiling or test coverage mechanism.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 @c man end
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 @node Invoking Gcov
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 @section Invoking @command{gcov}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 @smallexample
111
kono
parents: 67
diff changeset
114 gcov @r{[}@var{options}@r{]} @var{files}
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 @end smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 @command{gcov} accepts the following options:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 @ignore
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 @c man begin SYNOPSIS
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 gcov [@option{-v}|@option{--version}] [@option{-h}|@option{--help}]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 [@option{-a}|@option{--all-blocks}]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 [@option{-b}|@option{--branch-probabilities}]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 [@option{-c}|@option{--branch-counts}]
111
kono
parents: 67
diff changeset
125 [@option{-d}|@option{--display-progress}]
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 [@option{-f}|@option{--function-summaries}]
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
127 [@option{-i}|@option{--json-format}]
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
128 [@option{-j}|@option{--human-readable}]
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
129 [@option{-k}|@option{--use-colors}]
111
kono
parents: 67
diff changeset
130 [@option{-l}|@option{--long-file-names}]
kono
parents: 67
diff changeset
131 [@option{-m}|@option{--demangled-names}]
kono
parents: 67
diff changeset
132 [@option{-n}|@option{--no-output}]
kono
parents: 67
diff changeset
133 [@option{-o}|@option{--object-directory} @var{directory|file}]
kono
parents: 67
diff changeset
134 [@option{-p}|@option{--preserve-paths}]
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
135 [@option{-q}|@option{--use-hotness-colors}]
111
kono
parents: 67
diff changeset
136 [@option{-r}|@option{--relative-only}]
kono
parents: 67
diff changeset
137 [@option{-s}|@option{--source-prefix} @var{directory}]
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
138 [@option{-t}|@option{--stdout}]
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 [@option{-u}|@option{--unconditional-branches}]
111
kono
parents: 67
diff changeset
140 [@option{-x}|@option{--hash-filenames}]
kono
parents: 67
diff changeset
141 @var{files}
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 @c man end
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 @c man begin SEEALSO
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entry for @file{gcc}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 @c man end
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 @end ignore
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 @c man begin OPTIONS
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 @table @gcctabopt
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 @item -a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 @itemx --all-blocks
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 Write individual execution counts for every basic block. Normally gcov
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 outputs execution counts only for the main blocks of a line. With this
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 option you can determine if blocks within a single line are not being
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 executed.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 @item -b
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 @itemx --branch-probabilities
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 Write branch frequencies to the output file, and write branch summary
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 info to the standard output. This option allows you to see how often
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 each branch in your program was taken. Unconditional branches will not
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 be shown, unless the @option{-u} option is given.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 @item -c
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 @itemx --branch-counts
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 Write branch frequencies as the number of branches taken, rather than
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 the percentage of branches taken.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169
111
kono
parents: 67
diff changeset
170 @item -d
kono
parents: 67
diff changeset
171 @itemx --display-progress
kono
parents: 67
diff changeset
172 Display the progress on the standard output.
kono
parents: 67
diff changeset
173
kono
parents: 67
diff changeset
174 @item -f
kono
parents: 67
diff changeset
175 @itemx --function-summaries
kono
parents: 67
diff changeset
176 Output summaries for each function in addition to the file level summary.
kono
parents: 67
diff changeset
177
kono
parents: 67
diff changeset
178 @item -h
kono
parents: 67
diff changeset
179 @itemx --help
kono
parents: 67
diff changeset
180 Display help about using @command{gcov} (on the standard output), and
kono
parents: 67
diff changeset
181 exit without doing any further processing.
kono
parents: 67
diff changeset
182
kono
parents: 67
diff changeset
183 @item -i
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
184 @itemx --json-format
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
185 Output gcov file in an easy-to-parse JSON intermediate format
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
186 which does not require source code for generation. The JSON
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
187 file is compressed with gzip compression algorithm
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
188 and the files have @file{.gcov.json.gz} extension.
111
kono
parents: 67
diff changeset
189
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
190 Structure of the JSON is following:
111
kono
parents: 67
diff changeset
191
kono
parents: 67
diff changeset
192 @smallexample
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
193 @{
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
194 "current_working_directory": @var{current_working_directory},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
195 "data_file": @var{data_file},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
196 "format_version": @var{format_version},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
197 "gcc_version": @var{gcc_version}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
198 "files": [@var{file}]
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
199 @}
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
200 @end smallexample
111
kono
parents: 67
diff changeset
201
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
202 Fields of the root element have following semantics:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
203
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
204 @itemize @bullet
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
205 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
206 @var{current_working_directory}: working directory where
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
207 a compilation unit was compiled
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
208
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
209 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
210 @var{data_file}: name of the data file (GCDA)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
211
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
212 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
213 @var{format_version}: semantic version of the format
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
214
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
215 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
216 @var{gcc_version}: version of the GCC compiler
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
217 @end itemize
111
kono
parents: 67
diff changeset
218
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
219 Each @var{file} has the following form:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
220
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
221 @smallexample
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
222 @{
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
223 "file": @var{file_name},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
224 "functions": [@var{function}],
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
225 "lines": [@var{line}]
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
226 @}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
227 @end smallexample
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
228
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
229 Fields of the @var{file} element have following semantics:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
230
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
231 @itemize @bullet
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
232 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
233 @var{file_name}: name of the source file
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
234 @end itemize
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
235
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
236 Each @var{function} has the following form:
111
kono
parents: 67
diff changeset
237
kono
parents: 67
diff changeset
238 @smallexample
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
239 @{
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
240 "blocks": @var{blocks},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
241 "blocks_executed": @var{blocks_executed},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
242 "demangled_name": "@var{demangled_name},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
243 "end_column": @var{end_column},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
244 "end_line": @var{end_line},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
245 "execution_count": @var{execution_count},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
246 "name": @var{name},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
247 "start_column": @var{start_column}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
248 "start_line": @var{start_line}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
249 @}
111
kono
parents: 67
diff changeset
250 @end smallexample
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
252 Fields of the @var{function} element have following semantics:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
253
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
254 @itemize @bullet
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
255 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
256 @var{blocks}: number of blocks that are in the function
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
257
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
258 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
259 @var{blocks_executed}: number of executed blocks of the function
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
260
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
261 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
262 @var{demangled_name}: demangled name of the function
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
263
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
264 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
265 @var{end_column}: column in the source file where the function ends
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
266
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
267 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
268 @var{end_line}: line in the source file where the function ends
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
269
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
270 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
271 @var{execution_count}: number of executions of the function
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
272
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
273 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
274 @var{name}: name of the function
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
275
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
276 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
277 @var{start_column}: column in the source file where the function begins
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
278
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
279 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
280 @var{start_line}: line in the source file where the function begins
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
281 @end itemize
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
282
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
283 Note that line numbers and column numbers number from 1. In the current
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
284 implementation, @var{start_line} and @var{start_column} do not include
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
285 any template parameters and the leading return type but that
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
286 this is likely to be fixed in the future.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
287
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
288 Each @var{line} has the following form:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
289
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
290 @smallexample
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
291 @{
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
292 "branches": [@var{branch}],
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
293 "count": @var{count},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
294 "line_number": @var{line_number},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
295 "unexecuted_block": @var{unexecuted_block}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
296 "function_name": @var{function_name},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
297 @}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
298 @end smallexample
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
299
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
300 Branches are present only with @var{-b} option.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
301 Fields of the @var{line} element have following semantics:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
302
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
303 @itemize @bullet
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
304 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
305 @var{count}: number of executions of the line
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
306
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
307 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
308 @var{line_number}: line number
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
309
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
310 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
311 @var{unexecuted_block}: flag whether the line contains an unexecuted block
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
312 (not all statements on the line are executed)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
313
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
314 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
315 @var{function_name}: a name of a function this @var{line} belongs to
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
316 (for a line with an inlined statements can be not set)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
317 @end itemize
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
318
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
319 Each @var{branch} has the following form:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
320
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
321 @smallexample
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
322 @{
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
323 "count": @var{count},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
324 "fallthrough": @var{fallthrough},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
325 "throw": @var{throw}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
326 @}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
327 @end smallexample
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
328
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
329 Fields of the @var{branch} element have following semantics:
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
330
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
331 @itemize @bullet
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
332 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
333 @var{count}: number of executions of the branch
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
334
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
335 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
336 @var{fallthrough}: true when the branch is a fall through branch
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
337
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
338 @item
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
339 @var{throw}: true when the branch is an exceptional branch
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
340 @end itemize
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
341
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
342 @item -j
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
343 @itemx --human-readable
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
344 Write counts in human readable format (like 24.6k).
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
345
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
346 @item -k
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
347 @itemx --use-colors
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
348
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
349 Use colors for lines of code that have zero coverage. We use red color for
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
350 non-exceptional lines and cyan for exceptional. Same colors are used for
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
351 basic blocks with @option{-a} option.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
352
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 @item -l
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 @itemx --long-file-names
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 Create long file names for included source files. For example, if the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 header file @file{x.h} contains code, and was included in the file
111
kono
parents: 67
diff changeset
357 @file{a.c}, then running @command{gcov} on the file @file{a.c} will
kono
parents: 67
diff changeset
358 produce an output file called @file{a.c##x.h.gcov} instead of
kono
parents: 67
diff changeset
359 @file{x.h.gcov}. This can be useful if @file{x.h} is included in
kono
parents: 67
diff changeset
360 multiple source files and you want to see the individual
kono
parents: 67
diff changeset
361 contributions. If you use the @samp{-p} option, both the including
kono
parents: 67
diff changeset
362 and included file names will be complete path names.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
363
111
kono
parents: 67
diff changeset
364 @item -m
kono
parents: 67
diff changeset
365 @itemx --demangled-names
kono
parents: 67
diff changeset
366 Display demangled function names in output. The default is to show
kono
parents: 67
diff changeset
367 mangled function names.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368
111
kono
parents: 67
diff changeset
369 @item -n
kono
parents: 67
diff changeset
370 @itemx --no-output
kono
parents: 67
diff changeset
371 Do not create the @command{gcov} output file.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
372
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 @item -o @var{directory|file}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 @itemx --object-directory @var{directory}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 @itemx --object-file @var{file}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 Specify either the directory containing the gcov data files, or the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 object path name. The @file{.gcno}, and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 @file{.gcda} data files are searched for using this option. If a directory
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 is specified, the data files are in that directory and named after the
111
kono
parents: 67
diff changeset
380 input file name, without its extension. If a file is specified here,
kono
parents: 67
diff changeset
381 the data files are named after that file, without its extension.
kono
parents: 67
diff changeset
382
kono
parents: 67
diff changeset
383 @item -p
kono
parents: 67
diff changeset
384 @itemx --preserve-paths
kono
parents: 67
diff changeset
385 Preserve complete path information in the names of generated
kono
parents: 67
diff changeset
386 @file{.gcov} files. Without this option, just the filename component is
kono
parents: 67
diff changeset
387 used. With this option, all directories are used, with @samp{/} characters
kono
parents: 67
diff changeset
388 translated to @samp{#} characters, @file{.} directory components
kono
parents: 67
diff changeset
389 removed and unremoveable @file{..}
kono
parents: 67
diff changeset
390 components renamed to @samp{^}. This is useful if sourcefiles are in several
kono
parents: 67
diff changeset
391 different directories.
kono
parents: 67
diff changeset
392
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
393 @item -q
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
394 @itemx --use-hotness-colors
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
395
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
396 Emit perf-like colored output for hot lines. Legend of the color scale
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
397 is printed at the very beginning of the output file.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
398
111
kono
parents: 67
diff changeset
399 @item -r
kono
parents: 67
diff changeset
400 @itemx --relative-only
kono
parents: 67
diff changeset
401 Only output information about source files with a relative pathname
kono
parents: 67
diff changeset
402 (after source prefix elision). Absolute paths are usually system
kono
parents: 67
diff changeset
403 header files and coverage of any inline functions therein is normally
kono
parents: 67
diff changeset
404 uninteresting.
kono
parents: 67
diff changeset
405
kono
parents: 67
diff changeset
406 @item -s @var{directory}
kono
parents: 67
diff changeset
407 @itemx --source-prefix @var{directory}
kono
parents: 67
diff changeset
408 A prefix for source file names to remove when generating the output
kono
parents: 67
diff changeset
409 coverage files. This option is useful when building in a separate
kono
parents: 67
diff changeset
410 directory, and the pathname to the source directory is not wanted when
kono
parents: 67
diff changeset
411 determining the output file names. Note that this prefix detection is
kono
parents: 67
diff changeset
412 applied before determining whether the source file is absolute.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
414 @item -t
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
415 @itemx --stdout
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
416 Output to standard output instead of output files.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
417
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 @item -u
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 @itemx --unconditional-branches
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 When branch probabilities are given, include those of unconditional branches.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 Unconditional branches are normally not interesting.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
422
111
kono
parents: 67
diff changeset
423 @item -v
kono
parents: 67
diff changeset
424 @itemx --version
kono
parents: 67
diff changeset
425 Display the @command{gcov} version number (on the standard output),
kono
parents: 67
diff changeset
426 and exit without doing any further processing.
kono
parents: 67
diff changeset
427
kono
parents: 67
diff changeset
428 @item -w
kono
parents: 67
diff changeset
429 @itemx --verbose
kono
parents: 67
diff changeset
430 Print verbose informations related to basic blocks and arcs.
kono
parents: 67
diff changeset
431
kono
parents: 67
diff changeset
432 @item -x
kono
parents: 67
diff changeset
433 @itemx --hash-filenames
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
434 When using @var{--preserve-paths},
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
435 gcov uses the full pathname of the source files to create
111
kono
parents: 67
diff changeset
436 an output filename. This can lead to long filenames that can overflow
kono
parents: 67
diff changeset
437 filesystem limits. This option creates names of the form
kono
parents: 67
diff changeset
438 @file{@var{source-file}##@var{md5}.gcov},
kono
parents: 67
diff changeset
439 where the @var{source-file} component is the final filename part and
kono
parents: 67
diff changeset
440 the @var{md5} component is calculated from the full mangled name that
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
441 would have been used otherwise. The option is an alternative
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
442 to the @var{--preserve-paths} on systems which have a filesystem limit.
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
443
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 @end table
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
445
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
446 @command{gcov} should be run with the current directory the same as that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
447 when you invoked the compiler. Otherwise it will not be able to locate
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 the source files. @command{gcov} produces files called
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
449 @file{@var{mangledname}.gcov} in the current directory. These contain
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
450 the coverage information of the source file they correspond to.
111
kono
parents: 67
diff changeset
451 One @file{.gcov} file is produced for each source (or header) file
kono
parents: 67
diff changeset
452 containing code,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
453 which was compiled to produce the data files. The @var{mangledname} part
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
454 of the output file name is usually simply the source file name, but can
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
455 be something more complicated if the @samp{-l} or @samp{-p} options are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 given. Refer to those options for details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
457
111
kono
parents: 67
diff changeset
458 If you invoke @command{gcov} with multiple input files, the
kono
parents: 67
diff changeset
459 contributions from each input file are summed. Typically you would
kono
parents: 67
diff changeset
460 invoke it with the same list of files as the final link of your executable.
kono
parents: 67
diff changeset
461
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 The @file{.gcov} files contain the @samp{:} separated fields along with
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
463 program source code. The format is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
464
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
465 @smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 @var{execution_count}:@var{line_number}:@var{source line text}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
467 @end smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
468
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 Additional block information may succeed each line, when requested by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 command line option. The @var{execution_count} is @samp{-} for lines
111
kono
parents: 67
diff changeset
471 containing no code. Unexecuted lines are marked @samp{#####} or
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
472 @samp{=====}, depending on whether they are reachable by
111
kono
parents: 67
diff changeset
473 non-exceptional paths or only exceptional paths such as C++ exception
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
474 handlers, respectively. Given the @samp{-a} option, unexecuted blocks are
111
kono
parents: 67
diff changeset
475 marked @samp{$$$$$} or @samp{%%%%%}, depending on whether a basic block
kono
parents: 67
diff changeset
476 is reachable via non-exceptional or exceptional paths.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
477 Executed basic blocks having a statement with zero @var{execution_count}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
478 end with @samp{*} character and are colored with magenta color with
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
479 the @option{-k} option. This functionality is not supported in Ada.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
480
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
481 Note that GCC can completely remove the bodies of functions that are
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
482 not needed -- for instance if they are inlined everywhere. Such functions
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
483 are marked with @samp{-}, which can be confusing.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
484 Use the @option{-fkeep-inline-functions} and @option{-fkeep-static-functions}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
485 options to retain these functions and
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
486 allow gcov to properly show their @var{execution_count}.
111
kono
parents: 67
diff changeset
487
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 Some lines of information at the start have @var{line_number} of zero.
111
kono
parents: 67
diff changeset
489 These preamble lines are of the form
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
490
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 @smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 -:0:@var{tag}:@var{value}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 @end smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
494
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 The ordering and number of these preamble lines will be augmented as
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 @command{gcov} development progresses --- do not rely on them remaining
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 unchanged. Use @var{tag} to locate a particular preamble line.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 The additional block information is of the form
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 @smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 @var{tag} @var{information}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 @end smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
504
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 The @var{information} is human readable, but designed to be simple
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 enough for machine parsing too.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
507
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 When printing percentages, 0% and 100% are only printed when the values
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 are @emph{exactly} 0% and 100% respectively. Other values which would
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 conventionally be rounded to 0% or 100% are instead printed as the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511 nearest non-boundary value.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
513 When using @command{gcov}, you must first compile your program
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
514 with a special GCC option @samp{--coverage}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 This tells the compiler to generate additional information needed by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 gcov (basically a flow graph of the program) and also includes
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 additional code in the object files for generating the extra profiling
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 information needed by gcov. These additional files are placed in the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 directory where the object file is located.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 Running the program will cause profile output to be generated. For each
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
522 source file compiled with @option{-fprofile-arcs}, an accompanying
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 @file{.gcda} file will be placed in the object file directory.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
524
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
525 Running @command{gcov} with your program's source file names as arguments
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
526 will now produce a listing of the code along with frequency of execution
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
527 for each line. For example, if your program is called @file{tmp.cpp}, this
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
528 is what you see when you use the basic @command{gcov} facility:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
529
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 @smallexample
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
531 $ g++ --coverage tmp.cpp
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 $ a.out
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
533 $ gcov tmp.cpp -m
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
534 File 'tmp.cpp'
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
535 Lines executed:92.86% of 14
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
536 Creating 'tmp.cpp.gcov'
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 @end smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
538
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
539 The file @file{tmp.cpp.gcov} contains output from @command{gcov}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 Here is a sample:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
541
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
542 @smallexample
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
543 -: 0:Source:tmp.cpp
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
544 -: 0:Working directory:/home/gcc/testcase
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 -: 0:Graph:tmp.gcno
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 -: 0:Data:tmp.gcda
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 -: 0:Runs:1
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 -: 0:Programs:1
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 -: 1:#include <stdio.h>
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
550 -: 2:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
551 -: 3:template<class T>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
552 -: 4:class Foo
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
553 -: 5:@{
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
554 -: 6: public:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
555 1*: 7: Foo(): b (1000) @{@}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
556 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
557 Foo<char>::Foo():
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
558 #####: 7: Foo(): b (1000) @{@}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
559 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
560 Foo<int>::Foo():
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
561 1: 7: Foo(): b (1000) @{@}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
562 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
563 2*: 8: void inc () @{ b++; @}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
564 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
565 Foo<char>::inc():
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
566 #####: 8: void inc () @{ b++; @}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
567 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
568 Foo<int>::inc():
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
569 2: 8: void inc () @{ b++; @}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
570 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
571 -: 9:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
572 -: 10: private:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
573 -: 11: int b;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
574 -: 12:@};
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
575 -: 13:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
576 -: 14:template class Foo<int>;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
577 -: 15:template class Foo<char>;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
578 -: 16:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
579 -: 17:int
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
580 1: 18:main (void)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
581 -: 19:@{
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
582 -: 20: int i, total;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
583 1: 21: Foo<int> counter;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
584 -: 22:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
585 1: 23: counter.inc();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
586 1: 24: counter.inc();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
587 1: 25: total = 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
588 -: 26:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
589 11: 27: for (i = 0; i < 10; i++)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
590 10: 28: total += i;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
591 -: 29:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
592 1*: 30: int v = total > 100 ? 1 : 2;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
593 -: 31:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
594 1: 32: if (total != 45)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
595 #####: 33: printf ("Failure\n");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
596 -: 34: else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
597 1: 35: printf ("Success\n");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
598 1: 36: return 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
599 -: 37:@}
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 @end smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
601
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
602 Note that line 7 is shown in the report multiple times. First occurrence
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
603 presents total number of execution of the line and the next two belong
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
604 to instances of class Foo constructors. As you can also see, line 30 contains
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
605 some unexecuted basic blocks and thus execution count has asterisk symbol.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
606
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
607 When you use the @option{-a} option, you will get individual block
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
608 counts, and the output looks like this:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
609
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
610 @smallexample
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
611 -: 0:Source:tmp.cpp
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
612 -: 0:Working directory:/home/gcc/testcase
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 -: 0:Graph:tmp.gcno
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
614 -: 0:Data:tmp.gcda
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 -: 0:Runs:1
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 -: 0:Programs:1
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
617 -: 1:#include <stdio.h>
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
618 -: 2:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
619 -: 3:template<class T>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
620 -: 4:class Foo
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
621 -: 5:@{
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
622 -: 6: public:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
623 1*: 7: Foo(): b (1000) @{@}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
624 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
625 Foo<char>::Foo():
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
626 #####: 7: Foo(): b (1000) @{@}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
627 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
628 Foo<int>::Foo():
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
629 1: 7: Foo(): b (1000) @{@}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
630 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
631 2*: 8: void inc () @{ b++; @}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
632 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
633 Foo<char>::inc():
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
634 #####: 8: void inc () @{ b++; @}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
635 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
636 Foo<int>::inc():
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
637 2: 8: void inc () @{ b++; @}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
638 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
639 -: 9:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
640 -: 10: private:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
641 -: 11: int b;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
642 -: 12:@};
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
643 -: 13:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
644 -: 14:template class Foo<int>;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
645 -: 15:template class Foo<char>;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
646 -: 16:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
647 -: 17:int
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
648 1: 18:main (void)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
649 -: 19:@{
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
650 -: 20: int i, total;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
651 1: 21: Foo<int> counter;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
652 1: 21-block 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
653 -: 22:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
654 1: 23: counter.inc();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
655 1: 23-block 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
656 1: 24: counter.inc();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
657 1: 24-block 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
658 1: 25: total = 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
659 -: 26:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
660 11: 27: for (i = 0; i < 10; i++)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
661 1: 27-block 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
662 11: 27-block 1
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
663 10: 28: total += i;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
664 10: 28-block 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
665 -: 29:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
666 1*: 30: int v = total > 100 ? 1 : 2;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
667 1: 30-block 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
668 %%%%%: 30-block 1
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
669 1: 30-block 2
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
670 -: 31:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
671 1: 32: if (total != 45)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
672 1: 32-block 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
673 #####: 33: printf ("Failure\n");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
674 %%%%%: 33-block 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
675 -: 34: else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
676 1: 35: printf ("Success\n");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
677 1: 35-block 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
678 1: 36: return 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
679 1: 36-block 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
680 -: 37:@}
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 @end smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
682
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
683 In this mode, each basic block is only shown on one line -- the last
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
684 line of the block. A multi-line block will only contribute to the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
685 execution count of that last line, and other lines will not be shown
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
686 to contain code, unless previous blocks end on those lines.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
687 The total execution count of a line is shown and subsequent lines show
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 the execution counts for individual blocks that end on that line. After each
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
689 block, the branch and call counts of the block will be shown, if the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
690 @option{-b} option is given.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
691
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
692 Because of the way GCC instruments calls, a call count can be shown
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
693 after a line with no individual blocks.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
694 As you can see, line 33 contains a basic block that was not executed.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
695
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
696 @need 450
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
697 When you use the @option{-b} option, your output looks like this:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
698
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
699 @smallexample
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
700 -: 0:Source:tmp.cpp
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
701 -: 0:Working directory:/home/gcc/testcase
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
702 -: 0:Graph:tmp.gcno
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 -: 0:Data:tmp.gcda
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 -: 0:Runs:1
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 -: 0:Programs:1
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
706 -: 1:#include <stdio.h>
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 -: 2:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
708 -: 3:template<class T>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
709 -: 4:class Foo
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
710 -: 5:@{
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
711 -: 6: public:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
712 1*: 7: Foo(): b (1000) @{@}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
713 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
714 Foo<char>::Foo():
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
715 function Foo<char>::Foo() called 0 returned 0% blocks executed 0%
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
716 #####: 7: Foo(): b (1000) @{@}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
717 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
718 Foo<int>::Foo():
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
719 function Foo<int>::Foo() called 1 returned 100% blocks executed 100%
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
720 1: 7: Foo(): b (1000) @{@}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
721 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
722 2*: 8: void inc () @{ b++; @}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
723 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
724 Foo<char>::inc():
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
725 function Foo<char>::inc() called 0 returned 0% blocks executed 0%
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
726 #####: 8: void inc () @{ b++; @}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
727 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
728 Foo<int>::inc():
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
729 function Foo<int>::inc() called 2 returned 100% blocks executed 100%
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
730 2: 8: void inc () @{ b++; @}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
731 ------------------
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
732 -: 9:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
733 -: 10: private:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
734 -: 11: int b;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
735 -: 12:@};
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
736 -: 13:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
737 -: 14:template class Foo<int>;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
738 -: 15:template class Foo<char>;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
739 -: 16:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
740 -: 17:int
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
741 function main called 1 returned 100% blocks executed 81%
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
742 1: 18:main (void)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
743 -: 19:@{
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
744 -: 20: int i, total;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
745 1: 21: Foo<int> counter;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
746 call 0 returned 100%
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
747 branch 1 taken 100% (fallthrough)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
748 branch 2 taken 0% (throw)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
749 -: 22:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
750 1: 23: counter.inc();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
751 call 0 returned 100%
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
752 branch 1 taken 100% (fallthrough)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
753 branch 2 taken 0% (throw)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
754 1: 24: counter.inc();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
755 call 0 returned 100%
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
756 branch 1 taken 100% (fallthrough)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
757 branch 2 taken 0% (throw)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
758 1: 25: total = 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
759 -: 26:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
760 11: 27: for (i = 0; i < 10; i++)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 branch 0 taken 91% (fallthrough)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
762 branch 1 taken 9%
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
763 10: 28: total += i;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
764 -: 29:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
765 1*: 30: int v = total > 100 ? 1 : 2;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
766 branch 0 taken 0% (fallthrough)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
767 branch 1 taken 100%
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
768 -: 31:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
769 1: 32: if (total != 45)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
770 branch 0 taken 0% (fallthrough)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 branch 1 taken 100%
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
772 #####: 33: printf ("Failure\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
773 call 0 never executed
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
774 branch 1 never executed
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
775 branch 2 never executed
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
776 -: 34: else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
777 1: 35: printf ("Success\n");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
778 call 0 returned 100%
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
779 branch 1 taken 100% (fallthrough)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
780 branch 2 taken 0% (throw)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
781 1: 36: return 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
782 -: 37:@}
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
783 @end smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
784
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
785 For each function, a line is printed showing how many times the function
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
786 is called, how many times it returns and what percentage of the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
787 function's blocks were executed.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
788
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
789 For each basic block, a line is printed after the last line of the basic
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
790 block describing the branch or call that ends the basic block. There can
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
791 be multiple branches and calls listed for a single source line if there
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
792 are multiple basic blocks that end on that line. In this case, the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
793 branches and calls are each given a number. There is no simple way to map
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
794 these branches and calls back to source constructs. In general, though,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
795 the lowest numbered branch or call will correspond to the leftmost construct
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
796 on the source line.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
797
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
798 For a branch, if it was executed at least once, then a percentage
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
799 indicating the number of times the branch was taken divided by the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
800 number of times the branch was executed will be printed. Otherwise, the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
801 message ``never executed'' is printed.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
802
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
803 For a call, if it was executed at least once, then a percentage
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
804 indicating the number of times the call returned divided by the number
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
805 of times the call was executed will be printed. This will usually be
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
806 100%, but may be less for functions that call @code{exit} or @code{longjmp},
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
807 and thus may not return every time they are called.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
808
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
809 The execution counts are cumulative. If the example program were
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
810 executed again without removing the @file{.gcda} file, the count for the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
811 number of times each line in the source was executed would be added to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
812 the results of the previous run(s). This is potentially useful in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
813 several ways. For example, it could be used to accumulate data over a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
814 number of program runs as part of a test verification suite, or to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
815 provide more accurate long-term information over a large number of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
816 program runs.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
817
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
818 The data in the @file{.gcda} files is saved immediately before the program
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
819 exits. For each source file compiled with @option{-fprofile-arcs}, the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
820 profiling code first attempts to read in an existing @file{.gcda} file; if
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
821 the file doesn't match the executable (differing number of basic block
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
822 counts) it will ignore the contents of the file. It then adds in the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
823 new execution counts and finally writes the data to the file.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
824
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
825 @node Gcov and Optimization
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
826 @section Using @command{gcov} with GCC Optimization
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
827
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
828 If you plan to use @command{gcov} to help optimize your code, you must
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
829 first compile your program with a special GCC option
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
830 @samp{--coverage}. Aside from that, you can use any
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
831 other GCC options; but if you want to prove that every single line
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
832 in your program was executed, you should not compile with optimization
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
833 at the same time. On some machines the optimizer can eliminate some
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
834 simple code lines by combining them with other lines. For example, code
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
835 like this:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
836
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
837 @smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
838 if (a != b)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
839 c = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
840 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
841 c = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
842 @end smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
843
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
844 @noindent
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
845 can be compiled into one instruction on some machines. In this case,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
846 there is no way for @command{gcov} to calculate separate execution counts
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
847 for each line because there isn't separate code for each line. Hence
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
848 the @command{gcov} output looks like this if you compiled the program with
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
849 optimization:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
850
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
851 @smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
852 100: 12:if (a != b)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
853 100: 13: c = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
854 100: 14:else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 100: 15: c = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 @end smallexample
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
857
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
858 The output shows that this block of code, combined by optimization,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 executed 100 times. In one sense this result is correct, because there
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
860 was only one instruction representing all four of these lines. However,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
861 the output does not indicate how many times the result was 0 and how
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
862 many times the result was 1.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
863
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
864 Inlineable functions can create unexpected line counts. Line counts are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
865 shown for the source code of the inlineable function, but what is shown
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 depends on where the function is inlined, or if it is not inlined at all.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
867
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
868 If the function is not inlined, the compiler must emit an out of line
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
869 copy of the function, in any object file that needs it. If
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
870 @file{fileA.o} and @file{fileB.o} both contain out of line bodies of a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
871 particular inlineable function, they will also both contain coverage
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
872 counts for that function. When @file{fileA.o} and @file{fileB.o} are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
873 linked together, the linker will, on many systems, select one of those
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
874 out of line bodies for all calls to that function, and remove or ignore
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
875 the other. Unfortunately, it will not remove the coverage counters for
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
876 the unused function body. Hence when instrumented, all but one use of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
877 that function will show zero counts.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
878
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
879 If the function is inlined in several places, the block structure in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
880 each location might not be the same. For instance, a condition might
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
881 now be calculable at compile time in some instances. Because the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
882 coverage of all the uses of the inline function will be shown for the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
883 same source lines, the line counts themselves might seem inconsistent.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
884
111
kono
parents: 67
diff changeset
885 Long-running applications can use the @code{__gcov_reset} and @code{__gcov_dump}
kono
parents: 67
diff changeset
886 facilities to restrict profile collection to the program region of
kono
parents: 67
diff changeset
887 interest. Calling @code{__gcov_reset(void)} will clear all profile counters
kono
parents: 67
diff changeset
888 to zero, and calling @code{__gcov_dump(void)} will cause the profile information
kono
parents: 67
diff changeset
889 collected at that point to be dumped to @file{.gcda} output files.
kono
parents: 67
diff changeset
890 Instrumented applications use a static destructor with priority 99
kono
parents: 67
diff changeset
891 to invoke the @code{__gcov_dump} function. Thus @code{__gcov_dump}
kono
parents: 67
diff changeset
892 is executed after all user defined static destructors,
kono
parents: 67
diff changeset
893 as well as handlers registered with @code{atexit}.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
894 If an executable loads a dynamic shared object via dlopen functionality,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
895 @option{-Wl,--dynamic-list-data} is needed to dump all profile data.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
896
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
897 Profiling run-time library reports various errors related to profile
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
898 manipulation and profile saving. Errors are printed into standard error output
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
899 or @samp{GCOV_ERROR_FILE} file, if environment variable is used.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
900 In order to terminate immediately after an errors occurs
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
901 set @samp{GCOV_EXIT_AT_ERROR} environment variable.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
902 That can help users to find profile clashing which leads
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
903 to a misleading profile.
111
kono
parents: 67
diff changeset
904
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
905 @c man end
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
906
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
907 @node Gcov Data Files
111
kono
parents: 67
diff changeset
908 @section Brief Description of @command{gcov} Data Files
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
909
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
910 @command{gcov} uses two files for profiling. The names of these files
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
911 are derived from the original @emph{object} file by substituting the
111
kono
parents: 67
diff changeset
912 file suffix with either @file{.gcno}, or @file{.gcda}. The files
kono
parents: 67
diff changeset
913 contain coverage and profile data stored in a platform-independent format.
kono
parents: 67
diff changeset
914 The @file{.gcno} files are placed in the same directory as the object
kono
parents: 67
diff changeset
915 file. By default, the @file{.gcda} files are also stored in the same
kono
parents: 67
diff changeset
916 directory as the object file, but the GCC @option{-fprofile-dir} option
kono
parents: 67
diff changeset
917 may be used to store the @file{.gcda} files in a separate directory.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
918
111
kono
parents: 67
diff changeset
919 The @file{.gcno} notes file is generated when the source file is compiled
kono
parents: 67
diff changeset
920 with the GCC @option{-ftest-coverage} option. It contains information to
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
921 reconstruct the basic block graphs and assign source line numbers to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
922 blocks.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
923
111
kono
parents: 67
diff changeset
924 The @file{.gcda} count data file is generated when a program containing
kono
parents: 67
diff changeset
925 object files built with the GCC @option{-fprofile-arcs} option is executed.
kono
parents: 67
diff changeset
926 A separate @file{.gcda} file is created for each object file compiled with
kono
parents: 67
diff changeset
927 this option. It contains arc transition counts, value profile counts, and
kono
parents: 67
diff changeset
928 some summary information.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
929
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
930 It is not recommended to access the coverage files directly.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
931 Consumers should use the intermediate format that is provided
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
932 by @command{gcov} tool via @option{--json-format} option.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
933
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
934 @node Cross-profiling
111
kono
parents: 67
diff changeset
935 @section Data File Relocation to Support Cross-Profiling
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
936
111
kono
parents: 67
diff changeset
937 Running the program will cause profile output to be generated. For each
kono
parents: 67
diff changeset
938 source file compiled with @option{-fprofile-arcs}, an accompanying @file{.gcda}
kono
parents: 67
diff changeset
939 file will be placed in the object file directory. That implicitly requires
kono
parents: 67
diff changeset
940 running the program on the same system as it was built or having the same
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
941 absolute directory structure on the target system. The program will try
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
942 to create the needed directory structure, if it is not already present.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
943
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
944 To support cross-profiling, a program compiled with @option{-fprofile-arcs}
111
kono
parents: 67
diff changeset
945 can relocate the data files based on two environment variables:
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
946
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
947 @itemize @bullet
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
948 @item
111
kono
parents: 67
diff changeset
949 GCOV_PREFIX contains the prefix to add to the absolute paths
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
950 in the object file. Prefix can be absolute, or relative. The
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
951 default is no prefix.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
952
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
953 @item
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
954 GCOV_PREFIX_STRIP indicates the how many initial directory names to strip off
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
955 the hardwired absolute paths. Default value is 0.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
956
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
957 @emph{Note:} If GCOV_PREFIX_STRIP is set without GCOV_PREFIX is undefined,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
958 then a relative path is made out of the hardwired absolute paths.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
959 @end itemize
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
960
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
961 For example, if the object file @file{/user/build/foo.o} was built with
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
962 @option{-fprofile-arcs}, the final executable will try to create the data file
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
963 @file{/user/build/foo.gcda} when running on the target system. This will
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
964 fail if the corresponding directory does not exist and it is unable to create
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
965 it. This can be overcome by, for example, setting the environment as
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
966 @samp{GCOV_PREFIX=/target/run} and @samp{GCOV_PREFIX_STRIP=1}. Such a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
967 setting will name the data file @file{/target/run/build/foo.gcda}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
968
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
969 You must move the data files to the expected directory tree in order to
111
kono
parents: 67
diff changeset
970 use them for profile directed optimizations (@option{-fprofile-use}), or to
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
971 use the @command{gcov} tool.