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 ] [--external-symbol-table=name]
25        [ image-file ] [ profile-file ... ]
26

DESCRIPTION

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

OPTIONS

62       These options specify which of several output formats "gprof" should
63       produce.
64
65       Many of these options take an optional symspec to specify functions to
66       be included or excluded.  These options can be specified multiple
67       times, with different symspecs, to include or exclude sets of symbols.
68
69       Specifying any of these options overrides the default (-p -q), which
70       prints a flat profile and call graph analysis for all functions.
71
72       "-A[symspec]"
73       "--annotated-source[=symspec]"
74           The -A option causes "gprof" to print annotated source code.  If
75           symspec is specified, print output only for matching symbols.
76
77       "-b"
78       "--brief"
79           If the -b option is given, "gprof" doesn't print the verbose blurbs
80           that try to explain the meaning of all of the fields in the tables.
81           This is useful if you intend to print out the output, or are tired
82           of seeing the blurbs.
83
84       "-C[symspec]"
85       "--exec-counts[=symspec]"
86           The -C option causes "gprof" to print a tally of functions and the
87           number of times each was called.  If symspec is specified, print
88           tally only for matching symbols.
89
90           If the profile data file contains basic-block count records,
91           specifying the -l option, along with -C, will cause basic-block
92           execution counts to be tallied and displayed.
93
94       "-i"
95       "--file-info"
96           The -i option causes "gprof" to display summary information about
97           the profile data file(s) and then exit.  The number of histogram,
98           call graph, and basic-block count records is displayed.
99
100       "-I dirs"
101       "--directory-path=dirs"
102           The -I option specifies a list of search directories in which to
103           find source files.  Environment variable GPROF_PATH can also be
104           used to convey this information.  Used mostly for annotated source
105           output.
106
107       "-J[symspec]"
108       "--no-annotated-source[=symspec]"
109           The -J option causes "gprof" not to print annotated source code.
110           If symspec is specified, "gprof" prints annotated source, but
111           excludes matching symbols.
112
113       "-L"
114       "--print-path"
115           Normally, source filenames are printed with the path component
116           suppressed.  The -L option causes "gprof" to print the full
117           pathname of source filenames, which is determined from symbolic
118           debugging information in the image file and is relative to the
119           directory in which the compiler was invoked.
120
121       "-p[symspec]"
122       "--flat-profile[=symspec]"
123           The -p option causes "gprof" to print a flat profile.  If symspec
124           is specified, print flat profile only for matching symbols.
125
126       "-P[symspec]"
127       "--no-flat-profile[=symspec]"
128           The -P option causes "gprof" to suppress printing a flat profile.
129           If symspec is specified, "gprof" prints a flat profile, but
130           excludes matching symbols.
131
132       "-q[symspec]"
133       "--graph[=symspec]"
134           The -q option causes "gprof" to print the call graph analysis.  If
135           symspec is specified, print call graph only for matching symbols
136           and their children.
137
138       "-Q[symspec]"
139       "--no-graph[=symspec]"
140           The -Q option causes "gprof" to suppress printing the call graph.
141           If symspec is specified, "gprof" prints a call graph, but excludes
142           matching symbols.
143
144       "-t"
145       "--table-length=num"
146           The -t option causes the num most active source lines in each
147           source file to be listed when source annotation is enabled.  The
148           default is 10.
149
150       "-y"
151       "--separate-files"
152           This option affects annotated source output only.  Normally,
153           "gprof" prints annotated source files to standard-output.  If this
154           option is specified, annotated source for a file named
155           path/filename is generated in the file filename-ann.  If the
156           underlying file system would truncate filename-ann so that it
157           overwrites the original filename, "gprof" generates annotated
158           source in the file filename.ann instead (if the original file name
159           has an extension, that extension is replaced with .ann).
160
161       "-Z[symspec]"
162       "--no-exec-counts[=symspec]"
163           The -Z option causes "gprof" not to print a tally of functions and
164           the number of times each was called.  If symspec is specified,
165           print tally, but exclude matching symbols.
166
167       "-r"
168       "--function-ordering"
169           The --function-ordering option causes "gprof" to print a suggested
170           function ordering for the program based on profiling data.  This
171           option suggests an ordering which may improve paging, tlb and cache
172           behavior for the program on systems which support arbitrary
173           ordering of functions in an executable.
174
175           The exact details of how to force the linker to place functions in
176           a particular order is system dependent and out of the scope of this
177           manual.
178
179       "-R map_file"
180       "--file-ordering map_file"
181           The --file-ordering option causes "gprof" to print a suggested .o
182           link line ordering for the program based on profiling data.  This
183           option suggests an ordering which may improve paging, tlb and cache
184           behavior for the program on systems which do not support arbitrary
185           ordering of functions in an executable.
186
187           Use of the -a argument is highly recommended with this option.
188
189           The map_file argument is a pathname to a file which provides
190           function name to object file mappings.  The format of the file is
191           similar to the output of the program "nm".
192
193                   c-parse.o:00000000 T yyparse
194                   c-parse.o:00000004 C yyerrflag
195                   c-lang.o:00000000 T maybe_objc_method_name
196                   c-lang.o:00000000 T print_lang_statistics
197                   c-lang.o:00000000 T recognize_objc_keyword
198                   c-decl.o:00000000 T print_lang_identifier
199                   c-decl.o:00000000 T print_lang_type
200                   ...
201
202           To create a map_file with GNU "nm", type a command like "nm
203           --extern-only --defined-only -v --print-file-name program-name".
204
205       "-T"
206       "--traditional"
207           The -T option causes "gprof" to print its output in "traditional"
208           BSD style.
209
210       "-w width"
211       "--width=width"
212           Sets width of output lines to width.  Currently only used when
213           printing the function index at the bottom of the call graph.
214
215       "-x"
216       "--all-lines"
217           This option affects annotated source output only.  By default, only
218           the lines at the beginning of a basic-block are annotated.  If this
219           option is specified, every line in a basic-block is annotated by
220           repeating the annotation for the first line.  This behavior is
221           similar to "tcov"'s -a.
222
223       "--demangle[=style]"
224       "--no-demangle"
225           These options control whether C++ symbol names should be demangled
226           when printing output.  The default is to demangle symbols.  The
227           "--no-demangle" option may be used to turn off demangling.
228           Different compilers have different mangling styles.  The optional
229           demangling style argument can be used to choose an appropriate
230           demangling style for your compiler.
231
232   Analysis Options
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       "-Sfilename"
298       "--external-symbol-table=filename"
299           The -S option causes "gprof" to read an external symbol table file,
300           such as /proc/kallsyms, rather than read the symbol table from the
301           given object file (the default is "a.out"). This is useful for
302           profiling kernel modules.
303
304       "-z"
305       "--display-unused-functions"
306           If you give the -z option, "gprof" will mention all functions in
307           the flat profile, even those that were never called, and that had
308           no time spent in them.  This is useful in conjunction with the -c
309           option for discovering which routines were never called.
310
311   Miscellaneous Options
312       "-d[num]"
313       "--debug[=num]"
314           The -d num option specifies debugging options.  If num is not
315           specified, enable all debugging.
316
317       "-h"
318       "--help"
319           The -h option prints command line usage.
320
321       "-Oname"
322       "--file-format=name"
323           Selects the format of the profile data files.  Recognized formats
324           are auto (the default), bsd, 4.4bsd, magic, and prof (not yet
325           supported).
326
327       "-s"
328       "--sum"
329           The -s option causes "gprof" to summarize the information in the
330           profile data files it read in, and write out a profile data file
331           called gmon.sum, which contains all the information from the
332           profile data files that "gprof" read in.  The file gmon.sum may be
333           one of the specified input files; the effect of this is to merge
334           the data in the other input files into gmon.sum.
335
336           Eventually you can run "gprof" again without -s to analyze the
337           cumulative data in the file gmon.sum.
338
339       "-v"
340       "--version"
341           The -v flag causes "gprof" to print the current version number, and
342           then exit.
343
344   Deprecated Options
345       These options have been replaced with newer versions that use symspecs.
346
347       "-e function_name"
348           The -e function option tells "gprof" to not print information about
349           the function function_name (and its children...) in the call graph.
350           The function will still be listed as a child of any functions that
351           call it, but its index number will be shown as [not printed].  More
352           than one -e option may be given; only one function_name may be
353           indicated with each -e option.
354
355       "-E function_name"
356           The "-E function" option works like the "-e" option, but time spent
357           in the function (and children who were not called from anywhere
358           else), will not be used to compute the percentages-of-time for the
359           call graph.  More than one -E option may be given; only one
360           function_name may be indicated with each -E option.
361
362       "-f function_name"
363           The -f function option causes "gprof" to limit the call graph to
364           the function function_name and its children (and their
365           children...).  More than one -f option may be given; only one
366           function_name may be indicated with each -f option.
367
368       "-F function_name"
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, 1992, 1997, 1998, 1999, 2000, 2001, 2003, 2007,
419       2008, 2009 Free 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.3 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
428
429
430binutils-2.24                     2018-07-14                          GPROF(1)
Impressum