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