1GPROF(1)                              GNU                             GPROF(1)
2
3
4

NAME

6       gprof - display call graph profile data
7

SYNOPSIS

9       gprof [ -[abcDhilLrsTvwxyz] ] [ -[ACeEfFJnNOpPqQZ][name] ]
10        [ -I dirs ] [ -d[num] ] [ -k from/to ]
11        [ -m min-count ] [ -R map_file ] [ -t table-length ]
12        [ --[no-]annotated-source[=name] ]
13        [ --[no-]exec-counts[=name] ]
14        [ --[no-]flat-profile[=name] ] [ --[no-]graph[=name] ]
15        [ --[no-]time=name] [ --all-lines ] [ --brief ]
16        [ --debug[=level] ] [ --function-ordering ]
17        [ --file-ordering map_file ] [ --directory-path=dirs ]
18        [ --display-unused-functions ] [ --file-format=name ]
19        [ --file-info ] [ --help ] [ --line ] [ --min-count=n ]
20        [ --no-static ] [ --print-path ] [ --separate-files ]
21        [ --static-call-graph ] [ --sum ] [ --table-length=len ]
22        [ --traditional ] [ --version ] [ --width=n ]
23        [ --ignore-non-functions ] [ --demangle[=STYLE] ]
24        [ --no-demangle ] [ image-file ] [ profile-file ... ]
25

DESCRIPTION

27       "gprof" produces an execution profile of C, Pascal, or Fortran77
28       programs.  The effect of called routines is incorporated in the profile
29       of each caller.  The profile data is taken from the call graph profile
30       file (gmon.out default) which is created by programs that are compiled
31       with the -pg option of "cc", "pc", and "f77".  The -pg option also
32       links in versions of the library routines that are compiled for
33       profiling.  "Gprof" reads the given object file (the default is
34       "a.out") and establishes the relation between its symbol table and the
35       call graph profile from gmon.out.  If more than one profile file is
36       specified, the "gprof" output shows the sum of the profile information
37       in the given profile files.
38
39       "Gprof" calculates the amount of time spent in each routine.  Next,
40       these times are propagated along the edges of the call graph.  Cycles
41       are discovered, and calls into a cycle are made to share the time of
42       the cycle.
43
44       Several forms of output are available from the analysis.
45
46       The flat profile shows how much time your program spent in each
47       function, and how many times that function was called.  If you simply
48       want to know which functions burn most of the cycles, it is stated
49       concisely here.
50
51       The call graph shows, for each function, which functions called it,
52       which other functions it called, and how many times.  There is also an
53       estimate of how much time was spent in the subroutines of each
54       function.  This can suggest places where you might try to eliminate
55       function calls that use a lot of time.
56
57       The annotated source listing is a copy of the program's source code,
58       labeled with the number of times each line of the program was executed.
59

OPTIONS

