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 pro‐
28       grams.  The effect of called routines is incorporated in the profile of
29       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 profil‐
33       ing.   "Gprof" reads the given object file (the default is "a.out") and
34       establishes the relation between its symbol table and  the  call  graph
35       profile from gmon.out.  If more than one profile file is specified, the
36       "gprof" output shows the sum of the profile information  in  the  given
37       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  func‐
47       tion,  and how many times that function was called.  If you simply want
48       to know which functions burn most of the cycles, it is stated concisely
49       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 func‐
54       tion.  This can suggest places where you might try to  eliminate  func‐
55       tion 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, speci‐
90           fying  the  -l option, along with -C, will cause basic-block execu‐
91           tion 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 sup‐
115           pressed.  The -L option causes "gprof" to print the  full  pathname
116           of  source  filenames,  which is determined from symbolic debugging
117           information in the image file and is relative to the  directory  in
118           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  path/file‐
154           name is generated in the file filename-ann.  If the underlying file
155           system would truncate filename-ann so that it overwrites the origi‐
156           nal  filename, "gprof" generates annotated source in the file file‐
157           name.ann instead (if the original file name has an extension,  that
158           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  order‐
172           ing 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 func‐
189           tion name to object file mappings.  The format of the file is simi‐
190           lar 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 sim‐
220           ilar 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.  Differ‐
227           ent  compilers have different mangling styles.  The optional deman‐
228           gling style argument can be used to choose  an  appropriate  deman‐
229           gling 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 profil‐
251           ing  enabled  are also identified, but only if symbol table entries
252           are present for them.  Calls to dynamic library routines are  typi‐
253           cally not found by this option.  Parents or children identified via
254           this heuristic are indicated in the call graph with call counts  of
255           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  his‐
270           togram  hits to be charged to individual source code lines, instead
271           of functions.  If the program was compiled with basic-block  count‐
272           ing  enabled,  this  option  will also identify how many times each
273           line of code was executed.  While line-by-line profiling  can  help
274           isolate  where  in a large function a program is spending its time,
275           it also significantly increases the running time  of  "gprof",  and
276           magnifies statistical inaccuracies.
277
278       "-m num"
279       "--min-count=num"
280           This  option affects execution count output only.  Symbols that are
281           executed less than num times are suppressed.
282
283       "-nsymspec"
284       "--time=symspec"
285           The -n option causes "gprof", in its call graph analysis,  to  only
286           propagate times for symbols matching symspec.
287
288       "-Nsymspec"
289       "--no-time=symspec"
290           The  -n  option  causes "gprof", in its call graph analysis, not to
291           propagate times for symbols matching symspec.
292
293       "-z"
294       "--display-unused-functions"
295           If you give the -z option, "gprof" will mention  all  functions  in
296           the  flat  profile, even those that were never called, and that had
297           no time spent in them.  This is useful in conjunction with  the  -c
298           option for discovering which routines were never called.
299
300       Miscellaneous Options
301
302       "-d[num]"
303       "--debug[=num]"
304           The -d num option specifies debugging options.  If num is not spec‐
305           ified, enable all debugging.
306
307       "-h"
308       "--help"
309           The -h option prints command line usage.
310
311       "-Oname"
312       "--file-format=name"
313           Selects the format of the profile data files.   Recognized  formats
314           are  auto (the default), bsd, 4.4bsd, magic, and prof (not yet sup‐
315           ported).
316
317       "-s"
318       "--sum"
319           The -s option causes "gprof" to summarize the  information  in  the
320           profile  data  files  it read in, and write out a profile data file
321           called gmon.sum, which contains all the information from  the  pro‐
322           file data files that "gprof" read in.  The file gmon.sum may be one
323           of the specified input files; the effect of this is  to  merge  the
324           data in the other input files into gmon.sum.
325
326           Eventually  you  can  run  "gprof"  again without -s to analyze the
327           cumulative data in the file gmon.sum.
328
329       "-v"
330       "--version"
331           The -v flag causes "gprof" to print the current version number, and
332           then exit.
333
334       Deprecated Options
335
336           These  options have been replaced with newer versions that use sym‐
337           specs.
338
339       "-e function_name"
340           The -e function option tells "gprof" to not print information about
341           the function function_name (and its children...) in the call graph.
342           The function will still be listed as a child of any functions  that
343           call it, but its index number will be shown as [not printed].  More
344           than one -e option may be given;  only  one  function_name  may  be
345           indicated with each -e option.
346
347       "-E function_name"
348           The "-E function" option works like the "-e" option, but time spent
349           in the function (and children who were  not  called  from  anywhere
350           else),  will not be used to compute the percentages-of-time for the
351           call graph.  More than one -E option may be given; only  one  func‐
352           tion_name may be indicated with each -E option.
353
354       "-f function_name"
355           The  -f  function  option causes "gprof" to limit the call graph to
356           the function  function_name  and  its  children  (and  their  chil‐
357           dren...).   More  than  one  -f option may be given; only one func‐
358           tion_name may be indicated with each -f option.
359
360       "-F function_name"
361           The -F function option works like the "-f" option,  but  only  time
362           spent in the function and its children (and their children...) will
363           be used to determine total-time  and  percentages-of-time  for  the
364           call  graph.   More than one -F option may be given; only one func‐
365           tion_name may be indicated with each  -F  option.   The  -F  option
366           overrides the -E option.
367

FILES

369       "a.out"
370           the namelist and text space.
371
372       "gmon.out"
373           dynamic call graph and profile.
374
375       "gmon.sum"
376           summarized dynamic call graph and profile.
377

BUGS

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

SEE ALSO

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