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