61       These options specify which of several output formats "gprof" should
62       produce.
63
64       Many of these options take an optional symspec to specify functions to
65       be included or excluded.  These options can be specified multiple
66       times, with different symspecs, to include or exclude sets of symbols.
67
68       Specifying any of these options overrides the default (-p -q), which
69       prints a flat profile and call graph analysis for all functions.
70
71       "-A[symspec]"
72       "--annotated-source[=symspec]"
73           The -A option causes "gprof" to print annotated source code.  If
74           symspec is specified, print output only for matching symbols.
75
76       "-b"
77       "--brief"
78           If the -b option is given, "gprof" doesn't print the verbose blurbs
79           that try to explain the meaning of all of the fields in the tables.
80           This is useful if you intend to print out the output, or are tired
81           of seeing the blurbs.
82
83       "-C[symspec]"
84       "--exec-counts[=symspec]"
85           The -C option causes "gprof" to print a tally of functions and the
86           number of times each was called.  If symspec is specified, print
87           tally only for matching symbols.
88
89           If the profile data file contains basic-block count records,
90           specifying the -l option, along with -C, will cause basic-block
91           execution counts to be tallied and displayed.
92
93       "-i"
94       "--file-info"
95           The -i option causes "gprof" to display summary information about
96           the profile data file(s) and then exit.  The number of histogram,
97           call graph, and basic-block count records is displayed.
98
99       "-I dirs"
100       "--directory-path=dirs"
101           The -I option specifies a list of search directories in which to
102           find source files.  Environment variable GPROF_PATH can also be
103           used to convey this information.  Used mostly for annotated source
104           output.
105
106       "-J[symspec]"
107       "--no-annotated-source[=symspec]"
108           The -J option causes "gprof" not to print annotated source code.
109           If symspec is specified, "gprof" prints annotated source, but
110           excludes matching symbols.
111
112       "-L"
113       "--print-path"
114           Normally, source filenames are printed with the path component
115           suppressed.  The -L option causes "gprof" to print the full
116           pathname of source filenames, which is determined from symbolic
117           debugging information in the image file and is relative to the
118           directory in which the compiler was invoked.
119
120       "-p[symspec]"
121       "--flat-profile[=symspec]"
122           The -p option causes "gprof" to print a flat profile.  If symspec
123           is specified, print flat profile only for matching symbols.
124
125       "-P[symspec]"
126       "--no-flat-profile[=symspec]"
127           The -P option causes "gprof" to suppress printing a flat profile.
128           If symspec is specified, "gprof" prints a flat profile, but
129           excludes matching symbols.
130
131       "-q[symspec]"
132       "--graph[=symspec]"
133           The -q option causes "gprof" to print the call graph analysis.  If
134           symspec is specified, print call graph only for matching symbols
135           and their children.
136
137       "-Q[symspec]"
138       "--no-graph[=symspec]"
139           The -Q option causes "gprof" to suppress printing the call graph.
140           If symspec is specified, "gprof" prints a call graph, but excludes
141           matching symbols.
142
143       "-t"
144       "--table-length=num"
145           The -t option causes the num most active source lines in each
146           source file to be listed when source annotation is enabled.  The
147           default is 10.
148
149       "-y"
150       "--separate-files"
151           This option affects annotated source output only.  Normally,
152           "gprof" prints annotated source files to standard-output.  If this
153           option is specified, annotated source for a file named
154           path/filename is generated in the file filename-ann.  If the
155           underlying file system would truncate filename-ann so that it
156           overwrites the original filename, "gprof" generates annotated
157           source in the file filename.ann instead (if the original file name
158           has an extension, that extension is replaced with .ann).
159
160       "-Z[symspec]"
161       "--no-exec-counts[=symspec]"
162           The -Z option causes "gprof" not to print a tally of functions and
163           the number of times each was called.  If symspec is specified,
164           print tally, but exclude matching symbols.
165
166       "-r"
167       "--function-ordering"
168           The --function-ordering option causes "gprof" to print a suggested
169           function ordering for the program based on profiling data.  This
170           option suggests an ordering which may improve paging, tlb and cache
171           behavior for the program on systems which support arbitrary
172           ordering of functions in an executable.
173
174           The exact details of how to force the linker to place functions in
175           a particular order is system dependent and out of the scope of this
176           manual.
177
178       "-R map_file"
179       "--file-ordering map_file"
180           The --file-ordering option causes "gprof" to print a suggested .o
181           link line ordering for the program based on profiling data.  This
182           option suggests an ordering which may improve paging, tlb and cache
183           behavior for the program on systems which do not support arbitrary
184           ordering of functions in an executable.
185
186           Use of the -a argument is highly recommended with this option.
187
188           The map_file argument is a pathname to a file which provides
189           function name to object file mappings.  The format of the file is
190           similar to the output of the program "nm".
191
192                   c-parse.o:00000000 T yyparse
193                   c-parse.o:00000004 C yyerrflag
194                   c-lang.o:00000000 T maybe_objc_method_name
195                   c-lang.o:00000000 T print_lang_statistics
196                   c-lang.o:00000000 T recognize_objc_keyword
197                   c-decl.o:00000000 T print_lang_identifier
198                   c-decl.o:00000000 T print_lang_type
199                   ...
200
201           To create a map_file with GNU "nm", type a command like "nm
202           --extern-only --defined-only -v --print-file-name program-name".
203
204       "-T"
205       "--traditional"
206           The -T option causes "gprof" to print its output in "traditional"
207           BSD style.
208
209       "-w width"
210       "--width=width"
211           Sets width of output lines to width.  Currently only used when
212           printing the function index at the bottom of the call graph.
213
214       "-x"
215       "--all-lines"
216           This option affects annotated source output only.  By default, only
217           the lines at the beginning of a basic-block are annotated.  If this
218           option is specified, every line in a basic-block is annotated by
219           repeating the annotation for the first line.  This behavior is
220           similar to "tcov"'s -a.
221
222       "--demangle[=style]"
223       "--no-demangle"
224           These options control whether C++ symbol names should be demangled
225           when printing output.  The default is to demangle symbols.  The
226           "--no-demangle" option may be used to turn off demangling.
227           Different compilers have different mangling styles.  The optional
228           demangling style argument can be used to choose an appropriate
229           demangling style for your compiler.
230
231       Analysis Options
232
233       "-a"
234       "--no-static"
235           The -a option causes "gprof" to suppress the printing of statically
236           declared (private) functions.  (These are functions whose names are
237           not listed as global, and which are not visible outside the
238           file/function/block where they were defined.)  Time spent in these
239           functions, calls to/from them, etc., will all be attributed to the
240           function that was loaded directly before it in the executable file.
241           This option affects both the flat profile and the call graph.
242
243       "-c"
244       "--static-call-graph"
245           The -c option causes the call graph of the program to be augmented
246           by a heuristic which examines the text space of the object file and
247           identifies function calls in the binary machine code.  Since normal
248           call graph records are only generated when functions are entered,
249           this option identifies children that could have been called, but
250           never were.  Calls to functions that were not compiled with
251           profiling enabled are also identified, but only if symbol table
252           entries are present for them.  Calls to dynamic library routines
253           are typically not found by this option.  Parents or children
254           identified via this heuristic are indicated in the call graph with
255           call counts of 0.
256
257       "-D"
258       "--ignore-non-functions"
259           The -D option causes "gprof" to ignore symbols which are not known
260           to be functions.  This option will give more accurate profile data
261           on systems where it is supported (Solaris and HPUX for example).
262
263       "-k from/to"
264           The -k option allows you to delete from the call graph any arcs
265           from symbols matching symspec from to those matching symspec to.
266
267       "-l"
268       "--line"
269           The -l option enables line-by-line profiling, which causes
270           histogram hits to be charged to individual source code lines,
271           instead of functions.  This feature only works with programs
272           compiled by older versions of the "gcc" compiler.  Newer versions
273           of "gcc" are designed to work with the "gcov" tool instead.
274
275           If the program was compiled with basic-block counting enabled, this
276           option will also identify how many times each line of code was
277           executed.  While line-by-line profiling can help isolate where in a
278           large function a program is spending its time, it also
279           significantly increases the running time of "gprof", and magnifies
280           statistical inaccuracies.
281
282       "-m num"
283       "--min-count=num"
284           This option affects execution count output only.  Symbols that are
285           executed less than num times are suppressed.
286
287       "-nsymspec"
288       "--time=symspec"
289           The -n option causes "gprof", in its call graph analysis, to only
290           propagate times for symbols matching symspec.
291
292       "-Nsymspec"
293       "--no-time=symspec"
294           The -n option causes "gprof", in its call graph analysis, not to
295           propagate times for symbols matching symspec.
296
297       "-z"
298       "--display-unused-functions"
299           If you give the -z option, "gprof" will mention all functions in
300           the flat profile, even those that were never called, and that had
301           no time spent in them.  This is useful in conjunction with the -c
302           option for discovering which routines were never called.
303
304       Miscellaneous Options
305
306       "-d[num]"
307       "--debug[=num]"
308           The -d num option specifies debugging options.  If num is not
309           specified, enable all debugging.
310
311       "-h"
312       "--help"
313           The -h option prints command line usage.
314
315       "-Oname"
316       "--file-format=name"
317           Selects the format of the profile data files.  Recognized formats
318           are auto (the default), bsd, 4.4bsd, magic, and prof (not yet
319           supported).
320
321       "-s"
322       "--sum"
323           The -s option causes "gprof" to summarize the information in the
324           profile data files it read in, and write out a profile data file
325           called gmon.sum, which contains all the information from the
326           profile data files that "gprof" read in.  The file gmon.sum may be
327           one of the specified input files; the effect of this is to merge
328           the data in the other input files into gmon.sum.
329
330           Eventually you can run "gprof" again without -s to analyze the
331           cumulative data in the file gmon.sum.
332
333       "-v"
334       "--version"
335           The -v flag causes "gprof" to print the current version number, and
336           then exit.
337
338       Deprecated Options
339
340           These options have been replaced with newer versions that use
341           symspecs.
342
343           "-e function_name"
344
345           The -e function option tells "gprof" to not print information about
346           the function function_name (and its children...) in the call graph.
347           The function will still be listed as a child of any functions that
348           call it, but its index number will be shown as [not printed].  More
349           than one -e option may be given; only one function_name may be
350           indicated with each -e option.
351
352           "-E function_name"
353
354           The "-E function" option works like the "-e" option, but time spent
355           in the function (and children who were not called from anywhere
356           else), will not be used to compute the percentages-of-time for the
357           call graph.  More than one -E option may be given; only one
358           function_name may be indicated with each -E option.
359
360           "-f function_name"
361
362           The -f function option causes "gprof" to limit the call graph to
363           the function function_name and its children (and their
364           children...).  More than one -f option may be given; only one
365           function_name may be indicated with each -f option.
366
367           "-F function_name"
368
369           The -F function option works like the "-f" option, but only time
370           spent in the function and its children (and their children...) will
371           be used to determine total-time and percentages-of-time for the
372           call graph.  More than one -F option may be given; only one
373           function_name may be indicated with each -F option.  The -F option
374           overrides the -E option.
375

