Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/gprof/gprof.texi

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    1919This file documents the gprof profiler of the GNU system.
    2020
    21 Copyright (C) 1988, 92, 97, 98, 99, 2000 Free Software Foundation, Inc.
     21@c man begin COPYRIGHT
     22Copyright (C) 1988, 92, 97, 98, 99, 2000, 2001 Free Software Foundation, Inc.
     23
     24Permission is granted to copy, distribute and/or modify this document
     25under the terms of the GNU Free Documentation License, Version 1.1
     26or any later version published by the Free Software Foundation;
     27with no Invariant Sections, with no Front-Cover Texts, and with no
     28Back-Cover Texts.  A copy of the license is included in the
     29section entitled "GNU Free Documentation License".
     30
     31@c man end
     32
     33@ignore
     34Permission is granted to process this file through Tex and print the
     35results, provided the printed document carries copying permission
     36notice identical to this one except for the removal of this paragraph
     37(this paragraph not being relevant to the printed manual).
     38
     39@end ignore
     40@end ifinfo
     41
     42@finalout
     43@smallbook
     44
     45@titlepage
     46@title GNU gprof
     47@subtitle The @sc{gnu} Profiler
     48@author Jay Fenlason and Richard Stallman
     49
     50@page
     51
     52This manual describes the @sc{gnu} profiler, @code{gprof}, and how you
     53can use it to determine which parts of a program are taking most of the
     54execution time.  We assume that you know how to write, compile, and
     55execute programs.  @sc{gnu} @code{gprof} was written by Jay Fenlason.
     56
     57@vskip 0pt plus 1filll
     58Copyright @copyright{} 1988, 92, 97, 98, 99, 2000 Free Software Foundation, Inc.
    2259
    2360      Permission is granted to copy, distribute and/or modify this document
     
    2865      section entitled "GNU Free Documentation License".
    2966
    30 @ignore
    31 Permission is granted to process this file through Tex and print the
    32 results, provided the printed document carries copying permission
    33 notice identical to this one except for the removal of this paragraph
    34 (this paragraph not being relevant to the printed manual).
    35 
    36 @end ignore
    37 @end ifinfo
    38 
    39 @finalout
    40 @smallbook
    41 
    42 @titlepage
    43 @title GNU gprof
    44 @subtitle The @sc{gnu} Profiler
    45 @author Jay Fenlason and Richard Stallman
    46 
    47 @page
    48 
    49 This manual describes the @sc{gnu} profiler, @code{gprof}, and how you
    50 can use it to determine which parts of a program are taking most of the
    51 execution time.  We assume that you know how to write, compile, and
    52 execute programs.  @sc{gnu} @code{gprof} was written by Jay Fenlason.
    53 
    54 @vskip 0pt plus 1filll
    55 Copyright @copyright{} 1988, 92, 97, 98, 99, 2000 Free Software Foundation, Inc.
    56 
    57       Permission is granted to copy, distribute and/or modify this document
    58       under the terms of the GNU Free Documentation License, Version 1.1
    59       or any later version published by the Free Software Foundation;
    60       with no Invariant Sections, with no Front-Cover Texts, and with no
    61       Back-Cover Texts.  A copy of the license is included in the
    62       section entitled "GNU Free Documentation License".
    63 
    6467@end titlepage
    6568
    66 @ifinfo
     69@ifnottex
    6770@node Top
    6871@top Profiling a Program: Where Does It Spend Its Time?
     
    9295* GNU Free Documentation License::  GNU Free Documentation License
    9396@end menu
    94 @end ifinfo
     97@end ifnottex
    9598
    9699@node Introduction
    97100@chapter Introduction to Profiling
     101
     102@ifset man
     103@c man title gprof display call graph profile data
     104
     105@smallexample
     106@c man begin SYNOPSIS
     107gprof [ -[abcDhilLsTvwxyz] ] [ -[ACeEfFJnNOpPqQZ][@var{name}] ]
     108 [ -I @var{dirs} ] [ -d[@var{num}] ] [ -k @var{from/to} ]
     109 [ -m @var{min-count} ] [ -t @var{table-length} ]
     110 [ --[no-]annotated-source[=@var{name}] ]
     111 [ --[no-]exec-counts[=@var{name}] ]
     112 [ --[no-]flat-profile[=@var{name}] ] [ --[no-]graph[=@var{name}] ]
     113 [ --[no-]time=@var{name}] [ --all-lines ] [ --brief ]
     114 [ --debug[=@var{level}] ] [ --function-ordering ]
     115 [ --file-ordering ] [ --directory-path=@var{dirs} ]
     116 [ --display-unused-functions ] [ --file-format=@var{name} ]
     117 [ --file-info ] [ --help ] [ --line ] [ --min-count=@var{n} ]
     118 [ --no-static ] [ --print-path ] [ --separate-files ]
     119 [ --static-call-graph ] [ --sum ] [ --table-length=@var{len} ]
     120 [ --traditional ] [ --version ] [ --width=@var{n} ]
     121 [ --ignore-non-functions ] [ --demangle[=@var{STYLE}] ]
     122 [ --no-demangle ] [ @var{image-file} ] [ @var{profile-file} @dots{} ]
     123@c man end
     124@end smallexample
     125
     126@c man begin DESCRIPTION
     127@code{gprof} produces an execution profile of C, Pascal, or Fortran77
     128programs.  The effect of called routines is incorporated in the profile
     129of each caller.  The profile data is taken from the call graph profile file
     130(@file{gmon.out} default) which is created by programs
     131that are compiled with the @samp{-pg} option of
     132@code{cc}, @code{pc}, and @code{f77}.
     133The @samp{-pg} option also links in versions of the library routines
     134that are compiled for profiling.  @code{Gprof} reads the given object
     135file (the default is @code{a.out}) and establishes the relation between
     136its symbol table and the call graph profile from @file{gmon.out}.
     137If more than one profile file is specified, the @code{gprof}
     138output shows the sum of the profile information in the given profile files.
     139
     140@code{Gprof} calculates the amount of time spent in each routine.
     141Next, these times are propagated along the edges of the call graph.
     142Cycles are discovered, and calls into a cycle are made to share the time
     143of the cycle.
     144
     145@c man end
     146
     147@c man begin BUGS
     148The granularity of the sampling is shown, but remains
     149statistical at best.
     150We assume that the time for each execution of a function
     151can be expressed by the total time for the function divided
     152by the number of times the function is called.
     153Thus the time propagated along the call graph arcs to the function's
     154parents is directly proportional to the number of times that
     155arc is traversed.
     156
     157Parents that are not themselves profiled will have the time of
     158their profiled children propagated to them, but they will appear
     159to be spontaneously invoked in the call graph listing, and will
     160not have their time propagated further.
     161Similarly, signal catchers, even though profiled, will appear
     162to be spontaneous (although for more obscure reasons).
     163Any profiled children of signal catchers should have their times
     164propagated properly, unless the signal catcher was invoked during
     165the execution of the profiling routine, in which case all is lost.
     166
     167The profiled program must call @code{exit}(2)
     168or return normally for the profiling information to be saved
     169in the @file{gmon.out} file.
     170@c man end
     171
     172@c man begin FILES
     173@table @code
     174@item @file{a.out}
     175the namelist and text space.
     176@item @file{gmon.out}
     177dynamic call graph and profile.
     178@item @file{gmon.sum}
     179summarized dynamic call graph and profile. 
     180@end table
     181@c man end
     182
     183@c man begin SEEALSO
     184monitor(3), profil(2), cc(1), prof(1), and the Info entry for @file{gprof}.
     185
     186``An Execution Profiler for Modular Programs'',
     187by S. Graham, P. Kessler, M. McKusick;
     188Software - Practice and Experience,
     189Vol. 13, pp. 671-685, 1983.
     190
     191``gprof: A Call Graph Execution Profiler'',
     192by S. Graham, P. Kessler, M. McKusick;
     193Proceedings of the SIGPLAN '82 Symposium on Compiler Construction,
     194SIGPLAN Notices, Vol. 17, No  6, pp. 120-126, June 1982.
     195@c man end
     196@end ifset
    98197
    99198Profiling allows you to learn where your program spent its time and which
     
    130229The next three chapters explain these steps in greater detail.
    131230
     231@c man begin DESCRIPTION
     232
    132233Several forms of output are available from the analysis.
    133234
     
    146247source code, labeled with the number of times each line of the
    147248program was executed.  @xref{Annotated Source}.
     249@c man end
    148250
    149251To better understand how profiling works, you may wish to read
     
    256358The Perl script @code{bbconv.pl}, included with the @code{gprof}
    257359source distribution, will convert a @file{bb.out} file into
    258 a format readable by @code{gprof}.
     360a format readable by @code{gprof}.  Invoke it like this:
     361
     362@smallexample
     363bbconv.pl < bb.out > @var{bh-data}
     364@end smallexample
     365
     366This translates the information in @file{bb.out} into a form that
     367@code{gprof} can understand.  But you still need to tell @code{gprof}
     368about the existence of this translated information.  To do that, include
     369@var{bb-data} on the @code{gprof} command line, @emph{along with
     370@file{gmon.out}}, like this:
     371
     372@smallexample
     373gprof @var{options} @var{executable-file} gmon.out @var{bb-data} [@var{yet-more-profile-data-files}@dots{}] [> @var{outfile}]
     374@end smallexample
    259375
    260376@node Invoking
     
    298414@section Output Options
    299415
     416@c man begin OPTIONS
    300417These options specify which of several output formats
    301418@code{gprof} should produce.
     
    635752
    636753@end table
     754
     755@c man end
    637756
    638757Note that only one function can be specified with each @code{-e},
     
    17321851consists of a header containing the magic cookie and a version number,
    17331852as well as some spare bytes available for future extensions.  All data
    1734 in a profile data file is in the native format of the host on which
    1735 the profile was collected.  @sc{gnu} @code{gprof} adapts automatically to the
    1736 byte-order in use.
     1853in a profile data file is in the native format of the target for which
     1854the profile was collected.  @sc{gnu} @code{gprof} adapts automatically
     1855to the byte-order in use.
    17371856
    17381857In the new file format, the header is followed by a sequence of
Note: See TracChangeset for help on using the changeset viewer.