1 .\" Copyright (c) 1983, 1990, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
32 .\" @(#)gprof.1 8.1 (Berkeley) 6/6/93
40 .Nd display call graph profile data
49 .Op Fl k Ar fromname toname
50 .Op Ar a.out Op Ar a.out.gmon ...
54 utility produces an execution profile of C, Pascal, or Fortran77 programs.
55 The effect of called routines is incorporated in the profile of each caller.
56 The profile data is taken from the call graph profile file
57 which is created by programs that are compiled with the
66 option also links in versions of the library routines
67 that are compiled for profiling.
68 By convention these libraries have their name suffixed with
70 i.e., the profiled version of
74 and if you specify libraries directly to the
75 compiler or linker you can use
79 Read the given object file (the default is
81 and establishes the relation between its symbol table
82 and the call graph profile.
83 The default graph profile file name is the name
84 of the executable with the suffix
87 If more than one profile file is specified,
90 output shows the sum of the profile information in the given profile files.
94 utility calculates the amount of time spent in each routine.
95 Next, these times are propagated along the edges of the call graph.
96 Cycles are discovered, and calls into a cycle are made to share the time
98 The first listing shows the functions
99 sorted according to the time they represent
100 including the time of their call graph descendants.
101 Below each function entry is shown its (direct) call graph children,
102 and how their times are propagated to this function.
103 A similar display above the function shows how this function's time and the
104 time of its descendants is propagated to its (direct) call graph parents.
106 Cycles are also shown, with an entry for the cycle as a whole and
107 a listing of the members of the cycle and their contributions to the
108 time and call counts of the cycle.
110 Second, a flat profile is given,
111 similar to that provided by
113 This listing gives the total execution times, the call counts,
114 the time that the call spent in the routine itself, and
115 the time that the call spent in the routine itself including
117 The units for the per-call times are normally milliseconds,
118 but they are nanoseconds if the profiling clock frequency
119 is 10 million or larger,
120 and if a function appears to be never called then its total self time
121 is printed as a percentage in the self time per call column.
122 The very high profiling clock frequencies needed to get sufficient
123 accuracy in the per-call times for short-lived programs are only
126 (non-statistical) kernel profiling.
128 Finally, an index of the function names is provided.
130 The following options are available:
131 .Bl -tag -width indent
133 Suppress the printing of statically declared functions.
134 If this option is given, all relevant information about the static function
135 (e.g., time samples, calls to other functions, calls from other functions)
136 belongs to the function loaded just before the static function in the
140 Suppress the printing of a description of each field in the profile.
142 Find a minimal set of arcs that can be broken to eliminate all cycles with
145 Caution: the algorithm used to break cycles is exponential,
146 so using this option may cause
148 to run for a very long time.
150 Suppress the printing of the graph profile entry for routine
152 and all its descendants
153 (unless they have other ancestors that are not suppressed).
159 may be given with each
163 Suppress the printing of the graph profile entry for routine
165 (and its descendants) as
167 above, and also excludes the time spent in
169 (and its descendants) from the total and percentage time computations.
177 Print the graph profile entry of only the specified routine
185 may be given with each
189 Print the graph profile entry of only the routine
191 and its descendants (as
193 above) and also uses only the times of the printed routines
194 in total time and percentage computations.
200 may be given with each
210 .It Fl k Ar fromname Ar toname
211 Will delete any arcs from routine
215 This can be used to break undesired cycles.
219 Only one pair of routine names may be given with each
223 Gather information about symbols from the currently-running kernel using the
230 argument to be ignored, and allows for symbols in
234 Suppress the printing of the call-graph profile.
236 Suppress the printing of the flat profile.
240 is produced that represents
241 the sum of the profile information in all the specified profile files.
242 This summary profile file may be given to later
243 executions of gprof (probably also with a
245 to accumulate profile data across several runs of an
249 Suppress the printing of functions whose names are not visible to
251 For the ELF object format, this means names that
255 For the a.out object format, it means names that do not
259 All relevant information about such functions belongs to the
260 (non-suppressed) function with the next lowest address.
261 This is useful for eliminating "functions" that are just labels
262 inside other functions.
264 Display routines that have zero usage (as shown by call counts
265 and accumulated time).
266 This is useful with the
268 option for discovering which routines were never called.
271 .Bl -tag -width a.out.gmon -compact
273 The namelist and text space.
275 Dynamic call graph and profile.
277 Summarized dynamic call graph and profile.
286 .%T "An Execution Profiler for Modular Programs"
290 .%J "Software - Practice and Experience"
296 .%T "gprof: A Call Graph Execution Profiler"
300 .%J "Proceedings of the SIGPLAN '82 Symposium on Compiler Construction, SIGPLAN Notices"
313 The granularity of the sampling is shown, but remains
315 We assume that the time for each execution of a function
316 can be expressed by the total time for the function divided
317 by the number of times the function is called.
318 Thus the time propagated along the call graph arcs to the function's
319 parents is directly proportional to the number of times that
322 Parents that are not themselves profiled will have the time of
323 their profiled children propagated to them, but they will appear
324 to be spontaneously invoked in the call graph listing, and will
325 not have their time propagated further.
326 Similarly, signal catchers, even though profiled, will appear
327 to be spontaneous (although for more obscure reasons).
328 Any profiled children of signal catchers should have their times
329 propagated properly, unless the signal catcher was invoked during
330 the execution of the profiling routine, in which case all is lost.
332 The profiled program must call
334 or return normally for the profiling information to be saved
335 in the graph profile file.