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