]> Git Repo - binutils.git/blame - gprof/gprof.1
don't install gprof.{callg,flat}, install the man page, get the new
[binutils.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.\"
ea2b679c
DZ
20.TH GPROF 1 "July 24, 1990"
21.SH NAME
22gprof \- display call graph profile data
23.SH SYNOPSIS
24.B gprof
25.RB "[\|" a.out "\|]"
26.B
27gmon.out ...
28.SH DESCRIPTION
29.B gprof
3d6c6501
SEF
30produces an execution profile of C, Pascal, or Fortran77 programs.
31The effect of called routines is incorporated in the profile of each caller.
32The profile data is taken from the call graph profile file
ea2b679c 33\&(`gmon.out' default) which is created by programs
3d6c6501 34that are compiled with the
ea2b679c 35.B \-pg
3d6c6501 36option of
ea2b679c
DZ
37.BR cc ( 1 ) ,
38.BR pc ( 1 ) ,
3d6c6501 39and
ea2b679c 40.BR f77 ( 1 ) .
3d6c6501 41The
ea2b679c 42.B \-pg
3d6c6501
SEF
43option also links in versions of the library routines
44that are compiled for profiling.
ea2b679c
DZ
45.B Gprof
46reads the given object file (the default is `a.out')
47and establishes the relation between its symbol table
48and the call graph profile from `gmon.out'.
3d6c6501
SEF
49If more than one profile file is specified,
50the
ea2b679c 51.B gprof
3d6c6501 52output shows the sum of the profile information in the given profile files.
ea2b679c
DZ
53.PP
54.B Gprof
3d6c6501
SEF
55calculates the amount of time spent in each routine.
56Next, these times are propagated along the edges of the call graph.
57Cycles are discovered, and calls into a cycle are made to share the time
58of the cycle.
59The first listing shows the functions
60sorted according to the time they represent
61including the time of their call graph descendents.
62Below each function entry is shown its (direct) call graph children,
63and how their times are propagated to this function.
64A similar display above the function shows how this function's time and the
65time of its descendents is propagated to its (direct) call graph parents.
ea2b679c 66.PP
3d6c6501
SEF
67Cycles are also shown, with an entry for the cycle as a whole and
68a listing of the members of the cycle and their contributions to the
69time and call counts of the cycle.
ea2b679c 70.PP
3d6c6501
SEF
71Second, a flat profile is given,
72similar to that provided by
ea2b679c 73.BR prof ( 1 ) .
3d6c6501
SEF
74This listing gives the total execution times, the call counts,
75the time in milleseconds the call spent in the routine itself, and
76the time in milleseconds the call spent in the routine itself including
77its descendents.
ea2b679c 78.PP
3d6c6501 79Finally, an index of the function names is provided.
ea2b679c 80.SH OPTIONS
3d6c6501 81The following options are available:
ea2b679c
DZ
82.TP
83.B \-a
3d6c6501
SEF
84suppresses the printing of statically declared functions.
85If this option is given, all relevant information about the static function
86(e.g., time samples, calls to other functions, calls from other functions)
87belongs to the function loaded just before the static function in the
ea2b679c
DZ
88\&`a.out' file.
89.TP
90.B \-b
3d6c6501 91suppresses the printing of a description of each field in the profile.
ea2b679c
DZ
92.TP
93.B \-c
3d6c6501
SEF
94the static call graph of the program is discovered by a heuristic
95that examines the text space of the object file.
96Static-only parents or children are shown
97with call counts of 0.
ea2b679c
DZ
98.TP
99.BI "\-e " name
3d6c6501 100suppresses the printing of the graph profile entry for routine
ea2b679c 101.I name
3d6c6501
SEF
102and all its descendants
103(unless they have other ancestors that aren't suppressed).
104More than one
ea2b679c 105.B \-e
3d6c6501
SEF
106option may be given.
107Only one
ea2b679c 108.I name
3d6c6501 109may be given with each
ea2b679c 110.B \-e
3d6c6501 111option.
ea2b679c
DZ
112.TP
113.BI "\-E " name
3d6c6501 114suppresses the printing of the graph profile entry for routine
ea2b679c 115.I name
3d6c6501 116(and its descendants) as
ea2b679c 117.B \-e ,
3d6c6501 118above, and also excludes the time spent in
ea2b679c 119.I name
3d6c6501
SEF
120(and its descendants) from the total and percentage time computations.
121(For example,
ea2b679c
DZ
122.BI "\-E " mcount
123.BI "\-E " mcleanup
3d6c6501 124is the default.)
ea2b679c
DZ
125.TP
126.BI "\-f " name
3d6c6501 127prints the graph profile entry of only the specified routine
ea2b679c 128.I name
3d6c6501
SEF
129and its descendants.
130More than one
ea2b679c 131.B \-f
3d6c6501
SEF
132option may be given.
133Only one
ea2b679c 134.I name
3d6c6501 135may be given with each
ea2b679c 136.B \-f
3d6c6501 137option.
ea2b679c
DZ
138.TP
139.BI "\-F " name
3d6c6501 140prints the graph profile entry of only the routine
ea2b679c 141.I name
3d6c6501 142and its descendants (as
ea2b679c 143.B \-f ,
3d6c6501
SEF
144above) and also uses only the times of the printed routines
145in total time and percentage computations.
146More than one
ea2b679c 147.B \-F
3d6c6501
SEF
148option may be given.
149Only one
ea2b679c 150.I name
3d6c6501 151may be given with each
ea2b679c 152.B \-F
3d6c6501
SEF
153option.
154The
ea2b679c 155.B \-F
3d6c6501
SEF
156option
157overrides
158the
ea2b679c 159.B \-E
3d6c6501 160option.
ea2b679c
DZ
161.TP
162.BI "\-k " "fromname toname"
3d6c6501 163will delete any arcs from routine
ea2b679c 164.I fromname
3d6c6501 165to routine
ea2b679c 166.IR toname .
3d6c6501
SEF
167This can be used to break undesired cycles.
168More than one
ea2b679c 169.B \-k
3d6c6501
SEF
170option may be given.
171Only one pair of routine names may be given with each
ea2b679c 172.B \-k
3d6c6501 173option.
ea2b679c
DZ
174.TP
175.B \-s
176a profile file `gmon.sum' is produced that represents
3d6c6501
SEF
177the sum of the profile information in all the specified profile files.
178This summary profile file may be given to later
179executions of gprof (probably also with a
ea2b679c
DZ
180.BR \-s )
181to accumulate profile data across several runs of an `a.out' file.
182.TP
183.B -z
3d6c6501
SEF
184displays routines that have zero usage (as shown by call counts
185and accumulated time).
186This is useful with the
ea2b679c 187.B \-c
3d6c6501 188option for discovering which routines were never called.
ea2b679c
DZ
189.PP
190.SH FILES
191.ta \w'gmon.sum 'u
192a.out the namelist and text space.
3d6c6501 193.br
ea2b679c 194gmon.out dynamic call graph and profile.
3d6c6501 195.br
ea2b679c
DZ
196gmon.sum summarized dynamic call graph and profile.
197.SH SEE ALSO
198.BR monitor ( 3 ) ,
199.BR profil ( 2 ) ,
200.BR cc ( 1 ) ,
201.BR prof ( 1 )
202.sp
203``An Execution Profiler for Modular Programs'',
204by S. Graham, P. Kessler, M. McKusick;
205.I
206Software \- Practice and Experience,
207Vol. 13, pp. 671-685, 1983.
208.sp
209``gprof: A Call Graph Execution Profiler'',
3d6c6501 210by S. Graham, P. Kessler, M. McKusick;
ea2b679c 211.I
3d6c6501
SEF
212Proceedings of the SIGPLAN '82 Symposium on Compiler Construction,
213SIGPLAN Notices, Vol. 17, No 6, pp. 120-126, June 1982.
ea2b679c
DZ
214.SH HISTORY
215.B Gprof
3d6c6501 216appeared in 4.2 BSD.
ea2b679c 217.SH BUGS
3d6c6501
SEF
218The granularity of the sampling is shown, but remains
219statistical at best.
220We assume that the time for each execution of a function
221can be expressed by the total time for the function divided
222by the number of times the function is called.
223Thus the time propagated along the call graph arcs to the function's
224parents is directly proportional to the number of times that
225arc is traversed.
ea2b679c 226.PP
3d6c6501
SEF
227Parents that are not themselves profiled will have the time of
228their profiled children propagated to them, but they will appear
229to be spontaneously invoked in the call graph listing, and will
230not have their time propagated further.
231Similarly, signal catchers, even though profiled, will appear
232to be spontaneous (although for more obscure reasons).
233Any profiled children of signal catchers should have their times
234propagated properly, unless the signal catcher was invoked during
235the execution of the profiling routine, in which case all is lost.
ea2b679c 236.PP
3d6c6501 237The profiled program must call
ea2b679c 238.BR exit ( 2 )
3d6c6501 239or return normally for the profiling information to be saved
ea2b679c 240in the `gmon.out' file.
This page took 0.135144 seconds and 4 git commands to generate.