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. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .Nd display call graph profile data
42 .Op Fl k Ar fromname toname
43 .Op Ar a.out Op Ar a.out.gmon ...
47 utility 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
59 option also links in versions of the library routines
60 that are compiled for profiling.
61 By convention these libraries have their name suffixed with
63 i.e., the profiled version of
67 and if you specify libraries directly to the
68 compiler or linker you can use
72 Read the given object file (the default is
74 and establishes the relation between its symbol table
75 and the call graph profile.
76 The default graph profile file name is the name
77 of the executable with the suffix
80 If more than one profile file is specified,
83 output shows the sum of the profile information in the given profile files.
87 utility calculates the amount of time spent in each routine.
88 Next, these times are propagated along the edges of the call graph.
89 Cycles are discovered, and calls into a cycle are made to share the time
91 The first listing shows the functions
92 sorted according to the time they represent
93 including the time of their call graph descendants.
94 Below each function entry is shown its (direct) call graph children,
95 and how their times are propagated to this function.
96 A similar display above the function shows how this function's time and the
97 time of its descendants is propagated to its (direct) call graph parents.
99 Cycles are also shown, with an entry for the cycle as a whole and
100 a listing of the members of the cycle and their contributions to the
101 time and call counts of the cycle.
103 Second, a flat profile is given,
104 similar to that provided by
106 This listing gives the total execution times, the call counts,
107 the time that the call spent in the routine itself, and
108 the time that the call spent in the routine itself including
110 The units for the per-call times are normally milliseconds,
111 but they are nanoseconds if the profiling clock frequency
112 is 10 million or larger,
113 and if a function appears to be never called then its total self time
114 is printed as a percentage in the self time per call column.
115 The very high profiling clock frequencies needed to get sufficient
116 accuracy in the per-call times for short-lived programs are only
119 (non-statistical) kernel profiling.
121 Finally, an index of the function names is provided.
123 The following options are available:
124 .Bl -tag -width indent
126 Suppress the printing of statically declared functions.
127 If this option is given, all relevant information about the static function
128 (e.g., time samples, calls to other functions, calls from other functions)
129 belongs to the function loaded just before the static function in the
133 Suppress the printing of a description of each field in the profile.
135 Find a minimal set of arcs that can be broken to eliminate all cycles with
138 Caution: the algorithm used to break cycles is exponential,
139 so using this option may cause
141 to run for a very long time.
143 Suppress the printing of the graph profile entry for routine
145 and all its descendants
146 (unless they have other ancestors that are not suppressed).
152 may be given with each
156 Suppress the printing of the graph profile entry for routine
158 (and its descendants) as
160 above, and also excludes the time spent in
162 (and its descendants) from the total and percentage time computations.
170 Print the graph profile entry of only the specified routine
178 may be given with each
182 Print the graph profile entry of only the routine
184 and its descendants (as
186 above) and also uses only the times of the printed routines
187 in total time and percentage computations.
193 may be given with each
203 .It Fl k Ar fromname Ar toname
204 Will delete any arcs from routine
208 This can be used to break undesired cycles.
212 Only one pair of routine names may be given with each
216 Gather information about symbols from the currently-running kernel using the
223 argument to be ignored, and allows for symbols in
227 Suppress the printing of the call-graph profile.
229 Suppress the printing of the flat profile.
233 is produced that represents
234 the sum of the profile information in all the specified profile files.
235 This summary profile file may be given to later
236 executions of gprof (probably also with a
238 to accumulate profile data across several runs of an
242 Suppress the printing of functions whose names are not visible to
244 For the ELF object format, this means names that
248 For the a.out object format, it means names that do not
252 All relevant information about such functions belongs to the
253 (non-suppressed) function with the next lowest address.
254 This is useful for eliminating "functions" that are just labels
255 inside other functions.
257 Display routines that have zero usage (as shown by call counts
258 and accumulated time).
261 .Bl -tag -width a.out.gmon -compact
263 The namelist and text space.
265 Dynamic call graph and profile.
267 Summarized dynamic call graph and profile.
277 .%T "An Execution Profiler for Modular Programs"
281 .%J "Software - Practice and Experience"
287 .%T "gprof: A Call Graph Execution Profiler"
291 .%J "Proceedings of the SIGPLAN '82 Symposium on Compiler Construction, SIGPLAN Notices"
304 The granularity of the sampling is shown, but remains
306 We assume that the time for each execution of a function
307 can be expressed by the total time for the function divided
308 by the number of times the function is called.
309 Thus the time propagated along the call graph arcs to the function's
310 parents is directly proportional to the number of times that
313 Parents that are not themselves profiled will have the time of
314 their profiled children propagated to them, but they will appear
315 to be spontaneously invoked in the call graph listing, and will
316 not have their time propagated further.
317 Similarly, signal catchers, even though profiled, will appear
318 to be spontaneous (although for more obscure reasons).
319 Any profiled children of signal catchers should have their times
320 propagated properly, unless the signal catcher was invoked during
321 the execution of the profiling routine, in which case all is lost.
323 The profiled program must call
325 or return normally for the profiling information to be saved
326 in the graph profile file.