FILES

377       "a.out"
378           the namelist and text space.
379
380       "gmon.out"
381           dynamic call graph and profile.
382
383       "gmon.sum"
384           summarized dynamic call graph and profile.
385

BUGS

387       The granularity of the sampling is shown, but remains statistical at
388       best.  We assume that the time for each execution of a function can be
389       expressed by the total time for the function divided by the number of
390       times the function is called.  Thus the time propagated along the call
391       graph arcs to the function's parents is directly proportional to the
392       number of times that arc is traversed.
393
394       Parents that are not themselves profiled will have the time of their
395       profiled children propagated to them, but they will appear to be
396       spontaneously invoked in the call graph listing, and will not have
397       their time propagated further.  Similarly, signal catchers, even though
398       profiled, will appear to be spontaneous (although for more obscure
399       reasons).  Any profiled children of signal catchers should have their
400       times propagated properly, unless the signal catcher was invoked during
401       the execution of the profiling routine, in which case all is lost.
402
403       The profiled program must call "exit"(2) or return normally for the
404       profiling information to be saved in the gmon.out file.
405

SEE ALSO

407       monitor(3), profil(2), cc(1), prof(1), and the Info entry for gprof.
408
409       "An Execution Profiler for Modular Programs", by S. Graham, P. Kessler,
410       M. McKusick; Software - Practice and Experience, Vol. 13, pp. 671-685,
411       1983.
412
413       "gprof: A Call Graph Execution Profiler", by S. Graham, P. Kessler, M.
414       McKusick; Proceedings of the SIGPLAN '82 Symposium on Compiler
415       Construction, SIGPLAN Notices, Vol. 17, No  6, pp. 120-126, June 1982.
416
418       Copyright (c) 1988, 92, 97, 98, 99, 2000, 2001, 2003, 2007 Free
419       Software Foundation, Inc.
420
421       Permission is granted to copy, distribute and/or modify this document
422       under the terms of the GNU Free Documentation License, Version 1.1 or
423       any later version published by the Free Software Foundation; with no
424       Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
425       Texts.  A copy of the license is included in the section entitled "GNU
426       Free Documentation License".
427

POD ERRORS

429       Hey! The above document had some coding errors, which are explained
430       below:
431
432       Around line 527:
433           You can't have =items (as at line 533) unless the first thing after
434           the =over is an =item
435
436
437
438binutils-2.19.50.0.1              2009-07-28                          GPROF(1)
Impressum