add info about remote finger
[unix-history] / usr / src / usr.bin / gprof / gprof.1
CommitLineData
37890435
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
66c7a1bc 5.\" @(#)gprof.1 6.1 (Berkeley) %G%
37890435 6.\"
66c7a1bc 7.TH GPROF 1 ""
37890435
KM
8.UC 5
9.SH NAME
10gprof \- display call graph profile data
11.SH SYNOPSIS
12.B gprof
13[ options ] [ a.out [ gmon.out ... ] ]
14.SH DESCRIPTION
15.I gprof
16produces an execution profile of C, Pascal, or Fortran77 programs.
17The effect of called routines is incorporated in the profile of each caller.
18The profile data is taken from the call graph profile file
19.RI ( gmon.out
20default) which is created by programs
21which are compiled with the
22.B \-pg
23option of
24.IR cc ,
25.IR pc ,
26and
27.IR f77 .
28That option also links in versions of the library routines
29which are compiled for profiling.
30The symbol table in the
31named object file
32.RI ( a.out
33default)
34is read and correlated with the
35call graph profile file.
36If more than one profile file is specified,
37the
38.I gprof
39output shows the sum of the profile information in the given profile files.
40.PP
41First, a flat profile is given,
42similar to that provided by
43.IR prof (1).
44This listing gives the total execution times
45and call counts for each of the functions
46in the program, sorted by decreasing time.
47.PP
48Next, these times are propagated along the edges of the call graph.
49Cycles are discovered, and calls into a cycle are made to share the time
50of the cycle.
51A second listing shows the functions
52sorted according to the time they represent
53including the time of their call graph descendents.
54Below each function entry is shown its (direct) call graph children,
55and how their times are propagated to this function.
56A similar display above the function shows how this function's time and the
57time of its descendents is propagated to its (direct) call graph parents.
58.PP
59Cycles are also shown, with an entry for the cycle as a whole and
60a listing of the members of the cycle and their contributions to the
61time and call counts of the cycle.
62.PP
63The following options are available:
64.TP
65.B \-a
66suppresses the printing of statically declared functions.
67If this option is given, all relevant information about the static function
68.RI ( e.g.,
69time samples, calls to other functions, calls from other functions)
70belongs to the function loaded just before the static function in the
71.I a.out
72file.
73.TP
74.B \-b
75supresses the printing of a description of each field in the profile.
76.TP
77.B \-c
78the static call graph of the program is discovered by a heuristic
79which examines the text space of the object file.
80Static-only parents or children are indicated
81with call counts of 0.
82.TP
83.BI \-e " name"
84suppresses the printing of the graph profile entry for routine
85.I name
86and all its descendants
87(unless they have other ancestors that aren't suppressed).
88More than one
89.B \-e
90option may be given.
91Only one
92.I name
93may be given with each
94.B \-e
95option.
96.TP
97.BI \-E " name"
98suppresses the printing of the graph profile entry for routine
99.I name
100(and its descendants) as
101.BR \-e ,
102above, and also excludes the time spent in
103.I name
104(and its descendants) from the total and percentage time computations.
105(For example,
106.B \-E
107.I mcount
108.B \-E
109.I mcleanup
110is the default.)
111.TP
112.BI \-f " name"
113prints the graph profile entry of only the specified routine
114.I name
115and its descendants.
116More than one
117.B \-f
118option may be given.
119Only one
120.I name
121may be given with each
122.B \-f
123option.
124.TP
125.BI \-F " name"
126prints the graph profile entry of only the routine
127.I name
128and its descendants (as
129.BR \-f,
130above) and also uses only the times of the printed routines
131in total time and percentage computations.
132More than one
133.B \-F
134option may be given.
135Only one
136.I name
137may be given with each
138.B \-F
139option.
140The
141.B \-F
142option
143overrides
144the
145.B \-E
146option.
147.TP
148.B \-s
149a profile file
150.I gmon.sum
151is produced which represents
152the sum of the profile information in all the specified profile files.
153This summary profile file may be given to subsequent
154executions of gprof (probably also with a
155.BR \-s )
156to accumulate profile data across several runs of an
157.I a.out
158file.
159.TP
160.B \-z
161displays routines which have zero usage (as indicated by call counts
162and accumulated time).
163This is useful in conjunction with the
164.B \-c
165option for discovering which routines were never called.
166.SH FILES
167.ta 1.5i
168.I a.out
169the namelist and text space.
170.br
171.I gmon.out
172dynamic call graph and profile.
173.br
174.I gmon.sum
175summarized dynamic call graph and profile.
176.SH "SEE ALSO"
177monitor(3), profil(2), cc(1), prof(1)
178.br
179``gprof: A Call Graph Execution Profiler'', by
180Graham, S.L., Kessler, P.B., McKusick, M.K.;
181.IR "Proceedings of the SIGPLAN '82 Symposium on Compiler Construction" ,
182SIGPLAN Notices, Vol. 17, No. 6, pp. 120-126, June 1982.
183.SH BUGS
184Beware of quantization errors.
185The granularity of the sampling is shown, but remains
186statistical at best.
187We assume that the time for each execution of a function
188can be expressed by the total time for the function divided
189by the number of times the function is called.
190Thus the time propagated along the call graph arcs to parents of that
191function is directly proportional to the number of times that
192arc is traversed.
193.PP
194Parents which are not themselves profiled will have the time of
195their profiled children propagated to them, but they will appear
196to be spontaneously invoked in the call graph listing, and will
197not have their time propagated further.
198Similarly, signal catchers, even though profiled, will appear
199to be spontaneous (although for more obscure reasons).
200Any profiled children of signal catchers should have their times
201propagated properly, unless the signal catcher was invoked during
202the execution of the profiling routine, in which case all is lost.
203.PP
204The profiled program must call
205.IR exit (2)
206or return normally for the profiling information to be saved
207in the gmon.out file.