|
Packit Service |
72eb06 |
README for GPROF
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
This is the GNU profiler. It is distributed with other "binary
|
|
Packit Service |
72eb06 |
utilities" which should be in ../binutils. See ../binutils/README for
|
|
Packit Service |
72eb06 |
more general notes, including where to send bug reports.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
This file documents the changes and new features available with this
|
|
Packit Service |
72eb06 |
version of GNU gprof.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
* New Features
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o Long options
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o Supports generalized file format, without breaking backward compatibility:
|
|
Packit Service |
72eb06 |
new file format supports basic-block execution counts and non-realtime
|
|
Packit Service |
72eb06 |
histograms (see below)
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o Supports profiling at the line level: flat profiles, call-graph profiles,
|
|
Packit Service |
72eb06 |
and execution-counts can all be displayed at a level that identifies
|
|
Packit Service |
72eb06 |
individual lines rather than just functions
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o Test-coverage support (similar to Sun tcov program): source files
|
|
Packit Service |
72eb06 |
can be annotated with the number of times a function was invoked
|
|
Packit Service |
72eb06 |
or with the number of times each basic-block in a function was
|
|
Packit Service |
72eb06 |
executed
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o Generalized histograms: not just execution-time, but arbitrary
|
|
Packit Service |
72eb06 |
histograms are support (for example, performance counter based
|
|
Packit Service |
72eb06 |
profiles)
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o Powerful mechanism to select data to be included/excluded from
|
|
Packit Service |
72eb06 |
analysis and/or output
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o Support for DEC OSF/1 v3.0
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o Full cross-platform profiling support: gprof uses BFD to support
|
|
Packit Service |
72eb06 |
arbitrary, non-native object file formats and non-native byte-orders
|
|
Packit Service |
72eb06 |
(this feature has not been tested yet)
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o In the call-graph function index, static function names are now
|
|
Packit Service |
72eb06 |
printed together with the filename in which the function was defined
|
|
Packit Service |
72eb06 |
(required bfd_find_nearest_line() support and symbolic debugging
|
|
Packit Service |
72eb06 |
information to be present in the executable file)
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o Major overhaul of source code (compiles cleanly with -Wall, etc.)
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
* Supported Platforms
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
The current version is known to work on:
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o DEC OSF/1 v3.0
|
|
Packit Service |
72eb06 |
All features supported.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o SunOS 4.1.x
|
|
Packit Service |
72eb06 |
All features supported.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o Solaris 2.3
|
|
Packit Service |
72eb06 |
Line-level profiling unsupported because bfd_find_nearest_line()
|
|
Packit Service |
72eb06 |
is not fully implemented for Elf binaries.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
o HP-UX 9.01
|
|
Packit Service |
72eb06 |
Line-level profiling unsupported because bfd_find_nearest_line()
|
|
Packit Service |
72eb06 |
is not fully implemented for SOM binaries.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
* Detailed Description
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
** User Interface Changes
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
The command-line interface is backwards compatible with earlier
|
|
Packit Service |
72eb06 |
versions of GNU gprof and Berkeley gprof. The only exception is
|
|
Packit Service |
72eb06 |
the option to delete arcs from the call graph. The old syntax
|
|
Packit Service |
72eb06 |
was:
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-k fromname toname
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
while the new syntax is:
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-k fromname/toname
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
This change was necessary to be compatible with long-option parsing.
|
|
Packit Service |
72eb06 |
Also, "fromname" and "toname" can now be arbitrary symspecs rather
|
|
Packit Service |
72eb06 |
than just function names (see below for an explanation of symspecs).
|
|
Packit Service |
72eb06 |
For example, option "-k gprof.c/" suppresses all arcs due to calls out
|
|
Packit Service |
72eb06 |
of file "gprof.c".
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
*** Sym Specs
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
It is often necessary to apply gprof only to specific parts of a
|
|
Packit Service |
72eb06 |
program. GNU gprof has a simple but powerful mechanism to achieve
|
|
Packit Service |
72eb06 |
this. So called {\em symspecs\/} provide the foundation for this
|
|
Packit Service |
72eb06 |
mechanism. A symspec selects the parts of a profiled program to which
|
|
Packit Service |
72eb06 |
an operation should be applied to. The syntax of a symspec is
|
|
Packit Service |
72eb06 |
simple:
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
filename_containing_a_dot
|
|
Packit Service |
72eb06 |
| funcname_not_containing_a_dot
|
|
Packit Service |
72eb06 |
| linenumber
|
|
Packit Service |
72eb06 |
| ( [ any_filename ] `:' ( any_funcname | linenumber ) )
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
Here are some examples:
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
main.c Selects everything in file "main.c"---the
|
|
Packit Service |
72eb06 |
dot in the string tells gprof to interpret
|
|
Packit Service |
72eb06 |
the string as a filename, rather than as
|
|
Packit Service |
72eb06 |
a function name. To select a file whose
|
|
Packit Service |
72eb06 |
name does contain a dot, a trailing colon
|
|
Packit Service |
72eb06 |
should be specified. For example, "odd:" is
|
|
Packit Service |
72eb06 |
interpreted as the file named "odd".
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
main Selects all functions named "main". Notice
|
|
Packit Service |
72eb06 |
that there may be multiple instances of the
|
|
Packit Service |
72eb06 |
same function name because some of the
|
|
Packit Service |
72eb06 |
definitions may be local (i.e., static).
|
|
Packit Service |
72eb06 |
Unless a function name is unique in a program,
|
|
Packit Service |
72eb06 |
you must use the colon notation explained
|
|
Packit Service |
72eb06 |
below to specify a function from a specific
|
|
Packit Service |
72eb06 |
source file. Sometimes, functionnames contain
|
|
Packit Service |
72eb06 |
dots. In such cases, it is necessary to
|
|
Packit Service |
72eb06 |
add a leading colon to the name. For example,
|
|
Packit Service |
72eb06 |
":.mul" selects function ".mul".
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
main.c:main Selects function "main" in file "main.c".
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
main.c:134 Selects line 134 in file "main.c".
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
IMPLEMENTATION NOTE: The source code uses the type sym_id for symspecs.
|
|
Packit Service |
72eb06 |
At some point, this probably ought to be changed to "sym_spec" to make
|
|
Packit Service |
72eb06 |
reading the code easier.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
*** Long options
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
GNU gprof now supports long options. The following is a list of all
|
|
Packit Service |
72eb06 |
supported options. Options that are listed without description
|
|
Packit Service |
72eb06 |
operate in the same manner as the corresponding option in older
|
|
Packit Service |
72eb06 |
versions of gprof.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
Short Form: Long Form:
|
|
Packit Service |
72eb06 |
----------- ----------
|
|
Packit Service |
72eb06 |
-l --line
|
|
Packit Service |
72eb06 |
Request profiling at the line-level rather
|
|
Packit Service |
72eb06 |
than just at the function level. Source
|
|
Packit Service |
72eb06 |
lines are identified by symbols of the form:
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
func (file:line)
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
where "func" is the function name, "file" is the
|
|
Packit Service |
72eb06 |
file name and "line" is the line-number that
|
|
Packit Service |
72eb06 |
corresponds to the line.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
To work properly, the binary must contain symbolic
|
|
Packit Service |
72eb06 |
debugging information. This means that the source
|
|
Packit Service |
72eb06 |
have to be translated with option "-g" specified.
|
|
Packit Service |
72eb06 |
Functions for which there is no symbolic debugging
|
|
Packit Service |
72eb06 |
information available are treated as if "--line"
|
|
Packit Service |
72eb06 |
had not been specified. However, the line number
|
|
Packit Service |
72eb06 |
printed with such symbols is usually incorrect
|
|
Packit Service |
72eb06 |
and should be ignored.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-a --no-static
|
|
Packit Service |
72eb06 |
-A[symspec] --annotated-source[=symspec]
|
|
Packit Service |
72eb06 |
Request output in the form of annotated source
|
|
Packit Service |
72eb06 |
files. If "symspec" is specified, print output only
|
|
Packit Service |
72eb06 |
for symbols selected by "symspec". If the option
|
|
Packit Service |
72eb06 |
is specified multiple times, annotated output is
|
|
Packit Service |
72eb06 |
generated for the union of all symspecs.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
Examples:
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-A Prints annotated source for all
|
|
Packit Service |
72eb06 |
source files.
|
|
Packit Service |
72eb06 |
-Agprof.c Prints annotated source for file
|
|
Packit Service |
72eb06 |
gprof.c.
|
|
Packit Service |
72eb06 |
-Afoobar Prints annotated source for files
|
|
Packit Service |
72eb06 |
containing a function named "foobar".
|
|
Packit Service |
72eb06 |
The entire file will be printed, but
|
|
Packit Service |
72eb06 |
only the function itself will be
|
|
Packit Service |
72eb06 |
annotated with profile data.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-J[symspec] --no-annotated-source[=symspec]
|
|
Packit Service |
72eb06 |
Suppress annotated source output. If specified
|
|
Packit Service |
72eb06 |
without argument, annotated output is suppressed
|
|
Packit Service |
72eb06 |
completely. With an argument, annotated output
|
|
Packit Service |
72eb06 |
is suppressed only for the symbols selected by
|
|
Packit Service |
72eb06 |
"symspec". If the option is specified multiple
|
|
Packit Service |
72eb06 |
times, annotated output is suppressed for the
|
|
Packit Service |
72eb06 |
union of all symspecs. This option has lower
|
|
Packit Service |
72eb06 |
precedence than --annotated-source
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-p[symspec] --flat-profile[=symspec]
|
|
Packit Service |
72eb06 |
Request output in the form of a flat profile
|
|
Packit Service |
72eb06 |
(unless any other output-style option is specified,
|
|
Packit Service |
72eb06 |
this option is turned on by default). If
|
|
Packit Service |
72eb06 |
"symspec" is specified, include only symbols
|
|
Packit Service |
72eb06 |
selected by "symspec" in flat profile. If the
|
|
Packit Service |
72eb06 |
option is specified multiple times, the flat
|
|
Packit Service |
72eb06 |
profile includes symbols selected by the union
|
|
Packit Service |
72eb06 |
of all symspecs.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-P[symspec] --no-flat-profile[=symspec]
|
|
Packit Service |
72eb06 |
Suppress output in the flat profile. If given
|
|
Packit Service |
72eb06 |
without an argument, the flat profile is suppressed
|
|
Packit Service |
72eb06 |
completely. If "symspec" is specified, suppress
|
|
Packit Service |
72eb06 |
the selected symbols in the flat profile. If the
|
|
Packit Service |
72eb06 |
option is specified multiple times, the union of
|
|
Packit Service |
72eb06 |
the selected symbols is suppressed. This option
|
|
Packit Service |
72eb06 |
has lower precedence than --flat-profile.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-q[symspec] --graph[=symspec]
|
|
Packit Service |
72eb06 |
Request output in the form of a call-graph
|
|
Packit Service |
72eb06 |
(unless any other output-style option is specified,
|
|
Packit Service |
72eb06 |
this option is turned on by default). If "symspec"
|
|
Packit Service |
72eb06 |
is specified, include only symbols selected by
|
|
Packit Service |
72eb06 |
"symspec" in the call-graph. If the option is
|
|
Packit Service |
72eb06 |
specified multiple times, the call-graph includes
|
|
Packit Service |
72eb06 |
symbols selected by the union of all symspecs.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-Q[symspec] --no-graph[=symspec]
|
|
Packit Service |
72eb06 |
Suppress output in the call-graph. If given without
|
|
Packit Service |
72eb06 |
an argument, the call-graph is suppressed completely.
|
|
Packit Service |
72eb06 |
With a "symspec", suppress the selected symbols
|
|
Packit Service |
72eb06 |
from the call-graph. If the option is specified
|
|
Packit Service |
72eb06 |
multiple times, the union of the selected symbols
|
|
Packit Service |
72eb06 |
is suppressed. This option has lower precedence
|
|
Packit Service |
72eb06 |
than --graph.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-C[symspec] --exec-counts[=symspec]
|
|
Packit Service |
72eb06 |
Request output in the form of execution counts.
|
|
Packit Service |
72eb06 |
If "symspec" is present, include only symbols
|
|
Packit Service |
72eb06 |
selected by "symspec" in the execution count
|
|
Packit Service |
72eb06 |
listing. If the option is specified multiple
|
|
Packit Service |
72eb06 |
times, the execution count listing includes
|
|
Packit Service |
72eb06 |
symbols selected by the union of all symspecs.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-Z[symspec] --no-exec-counts[=symspec]
|
|
Packit Service |
72eb06 |
Suppress output in the execution count listing.
|
|
Packit Service |
72eb06 |
If given without an argument, the listing is
|
|
Packit Service |
72eb06 |
suppressed completely. With a "symspec", suppress
|
|
Packit Service |
72eb06 |
the selected symbols from the call-graph. If the
|
|
Packit Service |
72eb06 |
option is specified multiple times, the union of
|
|
Packit Service |
72eb06 |
the selected symbols is suppressed. This option
|
|
Packit Service |
72eb06 |
has lower precedence than --exec-counts.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-i --file-info
|
|
Packit Service |
72eb06 |
Print information about the profile files that
|
|
Packit Service |
72eb06 |
are read. The information consists of the
|
|
Packit Service |
72eb06 |
number and types of records present in the
|
|
Packit Service |
72eb06 |
profile file. Currently, a profile file can
|
|
Packit Service |
72eb06 |
contain any number and any combination of histogram,
|
|
Packit Service |
72eb06 |
call-graph, or basic-block count records.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-s --sum
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-x --all-lines
|
|
Packit Service |
72eb06 |
This option affects annotated source output only.
|
|
Packit Service |
72eb06 |
By default, only the lines at the beginning of
|
|
Packit Service |
72eb06 |
a basic-block are annotated. If this option is
|
|
Packit Service |
72eb06 |
specified, every line in a basic-block is annotated
|
|
Packit Service |
72eb06 |
by repeating the annotation for the first line.
|
|
Packit Service |
72eb06 |
This option is identical to tcov's "-a".
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-I dirs --directory-path=dirs
|
|
Packit Service |
72eb06 |
This option affects annotated source output only.
|
|
Packit Service |
72eb06 |
Specifies the list of directories to be searched
|
|
Packit Service |
72eb06 |
for source files. The argument "dirs" is a colon
|
|
Packit Service |
72eb06 |
separated list of directories. By default, gprof
|
|
Packit Service |
72eb06 |
searches for source files relative to the current
|
|
Packit Service |
72eb06 |
working directory only.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-z --display-unused-functions
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-m num --min-count=num
|
|
Packit Service |
72eb06 |
This option affects annotated source and execution
|
|
Packit Service |
72eb06 |
count output only. Symbols that are executed
|
|
Packit Service |
72eb06 |
less than "num" times are suppressed. For annotated
|
|
Packit Service |
72eb06 |
source output, suppressed symbols are marked
|
|
Packit Service |
72eb06 |
by five hash-marks (#####). In an execution count
|
|
Packit Service |
72eb06 |
output, suppressed symbols do not appear at all.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-L --print-path
|
|
Packit Service |
72eb06 |
Normally, source filenames are printed with the path
|
|
Packit Service |
72eb06 |
component suppressed. With this option, gprof
|
|
Packit Service |
72eb06 |
can be forced to print the full pathname of
|
|
Packit Service |
72eb06 |
source filenames. The full pathname is determined
|
|
Packit Service |
72eb06 |
from symbolic debugging information in the image file
|
|
Packit Service |
72eb06 |
and is relative to the directory in which the compiler
|
|
Packit Service |
72eb06 |
was invoked.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-y --separate-files
|
|
Packit Service |
72eb06 |
This option affects annotated source output only.
|
|
Packit Service |
72eb06 |
Normally, gprof prints annotated source files
|
|
Packit Service |
72eb06 |
to standard-output. If this option is specified,
|
|
Packit Service |
72eb06 |
annotated source for a file named "path/filename"
|
|
Packit Service |
72eb06 |
is generated in the file "filename-ann". That is,
|
|
Packit Service |
72eb06 |
annotated output is {\em always\/} generated in
|
|
Packit Service |
72eb06 |
gprof's current working directory. Care has to
|
|
Packit Service |
72eb06 |
be taken if a program consists of files that have
|
|
Packit Service |
72eb06 |
identical filenames, but distinct paths.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-c --static-call-graph
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-t num --table-length=num
|
|
Packit Service |
72eb06 |
This option affects annotated source output only.
|
|
Packit Service |
72eb06 |
After annotating a source file, gprof generates
|
|
Packit Service |
72eb06 |
an execution count summary consisting of a table
|
|
Packit Service |
72eb06 |
of lines with the top execution counts. By
|
|
Packit Service |
72eb06 |
default, this table is ten entries long.
|
|
Packit Service |
72eb06 |
This option can be used to change the table length
|
|
Packit Service |
72eb06 |
or, by specifying an argument value of 0, it can be
|
|
Packit Service |
72eb06 |
suppressed completely.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-n symspec --time=symspec
|
|
Packit Service |
72eb06 |
Only symbols selected by "symspec" are considered
|
|
Packit Service |
72eb06 |
in total and percentage time computations.
|
|
Packit Service |
72eb06 |
However, this option does not affect percentage time
|
|
Packit Service |
72eb06 |
computation for the flat profile.
|
|
Packit Service |
72eb06 |
If the option is specified multiple times, the union
|
|
Packit Service |
72eb06 |
of all selected symbols is used in time computations.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-N --no-time=symspec
|
|
Packit Service |
72eb06 |
Exclude the symbols selected by "symspec" from
|
|
Packit Service |
72eb06 |
total and percentage time computations.
|
|
Packit Service |
72eb06 |
However, this option does not affect percentage time
|
|
Packit Service |
72eb06 |
computation for the flat profile.
|
|
Packit Service |
72eb06 |
This option is ignored if any --time options are
|
|
Packit Service |
72eb06 |
specified.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-w num --width=num
|
|
Packit Service |
72eb06 |
Sets the output line width. Currently, this option
|
|
Packit Service |
72eb06 |
affects the printing of the call-graph function index
|
|
Packit Service |
72eb06 |
only.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-e <no long form---for backwards compatibility only>
|
|
Packit Service |
72eb06 |
-E <no long form---for backwards compatibility only>
|
|
Packit Service |
72eb06 |
-f <no long form---for backwards compatibility only>
|
|
Packit Service |
72eb06 |
-F <no long form---for backwards compatibility only>
|
|
Packit Service |
72eb06 |
-k <no long form---for backwards compatibility only>
|
|
Packit Service |
72eb06 |
-b --brief
|
|
Packit Service |
72eb06 |
-dnum --debug[=num]
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-h --help
|
|
Packit Service |
72eb06 |
Prints a usage message.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-O name --file-format=name
|
|
Packit Service |
72eb06 |
Selects the format of the profile data files.
|
|
Packit Service |
72eb06 |
Recognized formats are "auto", "bsd", "magic",
|
|
Packit Service |
72eb06 |
and "prof". The last one is not yet supported.
|
|
Packit Service |
72eb06 |
Format "auto" attempts to detect the file format
|
|
Packit Service |
72eb06 |
automatically (this is the default behavior).
|
|
Packit Service |
72eb06 |
It attempts to read the profile data files as
|
|
Packit Service |
72eb06 |
"magic" files and if this fails, falls back to
|
|
Packit Service |
72eb06 |
the "bsd" format. "bsd" forces gprof to read
|
|
Packit Service |
72eb06 |
the data files in the BSD format. "magic" forces
|
|
Packit Service |
72eb06 |
gprof to read the data files in the "magic" format.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
-T --traditional
|
|
Packit Service |
72eb06 |
-v --version
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
** File Format Changes
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
The old BSD-derived format used for profile data does not contain a
|
|
Packit Service |
72eb06 |
magic cookie that allows to check whether a data file really is a
|
|
Packit Service |
72eb06 |
gprof file. Furthermore, it does not provide a version number, thus
|
|
Packit Service |
72eb06 |
rendering changes to the file format almost impossible. GNU gprof
|
|
Packit Service |
72eb06 |
uses a new file format that provides these features. For backward
|
|
Packit Service |
72eb06 |
compatibility, GNU gprof continues to support the old BSD-derived
|
|
Packit Service |
72eb06 |
format, but not all features are supported with it. For example,
|
|
Packit Service |
72eb06 |
basic-block execution counts cannot be accommodated by the old file
|
|
Packit Service |
72eb06 |
format.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
The new file format is defined in header file \file{gmon_out.h}. It
|
|
Packit Service |
72eb06 |
consists of a header containing the magic cookie and a version number,
|
|
Packit Service |
72eb06 |
as well as some spare bytes available for future extensions. All data
|
|
Packit Service |
72eb06 |
in a profile data file is in the native format of the host on which
|
|
Packit Service |
72eb06 |
the profile was collected. GNU gprof adapts automatically to the
|
|
Packit Service |
72eb06 |
byte-order in use.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
In the new file format, the header is followed by a sequence of
|
|
Packit Service |
72eb06 |
records. Currently, there are three different record types: histogram
|
|
Packit Service |
72eb06 |
records, call-graph arc records, and basic-block execution count
|
|
Packit Service |
72eb06 |
records. Each file can contain any number of each record type. When
|
|
Packit Service |
72eb06 |
reading a file, GNU gprof will ensure records of the same type are
|
|
Packit Service |
72eb06 |
compatible with each other and compute the union of all records. For
|
|
Packit Service |
72eb06 |
example, for basic-block execution counts, the union is simply the sum
|
|
Packit Service |
72eb06 |
of all execution counts for each basic-block.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
*** Histogram Records
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
Histogram records consist of a header that is followed by an array of
|
|
Packit Service |
72eb06 |
bins. The header contains the text-segment range that the histogram
|
|
Packit Service |
72eb06 |
spans, the size of the histogram in bytes (unlike in the old BSD
|
|
Packit Service |
72eb06 |
format, this does not include the size of the header), the rate of the
|
|
Packit Service |
72eb06 |
profiling clock, and the physical dimension that the bin counts
|
|
Packit Service |
72eb06 |
represent after being scaled by the profiling clock rate. The
|
|
Packit Service |
72eb06 |
physical dimension is specified in two parts: a long name of up to 15
|
|
Packit Service |
72eb06 |
characters and a single character abbreviation. For example, a
|
|
Packit Service |
72eb06 |
histogram representing real-time would specify the long name as
|
|
Packit Service |
72eb06 |
"seconds" and the abbreviation as "s". This feature is useful for
|
|
Packit Service |
72eb06 |
architectures that support performance monitor hardware (which,
|
|
Packit Service |
72eb06 |
fortunately, is becoming increasingly common). For example, under DEC
|
|
Packit Service |
72eb06 |
OSF/1, the "uprofile" command can be used to produce a histogram of,
|
|
Packit Service |
72eb06 |
say, instruction cache misses. In this case, the dimension in the
|
|
Packit Service |
72eb06 |
histogram header could be set to "i-cache misses" and the abbreviation
|
|
Packit Service |
72eb06 |
could be set to "1" (because it is simply a count, not a physical
|
|
Packit Service |
72eb06 |
dimension). Also, the profiling rate would have to be set to 1 in
|
|
Packit Service |
72eb06 |
this case.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
Histogram bins are 16-bit numbers and each bin represent an equal
|
|
Packit Service |
72eb06 |
amount of text-space. For example, if the text-segment is one
|
|
Packit Service |
72eb06 |
thousand bytes long and if there are ten bins in the histogram, each
|
|
Packit Service |
72eb06 |
bin represents one hundred bytes.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
*** Call-Graph Records
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
Call-graph records have a format that is identical to the one used in
|
|
Packit Service |
72eb06 |
the BSD-derived file format. It consists of an arc in the call graph
|
|
Packit Service |
72eb06 |
and a count indicating the number of times the arc was traversed
|
|
Packit Service |
72eb06 |
during program execution. Arcs are specified by a pair of addresses:
|
|
Packit Service |
72eb06 |
the first must be within caller's function and the second must be
|
|
Packit Service |
72eb06 |
within the callee's function. When performing profiling at the
|
|
Packit Service |
72eb06 |
function level, these addresses can point anywhere within the
|
|
Packit Service |
72eb06 |
respective function. However, when profiling at the line-level, it is
|
|
Packit Service |
72eb06 |
better if the addresses are as close to the call-site/entry-point as
|
|
Packit Service |
72eb06 |
possible. This will ensure that the line-level call-graph is able to
|
|
Packit Service |
72eb06 |
identify exactly which line of source code performed calls to a
|
|
Packit Service |
72eb06 |
function.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
*** Basic-Block Execution Count Records
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
Basic-block execution count records consist of a header followed by a
|
|
Packit Service |
72eb06 |
sequence of address/count pairs. The header simply specifies the
|
|
Packit Service |
72eb06 |
length of the sequence. In an address/count pair, the address
|
|
Packit Service |
72eb06 |
identifies a basic-block and the count specifies the number of times
|
|
Packit Service |
72eb06 |
that basic-block was executed. Any address within the basic-address can
|
|
Packit Service |
72eb06 |
be used.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
IMPLEMENTATION NOTE: gcc -a can be used to instrument a program to
|
|
Packit Service |
72eb06 |
record basic-block execution counts. However, the __bb_exit_func()
|
|
Packit Service |
72eb06 |
that is currently present in libgcc2.c does not generate a gmon.out
|
|
Packit Service |
72eb06 |
file in a suitable format. This should be fixed for future releases
|
|
Packit Service |
72eb06 |
of gcc. In the meantime, contact davidm@cs.arizona.edu for a version
|
|
Packit Service |
72eb06 |
of __bb_exit_func() to is appropriate.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
|
Packit Service |
72eb06 |
|
|
Packit Service |
72eb06 |
Copying and distribution of this file, with or without modification,
|
|
Packit Service |
72eb06 |
are permitted in any medium without royalty provided the copyright
|
|
Packit Service |
72eb06 |
notice and this notice are preserved.
|