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