]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/gprof/gprof.1
This commit was generated by cvs2svn to compensate for changes in r47558,
[FreeBSD/FreeBSD.git] / usr.bin / gprof / gprof.1
1 .\" Copyright (c) 1983, 1990, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)gprof.1     8.1 (Berkeley) 6/6/93
33 .\"
34 .Dd June 6, 1993
35 .Dt GPROF 1
36 .Os BSD 4.2
37 .Sh NAME
38 .Nm gprof
39 .Nd display call graph profile data
40 .Sh SYNOPSIS
41 .Nm gprof
42 .Op options
43 .Op Ar a.out Op Ar a.out.gmon ...
44 .Sh DESCRIPTION
45 .Nm Gprof
46 produces an execution profile of C, Pascal, or Fortran77 programs.
47 The effect of called routines is incorporated in the profile of each caller.
48 The profile data is taken from the call graph profile file
49 which is created by programs that are compiled with the
50 .Fl pg
51 option of
52 .Xr cc 1 ,
53 .Xr pc 1 ,
54 and
55 .Xr f77 1 .
56 The
57 .Fl pg
58 option also links in versions of the library routines
59 that are compiled for profiling.
60 .Nm Gprof
61 reads the given object file (the default is
62 .Pa a.out)
63 and establishes the relation between it's symbol table
64 and the call graph profile. The default graph profile file name is the name
65 of the executable with the suffix
66 .Pa .gmon 
67 appended.
68 If more than one profile file is specified,
69 the
70 .Nm gprof
71 output shows the sum of the profile information in the given profile files.
72 .Pp
73 .Nm Gprof
74 calculates the amount of time spent in each routine.
75 Next, these times are propagated along the edges of the call graph.
76 Cycles are discovered, and calls into a cycle are made to share the time
77 of the cycle.
78 The first listing shows the functions
79 sorted according to the time they represent
80 including the time of their call graph descendents.
81 Below each function entry is shown its (direct) call graph children,
82 and how their times are propagated to this function.
83 A similar display above the function shows how this function's time and the
84 time of its descendents is propagated to its (direct) call graph parents.
85 .Pp
86 Cycles are also shown, with an entry for the cycle as a whole and
87 a listing of the members of the cycle and their contributions to the
88 time and call counts of the cycle.
89 .Pp
90 Second, a flat profile is given,
91 similar to that provided by
92 .Xr prof  1  .
93 This listing gives the total execution times, the call counts,
94 the time in msec or usec the call spent in the routine itself, and
95 the time in msec or usec the call spent in the routine itself including
96 its descendents.
97 .Pp
98 Finally, an index of the function names is provided.
99 .Pp
100 The following options are available:
101 .Bl -tag -width Fl
102 .It Fl a
103 Suppresses the printing of statically declared functions.
104 If this option is given, all relevant information about the static function
105 (e.g., time samples, calls to other functions, calls from other functions)
106 belongs to the function loaded just before the static function in the
107 .Pa a.out
108 file.
109 .It Fl b
110 Suppresses the printing of a description of each field in the profile.
111 .It Fl c
112 The static call graph of the program is discovered by a heuristic
113 that examines the text space of the object file.
114 Static-only parents or children are shown
115 with call counts of 0.
116 This option is not supported on some architectures.
117 .It Fl C Ar count
118 Find a minimal set of arcs that can be broken to eliminate all cycles with
119 .Ar count
120 or more members.
121 Caution: the algorithm used to break cycles is exponential,
122 so using this option may cause 
123 .Nm gprof
124 to run for a very long time.
125 .It Fl e Ar name 
126 Suppresses the printing of the graph profile entry for routine
127 .Ar name
128 and all its descendants
129 (unless they have other ancestors that aren't suppressed).
130 More than one
131 .Fl e
132 option may be given.
133 Only one
134 .Ar name
135 may be given with each
136 .Fl e
137 option.
138 .It Fl E Ar name 
139 Suppresses the printing of the graph profile entry for routine
140 .Ar name
141 (and its descendants) as
142 .Fl e  ,
143 above, and also excludes the time spent in
144 .Ar name
145 (and its descendants) from the total and percentage time computations.
146 (For example,
147 .Fl E
148 .Ar mcount
149 .Fl E
150 .Ar mcleanup
151 is the default.)
152 .It Fl f Ar name 
153 Prints the graph profile entry of only the specified routine
154 .Ar name
155 and its descendants.
156 More than one
157 .Fl f
158 option may be given.
159 Only one
160 .Ar name
161 may be given with each
162 .Fl f
163 option.
164 .It Fl F Ar name 
165 Prints the graph profile entry of only the routine
166 .Ar name
167 and its descendants (as
168 .Fl f ,
169 above) and also uses only the times of the printed routines
170 in total time and percentage computations.
171 More than one
172 .Fl F
173 option may be given.
174 Only one
175 .Ar name
176 may be given with each
177 .Fl F
178 option.
179 The
180 .Fl F
181 option
182 overrides
183 the
184 .Fl E
185 option.
186 .It Fl k Ar fromname Ar toname 
187 Will delete any arcs from routine
188 .Ar fromname
189 to routine
190 .Ar toname .
191 This can be used to break undesired cycles.
192 More than one
193 .Fl k
194 option may be given.
195 Only one pair of routine names may be given with each
196 .Fl k
197 option.
198 .It Fl l
199 Suppresses the printing of the call-graph profile.
200 .It Fl L
201 Suppresses the printing of the flat profile.
202 .It Fl s
203 A profile file
204 .Pa gmon.sum
205 is produced that represents
206 the sum of the profile information in all the specified profile files.
207 This summary profile file may be given to later
208 executions of gprof (probably also with a
209 .Fl s )
210 to accumulate profile data across several runs of an
211 .Pa a.out
212 file.
213 .It Fl u
214 Suppresses the printing of functions whose names are not visible to
215 C programs.  For the ELF object format, this means names that
216 contain the
217 .Ql \&.
218 character.  For the a.out object format, it means names that do not
219 begin with a
220 .Ql _
221 character.
222 All relevant information about such functions belongs to the
223 (non-suppressed) function with the next lowest address.
224 This is useful for eliminating "functions" that are just labels
225 inside other functions.
226 .It Fl z
227 Displays routines that have zero usage (as shown by call counts
228 and accumulated time).
229 This is useful with the
230 .Fl c
231 option for discovering which routines were never called.
232 .El
233 .Sh FILES
234 .Bl -tag -width a.out.gmon -compact
235 .It Pa a.out
236 The namelist and text space.
237 .It Pa a.out.gmon
238 Dynamic call graph and profile.
239 .It Pa gmon.sum
240 Summarized dynamic call graph and profile.
241 .El
242 .Sh SEE ALSO
243 .Xr cc 1 ,
244 .Xr profil 2 ,
245 .Xr clocks 7
246 .\" .Xr monitor 3 ,
247 .\" .Xr prof 1
248 .Rs
249 .%T "An Execution Profiler for Modular Programs"
250 .%A S. Graham
251 .%A P. Kessler
252 .%A M. McKusick
253 .%J "Software - Practice and Experience"
254 .%V 13
255 .%P pp. 671-685
256 .%D 1983
257 .Re
258 .Rs
259 .%T "gprof: A Call Graph Execution Profiler"
260 .%A S. Graham
261 .%A P. Kessler
262 .%A M. McKusick
263 .%J "Proceedings of the SIGPLAN '82 Symposium on Compiler Construction, SIGPLAN Notices"
264 .%V 17
265 .%N 6
266 .%P pp. 120-126
267 .%D June 1982
268 .Re
269 .Sh HISTORY
270 The
271 .Nm gprof
272 profiler
273 appeared in
274 .Bx 4.2 .
275 .Sh BUGS
276 The granularity of the sampling is shown, but remains
277 statistical at best.
278 We assume that the time for each execution of a function
279 can be expressed by the total time for the function divided
280 by the number of times the function is called.
281 Thus the time propagated along the call graph arcs to the function's
282 parents is directly proportional to the number of times that
283 arc is traversed.
284 .Pp
285 Parents that are not themselves profiled will have the time of
286 their profiled children propagated to them, but they will appear
287 to be spontaneously invoked in the call graph listing, and will
288 not have their time propagated further.
289 Similarly, signal catchers, even though profiled, will appear
290 to be spontaneous (although for more obscure reasons).
291 Any profiled children of signal catchers should have their times
292 propagated properly, unless the signal catcher was invoked during
293 the execution of the profiling routine, in which case all is lost.
294 .Pp
295 The profiled program must call
296 .Xr exit  3
297 or return normally for the profiling information to be saved
298 in the graph profile file.