Fixup patch for ncr3000.mh, delete patch for amix.mh, add patch for
[deliverable/binutils-gdb.git] / gprof / gprof.1
CommitLineData
3d6c6501
SEF
1.\" Copyright (c) 1983, 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms are permitted provided
5.\" that: (1) source distributions retain this entire copyright notice and
6.\" comment, and (2) distributions including binaries display the following
7.\" acknowledgement: ``This product includes software developed by the
8.\" University of California, Berkeley and its contributors'' in the
9.\" documentation or other materials provided with the distribution and in
10.\" all advertising materials mentioning features or use of this software.
11.\" Neither the name of the University nor the names of its contributors may
12.\" be used to endorse or promote products derived from this software without
13.\" specific prior written permission.
14.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17.\"
18.\" @(#)gprof.1 6.6 (Berkeley) 7/24/90
19.\"
20.Dd July 24, 1990
21.Dt GPROF 1
22.Os BSD 4.2
23.Sh NAME
24.Nm gprof
25.Nd display call graph profile data
26.Sh SYNOPSIS
27.Nm gprof
28.Op options
29.Op Ar a.out Op Ar gmon.out ...
30.Sh DESCRIPTION
31.Nm gprof
32produces an execution profile of C, Pascal, or Fortran77 programs.
33The effect of called routines is incorporated in the profile of each caller.
34The profile data is taken from the call graph profile file
35.Pf \&( Pa gmon.out
36default) which is created by programs
37that are compiled with the
38.Fl pg
39option of
40.Xr cc 1 ,
41.Xr pc 1 ,
42and
43.Xr f77 1 .
44The
45.Fl pg
46option also links in versions of the library routines
47that are compiled for profiling.
48.Nm Gprof
49reads the given object file (the default is
50.Pa a.out)
51and establishes the relation between it's symbol table
52and the call graph profile from
53.Pa gmon.out .
54If more than one profile file is specified,
55the
56.Nm gprof
57output shows the sum of the profile information in the given profile files.
58.Pp
59.Nm Gprof
60calculates the amount of time spent in each routine.
61Next, these times are propagated along the edges of the call graph.
62Cycles are discovered, and calls into a cycle are made to share the time
63of the cycle.
64The first listing shows the functions
65sorted according to the time they represent
66including the time of their call graph descendents.
67Below each function entry is shown its (direct) call graph children,
68and how their times are propagated to this function.
69A similar display above the function shows how this function's time and the
70time of its descendents is propagated to its (direct) call graph parents.
71.Pp
72Cycles are also shown, with an entry for the cycle as a whole and
73a listing of the members of the cycle and their contributions to the
74time and call counts of the cycle.
75.Pp
76Second, a flat profile is given,
77similar to that provided by
78.Xr prof 1 .
79This listing gives the total execution times, the call counts,
80the time in milleseconds the call spent in the routine itself, and
81the time in milleseconds the call spent in the routine itself including
82its descendents.
83.Pp
84Finally, an index of the function names is provided.
85.Pp
86The following options are available:
87.Tw Fl
88.Tp Fl a
89suppresses the printing of statically declared functions.
90If this option is given, all relevant information about the static function
91(e.g., time samples, calls to other functions, calls from other functions)
92belongs to the function loaded just before the static function in the
93.Pa a.out
94file.
95.Tp Fl b
96suppresses the printing of a description of each field in the profile.
97.Tp Fl c
98the static call graph of the program is discovered by a heuristic
99that examines the text space of the object file.
100Static-only parents or children are shown
101with call counts of 0.
102.Tc Fl e
103.Ws
104.Ar name
105.Cx
106suppresses the printing of the graph profile entry for routine
107.Ar name
108and all its descendants
109(unless they have other ancestors that aren't suppressed).
110More than one
111.Fl e
112option may be given.
113Only one
114.Ar name
115may be given with each
116.Fl e
117option.
118.Tc Fl E
119.Ws
120.Ar name
121.Cx
122suppresses the printing of the graph profile entry for routine
123.Ar name
124(and its descendants) as
125.Fl e ,
126above, and also excludes the time spent in
127.Ar name
128(and its descendants) from the total and percentage time computations.
129(For example,
130.Fl E
131.Ar mcount
132.Fl E
133.Ar mcleanup
134is the default.)
135.Tc Fl f
136.Ws
137.Ar name
138.Cx
139prints the graph profile entry of only the specified routine
140.Ar name
141and its descendants.
142More than one
143.Fl f
144option may be given.
145Only one
146.Ar name
147may be given with each
148.Fl f
149option.
150.Tc Fl F
151.Ws
152.Ar name
153.Cx
154prints the graph profile entry of only the routine
155.Ar name
156and its descendants (as
157.Fl f ,
158above) and also uses only the times of the printed routines
159in total time and percentage computations.
160More than one
161.Fl F
162option may be given.
163Only one
164.Ar name
165may be given with each
166.Fl F
167option.
168The
169.Fl F
170option
171overrides
172the
173.Fl E
174option.
175.Tc Fl k
176.Ws
177.Ar fromname
178.Ws
179.Ar toname
180.Cx
181will delete any arcs from routine
182.Ar fromname
183to routine
184.Ar toname .
185This can be used to break undesired cycles.
186More than one
187.Fl k
188option may be given.
189Only one pair of routine names may be given with each
190.Fl k
191option.
192.Tp Fl s
193a profile file
194.Pa gmon.sum
195is produced that represents
196the sum of the profile information in all the specified profile files.
197This summary profile file may be given to later
198executions of gprof (probably also with a
199.Fl s )
200to accumulate profile data across several runs of an
201.Pa a.out
202file.
203.Tp Fl z
204displays routines that have zero usage (as shown by call counts
205and accumulated time).
206This is useful with the
207.Fl c
208option for discovering which routines were never called.
209.Tp
210.Sh FILES
211.Dw gmon.sum
212.Di L
213.Dp Pa a.out
214the namelist and text space.
215.Dp Pa gmon.out
216dynamic call graph and profile.
217.Dp Pa gmon.sum
218summarized dynamic call graph and profile.
219.Dp
220.Sh SEE ALSO
221.Xr monitor 3 ,
222.Xr profil 2 ,
223.Xr cc 1 ,
224.Xr prof 1
225.br
226.Em An Execution Profiler for Modular Programs ,
227by
228S. Graham, P. Kessler, M. McKusick;
229Software - Practice and Experience,
230Vol. 13, pp. 671-685, 1983.
231.br
232.Em gprof: A Call Graph Execution Profiler ,
233by S. Graham, P. Kessler, M. McKusick;
234Proceedings of the SIGPLAN '82 Symposium on Compiler Construction,
235SIGPLAN Notices, Vol. 17, No 6, pp. 120-126, June 1982.
236.Sh HISTORY
237.Nm Gprof
238appeared in 4.2 BSD.
239.Sh BUGS
240The granularity of the sampling is shown, but remains
241statistical at best.
242We assume that the time for each execution of a function
243can be expressed by the total time for the function divided
244by the number of times the function is called.
245Thus the time propagated along the call graph arcs to the function's
246parents is directly proportional to the number of times that
247arc is traversed.
248.Pp
249Parents that are not themselves profiled will have the time of
250their profiled children propagated to them, but they will appear
251to be spontaneously invoked in the call graph listing, and will
252not have their time propagated further.
253Similarly, signal catchers, even though profiled, will appear
254to be spontaneous (although for more obscure reasons).
255Any profiled children of signal catchers should have their times
256propagated properly, unless the signal catcher was invoked during
257the execution of the profiling routine, in which case all is lost.
258.Pp
259The profiled program must call
260.Xr exit 2
261or return normally for the profiling information to be saved
262in the
263.Pa gmon.out
264file.
This page took 0.050681 seconds and 4 git commands to generate.