1 This is gprof.info, produced by makeinfo version 4.6 from gprof.texi.
4 * gprof: (gprof). Profiling your program's execution
7 This file documents the gprof profiler of the GNU system.
9 Copyright (C) 1988, 92, 97, 98, 99, 2000, 2001, 2003 Free Software
12 Permission is granted to copy, distribute and/or modify this document
13 under the terms of the GNU Free Documentation License, Version 1.1 or
14 any later version published by the Free Software Foundation; with no
15 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
16 Texts. A copy of the license is included in the section entitled "GNU
17 Free Documentation License".
20 File: gprof.info, Node: Top, Next: Introduction, Up: (dir)
22 Profiling a Program: Where Does It Spend Its Time?
23 **************************************************
25 This manual describes the GNU profiler, `gprof', and how you can use it
26 to determine which parts of a program are taking most of the execution
27 time. We assume that you know how to write, compile, and execute
28 programs. GNU `gprof' was written by Jay Fenlason.
30 This document is distributed under the terms of the GNU Free
31 Documentation License. A copy of the license is included in the
32 section entitled "GNU Free Documentation License".
36 * Introduction:: What profiling means, and why it is useful.
38 * Compiling:: How to compile your program for profiling.
39 * Executing:: Executing your program to generate profile data
40 * Invoking:: How to run `gprof', and its options
42 * Output:: Interpreting `gprof''s output
44 * Inaccuracy:: Potential problems you should be aware of
45 * How do I?:: Answers to common questions
46 * Incompatibilities:: (between GNU `gprof' and Unix `gprof'.)
47 * Details:: Details of how profiling is done
48 * GNU Free Documentation License:: GNU Free Documentation License
51 File: gprof.info, Node: Introduction, Next: Compiling, Prev: Top, Up: Top
53 Introduction to Profiling
54 *************************
56 Profiling allows you to learn where your program spent its time and
57 which functions called which other functions while it was executing.
58 This information can show you which pieces of your program are slower
59 than you expected, and might be candidates for rewriting to make your
60 program execute faster. It can also tell you which functions are being
61 called more or less often than you expected. This may help you spot
62 bugs that had otherwise been unnoticed.
64 Since the profiler uses information collected during the actual
65 execution of your program, it can be used on programs that are too
66 large or too complex to analyze by reading the source. However, how
67 your program is run will affect the information that shows up in the
68 profile data. If you don't use some feature of your program while it
69 is being profiled, no profile information will be generated for that
72 Profiling has several steps:
74 * You must compile and link your program with profiling enabled.
77 * You must execute your program to generate a profile data file.
80 * You must run `gprof' to analyze the profile data. *Note
83 The next three chapters explain these steps in greater detail.
85 Several forms of output are available from the analysis.
87 The "flat profile" shows how much time your program spent in each
88 function, and how many times that function was called. If you simply
89 want to know which functions burn most of the cycles, it is stated
90 concisely here. *Note Flat Profile::.
92 The "call graph" shows, for each function, which functions called
93 it, which other functions it called, and how many times. There is also
94 an estimate of how much time was spent in the subroutines of each
95 function. This can suggest places where you might try to eliminate
96 function calls that use a lot of time. *Note Call Graph::.
98 The "annotated source" listing is a copy of the program's source
99 code, labeled with the number of times each line of the program was
100 executed. *Note Annotated Source::.
102 To better understand how profiling works, you may wish to read a
103 description of its implementation. *Note Implementation::.
106 File: gprof.info, Node: Compiling, Next: Executing, Prev: Introduction, Up: Top
108 Compiling a Program for Profiling
109 *********************************
111 The first step in generating profile information for your program is to
112 compile and link it with profiling enabled.
114 To compile a source file for profiling, specify the `-pg' option when
115 you run the compiler. (This is in addition to the options you normally
118 To link the program for profiling, if you use a compiler such as `cc'
119 to do the linking, simply specify `-pg' in addition to your usual
120 options. The same option, `-pg', alters either compilation or linking
121 to do what is necessary for profiling. Here are examples:
123 cc -g -c myprog.c utils.c -pg
124 cc -o myprog myprog.o utils.o -pg
126 The `-pg' option also works with a command that both compiles and
129 cc -o myprog myprog.c utils.c -g -pg
131 Note: The `-pg' option must be part of your compilation options as
132 well as your link options. If it is not then no call-graph data will
133 be gathered and when you run `gprof' you will get an error message like
136 gprof: gmon.out file is missing call-graph data
138 If you add the `-Q' switch to suppress the printing of the call
139 graph data you will still be able to see the time samples:
143 Each sample counts as 0.01 seconds.
144 % cumulative self self total
145 time seconds seconds calls Ts/call Ts/call name
146 44.12 0.07 0.07 zazLoop
148 20.59 0.17 0.04 bazMillion
150 % the percentage of the total running time of the
152 If you run the linker `ld' directly instead of through a compiler
153 such as `cc', you may have to specify a profiling startup file
154 `gcrt0.o' as the first input file instead of the usual startup file
155 `crt0.o'. In addition, you would probably want to specify the
156 profiling C library, `libc_p.a', by writing `-lc_p' instead of the
157 usual `-lc'. This is not absolutely necessary, but doing this gives
158 you number-of-calls information for standard library functions such as
159 `read' and `open'. For example:
161 ld -o myprog /lib/gcrt0.o myprog.o utils.o -lc_p
163 If you compile only some of the modules of the program with `-pg',
164 you can still profile the program, but you won't get complete
165 information about the modules that were compiled without `-pg'. The
166 only information you get for the functions in those modules is the
167 total time spent in them; there is no record of how many times they
168 were called, or from where. This will not affect the flat profile
169 (except that the `calls' field for the functions will be blank), but
170 will greatly reduce the usefulness of the call graph.
172 If you wish to perform line-by-line profiling, you will also need to
173 specify the `-g' option, instructing the compiler to insert debugging
174 symbols into the program that match program addresses to source code
175 lines. *Note Line-by-line::.
177 In addition to the `-pg' and `-g' options, older versions of GCC
178 required you to specify the `-a' option when compiling in order to
179 instrument it to perform basic-block counting. Newer versions do not
180 require this option and will not accept it; basic-block counting is
181 always enabled when `-pg' is on.
183 When basic-block counting is enabled, as the program runs it will
184 count how many times it executed each branch of each `if' statement,
185 each iteration of each `do' loop, etc. This will enable `gprof' to
186 construct an annotated source code listing showing how many times each
187 line of code was executed.
189 It also worth noting that GCC supports a different profiling method
190 which is enabled by the `-fprofile-arcs', `-ftest-coverage' and
191 `-fprofile-values' switches. These switches do not produce data which
192 is useful to `gprof' however, so they are not discussed further here.
193 There is also the `-finstrument-functions' switch which will cause GCC
194 to insert calls to special user supplied instrumentation routines at
195 the entry and exit of every function in their program. This can be
196 used to implement an alternative profiling scheme.
199 File: gprof.info, Node: Executing, Next: Invoking, Prev: Compiling, Up: Top
201 Executing the Program
202 *********************
204 Once the program is compiled for profiling, you must run it in order to
205 generate the information that `gprof' needs. Simply run the program as
206 usual, using the normal arguments, file names, etc. The program should
207 run normally, producing the same output as usual. It will, however, run
208 somewhat slower than normal because of the time spent collecting and the
209 writing the profile data.
211 The way you run the program--the arguments and input that you give
212 it--may have a dramatic effect on what the profile information shows.
213 The profile data will describe the parts of the program that were
214 activated for the particular input you use. For example, if the first
215 command you give to your program is to quit, the profile data will show
216 the time used in initialization and in cleanup, but not much else.
218 Your program will write the profile data into a file called
219 `gmon.out' just before exiting. If there is already a file called
220 `gmon.out', its contents are overwritten. There is currently no way to
221 tell the program to write the profile data under a different name, but
222 you can rename the file afterwards if you are concerned that it may be
225 In order to write the `gmon.out' file properly, your program must
226 exit normally: by returning from `main' or by calling `exit'. Calling
227 the low-level function `_exit' does not write the profile data, and
228 neither does abnormal termination due to an unhandled signal.
230 The `gmon.out' file is written in the program's _current working
231 directory_ at the time it exits. This means that if your program calls
232 `chdir', the `gmon.out' file will be left in the last directory your
233 program `chdir''d to. If you don't have permission to write in this
234 directory, the file is not written, and you will get an error message.
236 Older versions of the GNU profiling library may also write a file
237 called `bb.out'. This file, if present, contains an human-readable
238 listing of the basic-block execution counts. Unfortunately, the
239 appearance of a human-readable `bb.out' means the basic-block counts
240 didn't get written into `gmon.out'. The Perl script `bbconv.pl',
241 included with the `gprof' source distribution, will convert a `bb.out'
242 file into a format readable by `gprof'. Invoke it like this:
244 bbconv.pl < bb.out > BH-DATA
246 This translates the information in `bb.out' into a form that `gprof'
247 can understand. But you still need to tell `gprof' about the existence
248 of this translated information. To do that, include BB-DATA on the
249 `gprof' command line, _along with `gmon.out'_, like this:
251 gprof OPTIONS EXECUTABLE-FILE gmon.out BB-DATA [YET-MORE-PROFILE-DATA-FILES...] [> OUTFILE]
254 File: gprof.info, Node: Invoking, Next: Output, Prev: Executing, Up: Top
256 `gprof' Command Summary
257 ***********************
259 After you have a profile data file `gmon.out', you can run `gprof' to
260 interpret the information in it. The `gprof' program prints a flat
261 profile and a call graph on standard output. Typically you would
262 redirect the output of `gprof' into a file with `>'.
264 You run `gprof' like this:
266 gprof OPTIONS [EXECUTABLE-FILE [PROFILE-DATA-FILES...]] [> OUTFILE]
268 Here square-brackets indicate optional arguments.
270 If you omit the executable file name, the file `a.out' is used. If
271 you give no profile data file name, the file `gmon.out' is used. If
272 any file is not in the proper format, or if the profile data file does
273 not appear to belong to the executable file, an error message is
276 You can give more than one profile data file by entering all their
277 names after the executable file name; then the statistics in all the
278 data files are summed together.
280 The order of these options does not matter.
284 * Output Options:: Controlling `gprof''s output style
285 * Analysis Options:: Controlling how `gprof' analyses its data
286 * Miscellaneous Options::
287 * Deprecated Options:: Options you no longer need to use, but which
288 have been retained for compatibility
289 * Symspecs:: Specifying functions to include or exclude
292 File: gprof.info, Node: Output Options, Next: Analysis Options, Up: Invoking
297 These options specify which of several output formats `gprof' should
300 Many of these options take an optional "symspec" to specify
301 functions to be included or excluded. These options can be specified
302 multiple times, with different symspecs, to include or exclude sets of
303 symbols. *Note Symspecs::.
305 Specifying any of these options overrides the default (`-p -q'),
306 which prints a flat profile and call graph analysis for all functions.
309 `--annotated-source[=SYMSPEC]'
310 The `-A' option causes `gprof' to print annotated source code. If
311 SYMSPEC is specified, print output only for matching symbols.
312 *Note Annotated Source::.
316 If the `-b' option is given, `gprof' doesn't print the verbose
317 blurbs that try to explain the meaning of all of the fields in the
318 tables. This is useful if you intend to print out the output, or
319 are tired of seeing the blurbs.
322 `--exec-counts[=SYMSPEC]'
323 The `-C' option causes `gprof' to print a tally of functions and
324 the number of times each was called. If SYMSPEC is specified,
325 print tally only for matching symbols.
327 If the profile data file contains basic-block count records,
328 specifying the `-l' option, along with `-C', will cause basic-block
329 execution counts to be tallied and displayed.
333 The `-i' option causes `gprof' to display summary information
334 about the profile data file(s) and then exit. The number of
335 histogram, call graph, and basic-block count records is displayed.
338 `--directory-path=DIRS'
339 The `-I' option specifies a list of search directories in which to
340 find source files. Environment variable GPROF_PATH can also be
341 used to convey this information. Used mostly for annotated source
345 `--no-annotated-source[=SYMSPEC]'
346 The `-J' option causes `gprof' not to print annotated source code.
347 If SYMSPEC is specified, `gprof' prints annotated source, but
348 excludes matching symbols.
352 Normally, source filenames are printed with the path component
353 suppressed. The `-L' option causes `gprof' to print the full
354 pathname of source filenames, which is determined from symbolic
355 debugging information in the image file and is relative to the
356 directory in which the compiler was invoked.
359 `--flat-profile[=SYMSPEC]'
360 The `-p' option causes `gprof' to print a flat profile. If
361 SYMSPEC is specified, print flat profile only for matching symbols.
362 *Note Flat Profile::.
365 `--no-flat-profile[=SYMSPEC]'
366 The `-P' option causes `gprof' to suppress printing a flat profile.
367 If SYMSPEC is specified, `gprof' prints a flat profile, but
368 excludes matching symbols.
372 The `-q' option causes `gprof' to print the call graph analysis.
373 If SYMSPEC is specified, print call graph only for matching symbols
374 and their children. *Note Call Graph::.
377 `--no-graph[=SYMSPEC]'
378 The `-Q' option causes `gprof' to suppress printing the call graph.
379 If SYMSPEC is specified, `gprof' prints a call graph, but excludes
384 This option affects annotated source output only. Normally,
385 `gprof' prints annotated source files to standard-output. If this
386 option is specified, annotated source for a file named
387 `path/FILENAME' is generated in the file `FILENAME-ann'. If the
388 underlying filesystem would truncate `FILENAME-ann' so that it
389 overwrites the original `FILENAME', `gprof' generates annotated
390 source in the file `FILENAME.ann' instead (if the original file
391 name has an extension, that extension is _replaced_ with `.ann').
394 `--no-exec-counts[=SYMSPEC]'
395 The `-Z' option causes `gprof' not to print a tally of functions
396 and the number of times each was called. If SYMSPEC is specified,
397 print tally, but exclude matching symbols.
399 `--function-ordering'
400 The `--function-ordering' option causes `gprof' to print a
401 suggested function ordering for the program based on profiling
402 data. This option suggests an ordering which may improve paging,
403 tlb and cache behavior for the program on systems which support
404 arbitrary ordering of functions in an executable.
406 The exact details of how to force the linker to place functions in
407 a particular order is system dependent and out of the scope of this
410 `--file-ordering MAP_FILE'
411 The `--file-ordering' option causes `gprof' to print a suggested
412 .o link line ordering for the program based on profiling data.
413 This option suggests an ordering which may improve paging, tlb and
414 cache behavior for the program on systems which do not support
415 arbitrary ordering of functions in an executable.
417 Use of the `-a' argument is highly recommended with this option.
419 The MAP_FILE argument is a pathname to a file which provides
420 function name to object file mappings. The format of the file is
421 similar to the output of the program `nm'.
423 c-parse.o:00000000 T yyparse
424 c-parse.o:00000004 C yyerrflag
425 c-lang.o:00000000 T maybe_objc_method_name
426 c-lang.o:00000000 T print_lang_statistics
427 c-lang.o:00000000 T recognize_objc_keyword
428 c-decl.o:00000000 T print_lang_identifier
429 c-decl.o:00000000 T print_lang_type
432 To create a MAP_FILE with GNU `nm', type a command like `nm
433 --extern-only --defined-only -v --print-file-name program-name'.
437 The `-T' option causes `gprof' to print its output in
438 "traditional" BSD style.
442 Sets width of output lines to WIDTH. Currently only used when
443 printing the function index at the bottom of the call graph.
447 This option affects annotated source output only. By default,
448 only the lines at the beginning of a basic-block are annotated.
449 If this option is specified, every line in a basic-block is
450 annotated by repeating the annotation for the first line. This
451 behavior is similar to `tcov''s `-a'.
455 These options control whether C++ symbol names should be demangled
456 when printing output. The default is to demangle symbols. The
457 `--no-demangle' option may be used to turn off demangling.
458 Different compilers have different mangling styles. The optional
459 demangling style argument can be used to choose an appropriate
460 demangling style for your compiler.
463 File: gprof.info, Node: Analysis Options, Next: Miscellaneous Options, Prev: Output Options, Up: Invoking
470 The `-a' option causes `gprof' to suppress the printing of
471 statically declared (private) functions. (These are functions
472 whose names are not listed as global, and which are not visible
473 outside the file/function/block where they were defined.) Time
474 spent in these functions, calls to/from them, etc, will all be
475 attributed to the function that was loaded directly before it in
476 the executable file. This option affects both the flat profile
480 `--static-call-graph'
481 The `-c' option causes the call graph of the program to be
482 augmented by a heuristic which examines the text space of the
483 object file and identifies function calls in the binary machine
484 code. Since normal call graph records are only generated when
485 functions are entered, this option identifies children that could
486 have been called, but never were. Calls to functions that were
487 not compiled with profiling enabled are also identified, but only
488 if symbol table entries are present for them. Calls to dynamic
489 library routines are typically _not_ found by this option.
490 Parents or children identified via this heuristic are indicated in
491 the call graph with call counts of `0'.
494 `--ignore-non-functions'
495 The `-D' option causes `gprof' to ignore symbols which are not
496 known to be functions. This option will give more accurate
497 profile data on systems where it is supported (Solaris and HPUX for
501 The `-k' option allows you to delete from the call graph any arcs
502 from symbols matching symspec FROM to those matching symspec TO.
506 The `-l' option enables line-by-line profiling, which causes
507 histogram hits to be charged to individual source code lines,
508 instead of functions. If the program was compiled with
509 basic-block counting enabled, this option will also identify how
510 many times each line of code was executed. While line-by-line
511 profiling can help isolate where in a large function a program is
512 spending its time, it also significantly increases the running
513 time of `gprof', and magnifies statistical inaccuracies. *Note
518 This option affects execution count output only. Symbols that are
519 executed less than NUM times are suppressed.
523 The `-n' option causes `gprof', in its call graph analysis, to
524 only propagate times for symbols matching SYMSPEC.
527 `--no-time[=SYMSPEC]'
528 The `-n' option causes `gprof', in its call graph analysis, not to
529 propagate times for symbols matching SYMSPEC.
532 `--display-unused-functions'
533 If you give the `-z' option, `gprof' will mention all functions in
534 the flat profile, even those that were never called, and that had
535 no time spent in them. This is useful in conjunction with the
536 `-c' option for discovering which routines were never called.
540 File: gprof.info, Node: Miscellaneous Options, Next: Deprecated Options, Prev: Analysis Options, Up: Invoking
542 Miscellaneous Options
543 =====================
547 The `-d NUM' option specifies debugging options. If NUM is not
548 specified, enable all debugging. *Note Debugging::.
552 Selects the format of the profile data files. Recognized formats
553 are `auto' (the default), `bsd', `4.4bsd', `magic', and `prof'
558 The `-s' option causes `gprof' to summarize the information in the
559 profile data files it read in, and write out a profile data file
560 called `gmon.sum', which contains all the information from the
561 profile data files that `gprof' read in. The file `gmon.sum' may
562 be one of the specified input files; the effect of this is to
563 merge the data in the other input files into `gmon.sum'.
565 Eventually you can run `gprof' again without `-s' to analyze the
566 cumulative data in the file `gmon.sum'.
570 The `-v' flag causes `gprof' to print the current version number,
575 File: gprof.info, Node: Deprecated Options, Next: Symspecs, Prev: Miscellaneous Options, Up: Invoking
580 These options have been replaced with newer versions that use
584 The `-e FUNCTION' option tells `gprof' to not print information
585 about the function FUNCTION_NAME (and its children...) in the call
586 graph. The function will still be listed as a child of any
587 functions that call it, but its index number will be shown as
588 `[not printed]'. More than one `-e' option may be given; only one
589 FUNCTION_NAME may be indicated with each `-e' option.
592 The `-E FUNCTION' option works like the `-e' option, but time
593 spent in the function (and children who were not called from
594 anywhere else), will not be used to compute the
595 percentages-of-time for the call graph. More than one `-E' option
596 may be given; only one FUNCTION_NAME may be indicated with each
600 The `-f FUNCTION' option causes `gprof' to limit the call graph to
601 the function FUNCTION_NAME and its children (and their
602 children...). More than one `-f' option may be given; only one
603 FUNCTION_NAME may be indicated with each `-f' option.
606 The `-F FUNCTION' option works like the `-f' option, but only time
607 spent in the function and its children (and their children...)
608 will be used to determine total-time and percentages-of-time for
609 the call graph. More than one `-F' option may be given; only one
610 FUNCTION_NAME may be indicated with each `-F' option. The `-F'
611 option overrides the `-E' option.
614 Note that only one function can be specified with each `-e', `-E',
615 `-f' or `-F' option. To specify more than one function, use multiple
616 options. For example, this command:
618 gprof -e boring -f foo -f bar myprogram > gprof.output
620 lists in the call graph all functions that were reached from either
621 `foo' or `bar' and were not reachable from `boring'.
624 File: gprof.info, Node: Symspecs, Prev: Deprecated Options, Up: Invoking
629 Many of the output options allow functions to be included or excluded
630 using "symspecs" (symbol specifications), which observe the following
633 filename_containing_a_dot
634 | funcname_not_containing_a_dot
636 | ( [ any_filename ] `:' ( any_funcname | linenumber ) )
638 Here are some sample symspecs:
641 Selects everything in file `main.c'--the dot in the string tells
642 `gprof' to interpret the string as a filename, rather than as a
643 function name. To select a file whose name does not contain a
644 dot, a trailing colon should be specified. For example, `odd:' is
645 interpreted as the file named `odd'.
648 Selects all functions named `main'.
650 Note that there may be multiple instances of the same function name
651 because some of the definitions may be local (i.e., static).
652 Unless a function name is unique in a program, you must use the
653 colon notation explained below to specify a function from a
654 specific source file.
656 Sometimes, function names contain dots. In such cases, it is
657 necessary to add a leading colon to the name. For example,
658 `:.mul' selects function `.mul'.
660 In some object file formats, symbols have a leading underscore.
661 `gprof' will normally not print these underscores. When you name a
662 symbol in a symspec, you should type it exactly as `gprof' prints
663 it in its output. For example, if the compiler produces a symbol
664 `_main' from your `main' function, `gprof' still prints it as
665 `main' in its output, so you should use `main' in symspecs.
668 Selects function `main' in file `main.c'.
671 Selects line 134 in file `main.c'.
674 File: gprof.info, Node: Output, Next: Inaccuracy, Prev: Invoking, Up: Top
676 Interpreting `gprof''s Output
677 *****************************
679 `gprof' can produce several different output styles, the most important
680 of which are described below. The simplest output styles (file
681 information, execution count, and function and file ordering) are not
682 described here, but are documented with the respective options that
683 trigger them. *Note Output Options::.
687 * Flat Profile:: The flat profile shows how much time was spent
688 executing directly in each function.
689 * Call Graph:: The call graph shows which functions called which
690 others, and how much time each function used
691 when its subroutine calls are included.
692 * Line-by-line:: `gprof' can analyze individual source code lines
693 * Annotated Source:: The annotated source listing displays source code
694 labeled with execution counts
697 File: gprof.info, Node: Flat Profile, Next: Call Graph, Up: Output
702 The "flat profile" shows the total amount of time your program spent
703 executing each function. Unless the `-z' option is given, functions
704 with no apparent time spent in them, and no apparent calls to them, are
705 not mentioned. Note that if a function was not compiled for profiling,
706 and didn't run long enough to show up on the program counter histogram,
707 it will be indistinguishable from a function that was never called.
709 This is part of a flat profile for a small program:
713 Each sample counts as 0.01 seconds.
714 % cumulative self self total
715 time seconds seconds calls ms/call ms/call name
716 33.34 0.02 0.02 7208 0.00 0.00 open
717 16.67 0.03 0.01 244 0.04 0.12 offtime
718 16.67 0.04 0.01 8 1.25 1.25 memccpy
719 16.67 0.05 0.01 7 1.43 1.43 write
720 16.67 0.06 0.01 mcount
721 0.00 0.06 0.00 236 0.00 0.00 tzset
722 0.00 0.06 0.00 192 0.00 0.00 tolower
723 0.00 0.06 0.00 47 0.00 0.00 strlen
724 0.00 0.06 0.00 45 0.00 0.00 strchr
725 0.00 0.06 0.00 1 0.00 50.00 main
726 0.00 0.06 0.00 1 0.00 0.00 memcpy
727 0.00 0.06 0.00 1 0.00 10.11 print
728 0.00 0.06 0.00 1 0.00 0.00 profil
729 0.00 0.06 0.00 1 0.00 50.00 report
732 The functions are sorted by first by decreasing run-time spent in them,
733 then by decreasing number of calls, then alphabetically by name. The
734 functions `mcount' and `profil' are part of the profiling apparatus and
735 appear in every flat profile; their time gives a measure of the amount
736 of overhead due to profiling.
738 Just before the column headers, a statement appears indicating how
739 much time each sample counted as. This "sampling period" estimates the
740 margin of error in each of the time figures. A time figure that is not
741 much larger than this is not reliable. In this example, each sample
742 counted as 0.01 seconds, suggesting a 100 Hz sampling rate. The
743 program's total execution time was 0.06 seconds, as indicated by the
744 `cumulative seconds' field. Since each sample counted for 0.01
745 seconds, this means only six samples were taken during the run. Two of
746 the samples occurred while the program was in the `open' function, as
747 indicated by the `self seconds' field. Each of the other four samples
748 occurred one each in `offtime', `memccpy', `write', and `mcount'.
749 Since only six samples were taken, none of these values can be regarded
750 as particularly reliable. In another run, the `self seconds' field for
751 `mcount' might well be `0.00' or `0.02'. *Note Sampling Error::, for a
754 The remaining functions in the listing (those whose `self seconds'
755 field is `0.00') didn't appear in the histogram samples at all.
756 However, the call graph indicated that they were called, so therefore
757 they are listed, sorted in decreasing order by the `calls' field.
758 Clearly some time was spent executing these functions, but the paucity
759 of histogram samples prevents any determination of how much time each
762 Here is what the fields in each line mean:
765 This is the percentage of the total execution time your program
766 spent in this function. These should all add up to 100%.
769 This is the cumulative total number of seconds the computer spent
770 executing this functions, plus the time spent in all the functions
771 above this one in this table.
774 This is the number of seconds accounted for by this function alone.
775 The flat profile listing is sorted first by this number.
778 This is the total number of times the function was called. If the
779 function was never called, or the number of times it was called
780 cannot be determined (probably because the function was not
781 compiled with profiling enabled), the "calls" field is blank.
784 This represents the average number of milliseconds spent in this
785 function per call, if this function is profiled. Otherwise, this
786 field is blank for this function.
789 This represents the average number of milliseconds spent in this
790 function and its descendants per call, if this function is
791 profiled. Otherwise, this field is blank for this function. This
792 is the only field in the flat profile that uses call graph
796 This is the name of the function. The flat profile is sorted by
797 this field alphabetically after the "self seconds" and "calls"
801 File: gprof.info, Node: Call Graph, Next: Line-by-line, Prev: Flat Profile, Up: Output
806 The "call graph" shows how much time was spent in each function and its
807 children. From this information, you can find functions that, while
808 they themselves may not have used much time, called other functions
809 that did use unusual amounts of time.
811 Here is a sample call from a small program. This call came from the
812 same `gprof' run as the flat profile example in the previous chapter.
814 granularity: each sample hit covers 2 byte(s) for 20.00% of 0.05 seconds
816 index % time self children called name
818 [1] 100.0 0.00 0.05 start [1]
819 0.00 0.05 1/1 main [2]
820 0.00 0.00 1/2 on_exit [28]
821 0.00 0.00 1/1 exit [59]
822 -----------------------------------------------
823 0.00 0.05 1/1 start [1]
824 [2] 100.0 0.00 0.05 1 main [2]
825 0.00 0.05 1/1 report [3]
826 -----------------------------------------------
827 0.00 0.05 1/1 main [2]
828 [3] 100.0 0.00 0.05 1 report [3]
829 0.00 0.03 8/8 timelocal [6]
830 0.00 0.01 1/1 print [9]
831 0.00 0.01 9/9 fgets [12]
832 0.00 0.00 12/34 strncmp <cycle 1> [40]
833 0.00 0.00 8/8 lookup [20]
834 0.00 0.00 1/1 fopen [21]
835 0.00 0.00 8/8 chewtime [24]
836 0.00 0.00 8/16 skipspace [44]
837 -----------------------------------------------
838 [4] 59.8 0.01 0.02 8+472 <cycle 2 as a whole> [4]
839 0.01 0.02 244+260 offtime <cycle 2> [7]
840 0.00 0.00 236+1 tzset <cycle 2> [26]
841 -----------------------------------------------
843 The lines full of dashes divide this table into "entries", one for
844 each function. Each entry has one or more lines.
846 In each entry, the primary line is the one that starts with an index
847 number in square brackets. The end of this line says which function
848 the entry is for. The preceding lines in the entry describe the
849 callers of this function and the following lines describe its
850 subroutines (also called "children" when we speak of the call graph).
852 The entries are sorted by time spent in the function and its
855 The internal profiling function `mcount' (*note Flat Profile::) is
856 never mentioned in the call graph.
860 * Primary:: Details of the primary line's contents.
861 * Callers:: Details of caller-lines' contents.
862 * Subroutines:: Details of subroutine-lines' contents.
863 * Cycles:: When there are cycles of recursion,
864 such as `a' calls `b' calls `a'...
867 File: gprof.info, Node: Primary, Next: Callers, Up: Call Graph
872 The "primary line" in a call graph entry is the line that describes the
873 function which the entry is about and gives the overall statistics for
876 For reference, we repeat the primary line from the entry for function
877 `report' in our main example, together with the heading line that shows
878 the names of the fields:
880 index % time self children called name
882 [3] 100.0 0.00 0.05 1 report [3]
884 Here is what the fields in the primary line mean:
887 Entries are numbered with consecutive integers. Each function
888 therefore has an index number, which appears at the beginning of
891 Each cross-reference to a function, as a caller or subroutine of
892 another, gives its index number as well as its name. The index
893 number guides you if you wish to look for the entry for that
897 This is the percentage of the total time that was spent in this
898 function, including time spent in subroutines called from this
901 The time spent in this function is counted again for the callers of
902 this function. Therefore, adding up these percentages is
906 This is the total amount of time spent in this function. This
907 should be identical to the number printed in the `seconds' field
908 for this function in the flat profile.
911 This is the total amount of time spent in the subroutine calls
912 made by this function. This should be equal to the sum of all the
913 `self' and `children' entries of the children listed directly
917 This is the number of times the function was called.
919 If the function called itself recursively, there are two numbers,
920 separated by a `+'. The first number counts non-recursive calls,
921 and the second counts recursive calls.
923 In the example above, the function `report' was called once from
927 This is the name of the current function. The index number is
930 If the function is part of a cycle of recursion, the cycle number
931 is printed between the function's name and the index number (*note
932 Cycles::). For example, if function `gnurr' is part of cycle
933 number one, and has index number twelve, its primary line would be
939 File: gprof.info, Node: Callers, Next: Subroutines, Prev: Primary, Up: Call Graph
941 Lines for a Function's Callers
942 ------------------------------
944 A function's entry has a line for each function it was called by.
945 These lines' fields correspond to the fields of the primary line, but
946 their meanings are different because of the difference in context.
948 For reference, we repeat two lines from the entry for the function
949 `report', the primary line and one caller-line preceding it, together
950 with the heading line that shows the names of the fields:
952 index % time self children called name
954 0.00 0.05 1/1 main [2]
955 [3] 100.0 0.00 0.05 1 report [3]
957 Here are the meanings of the fields in the caller-line for `report'
961 An estimate of the amount of time spent in `report' itself when it
962 was called from `main'.
965 An estimate of the amount of time spent in subroutines of `report'
966 when `report' was called from `main'.
968 The sum of the `self' and `children' fields is an estimate of the
969 amount of time spent within calls to `report' from `main'.
972 Two numbers: the number of times `report' was called from `main',
973 followed by the total number of non-recursive calls to `report'
974 from all its callers.
976 `name and index number'
977 The name of the caller of `report' to which this line applies,
978 followed by the caller's index number.
980 Not all functions have entries in the call graph; some options to
981 `gprof' request the omission of certain functions. When a caller
982 has no entry of its own, it still has caller-lines in the entries
983 of the functions it calls.
985 If the caller is part of a recursion cycle, the cycle number is
986 printed between the name and the index number.
988 If the identity of the callers of a function cannot be determined, a
989 dummy caller-line is printed which has `<spontaneous>' as the "caller's
990 name" and all other fields blank. This can happen for signal handlers.
993 File: gprof.info, Node: Subroutines, Next: Cycles, Prev: Callers, Up: Call Graph
995 Lines for a Function's Subroutines
996 ----------------------------------
998 A function's entry has a line for each of its subroutines--in other
999 words, a line for each other function that it called. These lines'
1000 fields correspond to the fields of the primary line, but their meanings
1001 are different because of the difference in context.
1003 For reference, we repeat two lines from the entry for the function
1004 `main', the primary line and a line for a subroutine, together with the
1005 heading line that shows the names of the fields:
1007 index % time self children called name
1009 [2] 100.0 0.00 0.05 1 main [2]
1010 0.00 0.05 1/1 report [3]
1012 Here are the meanings of the fields in the subroutine-line for `main'
1016 An estimate of the amount of time spent directly within `report'
1017 when `report' was called from `main'.
1020 An estimate of the amount of time spent in subroutines of `report'
1021 when `report' was called from `main'.
1023 The sum of the `self' and `children' fields is an estimate of the
1024 total time spent in calls to `report' from `main'.
1027 Two numbers, the number of calls to `report' from `main' followed
1028 by the total number of non-recursive calls to `report'. This
1029 ratio is used to determine how much of `report''s `self' and
1030 `children' time gets credited to `main'. *Note Assumptions::.
1033 The name of the subroutine of `main' to which this line applies,
1034 followed by the subroutine's index number.
1036 If the caller is part of a recursion cycle, the cycle number is
1037 printed between the name and the index number.
1040 File: gprof.info, Node: Cycles, Prev: Subroutines, Up: Call Graph
1042 How Mutually Recursive Functions Are Described
1043 ----------------------------------------------
1045 The graph may be complicated by the presence of "cycles of recursion"
1046 in the call graph. A cycle exists if a function calls another function
1047 that (directly or indirectly) calls (or appears to call) the original
1048 function. For example: if `a' calls `b', and `b' calls `a', then `a'
1049 and `b' form a cycle.
1051 Whenever there are call paths both ways between a pair of functions,
1052 they belong to the same cycle. If `a' and `b' call each other and `b'
1053 and `c' call each other, all three make one cycle. Note that even if
1054 `b' only calls `a' if it was not called from `a', `gprof' cannot
1055 determine this, so `a' and `b' are still considered a cycle.
1057 The cycles are numbered with consecutive integers. When a function
1058 belongs to a cycle, each time the function name appears in the call
1059 graph it is followed by `<cycle NUMBER>'.
1061 The reason cycles matter is that they make the time values in the
1062 call graph paradoxical. The "time spent in children" of `a' should
1063 include the time spent in its subroutine `b' and in `b''s
1064 subroutines--but one of `b''s subroutines is `a'! How much of `a''s
1065 time should be included in the children of `a', when `a' is indirectly
1068 The way `gprof' resolves this paradox is by creating a single entry
1069 for the cycle as a whole. The primary line of this entry describes the
1070 total time spent directly in the functions of the cycle. The
1071 "subroutines" of the cycle are the individual functions of the cycle,
1072 and all other functions that were called directly by them. The
1073 "callers" of the cycle are the functions, outside the cycle, that
1074 called functions in the cycle.
1076 Here is an example portion of a call graph which shows a cycle
1077 containing functions `a' and `b'. The cycle was entered by a call to
1078 `a' from `main'; both `a' and `b' called `c'.
1080 index % time self children called name
1081 ----------------------------------------
1083 [3] 91.71 1.77 0 1+5 <cycle 1 as a whole> [3]
1084 1.02 0 3 b <cycle 1> [4]
1085 0.75 0 2 a <cycle 1> [5]
1086 ----------------------------------------
1088 [4] 52.85 1.02 0 0 b <cycle 1> [4]
1091 ----------------------------------------
1094 [5] 38.86 0.75 0 1 a <cycle 1> [5]
1097 ----------------------------------------
1099 (The entire call graph for this program contains in addition an entry
1100 for `main', which calls `a', and an entry for `c', with callers `a' and
1103 index % time self children called name
1105 [1] 100.00 0 1.93 0 start [1]
1106 0.16 1.77 1/1 main [2]
1107 ----------------------------------------
1108 0.16 1.77 1/1 start [1]
1109 [2] 100.00 0.16 1.77 1 main [2]
1110 1.77 0 1/1 a <cycle 1> [5]
1111 ----------------------------------------
1113 [3] 91.71 1.77 0 1+5 <cycle 1 as a whole> [3]
1114 1.02 0 3 b <cycle 1> [4]
1115 0.75 0 2 a <cycle 1> [5]
1117 ----------------------------------------
1119 [4] 52.85 1.02 0 0 b <cycle 1> [4]
1122 ----------------------------------------
1125 [5] 38.86 0.75 0 1 a <cycle 1> [5]
1128 ----------------------------------------
1129 0 0 3/6 b <cycle 1> [4]
1130 0 0 3/6 a <cycle 1> [5]
1131 [6] 0.00 0 0 6 c [6]
1132 ----------------------------------------
1134 The `self' field of the cycle's primary line is the total time spent
1135 in all the functions of the cycle. It equals the sum of the `self'
1136 fields for the individual functions in the cycle, found in the entry in
1137 the subroutine lines for these functions.
1139 The `children' fields of the cycle's primary line and subroutine
1140 lines count only subroutines outside the cycle. Even though `a' calls
1141 `b', the time spent in those calls to `b' is not counted in `a''s
1142 `children' time. Thus, we do not encounter the problem of what to do
1143 when the time in those calls to `b' includes indirect recursive calls
1146 The `children' field of a caller-line in the cycle's entry estimates
1147 the amount of time spent _in the whole cycle_, and its other
1148 subroutines, on the times when that caller called a function in the
1151 The `calls' field in the primary line for the cycle has two numbers:
1152 first, the number of times functions in the cycle were called by
1153 functions outside the cycle; second, the number of times they were
1154 called by functions in the cycle (including times when a function in
1155 the cycle calls itself). This is a generalization of the usual split
1156 into non-recursive and recursive calls.
1158 The `calls' field of a subroutine-line for a cycle member in the
1159 cycle's entry says how many time that function was called from
1160 functions in the cycle. The total of all these is the second number in
1161 the primary line's `calls' field.
1163 In the individual entry for a function in a cycle, the other
1164 functions in the same cycle can appear as subroutines and as callers.
1165 These lines show how many times each function in the cycle called or
1166 was called from each other function in the cycle. The `self' and
1167 `children' fields in these lines are blank because of the difficulty of
1168 defining meanings for them when recursion is going on.
1171 File: gprof.info, Node: Line-by-line, Next: Annotated Source, Prev: Call Graph, Up: Output
1173 Line-by-line Profiling
1174 ======================
1176 `gprof''s `-l' option causes the program to perform "line-by-line"
1177 profiling. In this mode, histogram samples are assigned not to
1178 functions, but to individual lines of source code. The program usually
1179 must be compiled with a `-g' option, in addition to `-pg', in order to
1180 generate debugging symbols for tracking source code lines.
1182 The flat profile is the most useful output table in line-by-line
1183 mode. The call graph isn't as useful as normal, since the current
1184 version of `gprof' does not propagate call graph arcs from source code
1185 lines to the enclosing function. The call graph does, however, show
1186 each line of code that called each function, along with a count.
1188 Here is a section of `gprof''s output, without line-by-line
1189 profiling. Note that `ct_init' accounted for four histogram hits, and
1190 13327 calls to `init_block'.
1194 Each sample counts as 0.01 seconds.
1195 % cumulative self self total
1196 time seconds seconds calls us/call us/call name
1197 30.77 0.13 0.04 6335 6.31 6.31 ct_init
1200 Call graph (explanation follows)
1203 granularity: each sample hit covers 4 byte(s) for 7.69% of 0.13 seconds
1205 index % time self children called name
1207 0.00 0.00 1/13496 name_too_long
1208 0.00 0.00 40/13496 deflate
1209 0.00 0.00 128/13496 deflate_fast
1210 0.00 0.00 13327/13496 ct_init
1211 [7] 0.0 0.00 0.00 13496 init_block
1213 Now let's look at some of `gprof''s output from the same program run,
1214 this time with line-by-line profiling enabled. Note that `ct_init''s
1215 four histogram hits are broken down into four lines of source code -
1216 one hit occurred on each of lines 349, 351, 382 and 385. In the call
1217 graph, note how `ct_init''s 13327 calls to `init_block' are broken down
1218 into one call from line 396, 3071 calls from line 384, 3730 calls from
1219 line 385, and 6525 calls from 387.
1223 Each sample counts as 0.01 seconds.
1225 time seconds seconds calls name
1226 7.69 0.10 0.01 ct_init (trees.c:349)
1227 7.69 0.11 0.01 ct_init (trees.c:351)
1228 7.69 0.12 0.01 ct_init (trees.c:382)
1229 7.69 0.13 0.01 ct_init (trees.c:385)
1232 Call graph (explanation follows)
1235 granularity: each sample hit covers 4 byte(s) for 7.69% of 0.13 seconds
1237 % time self children called name
1239 0.00 0.00 1/13496 name_too_long (gzip.c:1440)
1240 0.00 0.00 1/13496 deflate (deflate.c:763)
1241 0.00 0.00 1/13496 ct_init (trees.c:396)
1242 0.00 0.00 2/13496 deflate (deflate.c:727)
1243 0.00 0.00 4/13496 deflate (deflate.c:686)
1244 0.00 0.00 5/13496 deflate (deflate.c:675)
1245 0.00 0.00 12/13496 deflate (deflate.c:679)
1246 0.00 0.00 16/13496 deflate (deflate.c:730)
1247 0.00 0.00 128/13496 deflate_fast (deflate.c:654)
1248 0.00 0.00 3071/13496 ct_init (trees.c:384)
1249 0.00 0.00 3730/13496 ct_init (trees.c:385)
1250 0.00 0.00 6525/13496 ct_init (trees.c:387)
1251 [6] 0.0 0.00 0.00 13496 init_block (trees.c:408)
1254 File: gprof.info, Node: Annotated Source, Prev: Line-by-line, Up: Output
1256 The Annotated Source Listing
1257 ============================
1259 `gprof''s `-A' option triggers an annotated source listing, which lists
1260 the program's source code, each function labeled with the number of
1261 times it was called. You may also need to specify the `-I' option, if
1262 `gprof' can't find the source code files.
1264 Compiling with `gcc ... -g -pg -a' augments your program with
1265 basic-block counting code, in addition to function counting code. This
1266 enables `gprof' to determine how many times each line of code was
1267 executed. For example, consider the following function, taken from
1268 gzip, with line numbers added:
1276 7 static ulg crc = (ulg)0xffffffffL;
1283 14 c = crc_32_tab[...];
1287 18 return c ^ 0xffffffffL;
1290 `updcrc' has at least five basic-blocks. One is the function
1291 itself. The `if' statement on line 9 generates two more basic-blocks,
1292 one for each branch of the `if'. A fourth basic-block results from the
1293 `if' on line 13, and the contents of the `do' loop form the fifth
1294 basic-block. The compiler may also generate additional basic-blocks to
1295 handle various special cases.
1297 A program augmented for basic-block counting can be analyzed with
1298 `gprof -l -A'. I also suggest use of the `-x' option, which ensures
1299 that each line of code is labeled at least once. Here is `updcrc''s
1300 annotated source listing for a sample `gzip' run:
1308 static ulg crc = (ulg)0xffffffffL;
1310 2 -> if (s == NULL) {
1311 1 -> c = 0xffffffffL;
1315 26312 -> c = crc_32_tab[...];
1316 26312,1,26311 -> } while (--n);
1319 2 -> return c ^ 0xffffffffL;
1322 In this example, the function was called twice, passing once through
1323 each branch of the `if' statement. The body of the `do' loop was
1324 executed a total of 26312 times. Note how the `while' statement is
1325 annotated. It began execution 26312 times, once for each iteration
1326 through the loop. One of those times (the last time) it exited, while
1327 it branched back to the beginning of the loop 26311 times.
1330 File: gprof.info, Node: Inaccuracy, Next: How do I?, Prev: Output, Up: Top
1332 Inaccuracy of `gprof' Output
1333 ****************************
1337 * Sampling Error:: Statistical margins of error
1338 * Assumptions:: Estimating children times
1341 File: gprof.info, Node: Sampling Error, Next: Assumptions, Up: Inaccuracy
1343 Statistical Sampling Error
1344 ==========================
1346 The run-time figures that `gprof' gives you are based on a sampling
1347 process, so they are subject to statistical inaccuracy. If a function
1348 runs only a small amount of time, so that on the average the sampling
1349 process ought to catch that function in the act only once, there is a
1350 pretty good chance it will actually find that function zero times, or
1353 By contrast, the number-of-calls and basic-block figures are derived
1354 by counting, not sampling. They are completely accurate and will not
1355 vary from run to run if your program is deterministic.
1357 The "sampling period" that is printed at the beginning of the flat
1358 profile says how often samples are taken. The rule of thumb is that a
1359 run-time figure is accurate if it is considerably bigger than the
1362 The actual amount of error can be predicted. For N samples, the
1363 _expected_ error is the square-root of N. For example, if the sampling
1364 period is 0.01 seconds and `foo''s run-time is 1 second, N is 100
1365 samples (1 second/0.01 seconds), sqrt(N) is 10 samples, so the expected
1366 error in `foo''s run-time is 0.1 seconds (10*0.01 seconds), or ten
1367 percent of the observed value. Again, if the sampling period is 0.01
1368 seconds and `bar''s run-time is 100 seconds, N is 10000 samples,
1369 sqrt(N) is 100 samples, so the expected error in `bar''s run-time is 1
1370 second, or one percent of the observed value. It is likely to vary
1371 this much _on the average_ from one profiling run to the next.
1372 (_Sometimes_ it will vary more.)
1374 This does not mean that a small run-time figure is devoid of
1375 information. If the program's _total_ run-time is large, a small
1376 run-time for one function does tell you that that function used an
1377 insignificant fraction of the whole program's time. Usually this means
1378 it is not worth optimizing.
1380 One way to get more accuracy is to give your program more (but
1381 similar) input data so it will take longer. Another way is to combine
1382 the data from several runs, using the `-s' option of `gprof'. Here is
1385 1. Run your program once.
1387 2. Issue the command `mv gmon.out gmon.sum'.
1389 3. Run your program again, the same as before.
1391 4. Merge the new data in `gmon.out' into `gmon.sum' with this command:
1393 gprof -s EXECUTABLE-FILE gmon.out gmon.sum
1395 5. Repeat the last two steps as often as you wish.
1397 6. Analyze the cumulative data using this command:
1399 gprof EXECUTABLE-FILE gmon.sum > OUTPUT-FILE
1402 File: gprof.info, Node: Assumptions, Prev: Sampling Error, Up: Inaccuracy
1404 Estimating `children' Times
1405 ===========================
1407 Some of the figures in the call graph are estimates--for example, the
1408 `children' time values and all the time figures in caller and
1411 There is no direct information about these measurements in the
1412 profile data itself. Instead, `gprof' estimates them by making an
1413 assumption about your program that might or might not be true.
1415 The assumption made is that the average time spent in each call to
1416 any function `foo' is not correlated with who called `foo'. If `foo'
1417 used 5 seconds in all, and 2/5 of the calls to `foo' came from `a',
1418 then `foo' contributes 2 seconds to `a''s `children' time, by
1421 This assumption is usually true enough, but for some programs it is
1422 far from true. Suppose that `foo' returns very quickly when its
1423 argument is zero; suppose that `a' always passes zero as an argument,
1424 while other callers of `foo' pass other arguments. In this program,
1425 all the time spent in `foo' is in the calls from callers other than `a'.
1426 But `gprof' has no way of knowing this; it will blindly and incorrectly
1427 charge 2 seconds of time in `foo' to the children of `a'.
1429 We hope some day to put more complete data into `gmon.out', so that
1430 this assumption is no longer needed, if we can figure out how. For the
1431 nonce, the estimated figures are usually more useful than misleading.
1434 File: gprof.info, Node: How do I?, Next: Incompatibilities, Prev: Inaccuracy, Up: Top
1436 Answers to Common Questions
1437 ***************************
1439 How can I get more exact information about hot spots in my program?
1440 Looking at the per-line call counts only tells part of the story.
1441 Because `gprof' can only report call times and counts by function,
1442 the best way to get finer-grained information on where the program
1443 is spending its time is to re-factor large functions into sequences
1444 of calls to smaller ones. Beware however that this can introduce
1445 artifical hot spots since compiling with `-pg' adds a significant
1446 overhead to function calls. An alternative solution is to use a
1447 non-intrusive profiler, e.g. oprofile.
1449 How do I find which lines in my program were executed the most times?
1450 Compile your program with basic-block counting enabled, run it,
1451 then use the following pipeline:
1453 gprof -l -C OBJFILE | sort -k 3 -n -r
1455 This listing will show you the lines in your code executed most
1456 often, but not necessarily those that consumed the most time.
1458 How do I find which lines in my program called a particular function?
1459 Use `gprof -l' and lookup the function in the call graph. The
1460 callers will be broken down by function and line number.
1462 How do I analyze a program that runs for less than a second?
1463 Try using a shell script like this one:
1465 for i in `seq 1 100`; do
1467 mv gmon.out gmon.out.$i
1470 gprof -s fastprog gmon.out.*
1472 gprof fastprog gmon.sum
1474 If your program is completely deterministic, all the call counts
1475 will be simple multiples of 100 (i.e. a function called once in
1476 each run will appear with a call count of 100).
1480 File: gprof.info, Node: Incompatibilities, Next: Details, Prev: How do I?, Up: Top
1482 Incompatibilities with Unix `gprof'
1483 ***********************************
1485 GNU `gprof' and Berkeley Unix `gprof' use the same data file
1486 `gmon.out', and provide essentially the same information. But there
1487 are a few differences.
1489 * GNU `gprof' uses a new, generalized file format with support for
1490 basic-block execution counts and non-realtime histograms. A magic
1491 cookie and version number allows `gprof' to easily identify new
1492 style files. Old BSD-style files can still be read. *Note File
1495 * For a recursive function, Unix `gprof' lists the function as a
1496 parent and as a child, with a `calls' field that lists the number
1497 of recursive calls. GNU `gprof' omits these lines and puts the
1498 number of recursive calls in the primary line.
1500 * When a function is suppressed from the call graph with `-e', GNU
1501 `gprof' still lists it as a subroutine of functions that call it.
1503 * GNU `gprof' accepts the `-k' with its argument in the form
1504 `from/to', instead of `from to'.
1506 * In the annotated source listing, if there are multiple basic
1507 blocks on the same line, GNU `gprof' prints all of their counts,
1508 separated by commas.
1510 * The blurbs, field widths, and output formats are different. GNU
1511 `gprof' prints blurbs after the tables, so that you can see the
1512 tables without skipping the blurbs.
1515 File: gprof.info, Node: Details, Next: GNU Free Documentation License, Prev: Incompatibilities, Up: Top
1517 Details of Profiling
1518 ********************
1522 * Implementation:: How a program collects profiling information
1523 * File Format:: Format of `gmon.out' files
1524 * Internals:: `gprof''s internal operation
1525 * Debugging:: Using `gprof''s `-d' option
1528 File: gprof.info, Node: Implementation, Next: File Format, Up: Details
1530 Implementation of Profiling
1531 ===========================
1533 Profiling works by changing how every function in your program is
1534 compiled so that when it is called, it will stash away some information
1535 about where it was called from. From this, the profiler can figure out
1536 what function called it, and can count how many times it was called.
1537 This change is made by the compiler when your program is compiled with
1538 the `-pg' option, which causes every function to call `mcount' (or
1539 `_mcount', or `__mcount', depending on the OS and compiler) as one of
1540 its first operations.
1542 The `mcount' routine, included in the profiling library, is
1543 responsible for recording in an in-memory call graph table both its
1544 parent routine (the child) and its parent's parent. This is typically
1545 done by examining the stack frame to find both the address of the
1546 child, and the return address in the original parent. Since this is a
1547 very machine-dependent operation, `mcount' itself is typically a short
1548 assembly-language stub routine that extracts the required information,
1549 and then calls `__mcount_internal' (a normal C function) with two
1550 arguments - `frompc' and `selfpc'. `__mcount_internal' is responsible
1551 for maintaining the in-memory call graph, which records `frompc',
1552 `selfpc', and the number of times each of these call arcs was traversed.
1554 GCC Version 2 provides a magical function
1555 (`__builtin_return_address'), which allows a generic `mcount' function
1556 to extract the required information from the stack frame. However, on
1557 some architectures, most notably the SPARC, using this builtin can be
1558 very computationally expensive, and an assembly language version of
1559 `mcount' is used for performance reasons.
1561 Number-of-calls information for library routines is collected by
1562 using a special version of the C library. The programs in it are the
1563 same as in the usual C library, but they were compiled with `-pg'. If
1564 you link your program with `gcc ... -pg', it automatically uses the
1565 profiling version of the library.
1567 Profiling also involves watching your program as it runs, and
1568 keeping a histogram of where the program counter happens to be every
1569 now and then. Typically the program counter is looked at around 100
1570 times per second of run time, but the exact frequency may vary from
1573 This is done is one of two ways. Most UNIX-like operating systems
1574 provide a `profil()' system call, which registers a memory array with
1575 the kernel, along with a scale factor that determines how the program's
1576 address space maps into the array. Typical scaling values cause every
1577 2 to 8 bytes of address space to map into a single array slot. On
1578 every tick of the system clock (assuming the profiled program is
1579 running), the value of the program counter is examined and the
1580 corresponding slot in the memory array is incremented. Since this is
1581 done in the kernel, which had to interrupt the process anyway to handle
1582 the clock interrupt, very little additional system overhead is required.
1584 However, some operating systems, most notably Linux 2.0 (and
1585 earlier), do not provide a `profil()' system call. On such a system,
1586 arrangements are made for the kernel to periodically deliver a signal
1587 to the process (typically via `setitimer()'), which then performs the
1588 same operation of examining the program counter and incrementing a slot
1589 in the memory array. Since this method requires a signal to be
1590 delivered to user space every time a sample is taken, it uses
1591 considerably more overhead than kernel-based profiling. Also, due to
1592 the added delay required to deliver the signal, this method is less
1595 A special startup routine allocates memory for the histogram and
1596 either calls `profil()' or sets up a clock signal handler. This
1597 routine (`monstartup') can be invoked in several ways. On Linux
1598 systems, a special profiling startup file `gcrt0.o', which invokes
1599 `monstartup' before `main', is used instead of the default `crt0.o'.
1600 Use of this special startup file is one of the effects of using `gcc
1601 ... -pg' to link. On SPARC systems, no special startup files are used.
1602 Rather, the `mcount' routine, when it is invoked for the first time
1603 (typically when `main' is called), calls `monstartup'.
1605 If the compiler's `-a' option was used, basic-block counting is also
1606 enabled. Each object file is then compiled with a static array of
1607 counts, initially zero. In the executable code, every time a new
1608 basic-block begins (i.e. when an `if' statement appears), an extra
1609 instruction is inserted to increment the corresponding count in the
1610 array. At compile time, a paired array was constructed that recorded
1611 the starting address of each basic-block. Taken together, the two
1612 arrays record the starting address of every basic-block, along with the
1613 number of times it was executed.
1615 The profiling library also includes a function (`mcleanup') which is
1616 typically registered using `atexit()' to be called as the program
1617 exits, and is responsible for writing the file `gmon.out'. Profiling
1618 is turned off, various headers are output, and the histogram is
1619 written, followed by the call-graph arcs and the basic-block counts.
1621 The output from `gprof' gives no indication of parts of your program
1622 that are limited by I/O or swapping bandwidth. This is because samples
1623 of the program counter are taken at fixed intervals of the program's
1624 run time. Therefore, the time measurements in `gprof' output say
1625 nothing about time that your program was not running. For example, a
1626 part of the program that creates so much data that it cannot all fit in
1627 physical memory at once may run very slowly due to thrashing, but
1628 `gprof' will say it uses little time. On the other hand, sampling by
1629 run time has the advantage that the amount of load due to other users
1630 won't directly affect the output you get.
1633 File: gprof.info, Node: File Format, Next: Internals, Prev: Implementation, Up: Details
1635 Profiling Data File Format
1636 ==========================
1638 The old BSD-derived file format used for profile data does not contain a
1639 magic cookie that allows to check whether a data file really is a
1640 `gprof' file. Furthermore, it does not provide a version number, thus
1641 rendering changes to the file format almost impossible. GNU `gprof'
1642 uses a new file format that provides these features. For backward
1643 compatibility, GNU `gprof' continues to support the old BSD-derived
1644 format, but not all features are supported with it. For example,
1645 basic-block execution counts cannot be accommodated by the old file
1648 The new file format is defined in header file `gmon_out.h'. It
1649 consists of a header containing the magic cookie and a version number,
1650 as well as some spare bytes available for future extensions. All data
1651 in a profile data file is in the native format of the target for which
1652 the profile was collected. GNU `gprof' adapts automatically to the
1655 In the new file format, the header is followed by a sequence of
1656 records. Currently, there are three different record types: histogram
1657 records, call-graph arc records, and basic-block execution count
1658 records. Each file can contain any number of each record type. When
1659 reading a file, GNU `gprof' will ensure records of the same type are
1660 compatible with each other and compute the union of all records. For
1661 example, for basic-block execution counts, the union is simply the sum
1662 of all execution counts for each basic-block.
1667 Histogram records consist of a header that is followed by an array of
1668 bins. The header contains the text-segment range that the histogram
1669 spans, the size of the histogram in bytes (unlike in the old BSD
1670 format, this does not include the size of the header), the rate of the
1671 profiling clock, and the physical dimension that the bin counts
1672 represent after being scaled by the profiling clock rate. The physical
1673 dimension is specified in two parts: a long name of up to 15 characters
1674 and a single character abbreviation. For example, a histogram
1675 representing real-time would specify the long name as "seconds" and the
1676 abbreviation as "s". This feature is useful for architectures that
1677 support performance monitor hardware (which, fortunately, is becoming
1678 increasingly common). For example, under DEC OSF/1, the "uprofile"
1679 command can be used to produce a histogram of, say, instruction cache
1680 misses. In this case, the dimension in the histogram header could be
1681 set to "i-cache misses" and the abbreviation could be set to "1"
1682 (because it is simply a count, not a physical dimension). Also, the
1683 profiling rate would have to be set to 1 in this case.
1685 Histogram bins are 16-bit numbers and each bin represent an equal
1686 amount of text-space. For example, if the text-segment is one thousand
1687 bytes long and if there are ten bins in the histogram, each bin
1688 represents one hundred bytes.
1693 Call-graph records have a format that is identical to the one used in
1694 the BSD-derived file format. It consists of an arc in the call graph
1695 and a count indicating the number of times the arc was traversed during
1696 program execution. Arcs are specified by a pair of addresses: the
1697 first must be within caller's function and the second must be within
1698 the callee's function. When performing profiling at the function
1699 level, these addresses can point anywhere within the respective
1700 function. However, when profiling at the line-level, it is better if
1701 the addresses are as close to the call-site/entry-point as possible.
1702 This will ensure that the line-level call-graph is able to identify
1703 exactly which line of source code performed calls to a function.
1705 Basic-Block Execution Count Records
1706 -----------------------------------
1708 Basic-block execution count records consist of a header followed by a
1709 sequence of address/count pairs. The header simply specifies the
1710 length of the sequence. In an address/count pair, the address
1711 identifies a basic-block and the count specifies the number of times
1712 that basic-block was executed. Any address within the basic-address can
1716 File: gprof.info, Node: Internals, Next: Debugging, Prev: File Format, Up: Details
1718 `gprof''s Internal Operation
1719 ============================
1721 Like most programs, `gprof' begins by processing its options. During
1722 this stage, it may building its symspec list (`sym_ids.c:sym_id_add'),
1723 if options are specified which use symspecs. `gprof' maintains a
1724 single linked list of symspecs, which will eventually get turned into
1725 12 symbol tables, organized into six include/exclude pairs - one pair
1726 each for the flat profile (INCL_FLAT/EXCL_FLAT), the call graph arcs
1727 (INCL_ARCS/EXCL_ARCS), printing in the call graph
1728 (INCL_GRAPH/EXCL_GRAPH), timing propagation in the call graph
1729 (INCL_TIME/EXCL_TIME), the annotated source listing
1730 (INCL_ANNO/EXCL_ANNO), and the execution count listing
1731 (INCL_EXEC/EXCL_EXEC).
1733 After option processing, `gprof' finishes building the symspec list
1734 by adding all the symspecs in `default_excluded_list' to the exclude
1735 lists EXCL_TIME and EXCL_GRAPH, and if line-by-line profiling is
1736 specified, EXCL_FLAT as well. These default excludes are not added to
1737 EXCL_ANNO, EXCL_ARCS, and EXCL_EXEC.
1739 Next, the BFD library is called to open the object file, verify that
1740 it is an object file, and read its symbol table (`core.c:core_init'),
1741 using `bfd_canonicalize_symtab' after mallocing an appropriately sized
1742 array of symbols. At this point, function mappings are read (if the
1743 `--file-ordering' option has been specified), and the core text space
1744 is read into memory (if the `-c' option was given).
1746 `gprof''s own symbol table, an array of Sym structures, is now built.
1747 This is done in one of two ways, by one of two routines, depending on
1748 whether line-by-line profiling (`-l' option) has been enabled. For
1749 normal profiling, the BFD canonical symbol table is scanned. For
1750 line-by-line profiling, every text space address is examined, and a new
1751 symbol table entry gets created every time the line number changes. In
1752 either case, two passes are made through the symbol table - one to
1753 count the size of the symbol table required, and the other to actually
1754 read the symbols. In between the two passes, a single array of type
1755 `Sym' is created of the appropriate length. Finally,
1756 `symtab.c:symtab_finalize' is called to sort the symbol table and
1757 remove duplicate entries (entries with the same memory address).
1759 The symbol table must be a contiguous array for two reasons. First,
1760 the `qsort' library function (which sorts an array) will be used to
1761 sort the symbol table. Also, the symbol lookup routine
1762 (`symtab.c:sym_lookup'), which finds symbols based on memory address,
1763 uses a binary search algorithm which requires the symbol table to be a
1764 sorted array. Function symbols are indicated with an `is_func' flag.
1765 Line number symbols have no special flags set. Additionally, a symbol
1766 can have an `is_static' flag to indicate that it is a local symbol.
1768 With the symbol table read, the symspecs can now be translated into
1769 Syms (`sym_ids.c:sym_id_parse'). Remember that a single symspec can
1770 match multiple symbols. An array of symbol tables (`syms') is created,
1771 each entry of which is a symbol table of Syms to be included or
1772 excluded from a particular listing. The master symbol table and the
1773 symspecs are examined by nested loops, and every symbol that matches a
1774 symspec is inserted into the appropriate syms table. This is done
1775 twice, once to count the size of each required symbol table, and again
1776 to build the tables, which have been malloced between passes. From now
1777 on, to determine whether a symbol is on an include or exclude symspec
1778 list, `gprof' simply uses its standard symbol lookup routine on the
1779 appropriate table in the `syms' array.
1781 Now the profile data file(s) themselves are read
1782 (`gmon_io.c:gmon_out_read'), first by checking for a new-style
1783 `gmon.out' header, then assuming this is an old-style BSD `gmon.out' if
1784 the magic number test failed.
1786 New-style histogram records are read by `hist.c:hist_read_rec'. For
1787 the first histogram record, allocate a memory array to hold all the
1788 bins, and read them in. When multiple profile data files (or files
1789 with multiple histogram records) are read, the starting address, ending
1790 address, number of bins and sampling rate must match between the
1791 various histograms, or a fatal error will result. If everything
1792 matches, just sum the additional histograms into the existing in-memory
1795 As each call graph record is read (`call_graph.c:cg_read_rec'), the
1796 parent and child addresses are matched to symbol table entries, and a
1797 call graph arc is created by `cg_arcs.c:arc_add', unless the arc fails
1798 a symspec check against INCL_ARCS/EXCL_ARCS. As each arc is added, a
1799 linked list is maintained of the parent's child arcs, and of the child's
1800 parent arcs. Both the child's call count and the arc's call count are
1801 incremented by the record's call count.
1803 Basic-block records are read (`basic_blocks.c:bb_read_rec'), but
1804 only if line-by-line profiling has been selected. Each basic-block
1805 address is matched to a corresponding line symbol in the symbol table,
1806 and an entry made in the symbol's bb_addr and bb_calls arrays. Again,
1807 if multiple basic-block records are present for the same address, the
1808 call counts are cumulative.
1810 A gmon.sum file is dumped, if requested (`gmon_io.c:gmon_out_write').
1812 If histograms were present in the data files, assign them to symbols
1813 (`hist.c:hist_assign_samples') by iterating over all the sample bins
1814 and assigning them to symbols. Since the symbol table is sorted in
1815 order of ascending memory addresses, we can simple follow along in the
1816 symbol table as we make our pass over the sample bins. This step
1817 includes a symspec check against INCL_FLAT/EXCL_FLAT. Depending on the
1818 histogram scale factor, a sample bin may span multiple symbols, in
1819 which case a fraction of the sample count is allocated to each symbol,
1820 proportional to the degree of overlap. This effect is rare for normal
1821 profiling, but overlaps are more common during line-by-line profiling,
1822 and can cause each of two adjacent lines to be credited with half a
1825 If call graph data is present, `cg_arcs.c:cg_assemble' is called.
1826 First, if `-c' was specified, a machine-dependent routine (`find_call')
1827 scans through each symbol's machine code, looking for subroutine call
1828 instructions, and adding them to the call graph with a zero call count.
1829 A topological sort is performed by depth-first numbering all the
1830 symbols (`cg_dfn.c:cg_dfn'), so that children are always numbered less
1831 than their parents, then making a array of pointers into the symbol
1832 table and sorting it into numerical order, which is reverse topological
1833 order (children appear before parents). Cycles are also detected at
1834 this point, all members of which are assigned the same topological
1835 number. Two passes are now made through this sorted array of symbol
1836 pointers. The first pass, from end to beginning (parents to children),
1837 computes the fraction of child time to propagate to each parent and a
1838 print flag. The print flag reflects symspec handling of
1839 INCL_GRAPH/EXCL_GRAPH, with a parent's include or exclude (print or no
1840 print) property being propagated to its children, unless they
1841 themselves explicitly appear in INCL_GRAPH or EXCL_GRAPH. A second
1842 pass, from beginning to end (children to parents) actually propagates
1843 the timings along the call graph, subject to a check against
1844 INCL_TIME/EXCL_TIME. With the print flag, fractions, and timings now
1845 stored in the symbol structures, the topological sort array is now
1846 discarded, and a new array of pointers is assembled, this time sorted
1849 Finally, print the various outputs the user requested, which is now
1850 fairly straightforward. The call graph (`cg_print.c:cg_print') and
1851 flat profile (`hist.c:hist_print') are regurgitations of values already
1852 computed. The annotated source listing
1853 (`basic_blocks.c:print_annotated_source') uses basic-block information,
1854 if present, to label each line of code with call counts, otherwise only
1855 the function call counts are presented.
1857 The function ordering code is marginally well documented in the
1858 source code itself (`cg_print.c'). Basically, the functions with the
1859 most use and the most parents are placed first, followed by other
1860 functions with the most use, followed by lower use functions, followed
1861 by unused functions at the end.
1864 File: gprof.info, Node: Debugging, Prev: Internals, Up: Details
1869 If `gprof' was compiled with debugging enabled, the `-d' option
1870 triggers debugging output (to stdout) which can be helpful in
1871 understanding its operation. The debugging number specified is
1872 interpreted as a sum of the following options:
1874 2 - Topological sort
1875 Monitor depth-first numbering of symbols during call graph analysis
1878 Shows symbols as they are identified as cycle heads
1881 As the call graph arcs are read, show each arc and how the total
1882 calls to each function are tallied
1884 32 - Call graph arc sorting
1885 Details sorting individual parents/children within each call graph
1888 64 - Reading histogram and call graph records
1889 Shows address ranges of histograms as they are read, and each call
1893 Reading, classifying, and sorting the symbol table from the object
1894 file. For line-by-line profiling (`-l' option), also shows line
1895 numbers being assigned to memory addresses.
1897 256 - Static call graph
1898 Trace operation of `-c' option
1900 512 - Symbol table and arc table lookups
1901 Detail operation of lookup routines
1903 1024 - Call graph propagation
1904 Shows how function times are propagated along the call graph
1907 Shows basic-block records as they are read from profile data (only
1908 meaningful with `-l' option)
1911 Shows symspec-to-symbol pattern matching operation
1913 8192 - Annotate source
1914 Tracks operation of `-A' option
1917 File: gprof.info, Node: GNU Free Documentation License, Prev: Details, Up: Top
1919 GNU Free Documentation License
1920 ******************************
1922 GNU Free Documentation License
1924 Version 1.1, March 2000
1926 Copyright (C) 2000 Free Software Foundation, Inc. 59 Temple
1927 Place, Suite 330, Boston, MA 02111-1307 USA
1929 Everyone is permitted to copy and distribute verbatim copies of
1930 this license document, but changing it is not allowed.
1934 The purpose of this License is to make a manual, textbook, or other
1935 written document "free" in the sense of freedom: to assure everyone the
1936 effective freedom to copy and redistribute it, with or without
1937 modifying it, either commercially or noncommercially. Secondarily,
1938 this License preserves for the author and publisher a way to get credit
1939 for their work, while not being considered responsible for
1940 modifications made by others.
1942 This License is a kind of "copyleft", which means that derivative
1943 works of the document must themselves be free in the same sense. It
1944 complements the GNU General Public License, which is a copyleft license
1945 designed for free software.
1947 We have designed this License in order to use it for manuals for free
1948 software, because free software needs free documentation: a free
1949 program should come with manuals providing the same freedoms that the
1950 software does. But this License is not limited to software manuals; it
1951 can be used for any textual work, regardless of subject matter or
1952 whether it is published as a printed book. We recommend this License
1953 principally for works whose purpose is instruction or reference.
1955 1. APPLICABILITY AND DEFINITIONS
1957 This License applies to any manual or other work that contains a
1958 notice placed by the copyright holder saying it can be distributed
1959 under the terms of this License. The "Document", below, refers to any
1960 such manual or work. Any member of the public is a licensee, and is
1963 A "Modified Version" of the Document means any work containing the
1964 Document or a portion of it, either copied verbatim, or with
1965 modifications and/or translated into another language.
1967 A "Secondary Section" is a named appendix or a front-matter section
1968 of the Document that deals exclusively with the relationship of the
1969 publishers or authors of the Document to the Document's overall subject
1970 (or to related matters) and contains nothing that could fall directly
1971 within that overall subject. (For example, if the Document is in part a
1972 textbook of mathematics, a Secondary Section may not explain any
1973 mathematics.) The relationship could be a matter of historical
1974 connection with the subject or with related matters, or of legal,
1975 commercial, philosophical, ethical or political position regarding them.
1977 The "Invariant Sections" are certain Secondary Sections whose titles
1978 are designated, as being those of Invariant Sections, in the notice
1979 that says that the Document is released under this License.
1981 The "Cover Texts" are certain short passages of text that are listed,
1982 as Front-Cover Texts or Back-Cover Texts, in the notice that says that
1983 the Document is released under this License.
1985 A "Transparent" copy of the Document means a machine-readable copy,
1986 represented in a format whose specification is available to the general
1987 public, whose contents can be viewed and edited directly and
1988 straightforwardly with generic text editors or (for images composed of
1989 pixels) generic paint programs or (for drawings) some widely available
1990 drawing editor, and that is suitable for input to text formatters or
1991 for automatic translation to a variety of formats suitable for input to
1992 text formatters. A copy made in an otherwise Transparent file format
1993 whose markup has been designed to thwart or discourage subsequent
1994 modification by readers is not Transparent. A copy that is not
1995 "Transparent" is called "Opaque".
1997 Examples of suitable formats for Transparent copies include plain
1998 ASCII without markup, Texinfo input format, LaTeX input format, SGML or
1999 XML using a publicly available DTD, and standard-conforming simple HTML
2000 designed for human modification. Opaque formats include PostScript,
2001 PDF, proprietary formats that can be read and edited only by
2002 proprietary word processors, SGML or XML for which the DTD and/or
2003 processing tools are not generally available, and the machine-generated
2004 HTML produced by some word processors for output purposes only.
2006 The "Title Page" means, for a printed book, the title page itself,
2007 plus such following pages as are needed to hold, legibly, the material
2008 this License requires to appear in the title page. For works in
2009 formats which do not have any title page as such, "Title Page" means
2010 the text near the most prominent appearance of the work's title,
2011 preceding the beginning of the body of the text.
2015 You may copy and distribute the Document in any medium, either
2016 commercially or noncommercially, provided that this License, the
2017 copyright notices, and the license notice saying this License applies
2018 to the Document are reproduced in all copies, and that you add no other
2019 conditions whatsoever to those of this License. You may not use
2020 technical measures to obstruct or control the reading or further
2021 copying of the copies you make or distribute. However, you may accept
2022 compensation in exchange for copies. If you distribute a large enough
2023 number of copies you must also follow the conditions in section 3.
2025 You may also lend copies, under the same conditions stated above, and
2026 you may publicly display copies.
2028 3. COPYING IN QUANTITY
2030 If you publish printed copies of the Document numbering more than
2031 100, and the Document's license notice requires Cover Texts, you must
2032 enclose the copies in covers that carry, clearly and legibly, all these
2033 Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts
2034 on the back cover. Both covers must also clearly and legibly identify
2035 you as the publisher of these copies. The front cover must present the
2036 full title with all words of the title equally prominent and visible.
2037 You may add other material on the covers in addition. Copying with
2038 changes limited to the covers, as long as they preserve the title of
2039 the Document and satisfy these conditions, can be treated as verbatim
2040 copying in other respects.
2042 If the required texts for either cover are too voluminous to fit
2043 legibly, you should put the first ones listed (as many as fit
2044 reasonably) on the actual cover, and continue the rest onto adjacent
2047 If you publish or distribute Opaque copies of the Document numbering
2048 more than 100, you must either include a machine-readable Transparent
2049 copy along with each Opaque copy, or state in or with each Opaque copy
2050 a publicly-accessible computer-network location containing a complete
2051 Transparent copy of the Document, free of added material, which the
2052 general network-using public has access to download anonymously at no
2053 charge using public-standard network protocols. If you use the latter
2054 option, you must take reasonably prudent steps, when you begin
2055 distribution of Opaque copies in quantity, to ensure that this
2056 Transparent copy will remain thus accessible at the stated location
2057 until at least one year after the last time you distribute an Opaque
2058 copy (directly or through your agents or retailers) of that edition to
2061 It is requested, but not required, that you contact the authors of
2062 the Document well before redistributing any large number of copies, to
2063 give them a chance to provide you with an updated version of the
2068 You may copy and distribute a Modified Version of the Document under
2069 the conditions of sections 2 and 3 above, provided that you release the
2070 Modified Version under precisely this License, with the Modified
2071 Version filling the role of the Document, thus licensing distribution
2072 and modification of the Modified Version to whoever possesses a copy of
2073 it. In addition, you must do these things in the Modified Version:
2075 A. Use in the Title Page (and on the covers, if any) a title distinct
2076 from that of the Document, and from those of previous versions
2077 (which should, if there were any, be listed in the History section
2078 of the Document). You may use the same title as a previous version
2079 if the original publisher of that version gives permission. B. List on
2080 the Title Page, as authors, one or more persons or entities
2081 responsible for authorship of the modifications in the Modified
2082 Version, together with at least five of the principal authors of the
2083 Document (all of its principal authors, if it has less than five). C.
2084 State on the Title page the name of the publisher of the Modified
2085 Version, as the publisher. D. Preserve all the copyright notices of
2086 the Document. E. Add an appropriate copyright notice for your
2087 modifications adjacent to the other copyright notices. F. Include,
2088 immediately after the copyright notices, a license notice giving the
2089 public permission to use the Modified Version under the terms of
2090 this License, in the form shown in the Addendum below. G. Preserve in
2091 that license notice the full lists of Invariant Sections and
2092 required Cover Texts given in the Document's license notice. H.
2093 Include an unaltered copy of this License. I. Preserve the section
2094 entitled "History", and its title, and add to it an item stating at
2095 least the title, year, new authors, and publisher of the Modified
2096 Version as given on the Title Page. If there is no section entitled
2097 "History" in the Document, create one stating the title, year,
2098 authors, and publisher of the Document as given on its Title Page,
2099 then add an item describing the Modified Version as stated in the
2100 previous sentence. J. Preserve the network location, if any, given in
2101 the Document for public access to a Transparent copy of the
2102 Document, and likewise the network locations given in the Document
2103 for previous versions it was based on. These may be placed in the
2104 "History" section. You may omit a network location for a work that
2105 was published at least four years before the Document itself, or if
2106 the original publisher of the version it refers to gives permission.
2107 K. In any section entitled "Acknowledgements" or "Dedications",
2108 preserve the section's title, and preserve in the section all the
2109 substance and tone of each of the contributor acknowledgements
2110 and/or dedications given therein. L. Preserve all the Invariant
2111 Sections of the Document, unaltered in their text and in their
2112 titles. Section numbers or the equivalent are not considered part
2113 of the section titles. M. Delete any section entitled "Endorsements".
2114 Such a section may not be included in the Modified Version. N. Do
2115 not retitle any existing section as "Endorsements" or to conflict in
2116 title with any Invariant Section.
2118 If the Modified Version includes new front-matter sections or
2119 appendices that qualify as Secondary Sections and contain no material
2120 copied from the Document, you may at your option designate some or all
2121 of these sections as invariant. To do this, add their titles to the
2122 list of Invariant Sections in the Modified Version's license notice.
2123 These titles must be distinct from any other section titles.
2125 You may add a section entitled "Endorsements", provided it contains
2126 nothing but endorsements of your Modified Version by various
2127 parties-for example, statements of peer review or that the text has
2128 been approved by an organization as the authoritative definition of a
2131 You may add a passage of up to five words as a Front-Cover Text, and
2132 a passage of up to 25 words as a Back-Cover Text, to the end of the list
2133 of Cover Texts in the Modified Version. Only one passage of
2134 Front-Cover Text and one of Back-Cover Text may be added by (or through
2135 arrangements made by) any one entity. If the Document already includes
2136 a cover text for the same cover, previously added by you or by
2137 arrangement made by the same entity you are acting on behalf of, you
2138 may not add another; but you may replace the old one, on explicit
2139 permission from the previous publisher that added the old one.
2141 The author(s) and publisher(s) of the Document do not by this License
2142 give permission to use their names for publicity for or to assert or
2143 imply endorsement of any Modified Version.
2145 5. COMBINING DOCUMENTS
2147 You may combine the Document with other documents released under this
2148 License, under the terms defined in section 4 above for modified
2149 versions, provided that you include in the combination all of the
2150 Invariant Sections of all of the original documents, unmodified, and
2151 list them all as Invariant Sections of your combined work in its
2154 The combined work need only contain one copy of this License, and
2155 multiple identical Invariant Sections may be replaced with a single
2156 copy. If there are multiple Invariant Sections with the same name but
2157 different contents, make the title of each such section unique by
2158 adding at the end of it, in parentheses, the name of the original
2159 author or publisher of that section if known, or else a unique number.
2160 Make the same adjustment to the section titles in the list of Invariant
2161 Sections in the license notice of the combined work.
2163 In the combination, you must combine any sections entitled "History"
2164 in the various original documents, forming one section entitled
2165 "History"; likewise combine any sections entitled "Acknowledgements",
2166 and any sections entitled "Dedications". You must delete all sections
2167 entitled "Endorsements."
2169 6. COLLECTIONS OF DOCUMENTS
2171 You may make a collection consisting of the Document and other
2172 documents released under this License, and replace the individual
2173 copies of this License in the various documents with a single copy that
2174 is included in the collection, provided that you follow the rules of
2175 this License for verbatim copying of each of the documents in all other
2178 You may extract a single document from such a collection, and
2179 distribute it individually under this License, provided you insert a
2180 copy of this License into the extracted document, and follow this
2181 License in all other respects regarding verbatim copying of that
2184 7. AGGREGATION WITH INDEPENDENT WORKS
2186 A compilation of the Document or its derivatives with other separate
2187 and independent documents or works, in or on a volume of a storage or
2188 distribution medium, does not as a whole count as a Modified Version of
2189 the Document, provided no compilation copyright is claimed for the
2190 compilation. Such a compilation is called an "aggregate", and this
2191 License does not apply to the other self-contained works thus compiled
2192 with the Document, on account of their being thus compiled, if they are
2193 not themselves derivative works of the Document.
2195 If the Cover Text requirement of section 3 is applicable to these
2196 copies of the Document, then if the Document is less than one quarter
2197 of the entire aggregate, the Document's Cover Texts may be placed on
2198 covers that surround only the Document within the aggregate. Otherwise
2199 they must appear on covers around the whole aggregate.
2203 Translation is considered a kind of modification, so you may
2204 distribute translations of the Document under the terms of section 4.
2205 Replacing Invariant Sections with translations requires special
2206 permission from their copyright holders, but you may include
2207 translations of some or all Invariant Sections in addition to the
2208 original versions of these Invariant Sections. You may include a
2209 translation of this License provided that you also include the original
2210 English version of this License. In case of a disagreement between the
2211 translation and the original English version of this License, the
2212 original English version will prevail.
2216 You may not copy, modify, sublicense, or distribute the Document
2217 except as expressly provided for under this License. Any other attempt
2218 to copy, modify, sublicense or distribute the Document is void, and will
2219 automatically terminate your rights under this License. However,
2220 parties who have received copies, or rights, from you under this
2221 License will not have their licenses terminated so long as such parties
2222 remain in full compliance.
2224 10. FUTURE REVISIONS OF THIS LICENSE
2226 The Free Software Foundation may publish new, revised versions of
2227 the GNU Free Documentation License from time to time. Such new
2228 versions will be similar in spirit to the present version, but may
2229 differ in detail to address new problems or concerns. See
2230 http://www.gnu.org/copyleft/.
2232 Each version of the License is given a distinguishing version number.
2233 If the Document specifies that a particular numbered version of this
2234 License "or any later version" applies to it, you have the option of
2235 following the terms and conditions either of that specified version or
2236 of any later version that has been published (not as a draft) by the
2237 Free Software Foundation. If the Document does not specify a version
2238 number of this License, you may choose any version ever published (not
2239 as a draft) by the Free Software Foundation.
2241 ADDENDUM: How to use this License for your documents
2243 To use this License in a document you have written, include a copy of
2244 the License in the document and put the following copyright and license
2245 notices just after the title page:
2247 Copyright (c) YEAR YOUR NAME.
2248 Permission is granted to copy, distribute and/or modify this document
2249 under the terms of the GNU Free Documentation License, Version 1.1
2250 or any later version published by the Free Software Foundation;
2251 with the Invariant Sections being LIST THEIR TITLES, with the
2252 Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
2253 A copy of the license is included in the section entitled "GNU
2254 Free Documentation License".
2256 If you have no Invariant Sections, write "with no Invariant Sections"
2257 instead of saying which ones are invariant. If you have no Front-Cover
2258 Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being
2259 LIST"; likewise for Back-Cover Texts.
2261 If your document contains nontrivial examples of program code, we
2262 recommend releasing these examples in parallel under your choice of
2263 free software license, such as the GNU General Public License, to
2264 permit their use in free software.
2270 Node: Introduction
\x7f1952
2271 Node: Compiling
\x7f4278
2272 Node: Executing
\x7f8502
2273 Node: Invoking
\x7f11290
2274 Node: Output Options
\x7f12701
2275 Node: Analysis Options
\x7f19510
2276 Node: Miscellaneous Options
\x7f22704
2277 Node: Deprecated Options
\x7f23866
2278 Node: Symspecs
\x7f25937
2279 Node: Output
\x7f27755
2280 Node: Flat Profile
\x7f28777
2281 Node: Call Graph
\x7f33704
2282 Node: Primary
\x7f36916
2283 Node: Callers
\x7f39445
2284 Node: Subroutines
\x7f41550
2285 Node: Cycles
\x7f43347
2286 Node: Line-by-line
\x7f50109
2287 Node: Annotated Source
\x7f53905
2288 Node: Inaccuracy
\x7f56763
2289 Node: Sampling Error
\x7f57017
2290 Node: Assumptions
\x7f59579
2291 Node: How do I?
\x7f61040
2292 Node: Incompatibilities
\x7f62872
2293 Node: Details
\x7f64336
2294 Node: Implementation
\x7f64725
2295 Node: File Format
\x7f70614
2296 Node: Internals
\x7f74860
2297 Node: Debugging
\x7f83229
2298 Node: GNU Free Documentation License
\x7f84822