head	1.12;
access;
symbols
	netbsd-11-0-RC4:1.10
	netbsd-11-0-RC3:1.10
	netbsd-11-0-RC2:1.10
	binutils-2-46:1.1.1.12
	netbsd-11-0-RC1:1.10
	binutils-2-45:1.1.1.11
	perseant-exfatfs-base-20250801:1.10
	netbsd-11:1.10.0.2
	netbsd-11-base:1.10
	netbsd-10-1-RELEASE:1.8
	perseant-exfatfs-base-20240630:1.10
	binutils-2-42:1.1.1.10
	perseant-exfatfs:1.9.0.2
	perseant-exfatfs-base:1.9
	netbsd-8-3-RELEASE:1.5
	netbsd-9-4-RELEASE:1.7
	netbsd-10-0-RELEASE:1.8
	netbsd-10-0-RC6:1.8
	netbsd-10-0-RC5:1.8
	netbsd-10-0-RC4:1.8
	netbsd-10-0-RC3:1.8
	netbsd-10-0-RC2:1.8
	netbsd-10-0-RC1:1.8
	binutils-2-39:1.1.1.9
	netbsd-10:1.8.0.6
	netbsd-10-base:1.8
	netbsd-9-3-RELEASE:1.7
	cjep_sun2x-base1:1.8
	cjep_sun2x:1.8.0.4
	cjep_sun2x-base:1.8
	cjep_staticlib_x-base1:1.8
	netbsd-9-2-RELEASE:1.7
	cjep_staticlib_x:1.8.0.2
	cjep_staticlib_x-base:1.8
	netbsd-9-1-RELEASE:1.7
	phil-wifi-20200421:1.8
	phil-wifi-20200411:1.8
	is-mlppp:1.7.0.4
	is-mlppp-base:1.7
	phil-wifi-20200406:1.8
	binutils-2-34:1.1.1.8
	netbsd-8-2-RELEASE:1.5
	netbsd-9-0-RELEASE:1.7
	netbsd-9-0-RC2:1.7
	netbsd-9-0-RC1:1.7
	phil-wifi-20191119:1.7
	netbsd-9:1.7.0.2
	netbsd-9-base:1.7
	phil-wifi-20190609:1.7
	netbsd-8-1-RELEASE:1.5
	netbsd-8-1-RC1:1.5
	pgoyette-compat-merge-20190127:1.5.12.2
	pgoyette-compat-20190127:1.7
	pgoyette-compat-20190118:1.7
	pgoyette-compat-1226:1.7
	pgoyette-compat-1126:1.7
	binutils-2-31-1:1.1.1.7
	pgoyette-compat-1020:1.6
	pgoyette-compat-0930:1.6
	pgoyette-compat-0906:1.6
	netbsd-7-2-RELEASE:1.3
	pgoyette-compat-0728:1.6
	netbsd-8-0-RELEASE:1.5
	phil-wifi:1.6.0.2
	phil-wifi-base:1.6
	pgoyette-compat-0625:1.6
	netbsd-8-0-RC2:1.5
	pgoyette-compat-0521:1.6
	pgoyette-compat-0502:1.6
	pgoyette-compat-0422:1.6
	netbsd-8-0-RC1:1.5
	pgoyette-compat-0415:1.5
	binutils-2-30:1.1.1.6
	pgoyette-compat-0407:1.5
	pgoyette-compat-0330:1.5
	pgoyette-compat-0322:1.5
	pgoyette-compat-0315:1.5
	netbsd-7-1-2-RELEASE:1.3
	pgoyette-compat:1.5.0.12
	pgoyette-compat-base:1.5
	netbsd-7-1-1-RELEASE:1.3
	matt-nb8-mediatek:1.5.0.10
	matt-nb8-mediatek-base:1.5
	perseant-stdc-iso10646:1.5.0.8
	perseant-stdc-iso10646-base:1.5
	netbsd-8:1.5.0.6
	netbsd-8-base:1.5
	prg-localcount2-base3:1.5
	prg-localcount2-base2:1.5
	prg-localcount2-base1:1.5
	prg-localcount2:1.5.0.4
	prg-localcount2-base:1.5
	pgoyette-localcount-20170426:1.5
	bouyer-socketcan-base1:1.5
	pgoyette-localcount-20170320:1.5
	netbsd-7-1:1.3.0.10
	netbsd-7-1-RELEASE:1.3
	netbsd-7-1-RC2:1.3
	netbsd-7-nhusb-base-20170116:1.3
	bouyer-socketcan:1.5.0.2
	bouyer-socketcan-base:1.5
	pgoyette-localcount-20170107:1.5
	netbsd-7-1-RC1:1.3
	pgoyette-localcount-20161104:1.5
	binutils-2-27:1.1.1.5
	netbsd-7-0-2-RELEASE:1.3
	localcount-20160914:1.4
	netbsd-7-nhusb:1.3.0.8
	netbsd-7-nhusb-base:1.3
	pgoyette-localcount-20160806:1.4
	binutils-2-26-1:1.1.1.4
	pgoyette-localcount-20160726:1.4
	pgoyette-localcount:1.4.0.2
	pgoyette-localcount-base:1.4
	netbsd-7-0-1-RELEASE:1.3
	binutils-2-26:1.1.1.4
	netbsd-7-0:1.3.0.6
	netbsd-7-0-RELEASE:1.3
	netbsd-7-0-RC3:1.3
	netbsd-7-0-RC2:1.3
	netbsd-7-0-RC1:1.3
	netbsd-6-0-6-RELEASE:1.2
	netbsd-6-1-5-RELEASE:1.2
	netbsd-7:1.3.0.4
	netbsd-7-base:1.3
	yamt-pagecache-base9:1.3
	yamt-pagecache-tag8:1.2
	netbsd-6-1-4-RELEASE:1.2
	netbsd-6-0-5-RELEASE:1.2
	tls-earlyentropy:1.3.0.2
	tls-earlyentropy-base:1.3
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.3
	riastradh-drm2-base3:1.3
	netbsd-6-1-3-RELEASE:1.2
	netbsd-6-0-4-RELEASE:1.2
	binutils-2-23-2:1.1.1.3
	netbsd-6-1-2-RELEASE:1.2
	netbsd-6-0-3-RELEASE:1.2
	netbsd-6-1-1-RELEASE:1.2
	riastradh-drm2-base2:1.2
	riastradh-drm2-base1:1.2
	riastradh-drm2:1.2.0.12
	riastradh-drm2-base:1.2
	netbsd-6-1:1.2.0.16
	netbsd-6-0-2-RELEASE:1.2
	netbsd-6-1-RELEASE:1.2
	netbsd-6-1-RC4:1.2
	netbsd-6-1-RC3:1.2
	agc-symver:1.2.0.14
	agc-symver-base:1.2
	netbsd-6-1-RC2:1.2
	netbsd-6-1-RC1:1.2
	yamt-pagecache-base8:1.2
	netbsd-6-0-1-RELEASE:1.2
	yamt-pagecache-base7:1.2
	matt-nb6-plus-nbase:1.2
	yamt-pagecache-base6:1.2
	netbsd-6-0:1.2.0.10
	netbsd-6-0-RELEASE:1.2
	netbsd-6-0-RC2:1.2
	tls-maxphys:1.2.0.8
	tls-maxphys-base:1.3
	matt-nb6-plus:1.2.0.6
	matt-nb6-plus-base:1.2
	netbsd-6-0-RC1:1.2
	yamt-pagecache-base5:1.2
	yamt-pagecache-base4:1.2
	netbsd-6:1.2.0.4
	netbsd-6-base:1.2
	yamt-pagecache-base3:1.2
	yamt-pagecache-base2:1.2
	yamt-pagecache:1.2.0.2
	yamt-pagecache-base:1.2
	binutils-2-21-1a:1.1.1.2
	cherry-xenmp:1.1.1.1.0.4
	cherry-xenmp-base:1.1.1.1
	bouyer-quota2-nbase:1.1.1.1
	bouyer-quota2:1.1.1.1.0.2
	bouyer-quota2-base:1.1.1.1
	matt-mips64-premerge-20101231:1.1.1.1
	binutils-2-19-1-20090402:1.1.1.1
	matt-premerge-20091211:1.1.1.1
	binutils-2-19-1:1.1.1.1
	FSF:1.1.1;
locks; strict;
comment	@# @;


1.12
date	2026.02.11.20.15.01;	author christos;	state Exp;
branches;
next	1.11;
commitid	2ZnkVhvajDjbVZtG;

1.11
date	2025.08.25.15.47.39;	author christos;	state Exp;
branches;
next	1.10;
commitid	83YQOH8LeFn9V78G;

1.10
date	2024.06.30.16.10.18;	author christos;	state Exp;
branches;
next	1.9;
commitid	YLzDDRlomJFmz1gF;

1.9
date	2022.12.24.20.17.06;	author christos;	state Exp;
branches
	1.9.2.1;
next	1.8;
commitid	y5TadmP38ddHKQ6E;

1.8
date	2020.04.03.23.48.48;	author christos;	state Exp;
branches;
next	1.7;
commitid	23XN8arVUk87UZ2C;

1.7
date	2018.11.07.01.13.54;	author christos;	state Exp;
branches;
next	1.6;
commitid	fBTCYRhE5Q1XTWYA;

1.6
date	2018.04.15.20.06.03;	author christos;	state Exp;
branches
	1.6.2.1;
next	1.5;
commitid	MpiHxWBBfLwGMzyA;

1.5
date	2016.10.26.18.43.25;	author christos;	state Exp;
branches
	1.5.12.1;
next	1.4;
commitid	icdZ2D2VouhuyGrz;

1.4
date	2016.01.29.14.42.46;	author christos;	state Exp;
branches
	1.4.2.1;
next	1.3;
commitid	QJ5IMUNnZ6y2WPSy;

1.3
date	2013.09.29.14.03.31;	author christos;	state Exp;
branches;
next	1.2;
commitid	M0UvZ6fnBgRH4l7x;

1.2
date	2011.09.25.04.32.42;	author christos;	state Exp;
branches
	1.2.2.1
	1.2.8.1;
next	1.1;

1.1
date	2009.08.18.10.16.42;	author skrll;	state Exp;
branches
	1.1.1.1;
next	;

1.9.2.1
date	2024.07.01.01.00.13;	author perseant;	state Exp;
branches;
next	;
commitid	NkoYLLCQWWw9v4gF;

1.6.2.1
date	2019.06.10.21.52.20;	author christos;	state Exp;
branches;
next	1.6.2.2;
commitid	jtc8rnCzWiEEHGqB;

1.6.2.2
date	2020.04.08.14.04.43;	author martin;	state Exp;
branches;
next	;
commitid	Qli2aW9E74UFuA3C;

1.5.12.1
date	2018.04.22.07.20.13;	author pgoyette;	state Exp;
branches;
next	1.5.12.2;
commitid	W6xykws0Zbl4kpzA;

1.5.12.2
date	2018.11.26.01.50.18;	author pgoyette;	state Exp;
branches;
next	;
commitid	Zj4q5SspGdKXto1B;

1.4.2.1
date	2016.11.04.14.43.18;	author pgoyette;	state Exp;
branches;
next	;
commitid	2m1JRwYmpwPkOOsz;

1.2.2.1
date	2014.05.22.15.54.29;	author yamt;	state Exp;
branches;
next	;
commitid	LcfsdHQ4HK08ayBx;

1.2.8.1
date	2014.08.19.23.52.43;	author tls;	state Exp;
branches;
next	;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.1
date	2009.08.18.10.16.42;	author skrll;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2011.09.24.22.35.33;	author christos;	state Exp;
branches;
next	1.1.1.3;

1.1.1.3
date	2013.09.29.13.45.04;	author christos;	state Exp;
branches;
next	1.1.1.4;
commitid	TyuuzSx830x3Yk7x;

1.1.1.4
date	2016.01.29.12.45.09;	author christos;	state Exp;
branches;
next	1.1.1.5;
commitid	B0qHLT45wK2yhPSy;

1.1.1.5
date	2016.10.26.17.30.15;	author christos;	state Exp;
branches;
next	1.1.1.6;
commitid	su5ccdRz6qdh9Grz;

1.1.1.6
date	2018.04.14.22.17.15;	author christos;	state Exp;
branches;
next	1.1.1.7;
commitid	ShNerhdmcUZyxsyA;

1.1.1.7
date	2018.11.06.21.19.16;	author christos;	state Exp;
branches;
next	1.1.1.8;
commitid	6Ndf2Zuj4yZRAVYA;

1.1.1.8
date	2020.04.03.23.40.28;	author christos;	state Exp;
branches;
next	1.1.1.9;
commitid	qJOWzDWs5P5cQZ2C;

1.1.1.9
date	2022.12.23.19.01.40;	author christos;	state Exp;
branches;
next	1.1.1.10;
commitid	AaAP7ITTx5JnmI6E;

1.1.1.10
date	2024.06.30.16.00.58;	author christos;	state Exp;
branches;
next	1.1.1.11;
commitid	Eqxmo2uubpM9w1gF;

1.1.1.11
date	2025.08.25.14.43.13;	author christos;	state Exp;
branches;
next	1.1.1.12;
commitid	aUBKFf4jmEzPv78G;

1.1.1.12
date	2026.02.11.19.50.14;	author christos;	state Exp;
branches;
next	;
commitid	vybCSY05tblOMZtG;


desc
@@


1.12
log
@Merge conflicts between 2.45 and 2.46, regen x86
@
text
@This is gprof.info, produced by makeinfo version 7.2 from gprof.texi.

This file documents the gprof profiler of the GNU system.

   Copyright © 1988-2026 Free Software Foundation, Inc.

   Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts.  A copy of the license is included in the section entitled "GNU
Free Documentation License".

INFO-DIR-SECTION Software development
START-INFO-DIR-ENTRY
* gprof: (gprof).                Profiling your program's execution
END-INFO-DIR-ENTRY


File: gprof.info,  Node: Top,  Next: Introduction,  Up: (dir)

Profiling a Program: Where Does It Spend Its Time?
**************************************************

This manual describes the GNU profiler, ‘gprof’, and how you can use it
to determine which parts of a program are taking most of the execution
time.  We assume that you know how to write, compile, and execute
programs.  GNU ‘gprof’ was written by Jay Fenlason.

   This manual is for ‘gprof’ (GNU Binutils) version 2.46.0.

   This document is distributed under the terms of the GNU Free
Documentation License version 1.3.  A copy of the license is included in
the section entitled "GNU Free Documentation License".

* Menu:

* Introduction::        What profiling means, and why it is useful.

* Compiling::           How to compile your program for profiling.
* Executing::           Executing your program to generate profile data
* Invoking::            How to run ‘gprof’, and its options

* Output::              Interpreting ‘gprof’'s output

* Inaccuracy::          Potential problems you should be aware of
* How do I?::           Answers to common questions
* Incompatibilities::   (between GNU ‘gprof’ and Unix ‘gprof’.)
* Details::             Details of how profiling is done
* GNU Free Documentation License::  GNU Free Documentation License


File: gprof.info,  Node: Introduction,  Next: Compiling,  Prev: Top,  Up: Top

1 Introduction to Profiling
***************************

Profiling allows you to learn where your program spent its time and
which functions called which other functions while it was executing.
This information can show you which pieces of your program are slower
than you expected, and might be candidates for rewriting to make your
program execute faster.  It can also tell you which functions are being
called more or less often than you expected.  This may help you spot
bugs that had otherwise been unnoticed.

   Since the profiler uses information collected during the actual
execution of your program, it can be used on programs that are too large
or too complex to analyze by reading the source.  However, how your
program is run will affect the information that shows up in the profile
data.  If you don't use some feature of your program while it is being
profiled, no profile information will be generated for that feature.

   Profiling has several steps:

   • You must compile and link your program with profiling enabled.
     *Note Compiling a Program for Profiling: Compiling.

   • You must execute your program to generate a profile data file.
     *Note Executing the Program: Executing.

   • You must run ‘gprof’ to analyze the profile data.  *Note ‘gprof’
     Command Summary: Invoking.

   The next three chapters explain these steps in greater detail.

   Several forms of output are available from the analysis.

   The “flat profile” shows how much time your program spent in each
function, and how many times that function was called.  If you simply
want to know which functions burn most of the cycles, it is stated
concisely here.  *Note The Flat Profile: Flat Profile.

   The “call graph” shows, for each function, which functions called it,
which other functions it called, and how many times.  There is also an
estimate of how much time was spent in the subroutines of each function.
This can suggest places where you might try to eliminate function calls
that use a lot of time.  *Note The Call Graph: Call Graph.

   The “annotated source” listing is a copy of the program's source
code, labeled with the number of times each line of the program was
executed.  *Note The Annotated Source Listing: Annotated Source.

   To better understand how profiling works, you may wish to read a
description of its implementation.  *Note Implementation of Profiling:
Implementation.


File: gprof.info,  Node: Compiling,  Next: Executing,  Prev: Introduction,  Up: Top

2 Compiling a Program for Profiling
***********************************

The first step in generating profile information for your program is to
compile and link it with profiling enabled.

   To compile a source file for profiling, specify the ‘-pg’ option when
you run the compiler.  (This is in addition to the options you normally
use.)

   To link the program for profiling, if you use a compiler such as ‘cc’
to do the linking, simply specify ‘-pg’ in addition to your usual
options.  The same option, ‘-pg’, alters either compilation or linking
to do what is necessary for profiling.  Here are examples:

     cc -g -c myprog.c utils.c -pg
     cc -o myprog myprog.o utils.o -pg

   The ‘-pg’ option also works with a command that both compiles and
links:

     cc -o myprog myprog.c utils.c -g -pg

   Note: The ‘-pg’ option must be part of your compilation options as
well as your link options.  If it is not then no call-graph data will be
gathered and when you run ‘gprof’ you will get an error message like
this:

     gprof: gmon.out file is missing call-graph data

   If you add the ‘-Q’ switch to suppress the printing of the call graph
data you will still be able to see the time samples:

     Flat profile:

     Each sample counts as 0.01 seconds.
       %   cumulative   self              self     total
      time   seconds   seconds    calls  Ts/call  Ts/call  name
      44.12      0.07     0.07                             zazLoop
      35.29      0.14     0.06                             main
      20.59      0.17     0.04                             bazMillion

   If you run the linker ‘ld’ directly instead of through a compiler
such as ‘cc’, you may have to specify a profiling startup file ‘gcrt0.o’
as the first input file instead of the usual startup file ‘crt0.o’.  In
addition, you would probably want to specify the profiling C library,
‘libc_p.a’, by writing ‘-lc_p’ instead of the usual ‘-lc’.  This is not
absolutely necessary, but doing this gives you number-of-calls
information for standard library functions such as ‘read’ and ‘open’.
For example:

     ld -o myprog /lib/gcrt0.o myprog.o utils.o -lc_p

   If you are running the program on a system which supports shared
libraries you may run into problems with the profiling support code in a
shared library being called before that library has been fully
initialised.  This is usually detected by the program encountering a
segmentation fault as soon as it is run.  The solution is to link
against a static version of the library containing the profiling support
code, which for ‘gcc’ users can be done via the ‘-static’ or
‘-static-libgcc’ command-line option.  For example:

     gcc -g -pg -static-libgcc myprog.c utils.c -o myprog

   If you compile only some of the modules of the program with ‘-pg’,
you can still profile the program, but you won't get complete
information about the modules that were compiled without ‘-pg’.  The
only information you get for the functions in those modules is the total
time spent in them; there is no record of how many times they were
called, or from where.  This will not affect the flat profile (except
that the ‘calls’ field for the functions will be blank), but will
greatly reduce the usefulness of the call graph.

   If you wish to perform line-by-line profiling you should use the
‘gcov’ tool instead of ‘gprof’.  See that tool's manual or info pages
for more details of how to do this.

   Note, older versions of ‘gcc’ produce line-by-line profiling
information that works with ‘gprof’ rather than ‘gcov’ so there is still
support for displaying this kind of information in ‘gprof’.  *Note
Line-by-line Profiling: Line-by-line.

   It also worth noting that ‘gcc’ implements a ‘-finstrument-functions’
command-line option which will insert calls to special user supplied
instrumentation routines at the entry and exit of every function in
their program.  This can be used to implement an alternative profiling
scheme.


File: gprof.info,  Node: Executing,  Next: Invoking,  Prev: Compiling,  Up: Top

3 Executing the Program
***********************

Once the program is compiled for profiling, you must run it in order to
generate the information that ‘gprof’ needs.  Simply run the program as
usual, using the normal arguments, file names, etc.  The program should
run normally, producing the same output as usual.  It will, however, run
somewhat slower than normal because of the time spent collecting and
writing the profile data.

   The way you run the program--the arguments and input that you give
it--may have a dramatic effect on what the profile information shows.
The profile data will describe the parts of the program that were
activated for the particular input you use.  For example, if the first
command you give to your program is to quit, the profile data will show
the time used in initialization and in cleanup, but not much else.

   Your program will write the profile data into a file called
‘gmon.out’ just before exiting.  If there is already a file called
‘gmon.out’, its contents are overwritten.  You can rename the file
afterwards if you are concerned that it may be overwritten.  If your
system libc allows you may be able to write the profile data under a
different name.  Set the GMON_OUT_PREFIX environment variable; this name
will be appended with the PID of the running program.

   In order to write the ‘gmon.out’ file properly, your program must
exit normally: by returning from ‘main’ or by calling ‘exit’.  Calling
the low-level function ‘_exit’ does not write the profile data, and
neither does abnormal termination due to an unhandled signal.

   The ‘gmon.out’ file is written in the program's _current working
directory_ at the time it exits.  This means that if your program calls
‘chdir’, the ‘gmon.out’ file will be left in the last directory your
program ‘chdir’'d to.  If you don't have permission to write in this
directory, the file is not written, and you will get an error message.

   Older versions of the GNU profiling library may also write a file
called ‘bb.out’.  This file, if present, contains an human-readable
listing of the basic-block execution counts.  Unfortunately, the
appearance of a human-readable ‘bb.out’ means the basic-block counts
didn't get written into ‘gmon.out’.  The Perl script ‘bbconv.pl’,
included with the ‘gprof’ source distribution, will convert a ‘bb.out’
file into a format readable by ‘gprof’.  Invoke it like this:

     bbconv.pl < bb.out > BH-DATA

   This translates the information in ‘bb.out’ into a form that ‘gprof’
can understand.  But you still need to tell ‘gprof’ about the existence
of this translated information.  To do that, include BB-DATA on the
‘gprof’ command line, _along with ‘gmon.out’_, like this:

     gprof OPTIONS EXECUTABLE-FILE gmon.out BB-DATA [YET-MORE-PROFILE-DATA-FILES...] [> OUTFILE]


File: gprof.info,  Node: Invoking,  Next: Output,  Prev: Executing,  Up: Top

4 ‘gprof’ Command Summary
*************************

After you have a profile data file ‘gmon.out’, you can run ‘gprof’ to
interpret the information in it.  The ‘gprof’ program prints a flat
profile and a call graph on standard output.  Typically you would
redirect the output of ‘gprof’ into a file with ‘>’.

   Note that ‘gprofng’, a more modern profiler which is also part of
binutils, can also read gmon files and provides more functionality than
‘gprof’.

   You run ‘gprof’ like this:

     gprof OPTIONS [EXECUTABLE-FILE [PROFILE-DATA-FILES...]] [> OUTFILE]

Here square-brackets indicate optional arguments.

   If you omit the executable file name, the file ‘a.out’ is used.  If
you give no profile data file name, the file ‘gmon.out’ is used.  If any
file is not in the proper format, or if the profile data file does not
appear to belong to the executable file, an error message is printed.

   You can give more than one profile data file by entering all their
names after the executable file name; then the statistics in all the
data files are summed together.

   The order of these options does not matter.

* Menu:

* Output Options::      Controlling ‘gprof’'s output style
* Analysis Options::    Controlling how ‘gprof’ analyzes its data
* Miscellaneous Options::
* Deprecated Options::  Options you no longer need to use, but which
                            have been retained for compatibility
* Symspecs::            Specifying functions to include or exclude


File: gprof.info,  Node: Output Options,  Next: Analysis Options,  Up: Invoking

4.1 Output Options
==================

These options specify which of several output formats ‘gprof’ should
produce.

   Many of these options take an optional “symspec” to specify functions
to be included or excluded.  These options can be specified multiple
times, with different symspecs, to include or exclude sets of symbols.
*Note Symspecs: Symspecs.

   Specifying any of these options overrides the default (‘-p -q’),
which prints a flat profile and call graph analysis for all functions.

‘-A[SYMSPEC]’
‘--annotated-source[=SYMSPEC]’
     The ‘-A’ option causes ‘gprof’ to print annotated source code.  If
     SYMSPEC is specified, print output only for matching symbols.
     *Note The Annotated Source Listing: Annotated Source.

‘-b’
‘--brief’
     If the ‘-b’ option is given, ‘gprof’ doesn't print the verbose
     blurbs that try to explain the meaning of all of the fields in the
     tables.  This is useful if you intend to print out the output, or
     are tired of seeing the blurbs.

‘-B’
     The ‘-B’ option causes ‘gprof’ to print the call graph analysis.

‘-C[SYMSPEC]’
‘--exec-counts[=SYMSPEC]’
     The ‘-C’ option causes ‘gprof’ to print a tally of functions and
     the number of times each was called.  If SYMSPEC is specified,
     print tally only for matching symbols.

     If the profile data file contains basic-block count records,
     specifying the ‘-l’ option, along with ‘-C’, will cause basic-block
     execution counts to be tallied and displayed.

‘-i’
‘--file-info’
     The ‘-i’ option causes ‘gprof’ to display summary information about
     the profile data file(s) and then exit.  The number of histogram,
     call graph, and basic-block count records is displayed.

‘-I DIRS’
‘--directory-path=DIRS’
     The ‘-I’ option specifies a list of search directories in which to
     find source files.  Environment variable GPROF_PATH can also be
     used to convey this information.  Used mostly for annotated source
     output.

‘-J[SYMSPEC]’
‘--no-annotated-source[=SYMSPEC]’
     The ‘-J’ option causes ‘gprof’ not to print annotated source code.
     If SYMSPEC is specified, ‘gprof’ prints annotated source, but
     excludes matching symbols.

‘-L’
‘--print-path’
     Normally, source filenames are printed with the path component
     suppressed.  The ‘-L’ option causes ‘gprof’ to print the full
     pathname of source filenames, which is determined from symbolic
     debugging information in the image file and is relative to the
     directory in which the compiler was invoked.

‘-p[SYMSPEC]’
‘--flat-profile[=SYMSPEC]’
     The ‘-p’ option causes ‘gprof’ to print a flat profile.  If SYMSPEC
     is specified, print flat profile only for matching symbols.  *Note
     The Flat Profile: Flat Profile.

‘-P[SYMSPEC]’
‘--no-flat-profile[=SYMSPEC]’
     The ‘-P’ option causes ‘gprof’ to suppress printing a flat profile.
     If SYMSPEC is specified, ‘gprof’ prints a flat profile, but
     excludes matching symbols.

‘-q[SYMSPEC]’
‘--graph[=SYMSPEC]’
     The ‘-q’ option causes ‘gprof’ to print the call graph analysis.
     If SYMSPEC is specified, print call graph only for matching symbols
     and their children.  *Note The Call Graph: Call Graph.

‘-Q[SYMSPEC]’
‘--no-graph[=SYMSPEC]’
     The ‘-Q’ option causes ‘gprof’ to suppress printing the call graph.
     If SYMSPEC is specified, ‘gprof’ prints a call graph, but excludes
     matching symbols.

‘-t’
‘--table-length=NUM’
     The ‘-t’ option causes the NUM most active source lines in each
     source file to be listed when source annotation is enabled.  The
     default is 10.

‘-y’
‘--separate-files’
     This option affects annotated source output only.  Normally,
     ‘gprof’ prints annotated source files to standard-output.  If this
     option is specified, annotated source for a file named
     ‘path/FILENAME’ is generated in the file ‘FILENAME-ann’.  If the
     underlying file system would truncate ‘FILENAME-ann’ so that it
     overwrites the original ‘FILENAME’, ‘gprof’ generates annotated
     source in the file ‘FILENAME.ann’ instead (if the original file
     name has an extension, that extension is _replaced_ with ‘.ann’).

‘-Z[SYMSPEC]’
‘--no-exec-counts[=SYMSPEC]’
     The ‘-Z’ option causes ‘gprof’ not to print a tally of functions
     and the number of times each was called.  If SYMSPEC is specified,
     print tally, but exclude matching symbols.

‘-r’
‘--function-ordering’
     The ‘--function-ordering’ option causes ‘gprof’ to print a
     suggested function ordering for the program based on profiling
     data.  This option suggests an ordering which may improve paging,
     tlb and cache behavior for the program on systems which support
     arbitrary ordering of functions in an executable.

     The exact details of how to force the linker to place functions in
     a particular order is system dependent and out of the scope of this
     manual.

‘-R MAP_FILE’
‘--file-ordering MAP_FILE’
     The ‘--file-ordering’ option causes ‘gprof’ to print a suggested .o
     link line ordering for the program based on profiling data.  This
     option suggests an ordering which may improve paging, tlb and cache
     behavior for the program on systems which do not support arbitrary
     ordering of functions in an executable.

     Use of the ‘-a’ argument is highly recommended with this option.

     The MAP_FILE argument is a pathname to a file which provides
     function name to object file mappings.  The format of the file is
     similar to the output of the program ‘nm’.

          c-parse.o:00000000 T yyparse
          c-parse.o:00000004 C yyerrflag
          c-lang.o:00000000 T maybe_objc_method_name
          c-lang.o:00000000 T print_lang_statistics
          c-lang.o:00000000 T recognize_objc_keyword
          c-decl.o:00000000 T print_lang_identifier
          c-decl.o:00000000 T print_lang_type
          ...

     To create a MAP_FILE with GNU ‘nm’, type a command like ‘nm
     --extern-only --defined-only -v --print-file-name program-name’.

‘-T’
‘--traditional’
     The ‘-T’ option causes ‘gprof’ to print its output in "traditional"
     BSD style.

‘-w WIDTH’
‘--width=WIDTH’
     Sets width of output lines to WIDTH.  Currently only used when
     printing the function index at the bottom of the call graph.

‘-x’
‘--all-lines’
     This option affects annotated source output only.  By default, only
     the lines at the beginning of a basic-block are annotated.  If this
     option is specified, every line in a basic-block is annotated by
     repeating the annotation for the first line.  This behavior is
     similar to ‘tcov’'s ‘-a’.

‘--demangle[=STYLE]’
‘--no-demangle’
     These options control whether C++ symbol names should be demangled
     when printing output.  The default is to demangle symbols.  The
     ‘--no-demangle’ option may be used to turn off demangling.
     Different compilers have different mangling styles.  The optional
     demangling style argument can be used to choose an appropriate
     demangling style for your compiler.


File: gprof.info,  Node: Analysis Options,  Next: Miscellaneous Options,  Prev: Output Options,  Up: Invoking

4.2 Analysis Options
====================

‘-a’
‘--no-static’
     The ‘-a’ option causes ‘gprof’ to suppress the printing of
     statically declared (private) functions.  (These are functions
     whose names are not listed as global, and which are not visible
     outside the file/function/block where they were defined.)  Time
     spent in these functions, calls to/from them, etc., will all be
     attributed to the function that was loaded directly before it in
     the executable file.  This option affects both the flat profile and
     the call graph.

‘-c’
‘--static-call-graph’
     The ‘-c’ option causes the call graph of the program to be
     augmented by a heuristic which examines the text space of the
     object file and identifies function calls in the binary machine
     code.  Since normal call graph records are only generated when
     functions are entered, this option identifies children that could
     have been called, but never were.  Calls to functions that were not
     compiled with profiling enabled are also identified, but only if
     symbol table entries are present for them.  Calls to dynamic
     library routines are typically _not_ found by this option.  Parents
     or children identified via this heuristic are indicated in the call
     graph with call counts of ‘0’.

‘-D’
‘--ignore-non-functions’
     The ‘-D’ option causes ‘gprof’ to ignore symbols which are not
     known to be functions.  This option will give more accurate profile
     data on systems where it is supported (Solaris and HPUX for
     example).

‘-k FROM/TO’
     The ‘-k’ option allows you to delete from the call graph any arcs
     from symbols matching symspec FROM to those matching symspec TO.

‘-l’
‘--line’
     The ‘-l’ option enables line-by-line profiling, which causes
     histogram hits to be charged to individual source code lines,
     instead of functions.  This feature only works with programs
     compiled by older versions of the ‘gcc’ compiler.  Newer versions
     of ‘gcc’ are designed to work with the ‘gcov’ tool instead.

     If the program was compiled with basic-block counting enabled, this
     option will also identify how many times each line of code was
     executed.  While line-by-line profiling can help isolate where in a
     large function a program is spending its time, it also
     significantly increases the running time of ‘gprof’, and magnifies
     statistical inaccuracies.  *Note Statistical Sampling Error:
     Sampling Error.

‘--inline-file-names’
     This option causes ‘gprof’ to print the source file after each
     symbol in both the flat profile and the call graph.  The full path
     to the file is printed if used with the ‘-L’ option.

‘-m NUM’
‘--min-count=NUM’
     This option affects execution count output only.  Symbols that are
     executed less than NUM times are suppressed.

‘-nSYMSPEC’
‘--time=SYMSPEC’
     The ‘-n’ option causes ‘gprof’, in its call graph analysis, to only
     propagate times for symbols matching SYMSPEC.

‘-NSYMSPEC’
‘--no-time=SYMSPEC’
     The ‘-n’ option causes ‘gprof’, in its call graph analysis, not to
     propagate times for symbols matching SYMSPEC.

‘-SFILENAME’
‘--external-symbol-table=FILENAME’
     The ‘-S’ option causes ‘gprof’ to read an external symbol table
     file, such as ‘/proc/kallsyms’, rather than read the symbol table
     from the given object file (the default is ‘a.out’).  This is
     useful for profiling kernel modules.

‘-z’
‘--display-unused-functions’
     If you give the ‘-z’ option, ‘gprof’ will mention all functions in
     the flat profile, even those that were never called, and that had
     no time spent in them.  This is useful in conjunction with the ‘-c’
     option for discovering which routines were never called.


File: gprof.info,  Node: Miscellaneous Options,  Next: Deprecated Options,  Prev: Analysis Options,  Up: Invoking

4.3 Miscellaneous Options
=========================

‘-d[NUM]’
‘--debug[=NUM]’
     The ‘-d NUM’ option specifies debugging options.  If NUM is not
     specified, enable all debugging.  *Note Debugging ‘gprof’:
     Debugging.

‘-h’
‘--help’
     The ‘-h’ option prints command line usage.

‘-ONAME’
‘--file-format=NAME’
     Selects the format of the profile data files.  Recognized formats
     are ‘auto’ (the default), ‘bsd’, ‘4.4bsd’, ‘magic’, and ‘prof’ (not
     yet supported).

‘-s’
‘--sum’
     The ‘-s’ option causes ‘gprof’ to summarize the information in the
     profile data files it read in, and write out a profile data file
     called ‘gmon.sum’, which contains all the information from the
     profile data files that ‘gprof’ read in.  The file ‘gmon.sum’ may
     be one of the specified input files; the effect of this is to merge
     the data in the other input files into ‘gmon.sum’.

     Eventually you can run ‘gprof’ again without ‘-s’ to analyze the
     cumulative data in the file ‘gmon.sum’.

‘-v’
‘--version’
     The ‘-v’ flag causes ‘gprof’ to print the current version number,
     and then exit.


File: gprof.info,  Node: Deprecated Options,  Next: Symspecs,  Prev: Miscellaneous Options,  Up: Invoking

4.4 Deprecated Options
======================

These options have been replaced with newer versions that use symspecs.

‘-e FUNCTION_NAME’
     The ‘-e FUNCTION’ option tells ‘gprof’ to not print information
     about the function FUNCTION_NAME (and its children...) in the call
     graph.  The function will still be listed as a child of any
     functions that call it, but its index number will be shown as ‘[not
     printed]’.  More than one ‘-e’ option may be given; only one
     FUNCTION_NAME may be indicated with each ‘-e’ option.

‘-E FUNCTION_NAME’
     The ‘-E FUNCTION’ option works like the ‘-e’ option, but time spent
     in the function (and children who were not called from anywhere
     else), will not be used to compute the percentages-of-time for the
     call graph.  More than one ‘-E’ option may be given; only one
     FUNCTION_NAME may be indicated with each ‘-E’ option.

‘-f FUNCTION_NAME’
     The ‘-f FUNCTION’ option causes ‘gprof’ to limit the call graph to
     the function FUNCTION_NAME and its children (and their
     children...).  More than one ‘-f’ option may be given; only one
     FUNCTION_NAME may be indicated with each ‘-f’ option.

‘-F FUNCTION_NAME’
     The ‘-F FUNCTION’ option works like the ‘-f’ option, but only time
     spent in the function and its children (and their children...) will
     be used to determine total-time and percentages-of-time for the
     call graph.  More than one ‘-F’ option may be given; only one
     FUNCTION_NAME may be indicated with each ‘-F’ option.  The ‘-F’
     option overrides the ‘-E’ option.

   Note that only one function can be specified with each ‘-e’, ‘-E’,
‘-f’ or ‘-F’ option.  To specify more than one function, use multiple
options.  For example, this command:

     gprof -e boring -f foo -f bar myprogram > gprof.output

lists in the call graph all functions that were reached from either
‘foo’ or ‘bar’ and were not reachable from ‘boring’.


File: gprof.info,  Node: Symspecs,  Prev: Deprecated Options,  Up: Invoking

4.5 Symspecs
============

Many of the output options allow functions to be included or excluded
using “symspecs” (symbol specifications), which observe the following
syntax:

       filename_containing_a_dot
     | funcname_not_containing_a_dot
     | linenumber
     | ( [ any_filename ] `:' ( any_funcname | linenumber ) )

   Here are some sample symspecs:

‘main.c’
     Selects everything in file ‘main.c’--the dot in the string tells
     ‘gprof’ to interpret the string as a filename, rather than as a
     function name.  To select a file whose name does not contain a dot,
     a trailing colon should be specified.  For example, ‘odd:’ is
     interpreted as the file named ‘odd’.

‘main’
     Selects all functions named ‘main’.

     Note that there may be multiple instances of the same function name
     because some of the definitions may be local (i.e., static).
     Unless a function name is unique in a program, you must use the
     colon notation explained below to specify a function from a
     specific source file.

     Sometimes, function names contain dots.  In such cases, it is
     necessary to add a leading colon to the name.  For example, ‘:.mul’
     selects function ‘.mul’.

     In some object file formats, symbols have a leading underscore.
     ‘gprof’ will normally not print these underscores.  When you name a
     symbol in a symspec, you should type it exactly as ‘gprof’ prints
     it in its output.  For example, if the compiler produces a symbol
     ‘_main’ from your ‘main’ function, ‘gprof’ still prints it as
     ‘main’ in its output, so you should use ‘main’ in symspecs.

‘main.c:main’
     Selects function ‘main’ in file ‘main.c’.

‘main.c:134’
     Selects line 134 in file ‘main.c’.


File: gprof.info,  Node: Output,  Next: Inaccuracy,  Prev: Invoking,  Up: Top

5 Interpreting ‘gprof’'s Output
*******************************

‘gprof’ can produce several different output styles, the most important
of which are described below.  The simplest output styles (file
information, execution count, and function and file ordering) are not
described here, but are documented with the respective options that
trigger them.  *Note Output Options: Output Options.

* Menu:

* Flat Profile::        The flat profile shows how much time was spent
                            executing directly in each function.
* Call Graph::          The call graph shows which functions called which
                            others, and how much time each function used
                            when its subroutine calls are included.
* Line-by-line::        ‘gprof’ can analyze individual source code lines
* Annotated Source::    The annotated source listing displays source code
                            labeled with execution counts


File: gprof.info,  Node: Flat Profile,  Next: Call Graph,  Up: Output

5.1 The Flat Profile
====================

The “flat profile” shows the total amount of time your program spent
executing each function.  Unless the ‘-z’ option is given, functions
with no apparent time spent in them, and no apparent calls to them, are
not mentioned.  Note that if a function was not compiled for profiling,
and didn't run long enough to show up on the program counter histogram,
it will be indistinguishable from a function that was never called.

   This is part of a flat profile for a small program:

     Flat profile:

     Each sample counts as 0.01 seconds.
       %   cumulative   self              self     total
      time   seconds   seconds    calls  ms/call  ms/call  name
      33.34      0.02     0.02     7208     0.00     0.00  open
      16.67      0.03     0.01      244     0.04     0.12  offtime
      16.67      0.04     0.01        8     1.25     1.25  memccpy
      16.67      0.05     0.01        7     1.43     1.43  write
      16.67      0.06     0.01                             mcount
       0.00      0.06     0.00      236     0.00     0.00  tzset
       0.00      0.06     0.00      192     0.00     0.00  tolower
       0.00      0.06     0.00       47     0.00     0.00  strlen
       0.00      0.06     0.00       45     0.00     0.00  strchr
       0.00      0.06     0.00        1     0.00    50.00  main
       0.00      0.06     0.00        1     0.00     0.00  memcpy
       0.00      0.06     0.00        1     0.00    10.11  print
       0.00      0.06     0.00        1     0.00     0.00  profil
       0.00      0.06     0.00        1     0.00    50.00  report
     ...

The functions are sorted first by decreasing run-time spent in them,
then by decreasing number of calls, then alphabetically by name.  The
functions ‘mcount’ and ‘profil’ are part of the profiling apparatus and
appear in every flat profile; their time gives a measure of the amount
of overhead due to profiling.

   Just before the column headers, a statement appears indicating how
much time each sample counted as.  This “sampling period” estimates the
margin of error in each of the time figures.  A time figure that is not
much larger than this is not reliable.  In this example, each sample
counted as 0.01 seconds, suggesting a 100 Hz sampling rate.  The
program's total execution time was 0.06 seconds, as indicated by the
‘cumulative seconds’ field.  Since each sample counted for 0.01 seconds,
this means only six samples were taken during the run.  Two of the
samples occurred while the program was in the ‘open’ function, as
indicated by the ‘self seconds’ field.  Each of the other four samples
occurred one each in ‘offtime’, ‘memccpy’, ‘write’, and ‘mcount’.  Since
only six samples were taken, none of these values can be regarded as
particularly reliable.  In another run, the ‘self seconds’ field for
‘mcount’ might well be ‘0.00’ or ‘0.02’.  *Note Statistical Sampling
Error: Sampling Error, for a complete discussion.

   The remaining functions in the listing (those whose ‘self seconds’
field is ‘0.00’) didn't appear in the histogram samples at all.
However, the call graph indicated that they were called, so therefore
they are listed, sorted in decreasing order by the ‘calls’ field.
Clearly some time was spent executing these functions, but the paucity
of histogram samples prevents any determination of how much time each
took.

   Here is what the fields in each line mean:

‘% time’
     This is the percentage of the total execution time your program
     spent in this function.  These should all add up to 100%.

‘cumulative seconds’
     This is the cumulative total number of seconds the computer spent
     executing this functions, plus the time spent in all the functions
     above this one in this table.

‘self seconds’
     This is the number of seconds accounted for by this function alone.
     The flat profile listing is sorted first by this number.

‘calls’
     This is the total number of times the function was called.  If the
     function was never called, or the number of times it was called
     cannot be determined (probably because the function was not
     compiled with profiling enabled), the “calls” field is blank.

‘self ms/call’
     This represents the average number of milliseconds spent in this
     function per call, if this function is profiled.  Otherwise, this
     field is blank for this function.

‘total ms/call’
     This represents the average number of milliseconds spent in this
     function and its descendants per call, if this function is
     profiled.  Otherwise, this field is blank for this function.  This
     is the only field in the flat profile that uses call graph
     analysis.

‘name’
     This is the name of the function.  The flat profile is sorted by
     this field alphabetically after the “self seconds” and “calls”
     fields are sorted.


File: gprof.info,  Node: Call Graph,  Next: Line-by-line,  Prev: Flat Profile,  Up: Output

5.2 The Call Graph
==================

The “call graph” shows how much time was spent in each function and its
children.  From this information, you can find functions that, while
they themselves may not have used much time, called other functions that
did use unusual amounts of time.

   Here is a sample call from a small program.  This call came from the
same ‘gprof’ run as the flat profile example in the previous section.

     granularity: each sample hit covers 2 byte(s) for 20.00% of 0.05 seconds

     index % time    self  children    called     name
                                                      <spontaneous>
     [1]    100.0    0.00    0.05                 start [1]
                     0.00    0.05       1/1           main [2]
                     0.00    0.00       1/2           on_exit [28]
                     0.00    0.00       1/1           exit [59]
     -----------------------------------------------
                     0.00    0.05       1/1           start [1]
     [2]    100.0    0.00    0.05       1         main [2]
                     0.00    0.05       1/1           report [3]
     -----------------------------------------------
                     0.00    0.05       1/1           main [2]
     [3]    100.0    0.00    0.05       1         report [3]
                     0.00    0.03       8/8           timelocal [6]
                     0.00    0.01       1/1           print [9]
                     0.00    0.01       9/9           fgets [12]
                     0.00    0.00      12/34          strncmp <cycle 1> [40]
                     0.00    0.00       8/8           lookup [20]
                     0.00    0.00       1/1           fopen [21]
                     0.00    0.00       8/8           chewtime [24]
                     0.00    0.00       8/16          skipspace [44]
     -----------------------------------------------
     [4]     59.8    0.01        0.02       8+472     <cycle 2 as a whole> [4]
                     0.01        0.02     244+260         offtime <cycle 2> [7]
                     0.00        0.00     236+1           tzset <cycle 2> [26]
     -----------------------------------------------

   The lines full of dashes divide this table into “entries”, one for
each function.  Each entry has one or more lines.

   In each entry, the primary line is the one that starts with an index
number in square brackets.  The end of this line says which function the
entry is for.  The preceding lines in the entry describe the callers of
this function and the following lines describe its subroutines (also
called “children” when we speak of the call graph).

   The entries are sorted by time spent in the function and its
subroutines.

   The internal profiling function ‘mcount’ (*note The Flat Profile:
Flat Profile.) is never mentioned in the call graph.

* Menu:

* Primary::       Details of the primary line's contents.
* Callers::       Details of caller-lines' contents.
* Subroutines::   Details of subroutine-lines' contents.
* Cycles::        When there are cycles of recursion,
                   such as ‘a’ calls ‘b’ calls ‘a’...


File: gprof.info,  Node: Primary,  Next: Callers,  Up: Call Graph

5.2.1 The Primary Line
----------------------

The “primary line” in a call graph entry is the line that describes the
function which the entry is about and gives the overall statistics for
this function.

   For reference, we repeat the primary line from the entry for function
‘report’ in our main example, together with the heading line that shows
the names of the fields:

     index  % time    self  children called     name
     ...
     [3]    100.0    0.00    0.05       1         report [3]

   Here is what the fields in the primary line mean:

‘index’
     Entries are numbered with consecutive integers.  Each function
     therefore has an index number, which appears at the beginning of
     its primary line.

     Each cross-reference to a function, as a caller or subroutine of
     another, gives its index number as well as its name.  The index
     number guides you if you wish to look for the entry for that
     function.

‘% time’
     This is the percentage of the total time that was spent in this
     function, including time spent in subroutines called from this
     function.

     The time spent in this function is counted again for the callers of
     this function.  Therefore, adding up these percentages is
     meaningless.

‘self’
     This is the total amount of time spent in this function.  This
     should be identical to the number printed in the ‘seconds’ field
     for this function in the flat profile.

‘children’
     This is the total amount of time spent in the subroutine calls made
     by this function.  This should be equal to the sum of all the
     ‘self’ and ‘children’ entries of the children listed directly below
     this function.

‘called’
     This is the number of times the function was called.

     If the function called itself recursively, there are two numbers,
     separated by a ‘+’.  The first number counts non-recursive calls,
     and the second counts recursive calls.

     In the example above, the function ‘report’ was called once from
     ‘main’.

‘name’
     This is the name of the current function.  The index number is
     repeated after it.

     If the function is part of a cycle of recursion, the cycle number
     is printed between the function's name and the index number (*note
     How Mutually Recursive Functions Are Described: Cycles.).  For
     example, if function ‘gnurr’ is part of cycle number one, and has
     index number twelve, its primary line would be end like this:

          gnurr <cycle 1> [12]


File: gprof.info,  Node: Callers,  Next: Subroutines,  Prev: Primary,  Up: Call Graph

5.2.2 Lines for a Function's Callers
------------------------------------

A function's entry has a line for each function it was called by.  These
lines' fields correspond to the fields of the primary line, but their
meanings are different because of the difference in context.

   For reference, we repeat two lines from the entry for the function
‘report’, the primary line and one caller-line preceding it, together
with the heading line that shows the names of the fields:

     index  % time    self  children called     name
     ...
                     0.00    0.05       1/1           main [2]
     [3]    100.0    0.00    0.05       1         report [3]

   Here are the meanings of the fields in the caller-line for ‘report’
called from ‘main’:

‘self’
     An estimate of the amount of time spent in ‘report’ itself when it
     was called from ‘main’.

‘children’
     An estimate of the amount of time spent in subroutines of ‘report’
     when ‘report’ was called from ‘main’.

     The sum of the ‘self’ and ‘children’ fields is an estimate of the
     amount of time spent within calls to ‘report’ from ‘main’.

‘called’
     Two numbers: the number of times ‘report’ was called from ‘main’,
     followed by the total number of non-recursive calls to ‘report’
     from all its callers.

‘name and index number’
     The name of the caller of ‘report’ to which this line applies,
     followed by the caller's index number.

     Not all functions have entries in the call graph; some options to
     ‘gprof’ request the omission of certain functions.  When a caller
     has no entry of its own, it still has caller-lines in the entries
     of the functions it calls.

     If the caller is part of a recursion cycle, the cycle number is
     printed between the name and the index number.

   If the identity of the callers of a function cannot be determined, a
dummy caller-line is printed which has ‘<spontaneous>’ as the "caller's
name" and all other fields blank.  This can happen for signal handlers.


File: gprof.info,  Node: Subroutines,  Next: Cycles,  Prev: Callers,  Up: Call Graph

5.2.3 Lines for a Function's Subroutines
----------------------------------------

A function's entry has a line for each of its subroutines--in other
words, a line for each other function that it called.  These lines'
fields correspond to the fields of the primary line, but their meanings
are different because of the difference in context.

   For reference, we repeat two lines from the entry for the function
‘main’, the primary line and a line for a subroutine, together with the
heading line that shows the names of the fields:

     index  % time    self  children called     name
     ...
     [2]    100.0    0.00    0.05       1         main [2]
                     0.00    0.05       1/1           report [3]

   Here are the meanings of the fields in the subroutine-line for ‘main’
calling ‘report’:

‘self’
     An estimate of the amount of time spent directly within ‘report’
     when ‘report’ was called from ‘main’.

‘children’
     An estimate of the amount of time spent in subroutines of ‘report’
     when ‘report’ was called from ‘main’.

     The sum of the ‘self’ and ‘children’ fields is an estimate of the
     total time spent in calls to ‘report’ from ‘main’.

‘called’
     Two numbers, the number of calls to ‘report’ from ‘main’ followed
     by the total number of non-recursive calls to ‘report’.  This ratio
     is used to determine how much of ‘report’'s ‘self’ and ‘children’
     time gets credited to ‘main’.  *Note Estimating ‘children’ Times:
     Assumptions.

‘name’
     The name of the subroutine of ‘main’ to which this line applies,
     followed by the subroutine's index number.

     If the caller is part of a recursion cycle, the cycle number is
     printed between the name and the index number.


File: gprof.info,  Node: Cycles,  Prev: Subroutines,  Up: Call Graph

5.2.4 How Mutually Recursive Functions Are Described
----------------------------------------------------

The graph may be complicated by the presence of “cycles of recursion” in
the call graph.  A cycle exists if a function calls another function
that (directly or indirectly) calls (or appears to call) the original
function.  For example: if ‘a’ calls ‘b’, and ‘b’ calls ‘a’, then ‘a’
and ‘b’ form a cycle.

   Whenever there are call paths both ways between a pair of functions,
they belong to the same cycle.  If ‘a’ and ‘b’ call each other and ‘b’
and ‘c’ call each other, all three make one cycle.  Note that even if
‘b’ only calls ‘a’ if it was not called from ‘a’, ‘gprof’ cannot
determine this, so ‘a’ and ‘b’ are still considered a cycle.

   The cycles are numbered with consecutive integers.  When a function
belongs to a cycle, each time the function name appears in the call
graph it is followed by ‘<cycle NUMBER>’.

   The reason cycles matter is that they make the time values in the
call graph paradoxical.  The "time spent in children" of ‘a’ should
include the time spent in its subroutine ‘b’ and in ‘b’'s
subroutines--but one of ‘b’'s subroutines is ‘a’!  How much of ‘a’'s
time should be included in the children of ‘a’, when ‘a’ is indirectly
recursive?

   The way ‘gprof’ resolves this paradox is by creating a single entry
for the cycle as a whole.  The primary line of this entry describes the
total time spent directly in the functions of the cycle.  The
"subroutines" of the cycle are the individual functions of the cycle,
and all other functions that were called directly by them.  The
"callers" of the cycle are the functions, outside the cycle, that called
functions in the cycle.

   Here is an example portion of a call graph which shows a cycle
containing functions ‘a’ and ‘b’.  The cycle was entered by a call to
‘a’ from ‘main’; both ‘a’ and ‘b’ called ‘c’.

     index  % time    self  children called     name
     ----------------------------------------
                      1.77        0    1/1        main [2]
     [3]     91.71    1.77        0    1+5    <cycle 1 as a whole> [3]
                      1.02        0    3          b <cycle 1> [4]
                      0.75        0    2          a <cycle 1> [5]
     ----------------------------------------
                                       3          a <cycle 1> [5]
     [4]     52.85    1.02        0    0      b <cycle 1> [4]
                                       2          a <cycle 1> [5]
                         0        0    3/6        c [6]
     ----------------------------------------
                      1.77        0    1/1        main [2]
                                       2          b <cycle 1> [4]
     [5]     38.86    0.75        0    1      a <cycle 1> [5]
                                       3          b <cycle 1> [4]
                         0        0    3/6        c [6]
     ----------------------------------------

(The entire call graph for this program contains in addition an entry
for ‘main’, which calls ‘a’, and an entry for ‘c’, with callers ‘a’ and
‘b’.)

     index  % time    self  children called     name
                                                  <spontaneous>
     [1]    100.00       0     1.93    0      start [1]
                      0.16     1.77    1/1        main [2]
     ----------------------------------------
                      0.16     1.77    1/1        start [1]
     [2]    100.00    0.16     1.77    1      main [2]
                      1.77        0    1/1        a <cycle 1> [5]
     ----------------------------------------
                      1.77        0    1/1        main [2]
     [3]     91.71    1.77        0    1+5    <cycle 1 as a whole> [3]
                      1.02        0    3          b <cycle 1> [4]
                      0.75        0    2          a <cycle 1> [5]
                         0        0    6/6        c [6]
     ----------------------------------------
                                       3          a <cycle 1> [5]
     [4]     52.85    1.02        0    0      b <cycle 1> [4]
                                       2          a <cycle 1> [5]
                         0        0    3/6        c [6]
     ----------------------------------------
                      1.77        0    1/1        main [2]
                                       2          b <cycle 1> [4]
     [5]     38.86    0.75        0    1      a <cycle 1> [5]
                                       3          b <cycle 1> [4]
                         0        0    3/6        c [6]
     ----------------------------------------
                         0        0    3/6        b <cycle 1> [4]
                         0        0    3/6        a <cycle 1> [5]
     [6]      0.00       0        0    6      c [6]
     ----------------------------------------

   The ‘self’ field of the cycle's primary line is the total time spent
in all the functions of the cycle.  It equals the sum of the ‘self’
fields for the individual functions in the cycle, found in the entry in
the subroutine lines for these functions.

   The ‘children’ fields of the cycle's primary line and subroutine
lines count only subroutines outside the cycle.  Even though ‘a’ calls
‘b’, the time spent in those calls to ‘b’ is not counted in ‘a’'s
‘children’ time.  Thus, we do not encounter the problem of what to do
when the time in those calls to ‘b’ includes indirect recursive calls
back to ‘a’.

   The ‘children’ field of a caller-line in the cycle's entry estimates
the amount of time spent _in the whole cycle_, and its other
subroutines, on the times when that caller called a function in the
cycle.

   The ‘called’ field in the primary line for the cycle has two numbers:
first, the number of times functions in the cycle were called by
functions outside the cycle; second, the number of times they were
called by functions in the cycle (including times when a function in the
cycle calls itself).  This is a generalization of the usual split into
non-recursive and recursive calls.

   The ‘called’ field of a subroutine-line for a cycle member in the
cycle's entry says how many time that function was called from functions
in the cycle.  The total of all these is the second number in the
primary line's ‘called’ field.

   In the individual entry for a function in a cycle, the other
functions in the same cycle can appear as subroutines and as callers.
These lines show how many times each function in the cycle called or was
called from each other function in the cycle.  The ‘self’ and ‘children’
fields in these lines are blank because of the difficulty of defining
meanings for them when recursion is going on.


File: gprof.info,  Node: Line-by-line,  Next: Annotated Source,  Prev: Call Graph,  Up: Output

5.3 Line-by-line Profiling
==========================

‘gprof’'s ‘-l’ option causes the program to perform “line-by-line”
profiling.  In this mode, histogram samples are assigned not to
functions, but to individual lines of source code.  This only works with
programs compiled with older versions of the ‘gcc’ compiler.  Newer
versions of ‘gcc’ use a different program - ‘gcov’ - to display
line-by-line profiling information.

   With the older versions of ‘gcc’ the program usually has to be
compiled with a ‘-g’ option, in addition to ‘-pg’, in order to generate
debugging symbols for tracking source code lines.  Note, in much older
versions of ‘gcc’ the program had to be compiled with the ‘-a’
command-line option as well.

   The flat profile is the most useful output table in line-by-line
mode.  The call graph isn't as useful as normal, since the current
version of ‘gprof’ does not propagate call graph arcs from source code
lines to the enclosing function.  The call graph does, however, show
each line of code that called each function, along with a count.

   Here is a section of ‘gprof’'s output, without line-by-line
profiling.  Note that ‘ct_init’ accounted for four histogram hits, and
13327 calls to ‘init_block’.

     Flat profile:

     Each sample counts as 0.01 seconds.
       %   cumulative   self              self     total
      time   seconds   seconds    calls  us/call  us/call  name
      30.77      0.13     0.04     6335     6.31     6.31  ct_init


     		     Call graph (explanation follows)


     granularity: each sample hit covers 4 byte(s) for 7.69% of 0.13 seconds

     index % time    self  children    called     name

                     0.00    0.00       1/13496       name_too_long
                     0.00    0.00      40/13496       deflate
                     0.00    0.00     128/13496       deflate_fast
                     0.00    0.00   13327/13496       ct_init
     [7]      0.0    0.00    0.00   13496         init_block

   Now let's look at some of ‘gprof’'s output from the same program run,
this time with line-by-line profiling enabled.  Note that ‘ct_init’'s
four histogram hits are broken down into four lines of source code--one
hit occurred on each of lines 349, 351, 382 and 385.  In the call graph,
note how ‘ct_init’'s 13327 calls to ‘init_block’ are broken down into
one call from line 396, 3071 calls from line 384, 3730 calls from line
385, and 6525 calls from 387.

     Flat profile:

     Each sample counts as 0.01 seconds.
       %   cumulative   self
      time   seconds   seconds    calls  name
       7.69      0.10     0.01           ct_init (trees.c:349)
       7.69      0.11     0.01           ct_init (trees.c:351)
       7.69      0.12     0.01           ct_init (trees.c:382)
       7.69      0.13     0.01           ct_init (trees.c:385)


     		     Call graph (explanation follows)


     granularity: each sample hit covers 4 byte(s) for 7.69% of 0.13 seconds

       % time    self  children    called     name

                 0.00    0.00       1/13496       name_too_long (gzip.c:1440)
                 0.00    0.00       1/13496       deflate (deflate.c:763)
                 0.00    0.00       1/13496       ct_init (trees.c:396)
                 0.00    0.00       2/13496       deflate (deflate.c:727)
                 0.00    0.00       4/13496       deflate (deflate.c:686)
                 0.00    0.00       5/13496       deflate (deflate.c:675)
                 0.00    0.00      12/13496       deflate (deflate.c:679)
                 0.00    0.00      16/13496       deflate (deflate.c:730)
                 0.00    0.00     128/13496       deflate_fast (deflate.c:654)
                 0.00    0.00    3071/13496       ct_init (trees.c:384)
                 0.00    0.00    3730/13496       ct_init (trees.c:385)
                 0.00    0.00    6525/13496       ct_init (trees.c:387)
     [6]  0.0    0.00    0.00   13496         init_block (trees.c:408)


File: gprof.info,  Node: Annotated Source,  Prev: Line-by-line,  Up: Output

5.4 The Annotated Source Listing
================================

‘gprof’'s ‘-A’ option triggers an annotated source listing, which lists
the program's source code, each function labeled with the number of
times it was called.  You may also need to specify the ‘-I’ option, if
‘gprof’ can't find the source code files.

   With older versions of ‘gcc’ compiling with ‘gcc ... -g -pg -a’
augments your program with basic-block counting code, in addition to
function counting code.  This enables ‘gprof’ to determine how many
times each line of code was executed.  With newer versions of ‘gcc’
support for displaying basic-block counts is provided by the ‘gcov’
program.

   For example, consider the following function, taken from gzip, with
line numbers added:

      1 ulg updcrc(s, n)
      2     uch *s;
      3     unsigned n;
      4 {
      5     register ulg c;
      6
      7     static ulg crc = (ulg)0xffffffffL;
      8
      9     if (s == NULL) {
     10         c = 0xffffffffL;
     11     } else {
     12         c = crc;
     13         if (n) do {
     14             c = crc_32_tab[...];
     15         } while (--n);
     16     }
     17     crc = c;
     18     return c ^ 0xffffffffL;
     19 }

   ‘updcrc’ has at least five basic-blocks.  One is the function itself.
The ‘if’ statement on line 9 generates two more basic-blocks, one for
each branch of the ‘if’.  A fourth basic-block results from the ‘if’ on
line 13, and the contents of the ‘do’ loop form the fifth basic-block.
The compiler may also generate additional basic-blocks to handle various
special cases.

   A program augmented for basic-block counting can be analyzed with
‘gprof -l -A’.  The ‘-x’ option is also helpful, to ensure that each
line of code is labeled at least once.  Here is ‘updcrc’'s annotated
source listing for a sample ‘gzip’ run:

                     ulg updcrc(s, n)
                         uch *s;
                         unsigned n;
                 2 ->{
                         register ulg c;

                         static ulg crc = (ulg)0xffffffffL;

                 2 ->    if (s == NULL) {
                 1 ->        c = 0xffffffffL;
                 1 ->    } else {
                 1 ->        c = crc;
                 1 ->        if (n) do {
             26312 ->            c = crc_32_tab[...];
     26312,1,26311 ->        } while (--n);
                         }
                 2 ->    crc = c;
                 2 ->    return c ^ 0xffffffffL;
                 2 ->}

   In this example, the function was called twice, passing once through
each branch of the ‘if’ statement.  The body of the ‘do’ loop was
executed a total of 26312 times.  Note how the ‘while’ statement is
annotated.  It began execution 26312 times, once for each iteration
through the loop.  One of those times (the last time) it exited, while
it branched back to the beginning of the loop 26311 times.


File: gprof.info,  Node: Inaccuracy,  Next: How do I?,  Prev: Output,  Up: Top

6 Inaccuracy of ‘gprof’ Output
******************************

* Menu:

* Sampling Error::      Statistical margins of error
* Assumptions::         Estimating children times


File: gprof.info,  Node: Sampling Error,  Next: Assumptions,  Up: Inaccuracy

6.1 Statistical Sampling Error
==============================

The run-time figures that ‘gprof’ gives you are based on a sampling
process, so they are subject to statistical inaccuracy.  If a function
runs only a small amount of time, so that on the average the sampling
process ought to catch that function in the act only once, there is a
pretty good chance it will actually find that function zero times, or
twice.

   By contrast, the number-of-calls and basic-block figures are derived
by counting, not sampling.  They are completely accurate and will not
vary from run to run if your program is deterministic and single
threaded.  In multi-threaded applications, or single threaded
applications that link with multi-threaded libraries, the counts are
only deterministic if the counting function is thread-safe.  (Note:
beware that the mcount counting function in glibc is _not_ thread-safe).
*Note Implementation of Profiling: Implementation.

   The “sampling period” that is printed at the beginning of the flat
profile says how often samples are taken.  The rule of thumb is that a
run-time figure is accurate if it is considerably bigger than the
sampling period.

   The actual amount of error can be predicted.  For N samples, the
_expected_ error is the square-root of N.  For example, if the sampling
period is 0.01 seconds and ‘foo’'s run-time is 1 second, N is 100
samples (1 second/0.01 seconds), sqrt(N) is 10 samples, so the expected
error in ‘foo’'s run-time is 0.1 seconds (10*0.01 seconds), or ten
percent of the observed value.  Again, if the sampling period is 0.01
seconds and ‘bar’'s run-time is 100 seconds, N is 10000 samples, sqrt(N)
is 100 samples, so the expected error in ‘bar’'s run-time is 1 second,
or one percent of the observed value.  It is likely to vary this much
_on the average_ from one profiling run to the next.  (_Sometimes_ it
will vary more.)

   This does not mean that a small run-time figure is devoid of
information.  If the program's _total_ run-time is large, a small
run-time for one function does tell you that that function used an
insignificant fraction of the whole program's time.  Usually this means
it is not worth optimizing.

   One way to get more accuracy is to give your program more (but
similar) input data so it will take longer.  Another way is to combine
the data from several runs, using the ‘-s’ option of ‘gprof’.  Here is
how:

  1. Run your program once.

  2. Issue the command ‘mv gmon.out gmon.sum’.

  3. Run your program again, the same as before.

  4. Merge the new data in ‘gmon.out’ into ‘gmon.sum’ with this command:

          gprof -s EXECUTABLE-FILE gmon.out gmon.sum

  5. Repeat the last two steps as often as you wish.

  6. Analyze the cumulative data using this command:

          gprof EXECUTABLE-FILE gmon.sum > OUTPUT-FILE


File: gprof.info,  Node: Assumptions,  Prev: Sampling Error,  Up: Inaccuracy

6.2 Estimating ‘children’ Times
===============================

Some of the figures in the call graph are estimates--for example, the
‘children’ time values and all the time figures in caller and subroutine
lines.

   There is no direct information about these measurements in the
profile data itself.  Instead, ‘gprof’ estimates them by making an
assumption about your program that might or might not be true.

   The assumption made is that the average time spent in each call to
any function ‘foo’ is not correlated with who called ‘foo’.  If ‘foo’
used 5 seconds in all, and 2/5 of the calls to ‘foo’ came from ‘a’, then
‘foo’ contributes 2 seconds to ‘a’'s ‘children’ time, by assumption.

   This assumption is usually true enough, but for some programs it is
far from true.  Suppose that ‘foo’ returns very quickly when its
argument is zero; suppose that ‘a’ always passes zero as an argument,
while other callers of ‘foo’ pass other arguments.  In this program, all
the time spent in ‘foo’ is in the calls from callers other than ‘a’.
But ‘gprof’ has no way of knowing this; it will blindly and incorrectly
charge 2 seconds of time in ‘foo’ to the children of ‘a’.

   We hope some day to put more complete data into ‘gmon.out’, so that
this assumption is no longer needed, if we can figure out how.  For the
novice, the estimated figures are usually more useful than misleading.


File: gprof.info,  Node: How do I?,  Next: Incompatibilities,  Prev: Inaccuracy,  Up: Top

7 Answers to Common Questions
*****************************

How can I get more exact information about hot spots in my program?

     Looking at the per-line call counts only tells part of the story.
     Because ‘gprof’ can only report call times and counts by function,
     the best way to get finer-grained information on where the program
     is spending its time is to re-factor large functions into sequences
     of calls to smaller ones.  Beware however that this can introduce
     artificial hot spots since compiling with ‘-pg’ adds a significant
     overhead to function calls.  An alternative solution is to use a
     non-intrusive profiler, e.g. oprofile.

How do I find which lines in my program were executed the most times?

     Use the ‘gcov’ program.

How do I find which lines in my program called a particular function?

     Use ‘gprof -l’ and lookup the function in the call graph.  The
     callers will be broken down by function and line number.

How do I analyze a program that runs for less than a second?

     Try using a shell script like this one:

          for i in `seq 1 100`; do
            fastprog
            mv gmon.out gmon.out.$i
          done

          gprof -s fastprog gmon.out.*

          gprof fastprog gmon.sum

     If your program is completely deterministic, all the call counts
     will be simple multiples of 100 (i.e., a function called once in
     each run will appear with a call count of 100).


File: gprof.info,  Node: Incompatibilities,  Next: Details,  Prev: How do I?,  Up: Top

8 Incompatibilities with Unix ‘gprof’
*************************************

GNU ‘gprof’ and Berkeley Unix ‘gprof’ use the same data file ‘gmon.out’,
and provide essentially the same information.  But there are a few
differences.

   • GNU ‘gprof’ uses a new, generalized file format with support for
     basic-block execution counts and non-realtime histograms.  A magic
     cookie and version number allows ‘gprof’ to easily identify new
     style files.  Old BSD-style files can still be read.  *Note
     Profiling Data File Format: File Format.

   • For a recursive function, Unix ‘gprof’ lists the function as a
     parent and as a child, with a ‘calls’ field that lists the number
     of recursive calls.  GNU ‘gprof’ omits these lines and puts the
     number of recursive calls in the primary line.

   • When a function is suppressed from the call graph with ‘-e’, GNU
     ‘gprof’ still lists it as a subroutine of functions that call it.

   • GNU ‘gprof’ accepts the ‘-k’ with its argument in the form
     ‘from/to’, instead of ‘from to’.

   • In the annotated source listing, if there are multiple basic blocks
     on the same line, GNU ‘gprof’ prints all of their counts, separated
     by commas.

   • The blurbs, field widths, and output formats are different.  GNU
     ‘gprof’ prints blurbs after the tables, so that you can see the
     tables without skipping the blurbs.


File: gprof.info,  Node: Details,  Next: GNU Free Documentation License,  Prev: Incompatibilities,  Up: Top

9 Details of Profiling
**********************

* Menu:

* Implementation::      How a program collects profiling information
* File Format::         Format of ‘gmon.out’ files
* Internals::           ‘gprof’'s internal operation
* Debugging::           Using ‘gprof’'s ‘-d’ option


File: gprof.info,  Node: Implementation,  Next: File Format,  Up: Details

9.1 Implementation of Profiling
===============================

Profiling works by changing how every function in your program is
compiled so that when it is called, it will stash away some information
about where it was called from.  From this, the profiler can figure out
what function called it, and can count how many times it was called.
This change is made by the compiler when your program is compiled with
the ‘-pg’ option, which causes every function to call ‘mcount’ (or
‘_mcount’, or ‘__mcount’, depending on the OS and compiler) as one of
its first operations.

   The ‘mcount’ routine, included in the profiling library, is
responsible for recording in an in-memory call graph table both its
parent routine (the child) and its parent's parent.  This is typically
done by examining the stack frame to find both the address of the child,
and the return address in the original parent.  Since this is a very
machine-dependent operation, ‘mcount’ itself is typically a short
assembly-language stub routine that extracts the required information,
and then calls ‘__mcount_internal’ (a normal C function) with two
arguments--‘frompc’ and ‘selfpc’.  ‘__mcount_internal’ is responsible
for maintaining the in-memory call graph, which records ‘frompc’,
‘selfpc’, and the number of times each of these call arcs was traversed.

   GCC Version 2 provides a magical function
(‘__builtin_return_address’), which allows a generic ‘mcount’ function
to extract the required information from the stack frame.  However, on
some architectures, most notably the SPARC, using this builtin can be
very computationally expensive, and an assembly language version of
‘mcount’ is used for performance reasons.

   Number-of-calls information for library routines is collected by
using a special version of the C library.  The programs in it are the
same as in the usual C library, but they were compiled with ‘-pg’.  If
you link your program with ‘gcc ... -pg’, it automatically uses the
profiling version of the library.

   Profiling also involves watching your program as it runs, and keeping
a histogram of where the program counter happens to be every now and
then.  Typically the program counter is looked at around 100 times per
second of run time, but the exact frequency may vary from system to
system.

   This is done is one of two ways.  Most UNIX-like operating systems
provide a ‘profil()’ system call, which registers a memory array with
the kernel, along with a scale factor that determines how the program's
address space maps into the array.  Typical scaling values cause every 2
to 8 bytes of address space to map into a single array slot.  On every
tick of the system clock (assuming the profiled program is running), the
value of the program counter is examined and the corresponding slot in
the memory array is incremented.  Since this is done in the kernel,
which had to interrupt the process anyway to handle the clock interrupt,
very little additional system overhead is required.

   However, some operating systems, most notably Linux 2.0 (and
earlier), do not provide a ‘profil()’ system call.  On such a system,
arrangements are made for the kernel to periodically deliver a signal to
the process (typically via ‘setitimer()’), which then performs the same
operation of examining the program counter and incrementing a slot in
the memory array.  Since this method requires a signal to be delivered
to user space every time a sample is taken, it uses considerably more
overhead than kernel-based profiling.  Also, due to the added delay
required to deliver the signal, this method is less accurate as well.

   A special startup routine allocates memory for the histogram and
either calls ‘profil()’ or sets up a clock signal handler.  This routine
(‘monstartup’) can be invoked in several ways.  On Linux systems, a
special profiling startup file ‘gcrt0.o’, which invokes ‘monstartup’
before ‘main’, is used instead of the default ‘crt0.o’.  Use of this
special startup file is one of the effects of using ‘gcc ... -pg’ to
link.  On SPARC systems, no special startup files are used.  Rather, the
‘mcount’ routine, when it is invoked for the first time (typically when
‘main’ is called), calls ‘monstartup’.

   If the compiler's ‘-a’ option was used, basic-block counting is also
enabled.  Each object file is then compiled with a static array of
counts, initially zero.  In the executable code, every time a new
basic-block begins (i.e., when an ‘if’ statement appears), an extra
instruction is inserted to increment the corresponding count in the
array.  At compile time, a paired array was constructed that recorded
the starting address of each basic-block.  Taken together, the two
arrays record the starting address of every basic-block, along with the
number of times it was executed.

   The profiling library also includes a function (‘mcleanup’) which is
typically registered using ‘atexit()’ to be called as the program exits,
and is responsible for writing the file ‘gmon.out’.  Profiling is turned
off, various headers are output, and the histogram is written, followed
by the call-graph arcs and the basic-block counts.

   The output from ‘gprof’ gives no indication of parts of your program
that are limited by I/O or swapping bandwidth.  This is because samples
of the program counter are taken at fixed intervals of the program's run
time.  Therefore, the time measurements in ‘gprof’ output say nothing
about time that your program was not running.  For example, a part of
the program that creates so much data that it cannot all fit in physical
memory at once may run very slowly due to thrashing, but ‘gprof’ will
say it uses little time.  On the other hand, sampling by run time has
the advantage that the amount of load due to other users won't directly
affect the output you get.


File: gprof.info,  Node: File Format,  Next: Internals,  Prev: Implementation,  Up: Details

9.2 Profiling Data File Format
==============================

The old BSD-derived file format used for profile data does not contain a
magic cookie that allows one to check whether a data file really is a
‘gprof’ file.  Furthermore, it does not provide a version number, thus
rendering changes to the file format almost impossible.  GNU ‘gprof’
uses a new file format that provides these features.  For backward
compatibility, GNU ‘gprof’ continues to support the old BSD-derived
format, but not all features are supported with it.  For example,
basic-block execution counts cannot be accommodated by the old file
format.

   The new file format is defined in header file ‘gmon_out.h’.  It
consists of a header containing the magic cookie and a version number,
as well as some spare bytes available for future extensions.  All data
in a profile data file is in the native format of the target for which
the profile was collected.  GNU ‘gprof’ adapts automatically to the
byte-order in use.

   In the new file format, the header is followed by a sequence of
records.  Currently, there are three different record types: histogram
records, call-graph arc records, and basic-block execution count
records.  Each file can contain any number of each record type.  When
reading a file, GNU ‘gprof’ will ensure records of the same type are
compatible with each other and compute the union of all records.  For
example, for basic-block execution counts, the union is simply the sum
of all execution counts for each basic-block.

9.2.1 Histogram Records
-----------------------

Histogram records consist of a header that is followed by an array of
bins.  The header contains the text-segment range that the histogram
spans, the size of the histogram in bytes (unlike in the old BSD format,
this does not include the size of the header), the rate of the profiling
clock, and the physical dimension that the bin counts represent after
being scaled by the profiling clock rate.  The physical dimension is
specified in two parts: a long name of up to 15 characters and a single
character abbreviation.  For example, a histogram representing real-time
would specify the long name as "seconds" and the abbreviation as "s".
This feature is useful for architectures that support performance
monitor hardware (which, fortunately, is becoming increasingly common).
For example, under DEC OSF/1, the "uprofile" command can be used to
produce a histogram of, say, instruction cache misses.  In this case,
the dimension in the histogram header could be set to "i-cache misses"
and the abbreviation could be set to "1" (because it is simply a count,
not a physical dimension).  Also, the profiling rate would have to be
set to 1 in this case.

   Histogram bins are 16-bit numbers and each bin represent an equal
amount of text-space.  For example, if the text-segment is one thousand
bytes long and if there are ten bins in the histogram, each bin
represents one hundred bytes.

9.2.2 Call-Graph Records
------------------------

Call-graph records have a format that is identical to the one used in
the BSD-derived file format.  It consists of an arc in the call graph
and a count indicating the number of times the arc was traversed during
program execution.  Arcs are specified by a pair of addresses: the first
must be within caller's function and the second must be within the
callee's function.  When performing profiling at the function level,
these addresses can point anywhere within the respective function.
However, when profiling at the line-level, it is better if the addresses
are as close to the call-site/entry-point as possible.  This will ensure
that the line-level call-graph is able to identify exactly which line of
source code performed calls to a function.

9.2.3 Basic-Block Execution Count Records
-----------------------------------------

Basic-block execution count records consist of a header followed by a
sequence of address/count pairs.  The header simply specifies the length
of the sequence.  In an address/count pair, the address identifies a
basic-block and the count specifies the number of times that basic-block
was executed.  Any address within the basic-address can be used.


File: gprof.info,  Node: Internals,  Next: Debugging,  Prev: File Format,  Up: Details

9.3 ‘gprof’'s Internal Operation
================================

Like most programs, ‘gprof’ begins by processing its options.  During
this stage, it may building its symspec list (‘sym_ids.c:sym_id_add’),
if options are specified which use symspecs.  ‘gprof’ maintains a single
linked list of symspecs, which will eventually get turned into 12 symbol
tables, organized into six include/exclude pairs--one pair each for the
flat profile (INCL_FLAT/EXCL_FLAT), the call graph arcs
(INCL_ARCS/EXCL_ARCS), printing in the call graph
(INCL_GRAPH/EXCL_GRAPH), timing propagation in the call graph
(INCL_TIME/EXCL_TIME), the annotated source listing
(INCL_ANNO/EXCL_ANNO), and the execution count listing
(INCL_EXEC/EXCL_EXEC).

   After option processing, ‘gprof’ finishes building the symspec list
by adding all the symspecs in ‘default_excluded_list’ to the exclude
lists EXCL_TIME and EXCL_GRAPH, and if line-by-line profiling is
specified, EXCL_FLAT as well.  These default excludes are not added to
EXCL_ANNO, EXCL_ARCS, and EXCL_EXEC.

   Next, the BFD library is called to open the object file, verify that
it is an object file, and read its symbol table (‘core.c:core_init’),
using ‘bfd_canonicalize_symtab’ after mallocing an appropriately sized
array of symbols.  At this point, function mappings are read (if the
‘--file-ordering’ option has been specified), and the core text space is
read into memory (if the ‘-c’ option was given).

   ‘gprof’'s own symbol table, an array of Sym structures, is now built.
This is done in one of two ways, by one of two routines, depending on
whether line-by-line profiling (‘-l’ option) has been enabled.  For
normal profiling, the BFD canonical symbol table is scanned.  For
line-by-line profiling, every text space address is examined, and a new
symbol table entry gets created every time the line number changes.  In
either case, two passes are made through the symbol table--one to count
the size of the symbol table required, and the other to actually read
the symbols.  In between the two passes, a single array of type ‘Sym’ is
created of the appropriate length.  Finally, ‘symtab.c:symtab_finalize’
is called to sort the symbol table and remove duplicate entries (entries
with the same memory address).

   The symbol table must be a contiguous array for two reasons.  First,
the ‘qsort’ library function (which sorts an array) will be used to sort
the symbol table.  Also, the symbol lookup routine
(‘symtab.c:sym_lookup’), which finds symbols based on memory address,
uses a binary search algorithm which requires the symbol table to be a
sorted array.  Function symbols are indicated with an ‘is_func’ flag.
Line number symbols have no special flags set.  Additionally, a symbol
can have an ‘is_static’ flag to indicate that it is a local symbol.

   With the symbol table read, the symspecs can now be translated into
Syms (‘sym_ids.c:sym_id_parse’).  Remember that a single symspec can
match multiple symbols.  An array of symbol tables (‘syms’) is created,
each entry of which is a symbol table of Syms to be included or excluded
from a particular listing.  The master symbol table and the symspecs are
examined by nested loops, and every symbol that matches a symspec is
inserted into the appropriate syms table.  This is done twice, once to
count the size of each required symbol table, and again to build the
tables, which have been malloced between passes.  From now on, to
determine whether a symbol is on an include or exclude symspec list,
‘gprof’ simply uses its standard symbol lookup routine on the
appropriate table in the ‘syms’ array.

   Now the profile data file(s) themselves are read
(‘gmon_io.c:gmon_out_read’), first by checking for a new-style
‘gmon.out’ header, then assuming this is an old-style BSD ‘gmon.out’ if
the magic number test failed.

   New-style histogram records are read by ‘hist.c:hist_read_rec’.  For
the first histogram record, allocate a memory array to hold all the
bins, and read them in.  When multiple profile data files (or files with
multiple histogram records) are read, the memory ranges of each pair of
histogram records must be either equal, or non-overlapping.  For each
pair of histogram records, the resolution (memory region size divided by
the number of bins) must be the same.  The time unit must be the same
for all histogram records.  If the above containts are met, all
histograms for the same memory range are merged.

   As each call graph record is read (‘call_graph.c:cg_read_rec’), the
parent and child addresses are matched to symbol table entries, and a
call graph arc is created by ‘cg_arcs.c:arc_add’, unless the arc fails a
symspec check against INCL_ARCS/EXCL_ARCS. As each arc is added, a
linked list is maintained of the parent's child arcs, and of the child's
parent arcs.  Both the child's call count and the arc's call count are
incremented by the record's call count.

   Basic-block records are read (‘basic_blocks.c:bb_read_rec’), but only
if line-by-line profiling has been selected.  Each basic-block address
is matched to a corresponding line symbol in the symbol table, and an
entry made in the symbol's bb_addr and bb_calls arrays.  Again, if
multiple basic-block records are present for the same address, the call
counts are cumulative.

   A gmon.sum file is dumped, if requested (‘gmon_io.c:gmon_out_write’).

   If histograms were present in the data files, assign them to symbols
(‘hist.c:hist_assign_samples’) by iterating over all the sample bins and
assigning them to symbols.  Since the symbol table is sorted in order of
ascending memory addresses, we can simple follow along in the symbol
table as we make our pass over the sample bins.  This step includes a
symspec check against INCL_FLAT/EXCL_FLAT. Depending on the histogram
scale factor, a sample bin may span multiple symbols, in which case a
fraction of the sample count is allocated to each symbol, proportional
to the degree of overlap.  This effect is rare for normal profiling, but
overlaps are more common during line-by-line profiling, and can cause
each of two adjacent lines to be credited with half a hit, for example.

   If call graph data is present, ‘cg_arcs.c:cg_assemble’ is called.
First, if ‘-c’ was specified, a machine-dependent routine (‘find_call’)
scans through each symbol's machine code, looking for subroutine call
instructions, and adding them to the call graph with a zero call count.
A topological sort is performed by depth-first numbering all the symbols
(‘cg_dfn.c:cg_dfn’), so that children are always numbered less than
their parents, then making a array of pointers into the symbol table and
sorting it into numerical order, which is reverse topological order
(children appear before parents).  Cycles are also detected at this
point, all members of which are assigned the same topological number.
Two passes are now made through this sorted array of symbol pointers.
The first pass, from end to beginning (parents to children), computes
the fraction of child time to propagate to each parent and a print flag.
The print flag reflects symspec handling of INCL_GRAPH/EXCL_GRAPH, with
a parent's include or exclude (print or no print) property being
propagated to its children, unless they themselves explicitly appear in
INCL_GRAPH or EXCL_GRAPH. A second pass, from beginning to end (children
to parents) actually propagates the timings along the call graph,
subject to a check against INCL_TIME/EXCL_TIME. With the print flag,
fractions, and timings now stored in the symbol structures, the
topological sort array is now discarded, and a new array of pointers is
assembled, this time sorted by propagated time.

   Finally, print the various outputs the user requested, which is now
fairly straightforward.  The call graph (‘cg_print.c:cg_print’) and flat
profile (‘hist.c:hist_print’) are regurgitations of values already
computed.  The annotated source listing
(‘basic_blocks.c:print_annotated_source’) uses basic-block information,
if present, to label each line of code with call counts, otherwise only
the function call counts are presented.

   The function ordering code is marginally well documented in the
source code itself (‘cg_print.c’).  Basically, the functions with the
most use and the most parents are placed first, followed by other
functions with the most use, followed by lower use functions, followed
by unused functions at the end.


File: gprof.info,  Node: Debugging,  Prev: Internals,  Up: Details

9.4 Debugging ‘gprof’
=====================

If ‘gprof’ was compiled with debugging enabled, the ‘-d’ option triggers
debugging output (to stdout) which can be helpful in understanding its
operation.  The debugging number specified is interpreted as a sum of
the following options:

2 - Topological sort
     Monitor depth-first numbering of symbols during call graph analysis
4 - Cycles
     Shows symbols as they are identified as cycle heads
16 - Tallying
     As the call graph arcs are read, show each arc and how the total
     calls to each function are tallied
32 - Call graph arc sorting
     Details sorting individual parents/children within each call graph
     entry
64 - Reading histogram and call graph records
     Shows address ranges of histograms as they are read, and each call
     graph arc
128 - Symbol table
     Reading, classifying, and sorting the symbol table from the object
     file.  For line-by-line profiling (‘-l’ option), also shows line
     numbers being assigned to memory addresses.
256 - Static call graph
     Trace operation of ‘-c’ option
512 - Symbol table and arc table lookups
     Detail operation of lookup routines
1024 - Call graph propagation
     Shows how function times are propagated along the call graph
2048 - Basic-blocks
     Shows basic-block records as they are read from profile data (only
     meaningful with ‘-l’ option)
4096 - Symspecs
     Shows symspec-to-symbol pattern matching operation
8192 - Annotate source
     Tracks operation of ‘-A’ option


File: gprof.info,  Node: GNU Free Documentation License,  Prev: Details,  Up: Top

Appendix A GNU Free Documentation License
*****************************************

                     Version 1.3, 3 November 2008

     Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
     <http://fsf.org/>

     Everyone is permitted to copy and distribute verbatim copies
     of this license document, but changing it is not allowed.

  0. PREAMBLE

     The purpose of this License is to make a manual, textbook, or other
     functional and useful document “free” in the sense of freedom: to
     assure everyone the effective freedom to copy and redistribute it,
     with or without modifying it, either commercially or
     noncommercially.  Secondarily, this License preserves for the
     author and publisher a way to get credit for their work, while not
     being considered responsible for modifications made by others.

     This License is a kind of "copyleft", which means that derivative
     works of the document must themselves be free in the same sense.
     It complements the GNU General Public License, which is a copyleft
     license designed for free software.

     We have designed this License in order to use it for manuals for
     free software, because free software needs free documentation: a
     free program should come with manuals providing the same freedoms
     that the software does.  But this License is not limited to
     software manuals; it can be used for any textual work, regardless
     of subject matter or whether it is published as a printed book.  We
     recommend this License principally for works whose purpose is
     instruction or reference.

  1. APPLICABILITY AND DEFINITIONS

     This License applies to any manual or other work, in any medium,
     that contains a notice placed by the copyright holder saying it can
     be distributed under the terms of this License.  Such a notice
     grants a world-wide, royalty-free license, unlimited in duration,
     to use that work under the conditions stated herein.  The
     "Document", below, refers to any such manual or work.  Any member
     of the public is a licensee, and is addressed as "you".  You accept
     the license if you copy, modify or distribute the work in a way
     requiring permission under copyright law.

     A "Modified Version" of the Document means any work containing the
     Document or a portion of it, either copied verbatim, or with
     modifications and/or translated into another language.

     A "Secondary Section" is a named appendix or a front-matter section
     of the Document that deals exclusively with the relationship of the
     publishers or authors of the Document to the Document's overall
     subject (or to related matters) and contains nothing that could
     fall directly within that overall subject.  (Thus, if the Document
     is in part a textbook of mathematics, a Secondary Section may not
     explain any mathematics.)  The relationship could be a matter of
     historical connection with the subject or with related matters, or
     of legal, commercial, philosophical, ethical or political position
     regarding them.

     The "Invariant Sections" are certain Secondary Sections whose
     titles are designated, as being those of Invariant Sections, in the
     notice that says that the Document is released under this License.
     If a section does not fit the above definition of Secondary then it
     is not allowed to be designated as Invariant.  The Document may
     contain zero Invariant Sections.  If the Document does not identify
     any Invariant Sections then there are none.

     The "Cover Texts" are certain short passages of text that are
     listed, as Front-Cover Texts or Back-Cover Texts, in the notice
     that says that the Document is released under this License.  A
     Front-Cover Text may be at most 5 words, and a Back-Cover Text may
     be at most 25 words.

     A "Transparent" copy of the Document means a machine-readable copy,
     represented in a format whose specification is available to the
     general public, that is suitable for revising the document
     straightforwardly with generic text editors or (for images composed
     of pixels) generic paint programs or (for drawings) some widely
     available drawing editor, and that is suitable for input to text
     formatters or for automatic translation to a variety of formats
     suitable for input to text formatters.  A copy made in an otherwise
     Transparent file format whose markup, or absence of markup, has
     been arranged to thwart or discourage subsequent modification by
     readers is not Transparent.  An image format is not Transparent if
     used for any substantial amount of text.  A copy that is not
     "Transparent" is called "Opaque".

     Examples of suitable formats for Transparent copies include plain
     ASCII without markup, Texinfo input format, LaTeX input format,
     SGML or XML using a publicly available DTD, and standard-conforming
     simple HTML, PostScript or PDF designed for human modification.
     Examples of transparent image formats include PNG, XCF and JPG.
     Opaque formats include proprietary formats that can be read and
     edited only by proprietary word processors, SGML or XML for which
     the DTD and/or processing tools are not generally available, and
     the machine-generated HTML, PostScript or PDF produced by some word
     processors for output purposes only.

     The "Title Page" means, for a printed book, the title page itself,
     plus such following pages as are needed to hold, legibly, the
     material this License requires to appear in the title page.  For
     works in formats which do not have any title page as such, "Title
     Page" means the text near the most prominent appearance of the
     work's title, preceding the beginning of the body of the text.

     The "publisher" means any person or entity that distributes copies
     of the Document to the public.

     A section "Entitled XYZ" means a named subunit of the Document
     whose title either is precisely XYZ or contains XYZ in parentheses
     following text that translates XYZ in another language.  (Here XYZ
     stands for a specific section name mentioned below, such as
     "Acknowledgements", "Dedications", "Endorsements", or "History".)
     To "Preserve the Title" of such a section when you modify the
     Document means that it remains a section "Entitled XYZ" according
     to this definition.

     The Document may include Warranty Disclaimers next to the notice
     which states that this License applies to the Document.  These
     Warranty Disclaimers are considered to be included by reference in
     this License, but only as regards disclaiming warranties: any other
     implication that these Warranty Disclaimers may have is void and
     has no effect on the meaning of this License.

  2. VERBATIM COPYING

     You may copy and distribute the Document in any medium, either
     commercially or noncommercially, provided that this License, the
     copyright notices, and the license notice saying this License
     applies to the Document are reproduced in all copies, and that you
     add no other conditions whatsoever to those of this License.  You
     may not use technical measures to obstruct or control the reading
     or further copying of the copies you make or distribute.  However,
     you may accept compensation in exchange for copies.  If you
     distribute a large enough number of copies you must also follow the
     conditions in section 3.

     You may also lend copies, under the same conditions stated above,
     and you may publicly display copies.

  3. COPYING IN QUANTITY

     If you publish printed copies (or copies in media that commonly
     have printed covers) of the Document, numbering more than 100, and
     the Document's license notice requires Cover Texts, you must
     enclose the copies in covers that carry, clearly and legibly, all
     these Cover Texts: Front-Cover Texts on the front cover, and
     Back-Cover Texts on the back cover.  Both covers must also clearly
     and legibly identify you as the publisher of these copies.  The
     front cover must present the full title with all words of the title
     equally prominent and visible.  You may add other material on the
     covers in addition.  Copying with changes limited to the covers, as
     long as they preserve the title of the Document and satisfy these
     conditions, can be treated as verbatim copying in other respects.

     If the required texts for either cover are too voluminous to fit
     legibly, you should put the first ones listed (as many as fit
     reasonably) on the actual cover, and continue the rest onto
     adjacent pages.

     If you publish or distribute Opaque copies of the Document
     numbering more than 100, you must either include a machine-readable
     Transparent copy along with each Opaque copy, or state in or with
     each Opaque copy a computer-network location from which the general
     network-using public has access to download using public-standard
     network protocols a complete Transparent copy of the Document, free
     of added material.  If you use the latter option, you must take
     reasonably prudent steps, when you begin distribution of Opaque
     copies in quantity, to ensure that this Transparent copy will
     remain thus accessible at the stated location until at least one
     year after the last time you distribute an Opaque copy (directly or
     through your agents or retailers) of that edition to the public.

     It is requested, but not required, that you contact the authors of
     the Document well before redistributing any large number of copies,
     to give them a chance to provide you with an updated version of the
     Document.

  4. MODIFICATIONS

     You may copy and distribute a Modified Version of the Document
     under the conditions of sections 2 and 3 above, provided that you
     release the Modified Version under precisely this License, with the
     Modified Version filling the role of the Document, thus licensing
     distribution and modification of the Modified Version to whoever
     possesses a copy of it.  In addition, you must do these things in
     the Modified Version:

       A. Use in the Title Page (and on the covers, if any) a title
          distinct from that of the Document, and from those of previous
          versions (which should, if there were any, be listed in the
          History section of the Document).  You may use the same title
          as a previous version if the original publisher of that
          version gives permission.

       B. List on the Title Page, as authors, one or more persons or
          entities responsible for authorship of the modifications in
          the Modified Version, together with at least five of the
          principal authors of the Document (all of its principal
          authors, if it has fewer than five), unless they release you
          from this requirement.

       C. State on the Title page the name of the publisher of the
          Modified Version, as the publisher.

       D. Preserve all the copyright notices of the Document.

       E. Add an appropriate copyright notice for your modifications
          adjacent to the other copyright notices.

       F. Include, immediately after the copyright notices, a license
          notice giving the public permission to use the Modified
          Version under the terms of this License, in the form shown in
          the Addendum below.

       G. Preserve in that license notice the full lists of Invariant
          Sections and required Cover Texts given in the Document's
          license notice.

       H. Include an unaltered copy of this License.

       I. Preserve the section Entitled "History", Preserve its Title,
          and add to it an item stating at least the title, year, new
          authors, and publisher of the Modified Version as given on the
          Title Page.  If there is no section Entitled "History" in the
          Document, create one stating the title, year, authors, and
          publisher of the Document as given on its Title Page, then add
          an item describing the Modified Version as stated in the
          previous sentence.

       J. Preserve the network location, if any, given in the Document
          for public access to a Transparent copy of the Document, and
          likewise the network locations given in the Document for
          previous versions it was based on.  These may be placed in the
          "History" section.  You may omit a network location for a work
          that was published at least four years before the Document
          itself, or if the original publisher of the version it refers
          to gives permission.

       K. For any section Entitled "Acknowledgements" or "Dedications",
          Preserve the Title of the section, and preserve in the section
          all the substance and tone of each of the contributor
          acknowledgements and/or dedications given therein.

       L. Preserve all the Invariant Sections of the Document, unaltered
          in their text and in their titles.  Section numbers or the
          equivalent are not considered part of the section titles.

       M. Delete any section Entitled "Endorsements".  Such a section
          may not be included in the Modified Version.

       N. Do not retitle any existing section to be Entitled
          "Endorsements" or to conflict in title with any Invariant
          Section.

       O. Preserve any Warranty Disclaimers.

     If the Modified Version includes new front-matter sections or
     appendices that qualify as Secondary Sections and contain no
     material copied from the Document, you may at your option designate
     some or all of these sections as invariant.  To do this, add their
     titles to the list of Invariant Sections in the Modified Version's
     license notice.  These titles must be distinct from any other
     section titles.

     You may add a section Entitled "Endorsements", provided it contains
     nothing but endorsements of your Modified Version by various
     parties--for example, statements of peer review or that the text
     has been approved by an organization as the authoritative
     definition of a standard.

     You may add a passage of up to five words as a Front-Cover Text,
     and a passage of up to 25 words as a Back-Cover Text, to the end of
     the list of Cover Texts in the Modified Version.  Only one passage
     of Front-Cover Text and one of Back-Cover Text may be added by (or
     through arrangements made by) any one entity.  If the Document
     already includes a cover text for the same cover, previously added
     by you or by arrangement made by the same entity you are acting on
     behalf of, you may not add another; but you may replace the old
     one, on explicit permission from the previous publisher that added
     the old one.

     The author(s) and publisher(s) of the Document do not by this
     License give permission to use their names for publicity for or to
     assert or imply endorsement of any Modified Version.

  5. COMBINING DOCUMENTS

     You may combine the Document with other documents released under
     this License, under the terms defined in section 4 above for
     modified versions, provided that you include in the combination all
     of the Invariant Sections of all of the original documents,
     unmodified, and list them all as Invariant Sections of your
     combined work in its license notice, and that you preserve all
     their Warranty Disclaimers.

     The combined work need only contain one copy of this License, and
     multiple identical Invariant Sections may be replaced with a single
     copy.  If there are multiple Invariant Sections with the same name
     but different contents, make the title of each such section unique
     by adding at the end of it, in parentheses, the name of the
     original author or publisher of that section if known, or else a
     unique number.  Make the same adjustment to the section titles in
     the list of Invariant Sections in the license notice of the
     combined work.

     In the combination, you must combine any sections Entitled
     "History" in the various original documents, forming one section
     Entitled "History"; likewise combine any sections Entitled
     "Acknowledgements", and any sections Entitled "Dedications".  You
     must delete all sections Entitled "Endorsements."

  6. COLLECTIONS OF DOCUMENTS

     You may make a collection consisting of the Document and other
     documents released under this License, and replace the individual
     copies of this License in the various documents with a single copy
     that is included in the collection, provided that you follow the
     rules of this License for verbatim copying of each of the documents
     in all other respects.

     You may extract a single document from such a collection, and
     distribute it individually under this License, provided you insert
     a copy of this License into the extracted document, and follow this
     License in all other respects regarding verbatim copying of that
     document.

  7. AGGREGATION WITH INDEPENDENT WORKS

     A compilation of the Document or its derivatives with other
     separate and independent documents or works, in or on a volume of a
     storage or distribution medium, is called an "aggregate" if the
     copyright resulting from the compilation is not used to limit the
     legal rights of the compilation's users beyond what the individual
     works permit.  When the Document is included in an aggregate, this
     License does not apply to the other works in the aggregate which
     are not themselves derivative works of the Document.

     If the Cover Text requirement of section 3 is applicable to these
     copies of the Document, then if the Document is less than one half
     of the entire aggregate, the Document's Cover Texts may be placed
     on covers that bracket the Document within the aggregate, or the
     electronic equivalent of covers if the Document is in electronic
     form.  Otherwise they must appear on printed covers that bracket
     the whole aggregate.

  8. TRANSLATION

     Translation is considered a kind of modification, so you may
     distribute translations of the Document under the terms of section
     4.  Replacing Invariant Sections with translations requires special
     permission from their copyright holders, but you may include
     translations of some or all Invariant Sections in addition to the
     original versions of these Invariant Sections.  You may include a
     translation of this License, and all the license notices in the
     Document, and any Warranty Disclaimers, provided that you also
     include the original English version of this License and the
     original versions of those notices and disclaimers.  In case of a
     disagreement between the translation and the original version of
     this License or a notice or disclaimer, the original version will
     prevail.

     If a section in the Document is Entitled "Acknowledgements",
     "Dedications", or "History", the requirement (section 4) to
     Preserve its Title (section 1) will typically require changing the
     actual title.

  9. TERMINATION

     You may not copy, modify, sublicense, or distribute the Document
     except as expressly provided under this License.  Any attempt
     otherwise to copy, modify, sublicense, or distribute it is void,
     and will automatically terminate your rights under this License.

     However, if you cease all violation of this License, then your
     license from a particular copyright holder is reinstated (a)
     provisionally, unless and until the copyright holder explicitly and
     finally terminates your license, and (b) permanently, if the
     copyright holder fails to notify you of the violation by some
     reasonable means prior to 60 days after the cessation.

     Moreover, your license from a particular copyright holder is
     reinstated permanently if the copyright holder notifies you of the
     violation by some reasonable means, this is the first time you have
     received notice of violation of this License (for any work) from
     that copyright holder, and you cure the violation prior to 30 days
     after your receipt of the notice.

     Termination of your rights under this section does not terminate
     the licenses of parties who have received copies or rights from you
     under this License.  If your rights have been terminated and not
     permanently reinstated, receipt of a copy of some or all of the
     same material does not give you any rights to use it.

  10. FUTURE REVISIONS OF THIS LICENSE

     The Free Software Foundation may publish new, revised versions of
     the GNU Free Documentation License from time to time.  Such new
     versions will be similar in spirit to the present version, but may
     differ in detail to address new problems or concerns.  See
     <http://www.gnu.org/copyleft/>.

     Each version of the License is given a distinguishing version
     number.  If the Document specifies that a particular numbered
     version of this License "or any later version" applies to it, you
     have the option of following the terms and conditions either of
     that specified version or of any later version that has been
     published (not as a draft) by the Free Software Foundation.  If the
     Document does not specify a version number of this License, you may
     choose any version ever published (not as a draft) by the Free
     Software Foundation.  If the Document specifies that a proxy can
     decide which future versions of this License can be used, that
     proxy's public statement of acceptance of a version permanently
     authorizes you to choose that version for the Document.

  11. RELICENSING

     "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
     World Wide Web server that publishes copyrightable works and also
     provides prominent facilities for anybody to edit those works.  A
     public wiki that anybody can edit is an example of such a server.
     A "Massive Multiauthor Collaboration" (or "MMC") contained in the
     site means any set of copyrightable works thus published on the MMC
     site.

     "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
     license published by Creative Commons Corporation, a not-for-profit
     corporation with a principal place of business in San Francisco,
     California, as well as future copyleft versions of that license
     published by that same organization.

     "Incorporate" means to publish or republish a Document, in whole or
     in part, as part of another Document.

     An MMC is "eligible for relicensing" if it is licensed under this
     License, and if all works that were first published under this
     License somewhere other than this MMC, and subsequently
     incorporated in whole or in part into the MMC, (1) had no cover
     texts or invariant sections, and (2) were thus incorporated prior
     to November 1, 2008.

     The operator of an MMC Site may republish an MMC contained in the
     site under CC-BY-SA on the same site at any time before August 1,
     2009, provided the MMC is eligible for relicensing.

ADDENDUM: How to use this License for your documents
====================================================

To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and license
notices just after the title page:

       Copyright (C)  YEAR  YOUR NAME.
       Permission is granted to copy, distribute and/or modify this document
       under the terms of the GNU Free Documentation License, Version 1.3
       or any later version published by the Free Software Foundation;
       with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
       Texts.  A copy of the license is included in the section entitled ``GNU
       Free Documentation License''.

   If you have Invariant Sections, Front-Cover Texts and Back-Cover
Texts, replace the "with...Texts."  line with this:

         with the Invariant Sections being LIST THEIR TITLES, with
         the Front-Cover Texts being LIST, and with the Back-Cover Texts
         being LIST.

   If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.

   If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of free
software license, such as the GNU General Public License, to permit
their use in free software.


Tag Table:
Node: Top718
Node: Introduction2071
Node: Compiling4588
Node: Executing8768
Node: Invoking11753
Node: Output Options13371
Node: Analysis Options20922
Node: Miscellaneous Options25022
Node: Deprecated Options26392
Node: Symspecs28575
Node: Output30489
Node: Flat Profile31541
Node: Call Graph36610
Node: Primary39874
Node: Callers42522
Node: Subroutines44728
Node: Cycles46673
Node: Line-by-line53670
Node: Annotated Source57820
Node: Inaccuracy60901
Node: Sampling Error61163
Node: Assumptions64111
Node: How do I?65661
Node: Incompatibilities67234
Node: Details68808
Node: Implementation69217
Node: File Format75268
Node: Internals79584
Node: Debugging88230
Node: GNU Free Documentation License89848

End Tag Table


Local Variables:
coding: utf-8
End:
@


1.11
log
@merge conflicts
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 7.1.1 from gprof.texi.
d5 1
a5 1
   Copyright © 1988-2025 Free Software Foundation, Inc.
d30 1
a30 1
   This manual is for ‘gprof’ (GNU Binutils) version 2.45.
d265 4
a446 1

a1251 1

a1291 1

a1332 1

a2427 1

d2430 1
a2430 1
Node: Top720
d2435 25
a2459 25
Node: Output Options13212
Node: Analysis Options20764
Node: Miscellaneous Options24864
Node: Deprecated Options26234
Node: Symspecs28417
Node: Output30331
Node: Flat Profile31383
Node: Call Graph36452
Node: Primary39716
Node: Callers42364
Node: Subroutines44570
Node: Cycles46515
Node: Line-by-line53512
Node: Annotated Source57664
Node: Inaccuracy60746
Node: Sampling Error61008
Node: Assumptions63956
Node: How do I?65506
Node: Incompatibilities67079
Node: Details68653
Node: Implementation69062
Node: File Format75113
Node: Internals79429
Node: Debugging88075
Node: GNU Free Documentation License89693
@


1.10
log
@Merge conflicts between 2.39 and 2.42
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 7.0.2 from gprof.texi.
d5 1
a5 1
   Copyright © 1988-2024 Free Software Foundation, Inc.
d11 2
a12 2
Texts.  A copy of the license is included in the section entitled “GNU
Free Documentation License”.
d16 1
a16 1
* gprof: (gprof).                Profiling your program’s execution
d30 1
a30 1
   This manual is for ‘gprof’ (GNU Binutils) version 2.42.
d34 1
a34 1
the section entitled “GNU Free Documentation License”.
d44 1
a44 1
* Output::              Interpreting ‘gprof’’s output
d70 1
a70 1
data.  If you don’t use some feature of your program while it is being
d99 1
a99 1
   The “annotated source” listing is a copy of the program’s source
d175 1
a175 1
you can still profile the program, but you won’t get complete
d184 1
a184 1
‘gcov’ tool instead of ‘gprof’.  See that tool’s manual or info pages
d211 2
a212 2
   The way you run the program—the arguments and input that you give
it—may have a dramatic effect on what the profile information shows.
d231 1
a231 1
   The ‘gmon.out’ file is written in the program’s _current working
d234 1
a234 1
program ‘chdir’’d to.  If you don’t have permission to write in this
d241 1
a241 1
didn’t get written into ‘gmon.out’.  The Perl script ‘bbconv.pl’,
d284 1
a284 1
* Output Options::      Controlling ‘gprof’’s output style
d316 1
a316 1
     If the ‘-b’ option is given, ‘gprof’ doesn’t print the verbose
d449 1
a449 1
     The ‘-T’ option causes ‘gprof’ to print its output in “traditional”
d463 1
a463 1
     similar to ‘tcov’’s ‘-a’.
d669 1
a669 1
     Selects everything in file ‘main.c’—the dot in the string tells
d704 1
a704 1
5 Interpreting ‘gprof’’s Output
d734 1
a734 1
and didn’t run long enough to show up on the program counter histogram,
d771 1
a771 1
program’s total execution time was 0.06 seconds, as indicated by the
d783 1
a783 1
field is ‘0.00’) didn’t appear in the histogram samples at all.
d888 3
a890 3
* Primary::       Details of the primary line’s contents.
* Callers::       Details of caller-lines’ contents.
* Subroutines::   Details of subroutine-lines’ contents.
d959 1
a959 1
     is printed between the function’s name and the index number (*note
d969 1
a969 1
5.2.2 Lines for a Function’s Callers
d972 2
a973 2
A function’s entry has a line for each function it was called by.  These
lines’ fields correspond to the fields of the primary line, but their
d1006 1
a1006 1
     followed by the caller’s index number.
d1017 2
a1018 2
dummy caller-line is printed which has ‘<spontaneous>’ as the “caller’s
name” and all other fields blank.  This can happen for signal handlers.
d1023 1
a1023 1
5.2.3 Lines for a Function’s Subroutines
d1026 2
a1027 2
A function’s entry has a line for each of its subroutines—in other
words, a line for each other function that it called.  These lines’
d1057 1
a1057 1
     is used to determine how much of ‘report’’s ‘self’ and ‘children’
d1063 1
a1063 1
     followed by the subroutine’s index number.
d1091 4
a1094 4
call graph paradoxical.  The “time spent in children” of ‘a’ should
include the time spent in its subroutine ‘b’ and in ‘b’’s
subroutines—but one of ‘b’’s subroutines is ‘a’!  How much of ‘a’’s time
should be included in the children of ‘a’, when ‘a’ is indirectly
d1100 1
a1100 1
“subroutines” of the cycle are the individual functions of the cycle,
d1102 1
a1102 1
“callers” of the cycle are the functions, outside the cycle, that called
d1163 1
a1163 1
   The ‘self’ field of the cycle’s primary line is the total time spent
d1168 1
a1168 1
   The ‘children’ fields of the cycle’s primary line and subroutine
d1170 1
a1170 1
‘b’, the time spent in those calls to ‘b’ is not counted in ‘a’’s
d1175 1
a1175 1
   The ‘children’ field of a caller-line in the cycle’s entry estimates
d1188 1
a1188 1
cycle’s entry says how many time that function was called from functions
d1190 1
a1190 1
primary line’s ‘called’ field.
d1205 1
a1205 1
‘gprof’’s ‘-l’ option causes the program to perform “line-by-line”
d1219 1
a1219 1
mode.  The call graph isn’t as useful as normal, since the current
d1224 1
a1224 1
   Here is a section of ‘gprof’’s output, without line-by-line
d1250 3
a1252 3
   Now let’s look at some of ‘gprof’’s output from the same program run,
this time with line-by-line profiling enabled.  Note that ‘ct_init’’s
four histogram hits are broken down into four lines of source code—one
d1254 1
a1254 1
note how ‘ct_init’’s 13327 calls to ‘init_block’ are broken down into
d1297 2
a1298 2
‘gprof’’s ‘-A’ option triggers an annotated source listing, which lists
the program’s source code, each function labeled with the number of
d1300 1
a1300 1
‘gprof’ can’t find the source code files.
d1342 1
a1342 1
line of code is labeled at least once.  Here is ‘updcrc’’s annotated
d1412 1
a1412 1
period is 0.01 seconds and ‘foo’’s run-time is 1 second, N is 100
d1414 1
a1414 1
error in ‘foo’’s run-time is 0.1 seconds (10*0.01 seconds), or ten
d1416 2
a1417 2
seconds and ‘bar’’s run-time is 100 seconds, N is 10000 samples, sqrt(N)
is 100 samples, so the expected error in ‘bar’’s run-time is 1 second,
d1423 1
a1423 1
information.  If the program’s _total_ run-time is large, a small
d1425 1
a1425 1
insignificant fraction of the whole program’s time.  Usually this means
d1455 1
a1455 1
Some of the figures in the call graph are estimates—for example, the
d1466 1
a1466 1
‘foo’ contributes 2 seconds to ‘a’’s ‘children’ time, by assumption.
d1568 2
a1569 2
* Internals::           ‘gprof’’s internal operation
* Debugging::           Using ‘gprof’’s ‘-d’ option
d1588 1
a1588 1
parent routine (the child) and its parent’s parent.  This is typically
d1594 3
a1596 3
arguments—‘frompc’ and ‘selfpc’.  ‘__mcount_internal’ is responsible for
maintaining the in-memory call graph, which records ‘frompc’, ‘selfpc’,
and the number of times each of these call arcs was traversed.
d1619 1
a1619 1
the kernel, along with a scale factor that determines how the program’s
d1648 1
a1648 1
   If the compiler’s ‘-a’ option was used, basic-block counting is also
d1666 1
a1666 1
of the program counter are taken at fixed intervals of the program’s run
d1672 1
a1672 1
the advantage that the amount of load due to other users won’t directly
d1718 1
a1718 1
would specify the long name as “seconds” and the abbreviation as “s”.
d1721 1
a1721 1
For example, under DEC OSF/1, the “uprofile” command can be used to
d1723 2
a1724 2
the dimension in the histogram header could be set to “i-cache misses”
and the abbreviation could be set to “1” (because it is simply a count,
d1740 2
a1741 2
must be within caller’s function and the second must be within the
callee’s function.  When performing profiling at the function level,
d1760 1
a1760 1
9.3 ‘gprof’’s Internal Operation
d1767 1
a1767 1
tables, organized into six include/exclude pairs—one pair each for the
d1788 1
a1788 1
   ‘gprof’’s own symbol table, an array of Sym structures, is now built.
d1794 1
a1794 1
either case, two passes are made through the symbol table—one to count
d1842 3
a1844 3
linked list is maintained of the parent’s child arcs, and of the child’s
parent arcs.  Both the child’s call count and the arc’s call count are
incremented by the record’s call count.
d1849 1
a1849 1
entry made in the symbol’s bb_addr and bb_calls arrays.  Again, if
d1869 1
a1869 1
scans through each symbol’s machine code, looking for subroutine call
d1881 1
a1881 1
a parent’s include or exclude (print or no print) property being
d1970 1
a1970 1
     This License is a kind of “copyleft”, which means that derivative
d1991 2
a1992 2
     “Document”, below, refers to any such manual or work.  Any member
     of the public is a licensee, and is addressed as “you”.  You accept
d1996 1
a1996 1
     A “Modified Version” of the Document means any work containing the
d2000 1
a2000 1
     A “Secondary Section” is a named appendix or a front-matter section
d2002 1
a2002 1
     publishers or authors of the Document to the Document’s overall
d2011 1
a2011 1
     The “Invariant Sections” are certain Secondary Sections whose
d2019 1
a2019 1
     The “Cover Texts” are certain short passages of text that are
d2025 1
a2025 1
     A “Transparent” copy of the Document means a machine-readable copy,
d2037 1
a2037 1
     “Transparent” is called “Opaque”.
d2050 1
a2050 1
     The “Title Page” means, for a printed book, the title page itself,
d2053 3
a2055 3
     works in formats which do not have any title page as such, “Title
     Page” means the text near the most prominent appearance of the
     work’s title, preceding the beginning of the body of the text.
d2057 1
a2057 1
     The “publisher” means any person or entity that distributes copies
d2060 1
a2060 1
     A section “Entitled XYZ” means a named subunit of the Document
d2064 3
a2066 3
     “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.)
     To “Preserve the Title” of such a section when you modify the
     Document means that it remains a section “Entitled XYZ” according
d2096 1
a2096 1
     the Document’s license notice requires Cover Texts, you must
d2168 1
a2168 1
          Sections and required Cover Texts given in the Document’s
d2173 1
a2173 1
       I. Preserve the section Entitled “History”, Preserve its Title,
d2176 1
a2176 1
          Title Page.  If there is no section Entitled “History” in the
d2186 1
a2186 1
          “History” section.  You may omit a network location for a work
d2191 1
a2191 1
       K. For any section Entitled “Acknowledgements” or “Dedications”,
d2200 1
a2200 1
       M. Delete any section Entitled “Endorsements”.  Such a section
d2204 1
a2204 1
          “Endorsements” or to conflict in title with any Invariant
d2213 1
a2213 1
     titles to the list of Invariant Sections in the Modified Version’s
d2217 1
a2217 1
     You may add a section Entitled “Endorsements”, provided it contains
d2219 3
a2221 3
     parties—for example, statements of peer review or that the text has
     been approved by an organization as the authoritative definition of
     a standard.
d2259 4
a2262 4
     “History” in the various original documents, forming one section
     Entitled “History”; likewise combine any sections Entitled
     “Acknowledgements”, and any sections Entitled “Dedications”.  You
     must delete all sections Entitled “Endorsements.”
d2283 1
a2283 1
     storage or distribution medium, is called an “aggregate” if the
d2285 1
a2285 1
     legal rights of the compilation’s users beyond what the individual
d2292 1
a2292 1
     of the entire aggregate, the Document’s Cover Texts may be placed
d2314 2
a2315 2
     If a section in the Document is Entitled “Acknowledgements”,
     “Dedications”, or “History”, the requirement (section 4) to
d2356 1
a2356 1
     version of this License “or any later version” applies to it, you
d2364 1
a2364 1
     proxy’s public statement of acceptance of a version permanently
d2369 1
a2369 1
     “Massive Multiauthor Collaboration Site” (or “MMC Site”) means any
d2373 1
a2373 1
     A “Massive Multiauthor Collaboration” (or “MMC”) contained in the
d2377 1
a2377 1
     “CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0
d2383 1
a2383 1
     “Incorporate” means to publish or republish a Document, in whole or
d2386 1
a2386 1
     An MMC is “eligible for relicensing” if it is licensed under this
d2413 1
a2413 1
Texts, replace the “with...Texts.” line with this:
d2431 30
a2460 30
Node: Top726
Node: Introduction2083
Node: Compiling4604
Node: Executing8788
Node: Invoking11783
Node: Output Options13244
Node: Analysis Options20804
Node: Miscellaneous Options24904
Node: Deprecated Options26274
Node: Symspecs28457
Node: Output30372
Node: Flat Profile31426
Node: Call Graph36501
Node: Primary39771
Node: Callers42421
Node: Subroutines44641
Node: Cycles46597
Node: Line-by-line53625
Node: Annotated Source57792
Node: Inaccuracy60882
Node: Sampling Error61144
Node: Assumptions64104
Node: How do I?65657
Node: Incompatibilities67230
Node: Details68804
Node: Implementation69217
Node: File Format75279
Node: Internals79619
Node: Debugging88287
Node: GNU Free Documentation License89905
@


1.9
log
@Merge conflicts between 2.34 and 2.39, and regen for x86_64
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 6.8 from gprof.texi.
d5 1
a5 1
   Copyright (C) 1988-2022 Free Software Foundation, Inc.
d11 2
a12 2
Texts.  A copy of the license is included in the section entitled "GNU
Free Documentation License".
d16 1
a16 1
* gprof: (gprof).                Profiling your program's execution
d25 1
a25 1
This manual describes the GNU profiler, 'gprof', and how you can use it
d28 1
a28 1
programs.  GNU 'gprof' was written by Jay Fenlason.
d30 1
a30 1
   This manual is for 'gprof' (GNU Binutils) version 2.39.
d34 1
a34 1
the section entitled "GNU Free Documentation License".
d42 1
a42 1
* Invoking::            How to run 'gprof', and its options
d44 1
a44 1
* Output::              Interpreting 'gprof''s output
d48 1
a48 1
* Incompatibilities::   (between GNU 'gprof' and Unix 'gprof'.)
d70 1
a70 1
data.  If you don't use some feature of your program while it is being
d75 1
a75 1
   * You must compile and link your program with profiling enabled.
d78 1
a78 1
   * You must execute your program to generate a profile data file.
d81 1
a81 1
   * You must run 'gprof' to analyze the profile data.  *Note 'gprof'
d88 1
a88 1
   The "flat profile" shows how much time your program spent in each
d93 1
a93 1
   The "call graph" shows, for each function, which functions called it,
d99 1
a99 1
   The "annotated source" listing is a copy of the program's source
d116 1
a116 1
   To compile a source file for profiling, specify the '-pg' option when
d120 3
a122 3
   To link the program for profiling, if you use a compiler such as 'cc'
to do the linking, simply specify '-pg' in addition to your usual
options.  The same option, '-pg', alters either compilation or linking
d128 1
a128 1
   The '-pg' option also works with a command that both compiles and
d133 1
a133 1
   Note: The '-pg' option must be part of your compilation options as
d135 1
a135 1
gathered and when you run 'gprof' you will get an error message like
d140 1
a140 1
   If you add the '-Q' switch to suppress the printing of the call graph
d152 3
a154 3
   If you run the linker 'ld' directly instead of through a compiler
such as 'cc', you may have to specify a profiling startup file 'gcrt0.o'
as the first input file instead of the usual startup file 'crt0.o'.  In
d156 1
a156 1
'libc_p.a', by writing '-lc_p' instead of the usual '-lc'.  This is not
d158 1
a158 1
information for standard library functions such as 'read' and 'open'.
d169 2
a170 2
code, which for 'gcc' users can be done via the '-static' or
'-static-libgcc' command-line option.  For example:
d174 3
a176 3
   If you compile only some of the modules of the program with '-pg',
you can still profile the program, but you won't get complete
information about the modules that were compiled without '-pg'.  The
d180 1
a180 1
that the 'calls' field for the functions will be blank), but will
d184 1
a184 1
'gcov' tool instead of 'gprof'.  See that tool's manual or info pages
d187 3
a189 3
   Note, older versions of 'gcc' produce line-by-line profiling
information that works with 'gprof' rather than 'gcov' so there is still
support for displaying this kind of information in 'gprof'.  *Note
d192 1
a192 1
   It also worth noting that 'gcc' implements a '-finstrument-functions'
d205 1
a205 1
generate the information that 'gprof' needs.  Simply run the program as
d211 2
a212 2
   The way you run the program--the arguments and input that you give
it--may have a dramatic effect on what the profile information shows.
d219 2
a220 2
'gmon.out' just before exiting.  If there is already a file called
'gmon.out', its contents are overwritten.  You can rename the file
d226 3
a228 3
   In order to write the 'gmon.out' file properly, your program must
exit normally: by returning from 'main' or by calling 'exit'.  Calling
the low-level function '_exit' does not write the profile data, and
d231 1
a231 1
   The 'gmon.out' file is written in the program's _current working
d233 2
a234 2
'chdir', the 'gmon.out' file will be left in the last directory your
program 'chdir''d to.  If you don't have permission to write in this
d238 1
a238 1
called 'bb.out'.  This file, if present, contains an human-readable
d240 4
a243 4
appearance of a human-readable 'bb.out' means the basic-block counts
didn't get written into 'gmon.out'.  The Perl script 'bbconv.pl',
included with the 'gprof' source distribution, will convert a 'bb.out'
file into a format readable by 'gprof'.  Invoke it like this:
d247 2
a248 2
   This translates the information in 'bb.out' into a form that 'gprof'
can understand.  But you still need to tell 'gprof' about the existence
d250 1
a250 1
'gprof' command line, _along with 'gmon.out'_, like this:
d257 1
a257 1
4 'gprof' Command Summary
d260 2
a261 2
After you have a profile data file 'gmon.out', you can run 'gprof' to
interpret the information in it.  The 'gprof' program prints a flat
d263 1
a263 1
redirect the output of 'gprof' into a file with '>'.
d265 1
a265 1
   You run 'gprof' like this:
d271 2
a272 2
   If you omit the executable file name, the file 'a.out' is used.  If
you give no profile data file name, the file 'gmon.out' is used.  If any
d284 2
a285 2
* Output Options::      Controlling 'gprof''s output style
* Analysis Options::    Controlling how 'gprof' analyzes its data
d297 1
a297 1
These options specify which of several output formats 'gprof' should
d300 1
a300 1
   Many of these options take an optional "symspec" to specify functions
d305 1
a305 1
   Specifying any of these options overrides the default ('-p -q'),
d308 3
a310 3
'-A[SYMSPEC]'
'--annotated-source[=SYMSPEC]'
     The '-A' option causes 'gprof' to print annotated source code.  If
d314 3
a316 3
'-b'
'--brief'
     If the '-b' option is given, 'gprof' doesn't print the verbose
d321 6
a326 3
'-C[SYMSPEC]'
'--exec-counts[=SYMSPEC]'
     The '-C' option causes 'gprof' to print a tally of functions and
d331 1
a331 1
     specifying the '-l' option, along with '-C', will cause basic-block
d334 3
a336 3
'-i'
'--file-info'
     The '-i' option causes 'gprof' to display summary information about
d340 3
a342 3
'-I DIRS'
'--directory-path=DIRS'
     The '-I' option specifies a list of search directories in which to
d347 4
a350 4
'-J[SYMSPEC]'
'--no-annotated-source[=SYMSPEC]'
     The '-J' option causes 'gprof' not to print annotated source code.
     If SYMSPEC is specified, 'gprof' prints annotated source, but
d353 2
a354 2
'-L'
'--print-path'
d356 1
a356 1
     suppressed.  The '-L' option causes 'gprof' to print the full
d361 3
a363 3
'-p[SYMSPEC]'
'--flat-profile[=SYMSPEC]'
     The '-p' option causes 'gprof' to print a flat profile.  If SYMSPEC
d367 4
a370 4
'-P[SYMSPEC]'
'--no-flat-profile[=SYMSPEC]'
     The '-P' option causes 'gprof' to suppress printing a flat profile.
     If SYMSPEC is specified, 'gprof' prints a flat profile, but
d373 3
a375 3
'-q[SYMSPEC]'
'--graph[=SYMSPEC]'
     The '-q' option causes 'gprof' to print the call graph analysis.
d379 4
a382 4
'-Q[SYMSPEC]'
'--no-graph[=SYMSPEC]'
     The '-Q' option causes 'gprof' to suppress printing the call graph.
     If SYMSPEC is specified, 'gprof' prints a call graph, but excludes
d385 3
a387 3
'-t'
'--table-length=NUM'
     The '-t' option causes the NUM most active source lines in each
d391 2
a392 2
'-y'
'--separate-files'
d394 1
a394 1
     'gprof' prints annotated source files to standard-output.  If this
d396 9
a404 9
     'path/FILENAME' is generated in the file 'FILENAME-ann'.  If the
     underlying file system would truncate 'FILENAME-ann' so that it
     overwrites the original 'FILENAME', 'gprof' generates annotated
     source in the file 'FILENAME.ann' instead (if the original file
     name has an extension, that extension is _replaced_ with '.ann').

'-Z[SYMSPEC]'
'--no-exec-counts[=SYMSPEC]'
     The '-Z' option causes 'gprof' not to print a tally of functions
d408 3
a410 3
'-r'
'--function-ordering'
     The '--function-ordering' option causes 'gprof' to print a
d420 3
a422 3
'-R MAP_FILE'
'--file-ordering MAP_FILE'
     The '--file-ordering' option causes 'gprof' to print a suggested .o
d428 1
a428 1
     Use of the '-a' argument is highly recommended with this option.
d432 1
a432 1
     similar to the output of the program 'nm'.
d444 2
a445 2
     To create a MAP_FILE with GNU 'nm', type a command like 'nm
     --extern-only --defined-only -v --print-file-name program-name'.
d447 3
a449 3
'-T'
'--traditional'
     The '-T' option causes 'gprof' to print its output in "traditional"
d452 2
a453 2
'-w WIDTH'
'--width=WIDTH'
d457 2
a458 2
'-x'
'--all-lines'
d463 1
a463 1
     similar to 'tcov''s '-a'.
d465 2
a466 2
'--demangle[=STYLE]'
'--no-demangle'
d469 1
a469 1
     '--no-demangle' option may be used to turn off demangling.
d480 3
a482 3
'-a'
'--no-static'
     The '-a' option causes 'gprof' to suppress the printing of
d491 3
a493 3
'-c'
'--static-call-graph'
     The '-c' option causes the call graph of the program to be
d503 1
a503 1
     graph with call counts of '0'.
d505 3
a507 3
'-D'
'--ignore-non-functions'
     The '-D' option causes 'gprof' to ignore symbols which are not
d512 2
a513 2
'-k FROM/TO'
     The '-k' option allows you to delete from the call graph any arcs
d516 3
a518 3
'-l'
'--line'
     The '-l' option enables line-by-line profiling, which causes
d521 2
a522 2
     compiled by older versions of the 'gcc' compiler.  Newer versions
     of 'gcc' are designed to work with the 'gcov' tool instead.
d528 1
a528 1
     significantly increases the running time of 'gprof', and magnifies
d532 2
a533 2
'--inline-file-names'
     This option causes 'gprof' to print the source file after each
d535 1
a535 1
     to the file is printed if used with the '-L' option.
d537 2
a538 2
'-m NUM'
'--min-count=NUM'
d542 3
a544 3
'-nSYMSPEC'
'--time=SYMSPEC'
     The '-n' option causes 'gprof', in its call graph analysis, to only
d547 3
a549 3
'-NSYMSPEC'
'--no-time=SYMSPEC'
     The '-n' option causes 'gprof', in its call graph analysis, not to
d552 5
a556 5
'-SFILENAME'
'--external-symbol-table=FILENAME'
     The '-S' option causes 'gprof' to read an external symbol table
     file, such as '/proc/kallsyms', rather than read the symbol table
     from the given object file (the default is 'a.out').  This is
d559 3
a561 3
'-z'
'--display-unused-functions'
     If you give the '-z' option, 'gprof' will mention all functions in
d563 1
a563 1
     no time spent in them.  This is useful in conjunction with the '-c'
d572 4
a575 4
'-d[NUM]'
'--debug[=NUM]'
     The '-d NUM' option specifies debugging options.  If NUM is not
     specified, enable all debugging.  *Note Debugging 'gprof':
d578 3
a580 3
'-h'
'--help'
     The '-h' option prints command line usage.
d582 2
a583 2
'-ONAME'
'--file-format=NAME'
d585 1
a585 1
     are 'auto' (the default), 'bsd', '4.4bsd', 'magic', and 'prof' (not
d588 3
a590 3
'-s'
'--sum'
     The '-s' option causes 'gprof' to summarize the information in the
d592 2
a593 2
     called 'gmon.sum', which contains all the information from the
     profile data files that 'gprof' read in.  The file 'gmon.sum' may
d595 1
a595 1
     the data in the other input files into 'gmon.sum'.
d597 2
a598 2
     Eventually you can run 'gprof' again without '-s' to analyze the
     cumulative data in the file 'gmon.sum'.
d600 3
a602 3
'-v'
'--version'
     The '-v' flag causes 'gprof' to print the current version number,
d613 2
a614 2
'-e FUNCTION_NAME'
     The '-e FUNCTION' option tells 'gprof' to not print information
d617 3
a619 3
     functions that call it, but its index number will be shown as '[not
     printed]'.  More than one '-e' option may be given; only one
     FUNCTION_NAME may be indicated with each '-e' option.
d621 2
a622 2
'-E FUNCTION_NAME'
     The '-E FUNCTION' option works like the '-e' option, but time spent
d625 2
a626 2
     call graph.  More than one '-E' option may be given; only one
     FUNCTION_NAME may be indicated with each '-E' option.
d628 2
a629 2
'-f FUNCTION_NAME'
     The '-f FUNCTION' option causes 'gprof' to limit the call graph to
d631 2
a632 2
     children...).  More than one '-f' option may be given; only one
     FUNCTION_NAME may be indicated with each '-f' option.
d634 2
a635 2
'-F FUNCTION_NAME'
     The '-F FUNCTION' option works like the '-f' option, but only time
d638 3
a640 3
     call graph.  More than one '-F' option may be given; only one
     FUNCTION_NAME may be indicated with each '-F' option.  The '-F'
     option overrides the '-E' option.
d642 2
a643 2
   Note that only one function can be specified with each '-e', '-E',
'-f' or '-F' option.  To specify more than one function, use multiple
d649 1
a649 1
'foo' or 'bar' and were not reachable from 'boring'.
d658 1
a658 1
using "symspecs" (symbol specifications), which observe the following
d668 3
a670 3
'main.c'
     Selects everything in file 'main.c'--the dot in the string tells
     'gprof' to interpret the string as a filename, rather than as a
d672 2
a673 2
     a trailing colon should be specified.  For example, 'odd:' is
     interpreted as the file named 'odd'.
d675 2
a676 2
'main'
     Selects all functions named 'main'.
d685 2
a686 2
     necessary to add a leading colon to the name.  For example, ':.mul'
     selects function '.mul'.
d689 2
a690 2
     'gprof' will normally not print these underscores.  When you name a
     symbol in a symspec, you should type it exactly as 'gprof' prints
d692 2
a693 2
     '_main' from your 'main' function, 'gprof' still prints it as
     'main' in its output, so you should use 'main' in symspecs.
d695 2
a696 2
'main.c:main'
     Selects function 'main' in file 'main.c'.
d698 2
a699 2
'main.c:134'
     Selects line 134 in file 'main.c'.
d704 1
a704 1
5 Interpreting 'gprof''s Output
d707 1
a707 1
'gprof' can produce several different output styles, the most important
d720 1
a720 1
* Line-by-line::        'gprof' can analyze individual source code lines
d730 2
a731 2
The "flat profile" shows the total amount of time your program spent
executing each function.  Unless the '-z' option is given, functions
d734 1
a734 1
and didn't run long enough to show up on the program counter histogram,
d762 1
a762 1
functions 'mcount' and 'profil' are part of the profiling apparatus and
d767 1
a767 1
much time each sample counted as.  This "sampling period" estimates the
d771 2
a772 2
program's total execution time was 0.06 seconds, as indicated by the
'cumulative seconds' field.  Since each sample counted for 0.01 seconds,
d774 3
a776 3
samples occurred while the program was in the 'open' function, as
indicated by the 'self seconds' field.  Each of the other four samples
occurred one each in 'offtime', 'memccpy', 'write', and 'mcount'.  Since
d778 2
a779 2
particularly reliable.  In another run, the 'self seconds' field for
'mcount' might well be '0.00' or '0.02'.  *Note Statistical Sampling
d782 2
a783 2
   The remaining functions in the listing (those whose 'self seconds'
field is '0.00') didn't appear in the histogram samples at all.
d785 1
a785 1
they are listed, sorted in decreasing order by the 'calls' field.
d792 1
a792 1
'% time'
d796 1
a796 1
'cumulative seconds'
d801 1
a801 1
'self seconds'
d805 1
a805 1
'calls'
d809 1
a809 1
     compiled with profiling enabled), the "calls" field is blank.
d811 1
a811 1
'self ms/call'
d816 1
a816 1
'total ms/call'
d823 1
a823 1
'name'
d825 1
a825 1
     this field alphabetically after the "self seconds" and "calls"
d834 1
a834 1
The "call graph" shows how much time was spent in each function and its
d840 1
a840 1
same 'gprof' run as the flat profile example in the previous section.
d871 1
a871 1
   The lines full of dashes divide this table into "entries", one for
d878 1
a878 1
called "children" when we speak of the call graph).
d883 1
a883 1
   The internal profiling function 'mcount' (*note The Flat Profile:
d888 3
a890 3
* Primary::       Details of the primary line's contents.
* Callers::       Details of caller-lines' contents.
* Subroutines::   Details of subroutine-lines' contents.
d892 1
a892 1
                   such as 'a' calls 'b' calls 'a'...
d900 1
a900 1
The "primary line" in a call graph entry is the line that describes the
d905 1
a905 1
'report' in our main example, together with the heading line that shows
d914 1
a914 1
'index'
d924 1
a924 1
'% time'
d933 1
a933 1
'self'
d935 1
a935 1
     should be identical to the number printed in the 'seconds' field
d938 1
a938 1
'children'
d941 1
a941 1
     'self' and 'children' entries of the children listed directly below
d944 1
a944 1
'called'
d948 1
a948 1
     separated by a '+'.  The first number counts non-recursive calls,
d951 2
a952 2
     In the example above, the function 'report' was called once from
     'main'.
d954 1
a954 1
'name'
d959 1
a959 1
     is printed between the function's name and the index number (*note
d961 1
a961 1
     example, if function 'gnurr' is part of cycle number one, and has
d969 1
a969 1
5.2.2 Lines for a Function's Callers
d972 2
a973 2
A function's entry has a line for each function it was called by.  These
lines' fields correspond to the fields of the primary line, but their
d977 1
a977 1
'report', the primary line and one caller-line preceding it, together
d985 2
a986 2
   Here are the meanings of the fields in the caller-line for 'report'
called from 'main':
d988 14
a1001 14
'self'
     An estimate of the amount of time spent in 'report' itself when it
     was called from 'main'.

'children'
     An estimate of the amount of time spent in subroutines of 'report'
     when 'report' was called from 'main'.

     The sum of the 'self' and 'children' fields is an estimate of the
     amount of time spent within calls to 'report' from 'main'.

'called'
     Two numbers: the number of times 'report' was called from 'main',
     followed by the total number of non-recursive calls to 'report'
d1004 3
a1006 3
'name and index number'
     The name of the caller of 'report' to which this line applies,
     followed by the caller's index number.
d1009 1
a1009 1
     'gprof' request the omission of certain functions.  When a caller
d1017 2
a1018 2
dummy caller-line is printed which has '<spontaneous>' as the "caller's
name" and all other fields blank.  This can happen for signal handlers.
d1023 1
a1023 1
5.2.3 Lines for a Function's Subroutines
d1026 2
a1027 2
A function's entry has a line for each of its subroutines--in other
words, a line for each other function that it called.  These lines'
d1032 1
a1032 1
'main', the primary line and a line for a subroutine, together with the
d1040 2
a1041 2
   Here are the meanings of the fields in the subroutine-line for 'main'
calling 'report':
d1043 16
a1058 16
'self'
     An estimate of the amount of time spent directly within 'report'
     when 'report' was called from 'main'.

'children'
     An estimate of the amount of time spent in subroutines of 'report'
     when 'report' was called from 'main'.

     The sum of the 'self' and 'children' fields is an estimate of the
     total time spent in calls to 'report' from 'main'.

'called'
     Two numbers, the number of calls to 'report' from 'main' followed
     by the total number of non-recursive calls to 'report'.  This ratio
     is used to determine how much of 'report''s 'self' and 'children'
     time gets credited to 'main'.  *Note Estimating 'children' Times:
d1061 3
a1063 3
'name'
     The name of the subroutine of 'main' to which this line applies,
     followed by the subroutine's index number.
d1074 1
a1074 1
The graph may be complicated by the presence of "cycles of recursion" in
d1077 2
a1078 2
function.  For example: if 'a' calls 'b', and 'b' calls 'a', then 'a'
and 'b' form a cycle.
d1081 4
a1084 4
they belong to the same cycle.  If 'a' and 'b' call each other and 'b'
and 'c' call each other, all three make one cycle.  Note that even if
'b' only calls 'a' if it was not called from 'a', 'gprof' cannot
determine this, so 'a' and 'b' are still considered a cycle.
d1088 1
a1088 1
graph it is followed by '<cycle NUMBER>'.
d1091 4
a1094 4
call graph paradoxical.  The "time spent in children" of 'a' should
include the time spent in its subroutine 'b' and in 'b''s
subroutines--but one of 'b''s subroutines is 'a'!  How much of 'a''s
time should be included in the children of 'a', when 'a' is indirectly
d1097 1
a1097 1
   The way 'gprof' resolves this paradox is by creating a single entry
d1100 1
a1100 1
"subroutines" of the cycle are the individual functions of the cycle,
d1102 1
a1102 1
"callers" of the cycle are the functions, outside the cycle, that called
d1106 2
a1107 2
containing functions 'a' and 'b'.  The cycle was entered by a call to
'a' from 'main'; both 'a' and 'b' called 'c'.
d1129 2
a1130 2
for 'main', which calls 'a', and an entry for 'c', with callers 'a' and
'b'.)
d1163 2
a1164 2
   The 'self' field of the cycle's primary line is the total time spent
in all the functions of the cycle.  It equals the sum of the 'self'
d1168 6
a1173 6
   The 'children' fields of the cycle's primary line and subroutine
lines count only subroutines outside the cycle.  Even though 'a' calls
'b', the time spent in those calls to 'b' is not counted in 'a''s
'children' time.  Thus, we do not encounter the problem of what to do
when the time in those calls to 'b' includes indirect recursive calls
back to 'a'.
d1175 1
a1175 1
   The 'children' field of a caller-line in the cycle's entry estimates
d1180 1
a1180 1
   The 'called' field in the primary line for the cycle has two numbers:
d1187 2
a1188 2
   The 'called' field of a subroutine-line for a cycle member in the
cycle's entry says how many time that function was called from functions
d1190 1
a1190 1
primary line's 'called' field.
d1195 1
a1195 1
called from each other function in the cycle.  The 'self' and 'children'
d1205 1
a1205 1
'gprof''s '-l' option causes the program to perform "line-by-line"
d1208 2
a1209 2
programs compiled with older versions of the 'gcc' compiler.  Newer
versions of 'gcc' use a different program - 'gcov' - to display
d1212 2
a1213 2
   With the older versions of 'gcc' the program usually has to be
compiled with a '-g' option, in addition to '-pg', in order to generate
d1215 1
a1215 1
versions of 'gcc' the program had to be compiled with the '-a'
d1219 2
a1220 2
mode.  The call graph isn't as useful as normal, since the current
version of 'gprof' does not propagate call graph arcs from source code
d1224 3
a1226 3
   Here is a section of 'gprof''s output, without line-by-line
profiling.  Note that 'ct_init' accounted for four histogram hits, and
13327 calls to 'init_block'.
d1250 3
a1252 3
   Now let's look at some of 'gprof''s output from the same program run,
this time with line-by-line profiling enabled.  Note that 'ct_init''s
four histogram hits are broken down into four lines of source code--one
d1254 1
a1254 1
note how 'ct_init''s 13327 calls to 'init_block' are broken down into
d1297 4
a1300 4
'gprof''s '-A' option triggers an annotated source listing, which lists
the program's source code, each function labeled with the number of
times it was called.  You may also need to specify the '-I' option, if
'gprof' can't find the source code files.
d1302 1
a1302 1
   With older versions of 'gcc' compiling with 'gcc ... -g -pg -a'
d1304 3
a1306 3
function counting code.  This enables 'gprof' to determine how many
times each line of code was executed.  With newer versions of 'gcc'
support for displaying basic-block counts is provided by the 'gcov'
d1333 4
a1336 4
   'updcrc' has at least five basic-blocks.  One is the function itself.
The 'if' statement on line 9 generates two more basic-blocks, one for
each branch of the 'if'.  A fourth basic-block results from the 'if' on
line 13, and the contents of the 'do' loop form the fifth basic-block.
d1341 3
a1343 3
'gprof -l -A'.  The '-x' option is also helpful, to ensure that each
line of code is labeled at least once.  Here is 'updcrc''s annotated
source listing for a sample 'gzip' run:
d1366 2
a1367 2
each branch of the 'if' statement.  The body of the 'do' loop was
executed a total of 26312 times.  Note how the 'while' statement is
d1375 1
a1375 1
6 Inaccuracy of 'gprof' Output
d1389 1
a1389 1
The run-time figures that 'gprof' gives you are based on a sampling
d1405 1
a1405 1
   The "sampling period" that is printed at the beginning of the flat
d1412 1
a1412 1
period is 0.01 seconds and 'foo''s run-time is 1 second, N is 100
d1414 1
a1414 1
error in 'foo''s run-time is 0.1 seconds (10*0.01 seconds), or ten
d1416 2
a1417 2
seconds and 'bar''s run-time is 100 seconds, N is 10000 samples, sqrt(N)
is 100 samples, so the expected error in 'bar''s run-time is 1 second,
d1423 1
a1423 1
information.  If the program's _total_ run-time is large, a small
d1425 1
a1425 1
insignificant fraction of the whole program's time.  Usually this means
d1430 1
a1430 1
the data from several runs, using the '-s' option of 'gprof'.  Here is
d1435 1
a1435 1
  2. Issue the command 'mv gmon.out gmon.sum'.
d1439 1
a1439 1
  4. Merge the new data in 'gmon.out' into 'gmon.sum' with this command:
d1452 1
a1452 1
6.2 Estimating 'children' Times
d1455 2
a1456 2
Some of the figures in the call graph are estimates--for example, the
'children' time values and all the time figures in caller and subroutine
d1460 1
a1460 1
profile data itself.  Instead, 'gprof' estimates them by making an
d1464 3
a1466 3
any function 'foo' is not correlated with who called 'foo'.  If 'foo'
used 5 seconds in all, and 2/5 of the calls to 'foo' came from 'a', then
'foo' contributes 2 seconds to 'a''s 'children' time, by assumption.
d1469 6
a1474 6
far from true.  Suppose that 'foo' returns very quickly when its
argument is zero; suppose that 'a' always passes zero as an argument,
while other callers of 'foo' pass other arguments.  In this program, all
the time spent in 'foo' is in the calls from callers other than 'a'.
But 'gprof' has no way of knowing this; it will blindly and incorrectly
charge 2 seconds of time in 'foo' to the children of 'a'.
d1476 1
a1476 1
   We hope some day to put more complete data into 'gmon.out', so that
d1489 1
a1489 1
     Because 'gprof' can only report call times and counts by function,
d1493 1
a1493 1
     artificial hot spots since compiling with '-pg' adds a significant
d1499 1
a1499 1
     Use the 'gcov' program.
d1503 1
a1503 1
     Use 'gprof -l' and lookup the function in the call graph.  The
d1526 1
a1526 1
8 Incompatibilities with Unix 'gprof'
d1529 1
a1529 1
GNU 'gprof' and Berkeley Unix 'gprof' use the same data file 'gmon.out',
d1533 1
a1533 1
   * GNU 'gprof' uses a new, generalized file format with support for
d1535 1
a1535 1
     cookie and version number allows 'gprof' to easily identify new
d1539 3
a1541 3
   * For a recursive function, Unix 'gprof' lists the function as a
     parent and as a child, with a 'calls' field that lists the number
     of recursive calls.  GNU 'gprof' omits these lines and puts the
d1544 2
a1545 2
   * When a function is suppressed from the call graph with '-e', GNU
     'gprof' still lists it as a subroutine of functions that call it.
d1547 2
a1548 2
   * GNU 'gprof' accepts the '-k' with its argument in the form
     'from/to', instead of 'from to'.
d1550 2
a1551 2
   * In the annotated source listing, if there are multiple basic blocks
     on the same line, GNU 'gprof' prints all of their counts, separated
d1554 2
a1555 2
   * The blurbs, field widths, and output formats are different.  GNU
     'gprof' prints blurbs after the tables, so that you can see the
d1567 3
a1569 3
* File Format::         Format of 'gmon.out' files
* Internals::           'gprof''s internal operation
* Debugging::           Using 'gprof''s '-d' option
d1582 2
a1583 2
the '-pg' option, which causes every function to call 'mcount' (or
'_mcount', or '__mcount', depending on the OS and compiler) as one of
d1586 1
a1586 1
   The 'mcount' routine, included in the profiling library, is
d1588 1
a1588 1
parent routine (the child) and its parent's parent.  This is typically
d1591 1
a1591 1
machine-dependent operation, 'mcount' itself is typically a short
d1593 4
a1596 4
and then calls '__mcount_internal' (a normal C function) with two
arguments--'frompc' and 'selfpc'.  '__mcount_internal' is responsible
for maintaining the in-memory call graph, which records 'frompc',
'selfpc', and the number of times each of these call arcs was traversed.
d1599 1
a1599 1
('__builtin_return_address'), which allows a generic 'mcount' function
d1603 1
a1603 1
'mcount' is used for performance reasons.
d1607 2
a1608 2
same as in the usual C library, but they were compiled with '-pg'.  If
you link your program with 'gcc ... -pg', it automatically uses the
d1618 2
a1619 2
provide a 'profil()' system call, which registers a memory array with
the kernel, along with a scale factor that determines how the program's
d1629 1
a1629 1
earlier), do not provide a 'profil()' system call.  On such a system,
d1631 1
a1631 1
the process (typically via 'setitimer()'), which then performs the same
d1639 5
a1643 5
either calls 'profil()' or sets up a clock signal handler.  This routine
('monstartup') can be invoked in several ways.  On Linux systems, a
special profiling startup file 'gcrt0.o', which invokes 'monstartup'
before 'main', is used instead of the default 'crt0.o'.  Use of this
special startup file is one of the effects of using 'gcc ... -pg' to
d1645 2
a1646 2
'mcount' routine, when it is invoked for the first time (typically when
'main' is called), calls 'monstartup'.
d1648 1
a1648 1
   If the compiler's '-a' option was used, basic-block counting is also
d1651 1
a1651 1
basic-block begins (i.e., when an 'if' statement appears), an extra
d1658 3
a1660 3
   The profiling library also includes a function ('mcleanup') which is
typically registered using 'atexit()' to be called as the program exits,
and is responsible for writing the file 'gmon.out'.  Profiling is turned
d1664 1
a1664 1
   The output from 'gprof' gives no indication of parts of your program
d1666 2
a1667 2
of the program counter are taken at fixed intervals of the program's run
time.  Therefore, the time measurements in 'gprof' output say nothing
d1670 1
a1670 1
memory at once may run very slowly due to thrashing, but 'gprof' will
d1672 1
a1672 1
the advantage that the amount of load due to other users won't directly
d1683 2
a1684 2
'gprof' file.  Furthermore, it does not provide a version number, thus
rendering changes to the file format almost impossible.  GNU 'gprof'
d1686 1
a1686 1
compatibility, GNU 'gprof' continues to support the old BSD-derived
d1691 1
a1691 1
   The new file format is defined in header file 'gmon_out.h'.  It
d1695 1
a1695 1
the profile was collected.  GNU 'gprof' adapts automatically to the
d1702 1
a1702 1
reading a file, GNU 'gprof' will ensure records of the same type are
d1718 1
a1718 1
would specify the long name as "seconds" and the abbreviation as "s".
d1721 1
a1721 1
For example, under DEC OSF/1, the "uprofile" command can be used to
d1723 2
a1724 2
the dimension in the histogram header could be set to "i-cache misses"
and the abbreviation could be set to "1" (because it is simply a count,
d1740 2
a1741 2
must be within caller's function and the second must be within the
callee's function.  When performing profiling at the function level,
d1760 1
a1760 1
9.3 'gprof''s Internal Operation
d1763 3
a1765 3
Like most programs, 'gprof' begins by processing its options.  During
this stage, it may building its symspec list ('sym_ids.c:sym_id_add'),
if options are specified which use symspecs.  'gprof' maintains a single
d1767 1
a1767 1
tables, organized into six include/exclude pairs--one pair each for the
d1775 2
a1776 2
   After option processing, 'gprof' finishes building the symspec list
by adding all the symspecs in 'default_excluded_list' to the exclude
d1782 2
a1783 2
it is an object file, and read its symbol table ('core.c:core_init'),
using 'bfd_canonicalize_symtab' after mallocing an appropriately sized
d1785 2
a1786 2
'--file-ordering' option has been specified), and the core text space is
read into memory (if the '-c' option was given).
d1788 1
a1788 1
   'gprof''s own symbol table, an array of Sym structures, is now built.
d1790 1
a1790 1
whether line-by-line profiling ('-l' option) has been enabled.  For
d1794 1
a1794 1
either case, two passes are made through the symbol table--one to count
d1796 2
a1797 2
the symbols.  In between the two passes, a single array of type 'Sym' is
created of the appropriate length.  Finally, 'symtab.c:symtab_finalize'
d1802 1
a1802 1
the 'qsort' library function (which sorts an array) will be used to sort
d1804 1
a1804 1
('symtab.c:sym_lookup'), which finds symbols based on memory address,
d1806 1
a1806 1
sorted array.  Function symbols are indicated with an 'is_func' flag.
d1808 1
a1808 1
can have an 'is_static' flag to indicate that it is a local symbol.
d1811 2
a1812 2
Syms ('sym_ids.c:sym_id_parse').  Remember that a single symspec can
match multiple symbols.  An array of symbol tables ('syms') is created,
d1820 2
a1821 2
'gprof' simply uses its standard symbol lookup routine on the
appropriate table in the 'syms' array.
d1824 2
a1825 2
('gmon_io.c:gmon_out_read'), first by checking for a new-style
'gmon.out' header, then assuming this is an old-style BSD 'gmon.out' if
d1828 1
a1828 1
   New-style histogram records are read by 'hist.c:hist_read_rec'.  For
d1838 1
a1838 1
   As each call graph record is read ('call_graph.c:cg_read_rec'), the
d1840 1
a1840 1
call graph arc is created by 'cg_arcs.c:arc_add', unless the arc fails a
d1842 3
a1844 3
linked list is maintained of the parent's child arcs, and of the child's
parent arcs.  Both the child's call count and the arc's call count are
incremented by the record's call count.
d1846 1
a1846 1
   Basic-block records are read ('basic_blocks.c:bb_read_rec'), but only
d1849 1
a1849 1
entry made in the symbol's bb_addr and bb_calls arrays.  Again, if
d1853 1
a1853 1
   A gmon.sum file is dumped, if requested ('gmon_io.c:gmon_out_write').
d1856 1
a1856 1
('hist.c:hist_assign_samples') by iterating over all the sample bins and
d1867 3
a1869 3
   If call graph data is present, 'cg_arcs.c:cg_assemble' is called.
First, if '-c' was specified, a machine-dependent routine ('find_call')
scans through each symbol's machine code, looking for subroutine call
d1872 1
a1872 1
('cg_dfn.c:cg_dfn'), so that children are always numbered less than
d1881 1
a1881 1
a parent's include or exclude (print or no print) property being
d1891 2
a1892 2
fairly straightforward.  The call graph ('cg_print.c:cg_print') and flat
profile ('hist.c:hist_print') are regurgitations of values already
d1894 1
a1894 1
('basic_blocks.c:print_annotated_source') uses basic-block information,
d1899 1
a1899 1
source code itself ('cg_print.c').  Basically, the functions with the
d1907 1
a1907 1
9.4 Debugging 'gprof'
d1910 1
a1910 1
If 'gprof' was compiled with debugging enabled, the '-d' option triggers
d1930 1
a1930 1
     file.  For line-by-line profiling ('-l' option), also shows line
d1933 1
a1933 1
     Trace operation of '-c' option
d1940 1
a1940 1
     meaningful with '-l' option)
d1944 1
a1944 1
     Tracks operation of '-A' option
d1954 1
a1954 1
     Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
d1963 1
a1963 1
     functional and useful document "free" in the sense of freedom: to
d1970 1
a1970 1
     This License is a kind of "copyleft", which means that derivative
d1991 2
a1992 2
     "Document", below, refers to any such manual or work.  Any member
     of the public is a licensee, and is addressed as "you".  You accept
d1996 1
a1996 1
     A "Modified Version" of the Document means any work containing the
d2000 1
a2000 1
     A "Secondary Section" is a named appendix or a front-matter section
d2002 1
a2002 1
     publishers or authors of the Document to the Document's overall
d2011 1
a2011 1
     The "Invariant Sections" are certain Secondary Sections whose
d2019 1
a2019 1
     The "Cover Texts" are certain short passages of text that are
d2025 1
a2025 1
     A "Transparent" copy of the Document means a machine-readable copy,
d2037 1
a2037 1
     "Transparent" is called "Opaque".
d2050 1
a2050 1
     The "Title Page" means, for a printed book, the title page itself,
d2053 3
a2055 3
     works in formats which do not have any title page as such, "Title
     Page" means the text near the most prominent appearance of the
     work's title, preceding the beginning of the body of the text.
d2057 1
a2057 1
     The "publisher" means any person or entity that distributes copies
d2060 1
a2060 1
     A section "Entitled XYZ" means a named subunit of the Document
d2064 3
a2066 3
     "Acknowledgements", "Dedications", "Endorsements", or "History".)
     To "Preserve the Title" of such a section when you modify the
     Document means that it remains a section "Entitled XYZ" according
d2096 1
a2096 1
     the Document's license notice requires Cover Texts, you must
d2168 1
a2168 1
          Sections and required Cover Texts given in the Document's
d2173 1
a2173 1
       I. Preserve the section Entitled "History", Preserve its Title,
d2176 1
a2176 1
          Title Page.  If there is no section Entitled "History" in the
d2186 1
a2186 1
          "History" section.  You may omit a network location for a work
d2191 1
a2191 1
       K. For any section Entitled "Acknowledgements" or "Dedications",
d2200 1
a2200 1
       M. Delete any section Entitled "Endorsements".  Such a section
d2204 1
a2204 1
          "Endorsements" or to conflict in title with any Invariant
d2213 1
a2213 1
     titles to the list of Invariant Sections in the Modified Version's
d2217 1
a2217 1
     You may add a section Entitled "Endorsements", provided it contains
d2219 3
a2221 3
     parties--for example, statements of peer review or that the text
     has been approved by an organization as the authoritative
     definition of a standard.
d2259 4
a2262 4
     "History" in the various original documents, forming one section
     Entitled "History"; likewise combine any sections Entitled
     "Acknowledgements", and any sections Entitled "Dedications".  You
     must delete all sections Entitled "Endorsements."
d2283 1
a2283 1
     storage or distribution medium, is called an "aggregate" if the
d2285 1
a2285 1
     legal rights of the compilation's users beyond what the individual
d2292 1
a2292 1
     of the entire aggregate, the Document's Cover Texts may be placed
d2314 2
a2315 2
     If a section in the Document is Entitled "Acknowledgements",
     "Dedications", or "History", the requirement (section 4) to
d2356 1
a2356 1
     version of this License "or any later version" applies to it, you
d2364 1
a2364 1
     proxy's public statement of acceptance of a version permanently
d2369 1
a2369 1
     "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
d2373 1
a2373 1
     A "Massive Multiauthor Collaboration" (or "MMC") contained in the
d2377 1
a2377 1
     "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
d2383 1
a2383 1
     "Incorporate" means to publish or republish a Document, in whole or
d2386 1
a2386 1
     An MMC is "eligible for relicensing" if it is licensed under this
d2413 1
a2413 1
Texts, replace the "with...Texts."  line with this:
d2431 30
a2460 30
Node: Top719
Node: Introduction2042
Node: Compiling4533
Node: Executing8589
Node: Invoking11482
Node: Output Options12897
Node: Analysis Options19989
Node: Miscellaneous Options23909
Node: Deprecated Options25163
Node: Symspecs27226
Node: Output29052
Node: Flat Profile30092
Node: Call Graph35045
Node: Primary38277
Node: Callers40865
Node: Subroutines42983
Node: Cycles44824
Node: Line-by-line51601
Node: Annotated Source55677
Node: Inaccuracy58675
Node: Sampling Error58933
Node: Assumptions61837
Node: How do I?63307
Node: Incompatibilities64864
Node: Details66358
Node: Implementation66751
Node: File Format72650
Node: Internals76942
Node: Debugging85432
Node: GNU Free Documentation License87022
@


1.9.2.1
log
@Sync with HEAD.
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 7.0.2 from gprof.texi.
d5 1
a5 1
   Copyright © 1988-2024 Free Software Foundation, Inc.
d11 2
a12 2
Texts.  A copy of the license is included in the section entitled “GNU
Free Documentation License”.
d16 1
a16 1
* gprof: (gprof).                Profiling your program’s execution
d25 1
a25 1
This manual describes the GNU profiler, ‘gprof’, and how you can use it
d28 1
a28 1
programs.  GNU ‘gprof’ was written by Jay Fenlason.
d30 1
a30 1
   This manual is for ‘gprof’ (GNU Binutils) version 2.42.
d34 1
a34 1
the section entitled “GNU Free Documentation License”.
d42 1
a42 1
* Invoking::            How to run ‘gprof’, and its options
d44 1
a44 1
* Output::              Interpreting ‘gprof’’s output
d48 1
a48 1
* Incompatibilities::   (between GNU ‘gprof’ and Unix ‘gprof’.)
d70 1
a70 1
data.  If you don’t use some feature of your program while it is being
d75 1
a75 1
   • You must compile and link your program with profiling enabled.
d78 1
a78 1
   • You must execute your program to generate a profile data file.
d81 1
a81 1
   • You must run ‘gprof’ to analyze the profile data.  *Note ‘gprof’
d88 1
a88 1
   The “flat profile” shows how much time your program spent in each
d93 1
a93 1
   The “call graph” shows, for each function, which functions called it,
d99 1
a99 1
   The “annotated source” listing is a copy of the program’s source
d116 1
a116 1
   To compile a source file for profiling, specify the ‘-pg’ option when
d120 3
a122 3
   To link the program for profiling, if you use a compiler such as ‘cc’
to do the linking, simply specify ‘-pg’ in addition to your usual
options.  The same option, ‘-pg’, alters either compilation or linking
d128 1
a128 1
   The ‘-pg’ option also works with a command that both compiles and
d133 1
a133 1
   Note: The ‘-pg’ option must be part of your compilation options as
d135 1
a135 1
gathered and when you run ‘gprof’ you will get an error message like
d140 1
a140 1
   If you add the ‘-Q’ switch to suppress the printing of the call graph
d152 3
a154 3
   If you run the linker ‘ld’ directly instead of through a compiler
such as ‘cc’, you may have to specify a profiling startup file ‘gcrt0.o’
as the first input file instead of the usual startup file ‘crt0.o’.  In
d156 1
a156 1
‘libc_p.a’, by writing ‘-lc_p’ instead of the usual ‘-lc’.  This is not
d158 1
a158 1
information for standard library functions such as ‘read’ and ‘open’.
d169 2
a170 2
code, which for ‘gcc’ users can be done via the ‘-static’ or
‘-static-libgcc’ command-line option.  For example:
d174 3
a176 3
   If you compile only some of the modules of the program with ‘-pg’,
you can still profile the program, but you won’t get complete
information about the modules that were compiled without ‘-pg’.  The
d180 1
a180 1
that the ‘calls’ field for the functions will be blank), but will
d184 1
a184 1
‘gcov’ tool instead of ‘gprof’.  See that tool’s manual or info pages
d187 3
a189 3
   Note, older versions of ‘gcc’ produce line-by-line profiling
information that works with ‘gprof’ rather than ‘gcov’ so there is still
support for displaying this kind of information in ‘gprof’.  *Note
d192 1
a192 1
   It also worth noting that ‘gcc’ implements a ‘-finstrument-functions’
d205 1
a205 1
generate the information that ‘gprof’ needs.  Simply run the program as
d211 2
a212 2
   The way you run the program—the arguments and input that you give
it—may have a dramatic effect on what the profile information shows.
d219 2
a220 2
‘gmon.out’ just before exiting.  If there is already a file called
‘gmon.out’, its contents are overwritten.  You can rename the file
d226 3
a228 3
   In order to write the ‘gmon.out’ file properly, your program must
exit normally: by returning from ‘main’ or by calling ‘exit’.  Calling
the low-level function ‘_exit’ does not write the profile data, and
d231 1
a231 1
   The ‘gmon.out’ file is written in the program’s _current working
d233 2
a234 2
‘chdir’, the ‘gmon.out’ file will be left in the last directory your
program ‘chdir’’d to.  If you don’t have permission to write in this
d238 1
a238 1
called ‘bb.out’.  This file, if present, contains an human-readable
d240 4
a243 4
appearance of a human-readable ‘bb.out’ means the basic-block counts
didn’t get written into ‘gmon.out’.  The Perl script ‘bbconv.pl’,
included with the ‘gprof’ source distribution, will convert a ‘bb.out’
file into a format readable by ‘gprof’.  Invoke it like this:
d247 2
a248 2
   This translates the information in ‘bb.out’ into a form that ‘gprof’
can understand.  But you still need to tell ‘gprof’ about the existence
d250 1
a250 1
‘gprof’ command line, _along with ‘gmon.out’_, like this:
d257 1
a257 1
4 ‘gprof’ Command Summary
d260 2
a261 2
After you have a profile data file ‘gmon.out’, you can run ‘gprof’ to
interpret the information in it.  The ‘gprof’ program prints a flat
d263 1
a263 1
redirect the output of ‘gprof’ into a file with ‘>’.
d265 1
a265 1
   You run ‘gprof’ like this:
d271 2
a272 2
   If you omit the executable file name, the file ‘a.out’ is used.  If
you give no profile data file name, the file ‘gmon.out’ is used.  If any
d284 2
a285 2
* Output Options::      Controlling ‘gprof’’s output style
* Analysis Options::    Controlling how ‘gprof’ analyzes its data
d297 1
a297 1
These options specify which of several output formats ‘gprof’ should
d300 1
a300 1
   Many of these options take an optional “symspec” to specify functions
d305 1
a305 1
   Specifying any of these options overrides the default (‘-p -q’),
d308 3
a310 3
‘-A[SYMSPEC]’
‘--annotated-source[=SYMSPEC]’
     The ‘-A’ option causes ‘gprof’ to print annotated source code.  If
d314 3
a316 3
‘-b’
‘--brief’
     If the ‘-b’ option is given, ‘gprof’ doesn’t print the verbose
d321 3
a323 6
‘-B’
     The ‘-B’ option causes ‘gprof’ to print the call graph analysis.

‘-C[SYMSPEC]’
‘--exec-counts[=SYMSPEC]’
     The ‘-C’ option causes ‘gprof’ to print a tally of functions and
d328 1
a328 1
     specifying the ‘-l’ option, along with ‘-C’, will cause basic-block
d331 3
a333 3
‘-i’
‘--file-info’
     The ‘-i’ option causes ‘gprof’ to display summary information about
d337 3
a339 3
‘-I DIRS’
‘--directory-path=DIRS’
     The ‘-I’ option specifies a list of search directories in which to
d344 4
a347 4
‘-J[SYMSPEC]’
‘--no-annotated-source[=SYMSPEC]’
     The ‘-J’ option causes ‘gprof’ not to print annotated source code.
     If SYMSPEC is specified, ‘gprof’ prints annotated source, but
d350 2
a351 2
‘-L’
‘--print-path’
d353 1
a353 1
     suppressed.  The ‘-L’ option causes ‘gprof’ to print the full
d358 3
a360 3
‘-p[SYMSPEC]’
‘--flat-profile[=SYMSPEC]’
     The ‘-p’ option causes ‘gprof’ to print a flat profile.  If SYMSPEC
d364 4
a367 4
‘-P[SYMSPEC]’
‘--no-flat-profile[=SYMSPEC]’
     The ‘-P’ option causes ‘gprof’ to suppress printing a flat profile.
     If SYMSPEC is specified, ‘gprof’ prints a flat profile, but
d370 3
a372 3
‘-q[SYMSPEC]’
‘--graph[=SYMSPEC]’
     The ‘-q’ option causes ‘gprof’ to print the call graph analysis.
d376 4
a379 4
‘-Q[SYMSPEC]’
‘--no-graph[=SYMSPEC]’
     The ‘-Q’ option causes ‘gprof’ to suppress printing the call graph.
     If SYMSPEC is specified, ‘gprof’ prints a call graph, but excludes
d382 3
a384 3
‘-t’
‘--table-length=NUM’
     The ‘-t’ option causes the NUM most active source lines in each
d388 2
a389 2
‘-y’
‘--separate-files’
d391 1
a391 1
     ‘gprof’ prints annotated source files to standard-output.  If this
d393 9
a401 9
     ‘path/FILENAME’ is generated in the file ‘FILENAME-ann’.  If the
     underlying file system would truncate ‘FILENAME-ann’ so that it
     overwrites the original ‘FILENAME’, ‘gprof’ generates annotated
     source in the file ‘FILENAME.ann’ instead (if the original file
     name has an extension, that extension is _replaced_ with ‘.ann’).

‘-Z[SYMSPEC]’
‘--no-exec-counts[=SYMSPEC]’
     The ‘-Z’ option causes ‘gprof’ not to print a tally of functions
d405 3
a407 3
‘-r’
‘--function-ordering’
     The ‘--function-ordering’ option causes ‘gprof’ to print a
d417 3
a419 3
‘-R MAP_FILE’
‘--file-ordering MAP_FILE’
     The ‘--file-ordering’ option causes ‘gprof’ to print a suggested .o
d425 1
a425 1
     Use of the ‘-a’ argument is highly recommended with this option.
d429 1
a429 1
     similar to the output of the program ‘nm’.
d441 2
a442 2
     To create a MAP_FILE with GNU ‘nm’, type a command like ‘nm
     --extern-only --defined-only -v --print-file-name program-name’.
d444 3
a446 3
‘-T’
‘--traditional’
     The ‘-T’ option causes ‘gprof’ to print its output in “traditional”
d449 2
a450 2
‘-w WIDTH’
‘--width=WIDTH’
d454 2
a455 2
‘-x’
‘--all-lines’
d460 1
a460 1
     similar to ‘tcov’’s ‘-a’.
d462 2
a463 2
‘--demangle[=STYLE]’
‘--no-demangle’
d466 1
a466 1
     ‘--no-demangle’ option may be used to turn off demangling.
d477 3
a479 3
‘-a’
‘--no-static’
     The ‘-a’ option causes ‘gprof’ to suppress the printing of
d488 3
a490 3
‘-c’
‘--static-call-graph’
     The ‘-c’ option causes the call graph of the program to be
d500 1
a500 1
     graph with call counts of ‘0’.
d502 3
a504 3
‘-D’
‘--ignore-non-functions’
     The ‘-D’ option causes ‘gprof’ to ignore symbols which are not
d509 2
a510 2
‘-k FROM/TO’
     The ‘-k’ option allows you to delete from the call graph any arcs
d513 3
a515 3
‘-l’
‘--line’
     The ‘-l’ option enables line-by-line profiling, which causes
d518 2
a519 2
     compiled by older versions of the ‘gcc’ compiler.  Newer versions
     of ‘gcc’ are designed to work with the ‘gcov’ tool instead.
d525 1
a525 1
     significantly increases the running time of ‘gprof’, and magnifies
d529 2
a530 2
‘--inline-file-names’
     This option causes ‘gprof’ to print the source file after each
d532 1
a532 1
     to the file is printed if used with the ‘-L’ option.
d534 2
a535 2
‘-m NUM’
‘--min-count=NUM’
d539 3
a541 3
‘-nSYMSPEC’
‘--time=SYMSPEC’
     The ‘-n’ option causes ‘gprof’, in its call graph analysis, to only
d544 3
a546 3
‘-NSYMSPEC’
‘--no-time=SYMSPEC’
     The ‘-n’ option causes ‘gprof’, in its call graph analysis, not to
d549 5
a553 5
‘-SFILENAME’
‘--external-symbol-table=FILENAME’
     The ‘-S’ option causes ‘gprof’ to read an external symbol table
     file, such as ‘/proc/kallsyms’, rather than read the symbol table
     from the given object file (the default is ‘a.out’).  This is
d556 3
a558 3
‘-z’
‘--display-unused-functions’
     If you give the ‘-z’ option, ‘gprof’ will mention all functions in
d560 1
a560 1
     no time spent in them.  This is useful in conjunction with the ‘-c’
d569 4
a572 4
‘-d[NUM]’
‘--debug[=NUM]’
     The ‘-d NUM’ option specifies debugging options.  If NUM is not
     specified, enable all debugging.  *Note Debugging ‘gprof’:
d575 3
a577 3
‘-h’
‘--help’
     The ‘-h’ option prints command line usage.
d579 2
a580 2
‘-ONAME’
‘--file-format=NAME’
d582 1
a582 1
     are ‘auto’ (the default), ‘bsd’, ‘4.4bsd’, ‘magic’, and ‘prof’ (not
d585 3
a587 3
‘-s’
‘--sum’
     The ‘-s’ option causes ‘gprof’ to summarize the information in the
d589 2
a590 2
     called ‘gmon.sum’, which contains all the information from the
     profile data files that ‘gprof’ read in.  The file ‘gmon.sum’ may
d592 1
a592 1
     the data in the other input files into ‘gmon.sum’.
d594 2
a595 2
     Eventually you can run ‘gprof’ again without ‘-s’ to analyze the
     cumulative data in the file ‘gmon.sum’.
d597 3
a599 3
‘-v’
‘--version’
     The ‘-v’ flag causes ‘gprof’ to print the current version number,
d610 2
a611 2
‘-e FUNCTION_NAME’
     The ‘-e FUNCTION’ option tells ‘gprof’ to not print information
d614 3
a616 3
     functions that call it, but its index number will be shown as ‘[not
     printed]’.  More than one ‘-e’ option may be given; only one
     FUNCTION_NAME may be indicated with each ‘-e’ option.
d618 2
a619 2
‘-E FUNCTION_NAME’
     The ‘-E FUNCTION’ option works like the ‘-e’ option, but time spent
d622 2
a623 2
     call graph.  More than one ‘-E’ option may be given; only one
     FUNCTION_NAME may be indicated with each ‘-E’ option.
d625 2
a626 2
‘-f FUNCTION_NAME’
     The ‘-f FUNCTION’ option causes ‘gprof’ to limit the call graph to
d628 2
a629 2
     children...).  More than one ‘-f’ option may be given; only one
     FUNCTION_NAME may be indicated with each ‘-f’ option.
d631 2
a632 2
‘-F FUNCTION_NAME’
     The ‘-F FUNCTION’ option works like the ‘-f’ option, but only time
d635 3
a637 3
     call graph.  More than one ‘-F’ option may be given; only one
     FUNCTION_NAME may be indicated with each ‘-F’ option.  The ‘-F’
     option overrides the ‘-E’ option.
d639 2
a640 2
   Note that only one function can be specified with each ‘-e’, ‘-E’,
‘-f’ or ‘-F’ option.  To specify more than one function, use multiple
d646 1
a646 1
‘foo’ or ‘bar’ and were not reachable from ‘boring’.
d655 1
a655 1
using “symspecs” (symbol specifications), which observe the following
d665 3
a667 3
‘main.c’
     Selects everything in file ‘main.c’—the dot in the string tells
     ‘gprof’ to interpret the string as a filename, rather than as a
d669 2
a670 2
     a trailing colon should be specified.  For example, ‘odd:’ is
     interpreted as the file named ‘odd’.
d672 2
a673 2
‘main’
     Selects all functions named ‘main’.
d682 2
a683 2
     necessary to add a leading colon to the name.  For example, ‘:.mul’
     selects function ‘.mul’.
d686 2
a687 2
     ‘gprof’ will normally not print these underscores.  When you name a
     symbol in a symspec, you should type it exactly as ‘gprof’ prints
d689 2
a690 2
     ‘_main’ from your ‘main’ function, ‘gprof’ still prints it as
     ‘main’ in its output, so you should use ‘main’ in symspecs.
d692 2
a693 2
‘main.c:main’
     Selects function ‘main’ in file ‘main.c’.
d695 2
a696 2
‘main.c:134’
     Selects line 134 in file ‘main.c’.
d701 1
a701 1
5 Interpreting ‘gprof’’s Output
d704 1
a704 1
‘gprof’ can produce several different output styles, the most important
d717 1
a717 1
* Line-by-line::        ‘gprof’ can analyze individual source code lines
d727 2
a728 2
The “flat profile” shows the total amount of time your program spent
executing each function.  Unless the ‘-z’ option is given, functions
d731 1
a731 1
and didn’t run long enough to show up on the program counter histogram,
d759 1
a759 1
functions ‘mcount’ and ‘profil’ are part of the profiling apparatus and
d764 1
a764 1
much time each sample counted as.  This “sampling period” estimates the
d768 2
a769 2
program’s total execution time was 0.06 seconds, as indicated by the
‘cumulative seconds’ field.  Since each sample counted for 0.01 seconds,
d771 3
a773 3
samples occurred while the program was in the ‘open’ function, as
indicated by the ‘self seconds’ field.  Each of the other four samples
occurred one each in ‘offtime’, ‘memccpy’, ‘write’, and ‘mcount’.  Since
d775 2
a776 2
particularly reliable.  In another run, the ‘self seconds’ field for
‘mcount’ might well be ‘0.00’ or ‘0.02’.  *Note Statistical Sampling
d779 2
a780 2
   The remaining functions in the listing (those whose ‘self seconds’
field is ‘0.00’) didn’t appear in the histogram samples at all.
d782 1
a782 1
they are listed, sorted in decreasing order by the ‘calls’ field.
d789 1
a789 1
‘% time’
d793 1
a793 1
‘cumulative seconds’
d798 1
a798 1
‘self seconds’
d802 1
a802 1
‘calls’
d806 1
a806 1
     compiled with profiling enabled), the “calls” field is blank.
d808 1
a808 1
‘self ms/call’
d813 1
a813 1
‘total ms/call’
d820 1
a820 1
‘name’
d822 1
a822 1
     this field alphabetically after the “self seconds” and “calls”
d831 1
a831 1
The “call graph” shows how much time was spent in each function and its
d837 1
a837 1
same ‘gprof’ run as the flat profile example in the previous section.
d868 1
a868 1
   The lines full of dashes divide this table into “entries”, one for
d875 1
a875 1
called “children” when we speak of the call graph).
d880 1
a880 1
   The internal profiling function ‘mcount’ (*note The Flat Profile:
d885 3
a887 3
* Primary::       Details of the primary line’s contents.
* Callers::       Details of caller-lines’ contents.
* Subroutines::   Details of subroutine-lines’ contents.
d889 1
a889 1
                   such as ‘a’ calls ‘b’ calls ‘a’...
d897 1
a897 1
The “primary line” in a call graph entry is the line that describes the
d902 1
a902 1
‘report’ in our main example, together with the heading line that shows
d911 1
a911 1
‘index’
d921 1
a921 1
‘% time’
d930 1
a930 1
‘self’
d932 1
a932 1
     should be identical to the number printed in the ‘seconds’ field
d935 1
a935 1
‘children’
d938 1
a938 1
     ‘self’ and ‘children’ entries of the children listed directly below
d941 1
a941 1
‘called’
d945 1
a945 1
     separated by a ‘+’.  The first number counts non-recursive calls,
d948 2
a949 2
     In the example above, the function ‘report’ was called once from
     ‘main’.
d951 1
a951 1
‘name’
d956 1
a956 1
     is printed between the function’s name and the index number (*note
d958 1
a958 1
     example, if function ‘gnurr’ is part of cycle number one, and has
d966 1
a966 1
5.2.2 Lines for a Function’s Callers
d969 2
a970 2
A function’s entry has a line for each function it was called by.  These
lines’ fields correspond to the fields of the primary line, but their
d974 1
a974 1
‘report’, the primary line and one caller-line preceding it, together
d982 2
a983 2
   Here are the meanings of the fields in the caller-line for ‘report’
called from ‘main’:
d985 14
a998 14
‘self’
     An estimate of the amount of time spent in ‘report’ itself when it
     was called from ‘main’.

‘children’
     An estimate of the amount of time spent in subroutines of ‘report’
     when ‘report’ was called from ‘main’.

     The sum of the ‘self’ and ‘children’ fields is an estimate of the
     amount of time spent within calls to ‘report’ from ‘main’.

‘called’
     Two numbers: the number of times ‘report’ was called from ‘main’,
     followed by the total number of non-recursive calls to ‘report’
d1001 3
a1003 3
‘name and index number’
     The name of the caller of ‘report’ to which this line applies,
     followed by the caller’s index number.
d1006 1
a1006 1
     ‘gprof’ request the omission of certain functions.  When a caller
d1014 2
a1015 2
dummy caller-line is printed which has ‘<spontaneous>’ as the “caller’s
name” and all other fields blank.  This can happen for signal handlers.
d1020 1
a1020 1
5.2.3 Lines for a Function’s Subroutines
d1023 2
a1024 2
A function’s entry has a line for each of its subroutines—in other
words, a line for each other function that it called.  These lines’
d1029 1
a1029 1
‘main’, the primary line and a line for a subroutine, together with the
d1037 2
a1038 2
   Here are the meanings of the fields in the subroutine-line for ‘main’
calling ‘report’:
d1040 16
a1055 16
‘self’
     An estimate of the amount of time spent directly within ‘report’
     when ‘report’ was called from ‘main’.

‘children’
     An estimate of the amount of time spent in subroutines of ‘report’
     when ‘report’ was called from ‘main’.

     The sum of the ‘self’ and ‘children’ fields is an estimate of the
     total time spent in calls to ‘report’ from ‘main’.

‘called’
     Two numbers, the number of calls to ‘report’ from ‘main’ followed
     by the total number of non-recursive calls to ‘report’.  This ratio
     is used to determine how much of ‘report’’s ‘self’ and ‘children’
     time gets credited to ‘main’.  *Note Estimating ‘children’ Times:
d1058 3
a1060 3
‘name’
     The name of the subroutine of ‘main’ to which this line applies,
     followed by the subroutine’s index number.
d1071 1
a1071 1
The graph may be complicated by the presence of “cycles of recursion” in
d1074 2
a1075 2
function.  For example: if ‘a’ calls ‘b’, and ‘b’ calls ‘a’, then ‘a’
and ‘b’ form a cycle.
d1078 4
a1081 4
they belong to the same cycle.  If ‘a’ and ‘b’ call each other and ‘b’
and ‘c’ call each other, all three make one cycle.  Note that even if
‘b’ only calls ‘a’ if it was not called from ‘a’, ‘gprof’ cannot
determine this, so ‘a’ and ‘b’ are still considered a cycle.
d1085 1
a1085 1
graph it is followed by ‘<cycle NUMBER>’.
d1088 4
a1091 4
call graph paradoxical.  The “time spent in children” of ‘a’ should
include the time spent in its subroutine ‘b’ and in ‘b’’s
subroutines—but one of ‘b’’s subroutines is ‘a’!  How much of ‘a’’s time
should be included in the children of ‘a’, when ‘a’ is indirectly
d1094 1
a1094 1
   The way ‘gprof’ resolves this paradox is by creating a single entry
d1097 1
a1097 1
“subroutines” of the cycle are the individual functions of the cycle,
d1099 1
a1099 1
“callers” of the cycle are the functions, outside the cycle, that called
d1103 2
a1104 2
containing functions ‘a’ and ‘b’.  The cycle was entered by a call to
‘a’ from ‘main’; both ‘a’ and ‘b’ called ‘c’.
d1126 2
a1127 2
for ‘main’, which calls ‘a’, and an entry for ‘c’, with callers ‘a’ and
‘b’.)
d1160 2
a1161 2
   The ‘self’ field of the cycle’s primary line is the total time spent
in all the functions of the cycle.  It equals the sum of the ‘self’
d1165 6
a1170 6
   The ‘children’ fields of the cycle’s primary line and subroutine
lines count only subroutines outside the cycle.  Even though ‘a’ calls
‘b’, the time spent in those calls to ‘b’ is not counted in ‘a’’s
‘children’ time.  Thus, we do not encounter the problem of what to do
when the time in those calls to ‘b’ includes indirect recursive calls
back to ‘a’.
d1172 1
a1172 1
   The ‘children’ field of a caller-line in the cycle’s entry estimates
d1177 1
a1177 1
   The ‘called’ field in the primary line for the cycle has two numbers:
d1184 2
a1185 2
   The ‘called’ field of a subroutine-line for a cycle member in the
cycle’s entry says how many time that function was called from functions
d1187 1
a1187 1
primary line’s ‘called’ field.
d1192 1
a1192 1
called from each other function in the cycle.  The ‘self’ and ‘children’
d1202 1
a1202 1
‘gprof’’s ‘-l’ option causes the program to perform “line-by-line”
d1205 2
a1206 2
programs compiled with older versions of the ‘gcc’ compiler.  Newer
versions of ‘gcc’ use a different program - ‘gcov’ - to display
d1209 2
a1210 2
   With the older versions of ‘gcc’ the program usually has to be
compiled with a ‘-g’ option, in addition to ‘-pg’, in order to generate
d1212 1
a1212 1
versions of ‘gcc’ the program had to be compiled with the ‘-a’
d1216 2
a1217 2
mode.  The call graph isn’t as useful as normal, since the current
version of ‘gprof’ does not propagate call graph arcs from source code
d1221 3
a1223 3
   Here is a section of ‘gprof’’s output, without line-by-line
profiling.  Note that ‘ct_init’ accounted for four histogram hits, and
13327 calls to ‘init_block’.
d1247 3
a1249 3
   Now let’s look at some of ‘gprof’’s output from the same program run,
this time with line-by-line profiling enabled.  Note that ‘ct_init’’s
four histogram hits are broken down into four lines of source code—one
d1251 1
a1251 1
note how ‘ct_init’’s 13327 calls to ‘init_block’ are broken down into
d1294 4
a1297 4
‘gprof’’s ‘-A’ option triggers an annotated source listing, which lists
the program’s source code, each function labeled with the number of
times it was called.  You may also need to specify the ‘-I’ option, if
‘gprof’ can’t find the source code files.
d1299 1
a1299 1
   With older versions of ‘gcc’ compiling with ‘gcc ... -g -pg -a’
d1301 3
a1303 3
function counting code.  This enables ‘gprof’ to determine how many
times each line of code was executed.  With newer versions of ‘gcc’
support for displaying basic-block counts is provided by the ‘gcov’
d1330 4
a1333 4
   ‘updcrc’ has at least five basic-blocks.  One is the function itself.
The ‘if’ statement on line 9 generates two more basic-blocks, one for
each branch of the ‘if’.  A fourth basic-block results from the ‘if’ on
line 13, and the contents of the ‘do’ loop form the fifth basic-block.
d1338 3
a1340 3
‘gprof -l -A’.  The ‘-x’ option is also helpful, to ensure that each
line of code is labeled at least once.  Here is ‘updcrc’’s annotated
source listing for a sample ‘gzip’ run:
d1363 2
a1364 2
each branch of the ‘if’ statement.  The body of the ‘do’ loop was
executed a total of 26312 times.  Note how the ‘while’ statement is
d1372 1
a1372 1
6 Inaccuracy of ‘gprof’ Output
d1386 1
a1386 1
The run-time figures that ‘gprof’ gives you are based on a sampling
d1402 1
a1402 1
   The “sampling period” that is printed at the beginning of the flat
d1409 1
a1409 1
period is 0.01 seconds and ‘foo’’s run-time is 1 second, N is 100
d1411 1
a1411 1
error in ‘foo’’s run-time is 0.1 seconds (10*0.01 seconds), or ten
d1413 2
a1414 2
seconds and ‘bar’’s run-time is 100 seconds, N is 10000 samples, sqrt(N)
is 100 samples, so the expected error in ‘bar’’s run-time is 1 second,
d1420 1
a1420 1
information.  If the program’s _total_ run-time is large, a small
d1422 1
a1422 1
insignificant fraction of the whole program’s time.  Usually this means
d1427 1
a1427 1
the data from several runs, using the ‘-s’ option of ‘gprof’.  Here is
d1432 1
a1432 1
  2. Issue the command ‘mv gmon.out gmon.sum’.
d1436 1
a1436 1
  4. Merge the new data in ‘gmon.out’ into ‘gmon.sum’ with this command:
d1449 1
a1449 1
6.2 Estimating ‘children’ Times
d1452 2
a1453 2
Some of the figures in the call graph are estimates—for example, the
‘children’ time values and all the time figures in caller and subroutine
d1457 1
a1457 1
profile data itself.  Instead, ‘gprof’ estimates them by making an
d1461 3
a1463 3
any function ‘foo’ is not correlated with who called ‘foo’.  If ‘foo’
used 5 seconds in all, and 2/5 of the calls to ‘foo’ came from ‘a’, then
‘foo’ contributes 2 seconds to ‘a’’s ‘children’ time, by assumption.
d1466 6
a1471 6
far from true.  Suppose that ‘foo’ returns very quickly when its
argument is zero; suppose that ‘a’ always passes zero as an argument,
while other callers of ‘foo’ pass other arguments.  In this program, all
the time spent in ‘foo’ is in the calls from callers other than ‘a’.
But ‘gprof’ has no way of knowing this; it will blindly and incorrectly
charge 2 seconds of time in ‘foo’ to the children of ‘a’.
d1473 1
a1473 1
   We hope some day to put more complete data into ‘gmon.out’, so that
d1486 1
a1486 1
     Because ‘gprof’ can only report call times and counts by function,
d1490 1
a1490 1
     artificial hot spots since compiling with ‘-pg’ adds a significant
d1496 1
a1496 1
     Use the ‘gcov’ program.
d1500 1
a1500 1
     Use ‘gprof -l’ and lookup the function in the call graph.  The
d1523 1
a1523 1
8 Incompatibilities with Unix ‘gprof’
d1526 1
a1526 1
GNU ‘gprof’ and Berkeley Unix ‘gprof’ use the same data file ‘gmon.out’,
d1530 1
a1530 1
   • GNU ‘gprof’ uses a new, generalized file format with support for
d1532 1
a1532 1
     cookie and version number allows ‘gprof’ to easily identify new
d1536 3
a1538 3
   • For a recursive function, Unix ‘gprof’ lists the function as a
     parent and as a child, with a ‘calls’ field that lists the number
     of recursive calls.  GNU ‘gprof’ omits these lines and puts the
d1541 2
a1542 2
   • When a function is suppressed from the call graph with ‘-e’, GNU
     ‘gprof’ still lists it as a subroutine of functions that call it.
d1544 2
a1545 2
   • GNU ‘gprof’ accepts the ‘-k’ with its argument in the form
     ‘from/to’, instead of ‘from to’.
d1547 2
a1548 2
   • In the annotated source listing, if there are multiple basic blocks
     on the same line, GNU ‘gprof’ prints all of their counts, separated
d1551 2
a1552 2
   • The blurbs, field widths, and output formats are different.  GNU
     ‘gprof’ prints blurbs after the tables, so that you can see the
d1564 3
a1566 3
* File Format::         Format of ‘gmon.out’ files
* Internals::           ‘gprof’’s internal operation
* Debugging::           Using ‘gprof’’s ‘-d’ option
d1579 2
a1580 2
the ‘-pg’ option, which causes every function to call ‘mcount’ (or
‘_mcount’, or ‘__mcount’, depending on the OS and compiler) as one of
d1583 1
a1583 1
   The ‘mcount’ routine, included in the profiling library, is
d1585 1
a1585 1
parent routine (the child) and its parent’s parent.  This is typically
d1588 1
a1588 1
machine-dependent operation, ‘mcount’ itself is typically a short
d1590 4
a1593 4
and then calls ‘__mcount_internal’ (a normal C function) with two
arguments—‘frompc’ and ‘selfpc’.  ‘__mcount_internal’ is responsible for
maintaining the in-memory call graph, which records ‘frompc’, ‘selfpc’,
and the number of times each of these call arcs was traversed.
d1596 1
a1596 1
(‘__builtin_return_address’), which allows a generic ‘mcount’ function
d1600 1
a1600 1
‘mcount’ is used for performance reasons.
d1604 2
a1605 2
same as in the usual C library, but they were compiled with ‘-pg’.  If
you link your program with ‘gcc ... -pg’, it automatically uses the
d1615 2
a1616 2
provide a ‘profil()’ system call, which registers a memory array with
the kernel, along with a scale factor that determines how the program’s
d1626 1
a1626 1
earlier), do not provide a ‘profil()’ system call.  On such a system,
d1628 1
a1628 1
the process (typically via ‘setitimer()’), which then performs the same
d1636 5
a1640 5
either calls ‘profil()’ or sets up a clock signal handler.  This routine
(‘monstartup’) can be invoked in several ways.  On Linux systems, a
special profiling startup file ‘gcrt0.o’, which invokes ‘monstartup’
before ‘main’, is used instead of the default ‘crt0.o’.  Use of this
special startup file is one of the effects of using ‘gcc ... -pg’ to
d1642 2
a1643 2
‘mcount’ routine, when it is invoked for the first time (typically when
‘main’ is called), calls ‘monstartup’.
d1645 1
a1645 1
   If the compiler’s ‘-a’ option was used, basic-block counting is also
d1648 1
a1648 1
basic-block begins (i.e., when an ‘if’ statement appears), an extra
d1655 3
a1657 3
   The profiling library also includes a function (‘mcleanup’) which is
typically registered using ‘atexit()’ to be called as the program exits,
and is responsible for writing the file ‘gmon.out’.  Profiling is turned
d1661 1
a1661 1
   The output from ‘gprof’ gives no indication of parts of your program
d1663 2
a1664 2
of the program counter are taken at fixed intervals of the program’s run
time.  Therefore, the time measurements in ‘gprof’ output say nothing
d1667 1
a1667 1
memory at once may run very slowly due to thrashing, but ‘gprof’ will
d1669 1
a1669 1
the advantage that the amount of load due to other users won’t directly
d1680 2
a1681 2
‘gprof’ file.  Furthermore, it does not provide a version number, thus
rendering changes to the file format almost impossible.  GNU ‘gprof’
d1683 1
a1683 1
compatibility, GNU ‘gprof’ continues to support the old BSD-derived
d1688 1
a1688 1
   The new file format is defined in header file ‘gmon_out.h’.  It
d1692 1
a1692 1
the profile was collected.  GNU ‘gprof’ adapts automatically to the
d1699 1
a1699 1
reading a file, GNU ‘gprof’ will ensure records of the same type are
d1715 1
a1715 1
would specify the long name as “seconds” and the abbreviation as “s”.
d1718 1
a1718 1
For example, under DEC OSF/1, the “uprofile” command can be used to
d1720 2
a1721 2
the dimension in the histogram header could be set to “i-cache misses”
and the abbreviation could be set to “1” (because it is simply a count,
d1737 2
a1738 2
must be within caller’s function and the second must be within the
callee’s function.  When performing profiling at the function level,
d1757 1
a1757 1
9.3 ‘gprof’’s Internal Operation
d1760 3
a1762 3
Like most programs, ‘gprof’ begins by processing its options.  During
this stage, it may building its symspec list (‘sym_ids.c:sym_id_add’),
if options are specified which use symspecs.  ‘gprof’ maintains a single
d1764 1
a1764 1
tables, organized into six include/exclude pairs—one pair each for the
d1772 2
a1773 2
   After option processing, ‘gprof’ finishes building the symspec list
by adding all the symspecs in ‘default_excluded_list’ to the exclude
d1779 2
a1780 2
it is an object file, and read its symbol table (‘core.c:core_init’),
using ‘bfd_canonicalize_symtab’ after mallocing an appropriately sized
d1782 2
a1783 2
‘--file-ordering’ option has been specified), and the core text space is
read into memory (if the ‘-c’ option was given).
d1785 1
a1785 1
   ‘gprof’’s own symbol table, an array of Sym structures, is now built.
d1787 1
a1787 1
whether line-by-line profiling (‘-l’ option) has been enabled.  For
d1791 1
a1791 1
either case, two passes are made through the symbol table—one to count
d1793 2
a1794 2
the symbols.  In between the two passes, a single array of type ‘Sym’ is
created of the appropriate length.  Finally, ‘symtab.c:symtab_finalize’
d1799 1
a1799 1
the ‘qsort’ library function (which sorts an array) will be used to sort
d1801 1
a1801 1
(‘symtab.c:sym_lookup’), which finds symbols based on memory address,
d1803 1
a1803 1
sorted array.  Function symbols are indicated with an ‘is_func’ flag.
d1805 1
a1805 1
can have an ‘is_static’ flag to indicate that it is a local symbol.
d1808 2
a1809 2
Syms (‘sym_ids.c:sym_id_parse’).  Remember that a single symspec can
match multiple symbols.  An array of symbol tables (‘syms’) is created,
d1817 2
a1818 2
‘gprof’ simply uses its standard symbol lookup routine on the
appropriate table in the ‘syms’ array.
d1821 2
a1822 2
(‘gmon_io.c:gmon_out_read’), first by checking for a new-style
‘gmon.out’ header, then assuming this is an old-style BSD ‘gmon.out’ if
d1825 1
a1825 1
   New-style histogram records are read by ‘hist.c:hist_read_rec’.  For
d1835 1
a1835 1
   As each call graph record is read (‘call_graph.c:cg_read_rec’), the
d1837 1
a1837 1
call graph arc is created by ‘cg_arcs.c:arc_add’, unless the arc fails a
d1839 3
a1841 3
linked list is maintained of the parent’s child arcs, and of the child’s
parent arcs.  Both the child’s call count and the arc’s call count are
incremented by the record’s call count.
d1843 1
a1843 1
   Basic-block records are read (‘basic_blocks.c:bb_read_rec’), but only
d1846 1
a1846 1
entry made in the symbol’s bb_addr and bb_calls arrays.  Again, if
d1850 1
a1850 1
   A gmon.sum file is dumped, if requested (‘gmon_io.c:gmon_out_write’).
d1853 1
a1853 1
(‘hist.c:hist_assign_samples’) by iterating over all the sample bins and
d1864 3
a1866 3
   If call graph data is present, ‘cg_arcs.c:cg_assemble’ is called.
First, if ‘-c’ was specified, a machine-dependent routine (‘find_call’)
scans through each symbol’s machine code, looking for subroutine call
d1869 1
a1869 1
(‘cg_dfn.c:cg_dfn’), so that children are always numbered less than
d1878 1
a1878 1
a parent’s include or exclude (print or no print) property being
d1888 2
a1889 2
fairly straightforward.  The call graph (‘cg_print.c:cg_print’) and flat
profile (‘hist.c:hist_print’) are regurgitations of values already
d1891 1
a1891 1
(‘basic_blocks.c:print_annotated_source’) uses basic-block information,
d1896 1
a1896 1
source code itself (‘cg_print.c’).  Basically, the functions with the
d1904 1
a1904 1
9.4 Debugging ‘gprof’
d1907 1
a1907 1
If ‘gprof’ was compiled with debugging enabled, the ‘-d’ option triggers
d1927 1
a1927 1
     file.  For line-by-line profiling (‘-l’ option), also shows line
d1930 1
a1930 1
     Trace operation of ‘-c’ option
d1937 1
a1937 1
     meaningful with ‘-l’ option)
d1941 1
a1941 1
     Tracks operation of ‘-A’ option
d1951 1
a1951 1
     Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
d1960 1
a1960 1
     functional and useful document “free” in the sense of freedom: to
d1967 1
a1967 1
     This License is a kind of “copyleft”, which means that derivative
d1988 2
a1989 2
     “Document”, below, refers to any such manual or work.  Any member
     of the public is a licensee, and is addressed as “you”.  You accept
d1993 1
a1993 1
     A “Modified Version” of the Document means any work containing the
d1997 1
a1997 1
     A “Secondary Section” is a named appendix or a front-matter section
d1999 1
a1999 1
     publishers or authors of the Document to the Document’s overall
d2008 1
a2008 1
     The “Invariant Sections” are certain Secondary Sections whose
d2016 1
a2016 1
     The “Cover Texts” are certain short passages of text that are
d2022 1
a2022 1
     A “Transparent” copy of the Document means a machine-readable copy,
d2034 1
a2034 1
     “Transparent” is called “Opaque”.
d2047 1
a2047 1
     The “Title Page” means, for a printed book, the title page itself,
d2050 3
a2052 3
     works in formats which do not have any title page as such, “Title
     Page” means the text near the most prominent appearance of the
     work’s title, preceding the beginning of the body of the text.
d2054 1
a2054 1
     The “publisher” means any person or entity that distributes copies
d2057 1
a2057 1
     A section “Entitled XYZ” means a named subunit of the Document
d2061 3
a2063 3
     “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.)
     To “Preserve the Title” of such a section when you modify the
     Document means that it remains a section “Entitled XYZ” according
d2093 1
a2093 1
     the Document’s license notice requires Cover Texts, you must
d2165 1
a2165 1
          Sections and required Cover Texts given in the Document’s
d2170 1
a2170 1
       I. Preserve the section Entitled “History”, Preserve its Title,
d2173 1
a2173 1
          Title Page.  If there is no section Entitled “History” in the
d2183 1
a2183 1
          “History” section.  You may omit a network location for a work
d2188 1
a2188 1
       K. For any section Entitled “Acknowledgements” or “Dedications”,
d2197 1
a2197 1
       M. Delete any section Entitled “Endorsements”.  Such a section
d2201 1
a2201 1
          “Endorsements” or to conflict in title with any Invariant
d2210 1
a2210 1
     titles to the list of Invariant Sections in the Modified Version’s
d2214 1
a2214 1
     You may add a section Entitled “Endorsements”, provided it contains
d2216 3
a2218 3
     parties—for example, statements of peer review or that the text has
     been approved by an organization as the authoritative definition of
     a standard.
d2256 4
a2259 4
     “History” in the various original documents, forming one section
     Entitled “History”; likewise combine any sections Entitled
     “Acknowledgements”, and any sections Entitled “Dedications”.  You
     must delete all sections Entitled “Endorsements.”
d2280 1
a2280 1
     storage or distribution medium, is called an “aggregate” if the
d2282 1
a2282 1
     legal rights of the compilation’s users beyond what the individual
d2289 1
a2289 1
     of the entire aggregate, the Document’s Cover Texts may be placed
d2311 2
a2312 2
     If a section in the Document is Entitled “Acknowledgements”,
     “Dedications”, or “History”, the requirement (section 4) to
d2353 1
a2353 1
     version of this License “or any later version” applies to it, you
d2361 1
a2361 1
     proxy’s public statement of acceptance of a version permanently
d2366 1
a2366 1
     “Massive Multiauthor Collaboration Site” (or “MMC Site”) means any
d2370 1
a2370 1
     A “Massive Multiauthor Collaboration” (or “MMC”) contained in the
d2374 1
a2374 1
     “CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0
d2380 1
a2380 1
     “Incorporate” means to publish or republish a Document, in whole or
d2383 1
a2383 1
     An MMC is “eligible for relicensing” if it is licensed under this
d2410 1
a2410 1
Texts, replace the “with...Texts.” line with this:
d2428 30
a2457 30
Node: Top726
Node: Introduction2083
Node: Compiling4604
Node: Executing8788
Node: Invoking11783
Node: Output Options13244
Node: Analysis Options20804
Node: Miscellaneous Options24904
Node: Deprecated Options26274
Node: Symspecs28457
Node: Output30372
Node: Flat Profile31426
Node: Call Graph36501
Node: Primary39771
Node: Callers42421
Node: Subroutines44641
Node: Cycles46597
Node: Line-by-line53625
Node: Annotated Source57792
Node: Inaccuracy60882
Node: Sampling Error61144
Node: Assumptions64104
Node: How do I?65657
Node: Incompatibilities67230
Node: Details68804
Node: Implementation69217
Node: File Format75279
Node: Internals79619
Node: Debugging88287
Node: GNU Free Documentation License89905
@


1.8
log
@Merge conflicts
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 6.5 from gprof.texi.
d5 1
a5 1
   Copyright (C) 1988-2020 Free Software Foundation, Inc.
d30 1
a30 1
   This manual is for 'gprof' (GNU Binutils) version 2.34.
d220 5
a224 4
'gmon.out', its contents are overwritten.  There is currently no way to
tell the program to write the profile data under a different name, but
you can rename the file afterwards if you are concerned that it may be
overwritten.
d1679 1
a1679 1
magic cookie that allows to check whether a data file really is a
d2432 26
a2457 26
Node: Invoking11377
Node: Output Options12792
Node: Analysis Options19884
Node: Miscellaneous Options23804
Node: Deprecated Options25058
Node: Symspecs27121
Node: Output28947
Node: Flat Profile29987
Node: Call Graph34940
Node: Primary38172
Node: Callers40760
Node: Subroutines42878
Node: Cycles44719
Node: Line-by-line51496
Node: Annotated Source55572
Node: Inaccuracy58570
Node: Sampling Error58828
Node: Assumptions61732
Node: How do I?63202
Node: Incompatibilities64759
Node: Details66253
Node: Implementation66646
Node: File Format72545
Node: Internals76833
Node: Debugging85323
Node: GNU Free Documentation License86913
d2460 5
@


1.7
log
@merge conflicts
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 6.4 from gprof.texi.
d5 1
a5 1
   Copyright (C) 1988-2018 Free Software Foundation, Inc.
d30 1
a30 1
   This manual is for 'gprof' (GNU Binutils) version 2.30.90.
d170 1
a170 1
'-static-libgcc' command line option.  For example:
d193 1
a193 1
command line option which will insert calls to special user supplied
d1211 2
a1212 2
versions of 'gcc' the program had to be compiled with the '-a' command
line option as well.
d2428 29
a2456 29
Node: Introduction2045
Node: Compiling4536
Node: Executing8592
Node: Invoking11380
Node: Output Options12795
Node: Analysis Options19887
Node: Miscellaneous Options23807
Node: Deprecated Options25061
Node: Symspecs27124
Node: Output28950
Node: Flat Profile29990
Node: Call Graph34943
Node: Primary38175
Node: Callers40763
Node: Subroutines42881
Node: Cycles44722
Node: Line-by-line51499
Node: Annotated Source55575
Node: Inaccuracy58573
Node: Sampling Error58831
Node: Assumptions61735
Node: How do I?63205
Node: Incompatibilities64762
Node: Details66256
Node: Implementation66649
Node: File Format72548
Node: Internals76836
Node: Debugging85326
Node: GNU Free Documentation License86916
@


1.6
log
@- merge conflicts for 2.30
- bump libraries
- regen for x86
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 6.3 from gprof.texi.
d30 1
a30 1
   This manual is for 'gprof' (GNU Binutils) version 2.30.0.
d2428 29
a2456 29
Node: Introduction2044
Node: Compiling4535
Node: Executing8591
Node: Invoking11379
Node: Output Options12794
Node: Analysis Options19886
Node: Miscellaneous Options23806
Node: Deprecated Options25060
Node: Symspecs27123
Node: Output28949
Node: Flat Profile29989
Node: Call Graph34942
Node: Primary38174
Node: Callers40762
Node: Subroutines42880
Node: Cycles44721
Node: Line-by-line51498
Node: Annotated Source55574
Node: Inaccuracy58572
Node: Sampling Error58830
Node: Assumptions61734
Node: How do I?63204
Node: Incompatibilities64761
Node: Details66255
Node: Implementation66648
Node: File Format72547
Node: Internals76835
Node: Debugging85325
Node: GNU Free Documentation License86915
@


1.6.2.1
log
@Sync with HEAD
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 6.4 from gprof.texi.
d30 1
a30 1
   This manual is for 'gprof' (GNU Binutils) version 2.30.90.
d2428 29
a2456 29
Node: Introduction2045
Node: Compiling4536
Node: Executing8592
Node: Invoking11380
Node: Output Options12795
Node: Analysis Options19887
Node: Miscellaneous Options23807
Node: Deprecated Options25061
Node: Symspecs27124
Node: Output28950
Node: Flat Profile29990
Node: Call Graph34943
Node: Primary38175
Node: Callers40763
Node: Subroutines42881
Node: Cycles44722
Node: Line-by-line51499
Node: Annotated Source55575
Node: Inaccuracy58573
Node: Sampling Error58831
Node: Assumptions61735
Node: How do I?63205
Node: Incompatibilities64762
Node: Details66256
Node: Implementation66649
Node: File Format72548
Node: Internals76836
Node: Debugging85326
Node: GNU Free Documentation License86916
@


1.6.2.2
log
@Merge changes from current as of 20200406
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 6.5 from gprof.texi.
d5 1
a5 1
   Copyright (C) 1988-2020 Free Software Foundation, Inc.
d30 1
a30 1
   This manual is for 'gprof' (GNU Binutils) version 2.34.
d170 1
a170 1
'-static-libgcc' command-line option.  For example:
d193 1
a193 1
command-line option which will insert calls to special user supplied
d1211 2
a1212 2
versions of 'gcc' the program had to be compiled with the '-a'
command-line option as well.
d2428 29
a2456 29
Node: Introduction2042
Node: Compiling4533
Node: Executing8589
Node: Invoking11377
Node: Output Options12792
Node: Analysis Options19884
Node: Miscellaneous Options23804
Node: Deprecated Options25058
Node: Symspecs27121
Node: Output28947
Node: Flat Profile29987
Node: Call Graph34940
Node: Primary38172
Node: Callers40760
Node: Subroutines42878
Node: Cycles44719
Node: Line-by-line51496
Node: Annotated Source55572
Node: Inaccuracy58570
Node: Sampling Error58828
Node: Assumptions61732
Node: How do I?63202
Node: Incompatibilities64759
Node: Details66253
Node: Implementation66646
Node: File Format72545
Node: Internals76833
Node: Debugging85323
Node: GNU Free Documentation License86913
@


1.5
log
@merge conflicts, disable testsuite
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 4.8 from gprof.texi.
d3 1
a3 6
INFO-DIR-SECTION Software development
START-INFO-DIR-ENTRY
* gprof: (gprof).                Profiling your program's execution
END-INFO-DIR-ENTRY

   This file documents the gprof profiler of the GNU system.
d5 1
a5 1
   Copyright (C) 1988-2016 Free Software Foundation, Inc.
d14 5
d25 1
a25 1
This manual describes the GNU profiler, `gprof', and how you can use it
d28 1
a28 1
programs.  GNU `gprof' was written by Jay Fenlason.
d30 1
a30 1
   This manual is for `gprof' (GNU Binutils) version 2.27.
d33 2
a34 2
Documentation License version 1.3.  A copy of the license is included
in the section entitled "GNU Free Documentation License".
d42 1
a42 1
* Invoking::            How to run `gprof', and its options
d44 1
a44 1
* Output::              Interpreting `gprof''s output
d48 1
a48 1
* Incompatibilities::   (between GNU `gprof' and Unix `gprof'.)
d67 5
a71 6
execution of your program, it can be used on programs that are too
large or too complex to analyze by reading the source.  However, how
your program is run will affect the information that shows up in the
profile data.  If you don't use some feature of your program while it
is being profiled, no profile information will be generated for that
feature.
d81 1
a81 1
   * You must run `gprof' to analyze the profile data.  *Note `gprof'
d93 5
a97 6
   The "call graph" shows, for each function, which functions called
it, which other functions it called, and how many times.  There is also
an estimate of how much time was spent in the subroutines of each
function.  This can suggest places where you might try to eliminate
function calls that use a lot of time.  *Note The Call Graph: Call
Graph.
d116 1
a116 1
   To compile a source file for profiling, specify the `-pg' option when
d120 3
a122 3
   To link the program for profiling, if you use a compiler such as `cc'
to do the linking, simply specify `-pg' in addition to your usual
options.  The same option, `-pg', alters either compilation or linking
d128 1
a128 1
   The `-pg' option also works with a command that both compiles and
d133 3
a135 3
   Note: The `-pg' option must be part of your compilation options as
well as your link options.  If it is not then no call-graph data will
be gathered and when you run `gprof' you will get an error message like
d140 2
a141 2
   If you add the `-Q' switch to suppress the printing of the call
graph data you will still be able to see the time samples:
d152 8
a159 8
   If you run the linker `ld' directly instead of through a compiler
such as `cc', you may have to specify a profiling startup file
`gcrt0.o' as the first input file instead of the usual startup file
`crt0.o'.  In addition, you would probably want to specify the
profiling C library, `libc_p.a', by writing `-lc_p' instead of the
usual `-lc'.  This is not absolutely necessary, but doing this gives
you number-of-calls information for standard library functions such as
`read' and `open'.  For example:
d164 2
a165 2
libraries you may run into problems with the profiling support code in
a shared library being called before that library has been fully
d168 3
a170 3
against a static version of the library containing the profiling
support code, which for `gcc' users can be done via the `-static' or
`-static-libgcc' command line option.  For example:
d174 1
a174 1
   If you compile only some of the modules of the program with `-pg',
d176 6
a181 6
information about the modules that were compiled without `-pg'.  The
only information you get for the functions in those modules is the
total time spent in them; there is no record of how many times they
were called, or from where.  This will not affect the flat profile
(except that the `calls' field for the functions will be blank), but
will greatly reduce the usefulness of the call graph.
d184 1
a184 1
`gcov' tool instead of `gprof'.  See that tool's manual or info pages
d187 3
a189 3
   Note, older versions of `gcc' produce line-by-line profiling
information that works with `gprof' rather than `gcov' so there is
still support for displaying this kind of information in `gprof'. *Note
d192 5
a196 5
   It also worth noting that `gcc' implements a
`-finstrument-functions' command line option which will insert calls to
special user supplied instrumentation routines at the entry and exit of
every function in their program.  This can be used to implement an
alternative profiling scheme.
d205 1
a205 1
generate the information that `gprof' needs.  Simply run the program as
d219 2
a220 2
`gmon.out' just before exiting.  If there is already a file called
`gmon.out', its contents are overwritten.  There is currently no way to
d225 3
a227 3
   In order to write the `gmon.out' file properly, your program must
exit normally: by returning from `main' or by calling `exit'.  Calling
the low-level function `_exit' does not write the profile data, and
d230 1
a230 1
   The `gmon.out' file is written in the program's _current working
d232 2
a233 2
`chdir', the `gmon.out' file will be left in the last directory your
program `chdir''d to.  If you don't have permission to write in this
d237 1
a237 1
called `bb.out'.  This file, if present, contains an human-readable
d239 4
a242 4
appearance of a human-readable `bb.out' means the basic-block counts
didn't get written into `gmon.out'.  The Perl script `bbconv.pl',
included with the `gprof' source distribution, will convert a `bb.out'
file into a format readable by `gprof'.  Invoke it like this:
d246 2
a247 2
   This translates the information in `bb.out' into a form that `gprof'
can understand.  But you still need to tell `gprof' about the existence
d249 1
a249 1
`gprof' command line, _along with `gmon.out'_, like this:
d256 1
a256 1
4 `gprof' Command Summary
d259 2
a260 2
After you have a profile data file `gmon.out', you can run `gprof' to
interpret the information in it.  The `gprof' program prints a flat
d262 1
a262 1
redirect the output of `gprof' into a file with `>'.
d264 1
a264 1
   You run `gprof' like this:
d270 4
a273 5
   If you omit the executable file name, the file `a.out' is used.  If
you give no profile data file name, the file `gmon.out' is used.  If
any file is not in the proper format, or if the profile data file does
not appear to belong to the executable file, an error message is
printed.
d283 2
a284 2
* Output Options::      Controlling `gprof''s output style
* Analysis Options::    Controlling how `gprof' analyzes its data
d296 1
a296 1
These options specify which of several output formats `gprof' should
d299 4
a302 4
   Many of these options take an optional "symspec" to specify
functions to be included or excluded.  These options can be specified
multiple times, with different symspecs, to include or exclude sets of
symbols.  *Note Symspecs: Symspecs.
d304 1
a304 1
   Specifying any of these options overrides the default (`-p -q'),
d307 3
a309 3
`-A[SYMSPEC]'
`--annotated-source[=SYMSPEC]'
     The `-A' option causes `gprof' to print annotated source code.  If
d313 3
a315 3
`-b'
`--brief'
     If the `-b' option is given, `gprof' doesn't print the verbose
d320 3
a322 3
`-C[SYMSPEC]'
`--exec-counts[=SYMSPEC]'
     The `-C' option causes `gprof' to print a tally of functions and
d327 1
a327 1
     specifying the `-l' option, along with `-C', will cause basic-block
d330 9
a338 9
`-i'
`--file-info'
     The `-i' option causes `gprof' to display summary information
     about the profile data file(s) and then exit.  The number of
     histogram, call graph, and basic-block count records is displayed.

`-I DIRS'
`--directory-path=DIRS'
     The `-I' option specifies a list of search directories in which to
d343 4
a346 4
`-J[SYMSPEC]'
`--no-annotated-source[=SYMSPEC]'
     The `-J' option causes `gprof' not to print annotated source code.
     If SYMSPEC is specified, `gprof' prints annotated source, but
d349 2
a350 2
`-L'
`--print-path'
d352 1
a352 1
     suppressed.  The `-L' option causes `gprof' to print the full
d357 10
a366 10
`-p[SYMSPEC]'
`--flat-profile[=SYMSPEC]'
     The `-p' option causes `gprof' to print a flat profile.  If
     SYMSPEC is specified, print flat profile only for matching symbols.
     *Note The Flat Profile: Flat Profile.

`-P[SYMSPEC]'
`--no-flat-profile[=SYMSPEC]'
     The `-P' option causes `gprof' to suppress printing a flat profile.
     If SYMSPEC is specified, `gprof' prints a flat profile, but
d369 3
a371 3
`-q[SYMSPEC]'
`--graph[=SYMSPEC]'
     The `-q' option causes `gprof' to print the call graph analysis.
d375 4
a378 4
`-Q[SYMSPEC]'
`--no-graph[=SYMSPEC]'
     The `-Q' option causes `gprof' to suppress printing the call graph.
     If SYMSPEC is specified, `gprof' prints a call graph, but excludes
d381 3
a383 3
`-t'
`--table-length=NUM'
     The `-t' option causes the NUM most active source lines in each
d387 2
a388 2
`-y'
`--separate-files'
d390 1
a390 1
     `gprof' prints annotated source files to standard-output.  If this
d392 9
a400 9
     `path/FILENAME' is generated in the file `FILENAME-ann'.  If the
     underlying file system would truncate `FILENAME-ann' so that it
     overwrites the original `FILENAME', `gprof' generates annotated
     source in the file `FILENAME.ann' instead (if the original file
     name has an extension, that extension is _replaced_ with `.ann').

`-Z[SYMSPEC]'
`--no-exec-counts[=SYMSPEC]'
     The `-Z' option causes `gprof' not to print a tally of functions
d404 3
a406 3
`-r'
`--function-ordering'
     The `--function-ordering' option causes `gprof' to print a
d416 7
a422 7
`-R MAP_FILE'
`--file-ordering MAP_FILE'
     The `--file-ordering' option causes `gprof' to print a suggested
     .o link line ordering for the program based on profiling data.
     This option suggests an ordering which may improve paging, tlb and
     cache behavior for the program on systems which do not support
     arbitrary ordering of functions in an executable.
d424 1
a424 1
     Use of the `-a' argument is highly recommended with this option.
d428 1
a428 1
     similar to the output of the program `nm'.
d439 2
a440 1
     To create a MAP_FILE with GNU `nm', type a command like `nm
d443 4
a446 4
`-T'
`--traditional'
     The `-T' option causes `gprof' to print its output in
     "traditional" BSD style.
d448 2
a449 2
`-w WIDTH'
`--width=WIDTH'
d453 7
a459 7
`-x'
`--all-lines'
     This option affects annotated source output only.  By default,
     only the lines at the beginning of a basic-block are annotated.
     If this option is specified, every line in a basic-block is
     annotated by repeating the annotation for the first line.  This
     behavior is similar to `tcov''s `-a'.
d461 2
a462 2
`--demangle[=STYLE]'
`--no-demangle'
d465 1
a465 1
     `--no-demangle' option may be used to turn off demangling.
d476 3
a478 3
`-a'
`--no-static'
     The `-a' option causes `gprof' to suppress the printing of
d484 2
a485 2
     the executable file.  This option affects both the flat profile
     and the call graph.
d487 3
a489 3
`-c'
`--static-call-graph'
     The `-c' option causes the call graph of the program to be
d494 12
a505 12
     have been called, but never were.  Calls to functions that were
     not compiled with profiling enabled are also identified, but only
     if symbol table entries are present for them.  Calls to dynamic
     library routines are typically _not_ found by this option.
     Parents or children identified via this heuristic are indicated in
     the call graph with call counts of `0'.

`-D'
`--ignore-non-functions'
     The `-D' option causes `gprof' to ignore symbols which are not
     known to be functions.  This option will give more accurate
     profile data on systems where it is supported (Solaris and HPUX for
d508 2
a509 2
`-k FROM/TO'
     The `-k' option allows you to delete from the call graph any arcs
d512 3
a514 3
`-l'
`--line'
     The `-l' option enables line-by-line profiling, which causes
d517 2
a518 2
     compiled by older versions of the `gcc' compiler.  Newer versions
     of `gcc' are designed to work with the `gcov' tool instead.
d520 5
a524 5
     If the program was compiled with basic-block counting enabled,
     this option will also identify how many times each line of code
     was executed.  While line-by-line profiling can help isolate where
     in a large function a program is spending its time, it also
     significantly increases the running time of `gprof', and magnifies
d528 4
a531 4
`--inline-file-names'
     This option causes `gprof' to print the source file after each
     symbol in both the flat profile and the call graph. The full path
     to the file is printed if used with the `-L' option.
d533 2
a534 2
`-m NUM'
`--min-count=NUM'
d538 3
a540 8
`-nSYMSPEC'
`--time=SYMSPEC'
     The `-n' option causes `gprof', in its call graph analysis, to
     only propagate times for symbols matching SYMSPEC.

`-NSYMSPEC'
`--no-time=SYMSPEC'
     The `-n' option causes `gprof', in its call graph analysis, not to
d543 15
a557 10
`-SFILENAME'
`--external-symbol-table=FILENAME'
     The `-S' option causes `gprof' to read an external symbol table
     file, such as `/proc/kallsyms', rather than read the symbol table
     from the given object file (the default is `a.out'). This is useful
     for profiling kernel modules.

`-z'
`--display-unused-functions'
     If you give the `-z' option, `gprof' will mention all functions in
d559 2
a560 3
     no time spent in them.  This is useful in conjunction with the
     `-c' option for discovering which routines were never called.

d568 4
a571 4
`-d[NUM]'
`--debug[=NUM]'
     The `-d NUM' option specifies debugging options.  If NUM is not
     specified, enable all debugging.  *Note Debugging `gprof':
d574 3
a576 3
`-h'
`--help'
     The `-h' option prints command line usage.
d578 2
a579 2
`-ONAME'
`--file-format=NAME'
d581 2
a582 2
     are `auto' (the default), `bsd', `4.4bsd', `magic', and `prof'
     (not yet supported).
d584 3
a586 3
`-s'
`--sum'
     The `-s' option causes `gprof' to summarize the information in the
d588 11
a598 11
     called `gmon.sum', which contains all the information from the
     profile data files that `gprof' read in.  The file `gmon.sum' may
     be one of the specified input files; the effect of this is to
     merge the data in the other input files into `gmon.sum'.

     Eventually you can run `gprof' again without `-s' to analyze the
     cumulative data in the file `gmon.sum'.

`-v'
`--version'
     The `-v' flag causes `gprof' to print the current version number,
a600 1

d609 2
a610 2
`-e FUNCTION_NAME'
     The `-e FUNCTION' option tells `gprof' to not print information
d613 10
a622 11
     functions that call it, but its index number will be shown as
     `[not printed]'.  More than one `-e' option may be given; only one
     FUNCTION_NAME may be indicated with each `-e' option.

`-E FUNCTION_NAME'
     The `-E FUNCTION' option works like the `-e' option, but time
     spent in the function (and children who were not called from
     anywhere else), will not be used to compute the
     percentages-of-time for the call graph.  More than one `-E' option
     may be given; only one FUNCTION_NAME may be indicated with each
     `-E' option.
d624 2
a625 2
`-f FUNCTION_NAME'
     The `-f FUNCTION' option causes `gprof' to limit the call graph to
d627 2
a628 10
     children...).  More than one `-f' option may be given; only one
     FUNCTION_NAME may be indicated with each `-f' option.

`-F FUNCTION_NAME'
     The `-F FUNCTION' option works like the `-f' option, but only time
     spent in the function and its children (and their children...)
     will be used to determine total-time and percentages-of-time for
     the call graph.  More than one `-F' option may be given; only one
     FUNCTION_NAME may be indicated with each `-F' option.  The `-F'
     option overrides the `-E' option.
d630 7
d638 2
a639 2
   Note that only one function can be specified with each `-e', `-E',
`-f' or `-F' option.  To specify more than one function, use multiple
d645 1
a645 1
`foo' or `bar' and were not reachable from `boring'.
d664 6
a669 6
`main.c'
     Selects everything in file `main.c'--the dot in the string tells
     `gprof' to interpret the string as a filename, rather than as a
     function name.  To select a file whose name does not contain a
     dot, a trailing colon should be specified.  For example, `odd:' is
     interpreted as the file named `odd'.
d671 2
a672 2
`main'
     Selects all functions named `main'.
d681 2
a682 2
     necessary to add a leading colon to the name.  For example,
     `:.mul' selects function `.mul'.
d685 2
a686 2
     `gprof' will normally not print these underscores.  When you name a
     symbol in a symspec, you should type it exactly as `gprof' prints
d688 2
a689 2
     `_main' from your `main' function, `gprof' still prints it as
     `main' in its output, so you should use `main' in symspecs.
d691 2
a692 2
`main.c:main'
     Selects function `main' in file `main.c'.
d694 2
a695 2
`main.c:134'
     Selects line 134 in file `main.c'.
d700 1
a700 1
5 Interpreting `gprof''s Output
d703 1
a703 1
`gprof' can produce several different output styles, the most important
d716 1
a716 1
* Line-by-line::        `gprof' can analyze individual source code lines
d727 1
a727 1
executing each function.  Unless the `-z' option is given, functions
d758 1
a758 1
functions `mcount' and `profil' are part of the profiling apparatus and
d768 8
a775 8
`cumulative seconds' field.  Since each sample counted for 0.01
seconds, this means only six samples were taken during the run.  Two of
the samples occurred while the program was in the `open' function, as
indicated by the `self seconds' field.  Each of the other four samples
occurred one each in `offtime', `memccpy', `write', and `mcount'.
Since only six samples were taken, none of these values can be regarded
as particularly reliable.  In another run, the `self seconds' field for
`mcount' might well be `0.00' or `0.02'.  *Note Statistical Sampling
d778 2
a779 2
   The remaining functions in the listing (those whose `self seconds'
field is `0.00') didn't appear in the histogram samples at all.
d781 1
a781 1
they are listed, sorted in decreasing order by the `calls' field.
d788 1
a788 1
`% time'
d792 1
a792 1
`cumulative seconds'
d797 1
a797 1
`self seconds'
d801 1
a801 1
`calls'
d807 1
a807 1
`self ms/call'
d812 1
a812 1
`total ms/call'
d819 2
a820 2
`name'
     This is the name of the function.   The flat profile is sorted by
d832 2
a833 2
they themselves may not have used much time, called other functions
that did use unusual amounts of time.
d836 1
a836 1
same `gprof' run as the flat profile example in the previous section.
d871 4
a874 4
number in square brackets.  The end of this line says which function
the entry is for.  The preceding lines in the entry describe the
callers of this function and the following lines describe its
subroutines (also called "children" when we speak of the call graph).
d879 1
a879 1
   The internal profiling function `mcount' (*note The Flat Profile:
d888 1
a888 1
                   such as `a' calls `b' calls `a'...
d901 1
a901 1
`report' in our main example, together with the heading line that shows
d910 1
a910 1
`index'
d920 1
a920 1
`% time'
d929 1
a929 1
`self'
d931 1
a931 1
     should be identical to the number printed in the `seconds' field
d934 5
a938 5
`children'
     This is the total amount of time spent in the subroutine calls
     made by this function.  This should be equal to the sum of all the
     `self' and `children' entries of the children listed directly
     below this function.
d940 1
a940 1
`called'
d944 1
a944 1
     separated by a `+'.  The first number counts non-recursive calls,
d947 2
a948 2
     In the example above, the function `report' was called once from
     `main'.
d950 1
a950 1
`name'
d957 1
a957 1
     example, if function `gnurr' is part of cycle number one, and has
d968 3
a970 3
A function's entry has a line for each function it was called by.
These lines' fields correspond to the fields of the primary line, but
their meanings are different because of the difference in context.
d973 1
a973 1
`report', the primary line and one caller-line preceding it, together
d981 2
a982 2
   Here are the meanings of the fields in the caller-line for `report'
called from `main':
d984 14
a997 14
`self'
     An estimate of the amount of time spent in `report' itself when it
     was called from `main'.

`children'
     An estimate of the amount of time spent in subroutines of `report'
     when `report' was called from `main'.

     The sum of the `self' and `children' fields is an estimate of the
     amount of time spent within calls to `report' from `main'.

`called'
     Two numbers: the number of times `report' was called from `main',
     followed by the total number of non-recursive calls to `report'
d1000 2
a1001 2
`name and index number'
     The name of the caller of `report' to which this line applies,
d1005 1
a1005 1
     `gprof' request the omission of certain functions.  When a caller
d1013 1
a1013 1
dummy caller-line is printed which has `<spontaneous>' as the "caller's
d1028 1
a1028 1
`main', the primary line and a line for a subroutine, together with the
d1036 2
a1037 2
   Here are the meanings of the fields in the subroutine-line for `main'
calling `report':
d1039 17
a1055 17
`self'
     An estimate of the amount of time spent directly within `report'
     when `report' was called from `main'.

`children'
     An estimate of the amount of time spent in subroutines of `report'
     when `report' was called from `main'.

     The sum of the `self' and `children' fields is an estimate of the
     total time spent in calls to `report' from `main'.

`called'
     Two numbers, the number of calls to `report' from `main' followed
     by the total number of non-recursive calls to `report'.  This
     ratio is used to determine how much of `report''s `self' and
     `children' time gets credited to `main'.  *Note Estimating
     `children' Times: Assumptions.
d1057 2
a1058 2
`name'
     The name of the subroutine of `main' to which this line applies,
d1070 2
a1071 2
The graph may be complicated by the presence of "cycles of recursion"
in the call graph.  A cycle exists if a function calls another function
d1073 2
a1074 2
function.  For example: if `a' calls `b', and `b' calls `a', then `a'
and `b' form a cycle.
d1077 4
a1080 4
they belong to the same cycle.  If `a' and `b' call each other and `b'
and `c' call each other, all three make one cycle.  Note that even if
`b' only calls `a' if it was not called from `a', `gprof' cannot
determine this, so `a' and `b' are still considered a cycle.
d1084 1
a1084 1
graph it is followed by `<cycle NUMBER>'.
d1087 4
a1090 4
call graph paradoxical.  The "time spent in children" of `a' should
include the time spent in its subroutine `b' and in `b''s
subroutines--but one of `b''s subroutines is `a'!  How much of `a''s
time should be included in the children of `a', when `a' is indirectly
d1093 1
a1093 1
   The way `gprof' resolves this paradox is by creating a single entry
d1098 2
a1099 2
"callers" of the cycle are the functions, outside the cycle, that
called functions in the cycle.
d1102 2
a1103 2
containing functions `a' and `b'.  The cycle was entered by a call to
`a' from `main'; both `a' and `b' called `c'.
d1125 2
a1126 2
for `main', which calls `a', and an entry for `c', with callers `a' and
`b'.)
d1159 2
a1160 2
   The `self' field of the cycle's primary line is the total time spent
in all the functions of the cycle.  It equals the sum of the `self'
d1164 6
a1169 6
   The `children' fields of the cycle's primary line and subroutine
lines count only subroutines outside the cycle.  Even though `a' calls
`b', the time spent in those calls to `b' is not counted in `a''s
`children' time.  Thus, we do not encounter the problem of what to do
when the time in those calls to `b' includes indirect recursive calls
back to `a'.
d1171 1
a1171 1
   The `children' field of a caller-line in the cycle's entry estimates
d1176 1
a1176 1
   The `called' field in the primary line for the cycle has two numbers:
d1179 8
a1186 8
called by functions in the cycle (including times when a function in
the cycle calls itself).  This is a generalization of the usual split
into non-recursive and recursive calls.

   The `called' field of a subroutine-line for a cycle member in the
cycle's entry says how many time that function was called from
functions in the cycle.  The total of all these is the second number in
the primary line's `called' field.
d1190 4
a1193 4
These lines show how many times each function in the cycle called or
was called from each other function in the cycle.  The `self' and
`children' fields in these lines are blank because of the difficulty of
defining meanings for them when recursion is going on.
d1201 1
a1201 1
`gprof''s `-l' option causes the program to perform "line-by-line"
d1203 3
a1205 3
functions, but to individual lines of source code.  This only works
with programs compiled with older versions of the `gcc' compiler.
Newer versions of `gcc' use a different program - `gcov' - to display
d1208 2
a1209 2
   With the older versions of `gcc' the program usually has to be
compiled with a `-g' option, in addition to `-pg', in order to generate
d1211 1
a1211 1
versions of `gcc' the program had to be compiled with the `-a' command
d1216 1
a1216 1
version of `gprof' does not propagate call graph arcs from source code
d1220 3
a1222 3
   Here is a section of `gprof''s output, without line-by-line
profiling.  Note that `ct_init' accounted for four histogram hits, and
13327 calls to `init_block'.
d1245 3
a1247 2
   Now let's look at some of `gprof''s output from the same program run,
this time with line-by-line profiling enabled.  Note that `ct_init''s
d1250 1
a1250 1
note how `ct_init''s 13327 calls to `init_block' are broken down into
d1286 1
d1293 1
a1293 1
`gprof''s `-A' option triggers an annotated source listing, which lists
d1295 2
a1296 2
times it was called.  You may also need to specify the `-I' option, if
`gprof' can't find the source code files.
d1298 1
a1298 1
   With older versions of `gcc' compiling with `gcc ... -g -pg -a'
d1300 3
a1302 3
function counting code.  This enables `gprof' to determine how many
times each line of code was executed.  With newer versions of `gcc'
support for displaying basic-block counts is provided by the `gcov'
d1328 7
a1334 6
   `updcrc' has at least five basic-blocks.  One is the function
itself.  The `if' statement on line 9 generates two more basic-blocks,
one for each branch of the `if'.  A fourth basic-block results from the
`if' on line 13, and the contents of the `do' loop form the fifth
basic-block.  The compiler may also generate additional basic-blocks to
handle various special cases.
d1337 3
a1339 3
`gprof -l -A'.  The `-x' option is also helpful, to ensure that each
line of code is labeled at least once.  Here is `updcrc''s annotated
source listing for a sample `gzip' run:
d1362 2
a1363 2
each branch of the `if' statement.  The body of the `do' loop was
executed a total of 26312 times.  Note how the `while' statement is
d1371 1
a1371 1
6 Inaccuracy of `gprof' Output
d1385 1
a1385 1
The run-time figures that `gprof' gives you are based on a sampling
d1398 2
a1399 2
beware that the mcount counting function in glibc is _not_
thread-safe).  *Note Implementation of Profiling: Implementation.
d1408 1
a1408 1
period is 0.01 seconds and `foo''s run-time is 1 second, N is 100
d1410 1
a1410 1
error in `foo''s run-time is 0.1 seconds (10*0.01 seconds), or ten
d1412 5
a1416 5
seconds and `bar''s run-time is 100 seconds, N is 10000 samples,
sqrt(N) is 100 samples, so the expected error in `bar''s run-time is 1
second, or one percent of the observed value.  It is likely to vary
this much _on the average_ from one profiling run to the next.
(_Sometimes_ it will vary more.)
d1426 1
a1426 1
the data from several runs, using the `-s' option of `gprof'.  Here is
d1431 1
a1431 1
  2. Issue the command `mv gmon.out gmon.sum'.
d1435 1
a1435 1
  4. Merge the new data in `gmon.out' into `gmon.sum' with this command:
d1448 1
a1448 1
6.2 Estimating `children' Times
d1452 2
a1453 2
`children' time values and all the time figures in caller and
subroutine lines.
d1456 1
a1456 1
profile data itself.  Instead, `gprof' estimates them by making an
d1460 3
a1462 4
any function `foo' is not correlated with who called `foo'.  If `foo'
used 5 seconds in all, and 2/5 of the calls to `foo' came from `a',
then `foo' contributes 2 seconds to `a''s `children' time, by
assumption.
d1465 6
a1470 6
far from true.  Suppose that `foo' returns very quickly when its
argument is zero; suppose that `a' always passes zero as an argument,
while other callers of `foo' pass other arguments.  In this program,
all the time spent in `foo' is in the calls from callers other than `a'.
But `gprof' has no way of knowing this; it will blindly and incorrectly
charge 2 seconds of time in `foo' to the children of `a'.
d1472 1
a1472 1
   We hope some day to put more complete data into `gmon.out', so that
d1483 1
d1485 1
a1485 1
     Because `gprof' can only report call times and counts by function,
d1489 1
a1489 1
     artificial hot spots since compiling with `-pg' adds a significant
d1494 2
a1495 1
     Use the `gcov' program.
d1498 2
a1499 1
     Use `gprof -l' and lookup the function in the call graph.  The
d1503 1
a1518 1

d1522 1
a1522 1
8 Incompatibilities with Unix `gprof'
d1525 3
a1527 3
GNU `gprof' and Berkeley Unix `gprof' use the same data file
`gmon.out', and provide essentially the same information.  But there
are a few differences.
d1529 1
a1529 1
   * GNU `gprof' uses a new, generalized file format with support for
d1531 1
a1531 1
     cookie and version number allows `gprof' to easily identify new
d1535 3
a1537 3
   * For a recursive function, Unix `gprof' lists the function as a
     parent and as a child, with a `calls' field that lists the number
     of recursive calls.  GNU `gprof' omits these lines and puts the
d1540 2
a1541 2
   * When a function is suppressed from the call graph with `-e', GNU
     `gprof' still lists it as a subroutine of functions that call it.
d1543 2
a1544 2
   * GNU `gprof' accepts the `-k' with its argument in the form
     `from/to', instead of `from to'.
d1546 3
a1548 3
   * In the annotated source listing, if there are multiple basic
     blocks on the same line, GNU `gprof' prints all of their counts,
     separated by commas.
d1551 1
a1551 1
     `gprof' prints blurbs after the tables, so that you can see the
d1563 3
a1565 3
* File Format::         Format of `gmon.out' files
* Internals::           `gprof''s internal operation
* Debugging::           Using `gprof''s `-d' option
d1578 2
a1579 2
the `-pg' option, which causes every function to call `mcount' (or
`_mcount', or `__mcount', depending on the OS and compiler) as one of
d1582 1
a1582 1
   The `mcount' routine, included in the profiling library, is
d1585 3
a1587 3
done by examining the stack frame to find both the address of the
child, and the return address in the original parent.  Since this is a
very machine-dependent operation, `mcount' itself is typically a short
d1589 4
a1592 4
and then calls `__mcount_internal' (a normal C function) with two
arguments--`frompc' and `selfpc'.  `__mcount_internal' is responsible
for maintaining the in-memory call graph, which records `frompc',
`selfpc', and the number of times each of these call arcs was traversed.
d1595 1
a1595 1
(`__builtin_return_address'), which allows a generic `mcount' function
d1599 1
a1599 1
`mcount' is used for performance reasons.
d1603 2
a1604 2
same as in the usual C library, but they were compiled with `-pg'.  If
you link your program with `gcc ... -pg', it automatically uses the
d1607 5
a1611 5
   Profiling also involves watching your program as it runs, and
keeping a histogram of where the program counter happens to be every
now and then.  Typically the program counter is looked at around 100
times per second of run time, but the exact frequency may vary from
system to system.
d1614 1
a1614 1
provide a `profil()' system call, which registers a memory array with
d1616 7
a1622 7
address space maps into the array.  Typical scaling values cause every
2 to 8 bytes of address space to map into a single array slot.  On
every tick of the system clock (assuming the profiled program is
running), the value of the program counter is examined and the
corresponding slot in the memory array is incremented.  Since this is
done in the kernel, which had to interrupt the process anyway to handle
the clock interrupt, very little additional system overhead is required.
d1625 8
a1632 9
earlier), do not provide a `profil()' system call.  On such a system,
arrangements are made for the kernel to periodically deliver a signal
to the process (typically via `setitimer()'), which then performs the
same operation of examining the program counter and incrementing a slot
in the memory array.  Since this method requires a signal to be
delivered to user space every time a sample is taken, it uses
considerably more overhead than kernel-based profiling.  Also, due to
the added delay required to deliver the signal, this method is less
accurate as well.
d1635 8
a1642 8
either calls `profil()' or sets up a clock signal handler.  This
routine (`monstartup') can be invoked in several ways.  On Linux
systems, a special profiling startup file `gcrt0.o', which invokes
`monstartup' before `main', is used instead of the default `crt0.o'.
Use of this special startup file is one of the effects of using `gcc
... -pg' to link.  On SPARC systems, no special startup files are used.
Rather, the `mcount' routine, when it is invoked for the first time
(typically when `main' is called), calls `monstartup'.
d1644 1
a1644 1
   If the compiler's `-a' option was used, basic-block counting is also
d1647 1
a1647 1
basic-block begins (i.e., when an `if' statement appears), an extra
d1654 5
a1658 5
   The profiling library also includes a function (`mcleanup') which is
typically registered using `atexit()' to be called as the program
exits, and is responsible for writing the file `gmon.out'.  Profiling
is turned off, various headers are output, and the histogram is
written, followed by the call-graph arcs and the basic-block counts.
d1660 1
a1660 1
   The output from `gprof' gives no indication of parts of your program
d1662 8
a1669 8
of the program counter are taken at fixed intervals of the program's
run time.  Therefore, the time measurements in `gprof' output say
nothing about time that your program was not running.  For example, a
part of the program that creates so much data that it cannot all fit in
physical memory at once may run very slowly due to thrashing, but
`gprof' will say it uses little time.  On the other hand, sampling by
run time has the advantage that the amount of load due to other users
won't directly affect the output you get.
d1679 2
a1680 2
`gprof' file.  Furthermore, it does not provide a version number, thus
rendering changes to the file format almost impossible.  GNU `gprof'
d1682 1
a1682 1
compatibility, GNU `gprof' continues to support the old BSD-derived
d1687 1
a1687 1
   The new file format is defined in header file `gmon_out.h'.  It
d1691 1
a1691 1
the profile was collected.  GNU `gprof' adapts automatically to the
d1698 1
a1698 1
reading a file, GNU `gprof' will ensure records of the same type are
d1708 15
a1722 15
spans, the size of the histogram in bytes (unlike in the old BSD
format, this does not include the size of the header), the rate of the
profiling clock, and the physical dimension that the bin counts
represent after being scaled by the profiling clock rate.  The physical
dimension is specified in two parts: a long name of up to 15 characters
and a single character abbreviation.  For example, a histogram
representing real-time would specify the long name as "seconds" and the
abbreviation as "s".  This feature is useful for architectures that
support performance monitor hardware (which, fortunately, is becoming
increasingly common).  For example, under DEC OSF/1, the "uprofile"
command can be used to produce a histogram of, say, instruction cache
misses.  In this case, the dimension in the histogram header could be
set to "i-cache misses" and the abbreviation could be set to "1"
(because it is simply a count, not a physical dimension).  Also, the
profiling rate would have to be set to 1 in this case.
d1735 8
a1742 8
program execution.  Arcs are specified by a pair of addresses: the
first must be within caller's function and the second must be within
the callee's function.  When performing profiling at the function
level, these addresses can point anywhere within the respective
function.  However, when profiling at the line-level, it is better if
the addresses are as close to the call-site/entry-point as possible.
This will ensure that the line-level call-graph is able to identify
exactly which line of source code performed calls to a function.
d1748 4
a1751 5
sequence of address/count pairs.  The header simply specifies the
length of the sequence.  In an address/count pair, the address
identifies a basic-block and the count specifies the number of times
that basic-block was executed.  Any address within the basic-address can
be used.
d1756 1
a1756 1
9.3 `gprof''s Internal Operation
d1759 6
a1764 6
Like most programs, `gprof' begins by processing its options.  During
this stage, it may building its symspec list (`sym_ids.c:sym_id_add'),
if options are specified which use symspecs.  `gprof' maintains a
single linked list of symspecs, which will eventually get turned into
12 symbol tables, organized into six include/exclude pairs--one pair
each for the flat profile (INCL_FLAT/EXCL_FLAT), the call graph arcs
d1771 2
a1772 2
   After option processing, `gprof' finishes building the symspec list
by adding all the symspecs in `default_excluded_list' to the exclude
d1778 2
a1779 2
it is an object file, and read its symbol table (`core.c:core_init'),
using `bfd_canonicalize_symtab' after mallocing an appropriately sized
d1781 2
a1782 2
`--file-ordering' option has been specified), and the core text space
is read into memory (if the `-c' option was given).
d1784 1
a1784 1
   `gprof''s own symbol table, an array of Sym structures, is now built.
d1786 1
a1786 1
whether line-by-line profiling (`-l' option) has been enabled.  For
d1792 4
a1795 4
the symbols.  In between the two passes, a single array of type `Sym'
is created of the appropriate length.  Finally,
`symtab.c:symtab_finalize' is called to sort the symbol table and
remove duplicate entries (entries with the same memory address).
d1798 3
a1800 3
the `qsort' library function (which sorts an array) will be used to
sort the symbol table.  Also, the symbol lookup routine
(`symtab.c:sym_lookup'), which finds symbols based on memory address,
d1802 1
a1802 1
sorted array.  Function symbols are indicated with an `is_func' flag.
d1804 1
a1804 1
can have an `is_static' flag to indicate that it is a local symbol.
d1807 11
a1817 11
Syms (`sym_ids.c:sym_id_parse').  Remember that a single symspec can
match multiple symbols.  An array of symbol tables (`syms') is created,
each entry of which is a symbol table of Syms to be included or
excluded from a particular listing.  The master symbol table and the
symspecs are examined by nested loops, and every symbol that matches a
symspec is inserted into the appropriate syms table.  This is done
twice, once to count the size of each required symbol table, and again
to build the tables, which have been malloced between passes.  From now
on, to determine whether a symbol is on an include or exclude symspec
list, `gprof' simply uses its standard symbol lookup routine on the
appropriate table in the `syms' array.
d1820 2
a1821 2
(`gmon_io.c:gmon_out_read'), first by checking for a new-style
`gmon.out' header, then assuming this is an old-style BSD `gmon.out' if
d1824 1
a1824 1
   New-style histogram records are read by `hist.c:hist_read_rec'.  For
d1826 6
a1831 6
bins, and read them in.  When multiple profile data files (or files
with multiple histogram records) are read, the memory ranges of each
pair of histogram records must be either equal, or non-overlapping.
For each pair of histogram records, the resolution (memory region size
divided by the number of bins) must be the same.  The time unit must be
the same for all histogram records. If the above containts are met, all
d1834 1
a1834 1
   As each call graph record is read (`call_graph.c:cg_read_rec'), the
d1836 2
a1837 2
call graph arc is created by `cg_arcs.c:arc_add', unless the arc fails
a symspec check against INCL_ARCS/EXCL_ARCS.  As each arc is added, a
d1842 6
a1847 6
   Basic-block records are read (`basic_blocks.c:bb_read_rec'), but
only if line-by-line profiling has been selected.  Each basic-block
address is matched to a corresponding line symbol in the symbol table,
and an entry made in the symbol's bb_addr and bb_calls arrays.  Again,
if multiple basic-block records are present for the same address, the
call counts are cumulative.
d1849 1
a1849 1
   A gmon.sum file is dumped, if requested (`gmon_io.c:gmon_out_write').
d1852 10
a1861 11
(`hist.c:hist_assign_samples') by iterating over all the sample bins
and assigning them to symbols.  Since the symbol table is sorted in
order of ascending memory addresses, we can simple follow along in the
symbol table as we make our pass over the sample bins.  This step
includes a symspec check against INCL_FLAT/EXCL_FLAT.  Depending on the
histogram scale factor, a sample bin may span multiple symbols, in
which case a fraction of the sample count is allocated to each symbol,
proportional to the degree of overlap.  This effect is rare for normal
profiling, but overlaps are more common during line-by-line profiling,
and can cause each of two adjacent lines to be credited with half a
hit, for example.
d1863 2
a1864 2
   If call graph data is present, `cg_arcs.c:cg_assemble' is called.
First, if `-c' was specified, a machine-dependent routine (`find_call')
d1867 18
a1884 19
A topological sort is performed by depth-first numbering all the
symbols (`cg_dfn.c:cg_dfn'), so that children are always numbered less
than their parents, then making a array of pointers into the symbol
table and sorting it into numerical order, which is reverse topological
order (children appear before parents).  Cycles are also detected at
this point, all members of which are assigned the same topological
number.  Two passes are now made through this sorted array of symbol
pointers.  The first pass, from end to beginning (parents to children),
computes the fraction of child time to propagate to each parent and a
print flag.  The print flag reflects symspec handling of
INCL_GRAPH/EXCL_GRAPH, with a parent's include or exclude (print or no
print) property being propagated to its children, unless they
themselves explicitly appear in INCL_GRAPH or EXCL_GRAPH.  A second
pass, from beginning to end (children to parents) actually propagates
the timings along the call graph, subject to a check against
INCL_TIME/EXCL_TIME.  With the print flag, fractions, and timings now
stored in the symbol structures, the topological sort array is now
discarded, and a new array of pointers is assembled, this time sorted
by propagated time.
d1887 2
a1888 2
fairly straightforward.  The call graph (`cg_print.c:cg_print') and
flat profile (`hist.c:hist_print') are regurgitations of values already
d1890 1
a1890 1
(`basic_blocks.c:print_annotated_source') uses basic-block information,
d1895 1
a1895 1
source code itself (`cg_print.c').  Basically, the functions with the
d1903 1
a1903 1
9.4 Debugging `gprof'
d1906 4
a1909 4
If `gprof' was compiled with debugging enabled, the `-d' option
triggers debugging output (to stdout) which can be helpful in
understanding its operation.  The debugging number specified is
interpreted as a sum of the following options:
a1912 1

a1914 1

a1917 1

a1920 1

a1923 1

d1926 1
a1926 1
     file.  For line-by-line profiling (`-l' option), also shows line
a1927 1

d1929 1
a1929 2
     Trace operation of `-c' option

a1931 1

a1933 1

d1936 1
a1936 2
     meaningful with `-l' option)

a1938 1

d1940 1
a1940 1
     Tracks operation of `-A' option
d1951 1
a1951 1
     `http://fsf.org/'
d1976 2
a1977 2
     of subject matter or whether it is published as a printed book.
     We recommend this License principally for works whose purpose is
d1983 2
a1984 2
     that contains a notice placed by the copyright holder saying it
     can be distributed under the terms of this License.  Such a notice
d1988 3
a1990 3
     of the public is a licensee, and is addressed as "you".  You
     accept the license if you copy, modify or distribute the work in a
     way requiring permission under copyright law.
d2008 6
a2013 6
     titles are designated, as being those of Invariant Sections, in
     the notice that says that the Document is released under this
     License.  If a section does not fit the above definition of
     Secondary then it is not allowed to be designated as Invariant.
     The Document may contain zero Invariant Sections.  If the Document
     does not identify any Invariant Sections then there are none.
d2024 10
a2033 10
     straightforwardly with generic text editors or (for images
     composed of pixels) generic paint programs or (for drawings) some
     widely available drawing editor, and that is suitable for input to
     text formatters or for automatic translation to a variety of
     formats suitable for input to text formatters.  A copy made in an
     otherwise Transparent file format whose markup, or absence of
     markup, has been arranged to thwart or discourage subsequent
     modification by readers is not Transparent.  An image format is
     not Transparent if used for any substantial amount of text.  A
     copy that is not "Transparent" is called "Opaque".
d2037 8
a2044 8
     SGML or XML using a publicly available DTD, and
     standard-conforming simple HTML, PostScript or PDF designed for
     human modification.  Examples of transparent image formats include
     PNG, XCF and JPG.  Opaque formats include proprietary formats that
     can be read and edited only by proprietary word processors, SGML or
     XML for which the DTD and/or processing tools are not generally
     available, and the machine-generated HTML, PostScript or PDF
     produced by some word processors for output purposes only.
d2082 2
a2083 2
     distribute a large enough number of copies you must also follow
     the conditions in section 3.
d2097 5
a2101 6
     front cover must present the full title with all words of the
     title equally prominent and visible.  You may add other material
     on the covers in addition.  Copying with changes limited to the
     covers, as long as they preserve the title of the Document and
     satisfy these conditions, can be treated as verbatim copying in
     other respects.
d2109 11
a2119 12
     numbering more than 100, you must either include a
     machine-readable Transparent copy along with each Opaque copy, or
     state in or with each Opaque copy a computer-network location from
     which the general network-using public has access to download
     using public-standard network protocols a complete Transparent
     copy of the Document, free of added material.  If you use the
     latter option, you must take reasonably prudent steps, when you
     begin distribution of Opaque copies in quantity, to ensure that
     this Transparent copy will remain thus accessible at the stated
     location until at least one year after the last time you
     distribute an Opaque copy (directly or through your agents or
     retailers) of that edition to the public.
d2122 3
a2124 3
     the Document well before redistributing any large number of
     copies, to give them a chance to provide you with an updated
     version of the Document.
d2130 5
a2134 5
     release the Modified Version under precisely this License, with
     the Modified Version filling the role of the Document, thus
     licensing distribution and modification of the Modified Version to
     whoever possesses a copy of it.  In addition, you must do these
     things in the Modified Version:
d2137 5
a2141 5
          distinct from that of the Document, and from those of
          previous versions (which should, if there were any, be listed
          in the History section of the Document).  You may use the
          same title as a previous version if the original publisher of
          that version gives permission.
d2171 6
a2176 6
          authors, and publisher of the Modified Version as given on
          the Title Page.  If there is no section Entitled "History" in
          the Document, create one stating the title, year, authors,
          and publisher of the Document as given on its Title Page,
          then add an item describing the Modified Version as stated in
          the previous sentence.
d2181 5
a2185 5
          previous versions it was based on.  These may be placed in
          the "History" section.  You may omit a network location for a
          work that was published at least four years before the
          Document itself, or if the original publisher of the version
          it refers to gives permission.
d2188 2
a2189 2
          Preserve the Title of the section, and preserve in the
          section all the substance and tone of each of the contributor
d2192 3
a2194 4
       L. Preserve all the Invariant Sections of the Document,
          unaltered in their text and in their titles.  Section numbers
          or the equivalent are not considered part of the section
          titles.
d2207 5
a2211 5
     material copied from the Document, you may at your option
     designate some or all of these sections as invariant.  To do this,
     add their titles to the list of Invariant Sections in the Modified
     Version's license notice.  These titles must be distinct from any
     other section titles.
d2220 9
a2228 9
     and a passage of up to 25 words as a Back-Cover Text, to the end
     of the list of Cover Texts in the Modified Version.  Only one
     passage of Front-Cover Text and one of Back-Cover Text may be
     added by (or through arrangements made by) any one entity.  If the
     Document already includes a cover text for the same cover,
     previously added by you or by arrangement made by the same entity
     you are acting on behalf of, you may not add another; but you may
     replace the old one, on explicit permission from the previous
     publisher that added the old one.
d2238 2
a2239 2
     modified versions, provided that you include in the combination
     all of the Invariant Sections of all of the original documents,
d2266 2
a2267 2
     rules of this License for verbatim copying of each of the
     documents in all other respects.
d2271 3
a2273 3
     a copy of this License into the extracted document, and follow
     this License in all other respects regarding verbatim copying of
     that document.
d2278 2
a2279 2
     separate and independent documents or works, in or on a volume of
     a storage or distribution medium, is called an "aggregate" if the
d2324 2
a2325 2
     provisionally, unless and until the copyright holder explicitly
     and finally terminates your license, and (b) permanently, if the
d2337 4
a2340 4
     the licenses of parties who have received copies or rights from
     you under this License.  If your rights have been terminated and
     not permanently reinstated, receipt of a copy of some or all of
     the same material does not give you any rights to use it.
d2342 1
a2342 1
 10. FUTURE REVISIONS OF THIS LICENSE
d2348 1
a2348 1
     `http://www.gnu.org/copyleft/'.
d2355 5
a2359 5
     published (not as a draft) by the Free Software Foundation.  If
     the Document does not specify a version number of this License,
     you may choose any version ever published (not as a draft) by the
     Free Software Foundation.  If the Document specifies that a proxy
     can decide which future versions of this License can be used, that
d2363 1
a2363 1
 11. RELICENSING
a2392 1

d2409 1
a2409 1
Texts, replace the "with...Texts." line with this:
d2420 3
a2422 3
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License, to
permit their use in free software.
d2427 18
a2444 18
Node: Top722
Node: Introduction2045
Node: Compiling4537
Node: Executing8593
Node: Invoking11381
Node: Output Options12796
Node: Analysis Options19885
Node: Miscellaneous Options23803
Node: Deprecated Options25058
Node: Symspecs27127
Node: Output28953
Node: Flat Profile29993
Node: Call Graph34946
Node: Primary38178
Node: Callers40766
Node: Subroutines42883
Node: Cycles44724
Node: Line-by-line51501
d2446 11
a2456 11
Node: Inaccuracy58573
Node: Sampling Error58831
Node: Assumptions61735
Node: How do I?63205
Node: Incompatibilities64759
Node: Details66253
Node: Implementation66646
Node: File Format72543
Node: Internals76833
Node: Debugging85328
Node: GNU Free Documentation License86929
@


1.5.12.1
log
@Sync with HEAD
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 6.3 from gprof.texi.
d3 6
a8 1
This file documents the gprof profiler of the GNU system.
d10 1
a10 1
   Copyright (C) 1988-2018 Free Software Foundation, Inc.
a18 5
INFO-DIR-SECTION Software development
START-INFO-DIR-ENTRY
* gprof: (gprof).                Profiling your program's execution
END-INFO-DIR-ENTRY

d25 1
a25 1
This manual describes the GNU profiler, 'gprof', and how you can use it
d28 1
a28 1
programs.  GNU 'gprof' was written by Jay Fenlason.
d30 1
a30 1
   This manual is for 'gprof' (GNU Binutils) version 2.30.0.
d33 2
a34 2
Documentation License version 1.3.  A copy of the license is included in
the section entitled "GNU Free Documentation License".
d42 1
a42 1
* Invoking::            How to run 'gprof', and its options
d44 1
a44 1
* Output::              Interpreting 'gprof''s output
d48 1
a48 1
* Incompatibilities::   (between GNU 'gprof' and Unix 'gprof'.)
d67 6
a72 5
execution of your program, it can be used on programs that are too large
or too complex to analyze by reading the source.  However, how your
program is run will affect the information that shows up in the profile
data.  If you don't use some feature of your program while it is being
profiled, no profile information will be generated for that feature.
d82 1
a82 1
   * You must run 'gprof' to analyze the profile data.  *Note 'gprof'
d94 6
a99 5
   The "call graph" shows, for each function, which functions called it,
which other functions it called, and how many times.  There is also an
estimate of how much time was spent in the subroutines of each function.
This can suggest places where you might try to eliminate function calls
that use a lot of time.  *Note The Call Graph: Call Graph.
d118 1
a118 1
   To compile a source file for profiling, specify the '-pg' option when
d122 3
a124 3
   To link the program for profiling, if you use a compiler such as 'cc'
to do the linking, simply specify '-pg' in addition to your usual
options.  The same option, '-pg', alters either compilation or linking
d130 1
a130 1
   The '-pg' option also works with a command that both compiles and
d135 3
a137 3
   Note: The '-pg' option must be part of your compilation options as
well as your link options.  If it is not then no call-graph data will be
gathered and when you run 'gprof' you will get an error message like
d142 2
a143 2
   If you add the '-Q' switch to suppress the printing of the call graph
data you will still be able to see the time samples:
d154 8
a161 8
   If you run the linker 'ld' directly instead of through a compiler
such as 'cc', you may have to specify a profiling startup file 'gcrt0.o'
as the first input file instead of the usual startup file 'crt0.o'.  In
addition, you would probably want to specify the profiling C library,
'libc_p.a', by writing '-lc_p' instead of the usual '-lc'.  This is not
absolutely necessary, but doing this gives you number-of-calls
information for standard library functions such as 'read' and 'open'.
For example:
d166 2
a167 2
libraries you may run into problems with the profiling support code in a
shared library being called before that library has been fully
d170 3
a172 3
against a static version of the library containing the profiling support
code, which for 'gcc' users can be done via the '-static' or
'-static-libgcc' command line option.  For example:
d176 1
a176 1
   If you compile only some of the modules of the program with '-pg',
d178 6
a183 6
information about the modules that were compiled without '-pg'.  The
only information you get for the functions in those modules is the total
time spent in them; there is no record of how many times they were
called, or from where.  This will not affect the flat profile (except
that the 'calls' field for the functions will be blank), but will
greatly reduce the usefulness of the call graph.
d186 1
a186 1
'gcov' tool instead of 'gprof'.  See that tool's manual or info pages
d189 3
a191 3
   Note, older versions of 'gcc' produce line-by-line profiling
information that works with 'gprof' rather than 'gcov' so there is still
support for displaying this kind of information in 'gprof'.  *Note
d194 5
a198 5
   It also worth noting that 'gcc' implements a '-finstrument-functions'
command line option which will insert calls to special user supplied
instrumentation routines at the entry and exit of every function in
their program.  This can be used to implement an alternative profiling
scheme.
d207 1
a207 1
generate the information that 'gprof' needs.  Simply run the program as
d221 2
a222 2
'gmon.out' just before exiting.  If there is already a file called
'gmon.out', its contents are overwritten.  There is currently no way to
d227 3
a229 3
   In order to write the 'gmon.out' file properly, your program must
exit normally: by returning from 'main' or by calling 'exit'.  Calling
the low-level function '_exit' does not write the profile data, and
d232 1
a232 1
   The 'gmon.out' file is written in the program's _current working
d234 2
a235 2
'chdir', the 'gmon.out' file will be left in the last directory your
program 'chdir''d to.  If you don't have permission to write in this
d239 1
a239 1
called 'bb.out'.  This file, if present, contains an human-readable
d241 4
a244 4
appearance of a human-readable 'bb.out' means the basic-block counts
didn't get written into 'gmon.out'.  The Perl script 'bbconv.pl',
included with the 'gprof' source distribution, will convert a 'bb.out'
file into a format readable by 'gprof'.  Invoke it like this:
d248 2
a249 2
   This translates the information in 'bb.out' into a form that 'gprof'
can understand.  But you still need to tell 'gprof' about the existence
d251 1
a251 1
'gprof' command line, _along with 'gmon.out'_, like this:
d258 1
a258 1
4 'gprof' Command Summary
d261 2
a262 2
After you have a profile data file 'gmon.out', you can run 'gprof' to
interpret the information in it.  The 'gprof' program prints a flat
d264 1
a264 1
redirect the output of 'gprof' into a file with '>'.
d266 1
a266 1
   You run 'gprof' like this:
d272 5
a276 4
   If you omit the executable file name, the file 'a.out' is used.  If
you give no profile data file name, the file 'gmon.out' is used.  If any
file is not in the proper format, or if the profile data file does not
appear to belong to the executable file, an error message is printed.
d286 2
a287 2
* Output Options::      Controlling 'gprof''s output style
* Analysis Options::    Controlling how 'gprof' analyzes its data
d299 1
a299 1
These options specify which of several output formats 'gprof' should
d302 4
a305 4
   Many of these options take an optional "symspec" to specify functions
to be included or excluded.  These options can be specified multiple
times, with different symspecs, to include or exclude sets of symbols.
*Note Symspecs: Symspecs.
d307 1
a307 1
   Specifying any of these options overrides the default ('-p -q'),
d310 3
a312 3
'-A[SYMSPEC]'
'--annotated-source[=SYMSPEC]'
     The '-A' option causes 'gprof' to print annotated source code.  If
d316 3
a318 3
'-b'
'--brief'
     If the '-b' option is given, 'gprof' doesn't print the verbose
d323 3
a325 3
'-C[SYMSPEC]'
'--exec-counts[=SYMSPEC]'
     The '-C' option causes 'gprof' to print a tally of functions and
d330 1
a330 1
     specifying the '-l' option, along with '-C', will cause basic-block
d333 9
a341 9
'-i'
'--file-info'
     The '-i' option causes 'gprof' to display summary information about
     the profile data file(s) and then exit.  The number of histogram,
     call graph, and basic-block count records is displayed.

'-I DIRS'
'--directory-path=DIRS'
     The '-I' option specifies a list of search directories in which to
d346 4
a349 4
'-J[SYMSPEC]'
'--no-annotated-source[=SYMSPEC]'
     The '-J' option causes 'gprof' not to print annotated source code.
     If SYMSPEC is specified, 'gprof' prints annotated source, but
d352 2
a353 2
'-L'
'--print-path'
d355 1
a355 1
     suppressed.  The '-L' option causes 'gprof' to print the full
d360 10
a369 10
'-p[SYMSPEC]'
'--flat-profile[=SYMSPEC]'
     The '-p' option causes 'gprof' to print a flat profile.  If SYMSPEC
     is specified, print flat profile only for matching symbols.  *Note
     The Flat Profile: Flat Profile.

'-P[SYMSPEC]'
'--no-flat-profile[=SYMSPEC]'
     The '-P' option causes 'gprof' to suppress printing a flat profile.
     If SYMSPEC is specified, 'gprof' prints a flat profile, but
d372 3
a374 3
'-q[SYMSPEC]'
'--graph[=SYMSPEC]'
     The '-q' option causes 'gprof' to print the call graph analysis.
d378 4
a381 4
'-Q[SYMSPEC]'
'--no-graph[=SYMSPEC]'
     The '-Q' option causes 'gprof' to suppress printing the call graph.
     If SYMSPEC is specified, 'gprof' prints a call graph, but excludes
d384 3
a386 3
'-t'
'--table-length=NUM'
     The '-t' option causes the NUM most active source lines in each
d390 2
a391 2
'-y'
'--separate-files'
d393 1
a393 1
     'gprof' prints annotated source files to standard-output.  If this
d395 9
a403 9
     'path/FILENAME' is generated in the file 'FILENAME-ann'.  If the
     underlying file system would truncate 'FILENAME-ann' so that it
     overwrites the original 'FILENAME', 'gprof' generates annotated
     source in the file 'FILENAME.ann' instead (if the original file
     name has an extension, that extension is _replaced_ with '.ann').

'-Z[SYMSPEC]'
'--no-exec-counts[=SYMSPEC]'
     The '-Z' option causes 'gprof' not to print a tally of functions
d407 3
a409 3
'-r'
'--function-ordering'
     The '--function-ordering' option causes 'gprof' to print a
d419 7
a425 7
'-R MAP_FILE'
'--file-ordering MAP_FILE'
     The '--file-ordering' option causes 'gprof' to print a suggested .o
     link line ordering for the program based on profiling data.  This
     option suggests an ordering which may improve paging, tlb and cache
     behavior for the program on systems which do not support arbitrary
     ordering of functions in an executable.
d427 1
a427 1
     Use of the '-a' argument is highly recommended with this option.
d431 1
a431 1
     similar to the output of the program 'nm'.
d442 1
a442 2

     To create a MAP_FILE with GNU 'nm', type a command like 'nm
d445 4
a448 4
'-T'
'--traditional'
     The '-T' option causes 'gprof' to print its output in "traditional"
     BSD style.
d450 2
a451 2
'-w WIDTH'
'--width=WIDTH'
d455 7
a461 7
'-x'
'--all-lines'
     This option affects annotated source output only.  By default, only
     the lines at the beginning of a basic-block are annotated.  If this
     option is specified, every line in a basic-block is annotated by
     repeating the annotation for the first line.  This behavior is
     similar to 'tcov''s '-a'.
d463 2
a464 2
'--demangle[=STYLE]'
'--no-demangle'
d467 1
a467 1
     '--no-demangle' option may be used to turn off demangling.
d478 3
a480 3
'-a'
'--no-static'
     The '-a' option causes 'gprof' to suppress the printing of
d486 2
a487 2
     the executable file.  This option affects both the flat profile and
     the call graph.
d489 3
a491 3
'-c'
'--static-call-graph'
     The '-c' option causes the call graph of the program to be
d496 12
a507 12
     have been called, but never were.  Calls to functions that were not
     compiled with profiling enabled are also identified, but only if
     symbol table entries are present for them.  Calls to dynamic
     library routines are typically _not_ found by this option.  Parents
     or children identified via this heuristic are indicated in the call
     graph with call counts of '0'.

'-D'
'--ignore-non-functions'
     The '-D' option causes 'gprof' to ignore symbols which are not
     known to be functions.  This option will give more accurate profile
     data on systems where it is supported (Solaris and HPUX for
d510 2
a511 2
'-k FROM/TO'
     The '-k' option allows you to delete from the call graph any arcs
d514 3
a516 3
'-l'
'--line'
     The '-l' option enables line-by-line profiling, which causes
d519 2
a520 2
     compiled by older versions of the 'gcc' compiler.  Newer versions
     of 'gcc' are designed to work with the 'gcov' tool instead.
d522 5
a526 5
     If the program was compiled with basic-block counting enabled, this
     option will also identify how many times each line of code was
     executed.  While line-by-line profiling can help isolate where in a
     large function a program is spending its time, it also
     significantly increases the running time of 'gprof', and magnifies
d530 4
a533 4
'--inline-file-names'
     This option causes 'gprof' to print the source file after each
     symbol in both the flat profile and the call graph.  The full path
     to the file is printed if used with the '-L' option.
d535 2
a536 2
'-m NUM'
'--min-count=NUM'
d540 8
a547 3
'-nSYMSPEC'
'--time=SYMSPEC'
     The '-n' option causes 'gprof', in its call graph analysis, to only
d550 13
a562 4
'-NSYMSPEC'
'--no-time=SYMSPEC'
     The '-n' option causes 'gprof', in its call graph analysis, not to
     propagate times for symbols matching SYMSPEC.
a563 13
'-SFILENAME'
'--external-symbol-table=FILENAME'
     The '-S' option causes 'gprof' to read an external symbol table
     file, such as '/proc/kallsyms', rather than read the symbol table
     from the given object file (the default is 'a.out').  This is
     useful for profiling kernel modules.

'-z'
'--display-unused-functions'
     If you give the '-z' option, 'gprof' will mention all functions in
     the flat profile, even those that were never called, and that had
     no time spent in them.  This is useful in conjunction with the '-c'
     option for discovering which routines were never called.
d571 4
a574 4
'-d[NUM]'
'--debug[=NUM]'
     The '-d NUM' option specifies debugging options.  If NUM is not
     specified, enable all debugging.  *Note Debugging 'gprof':
d577 3
a579 3
'-h'
'--help'
     The '-h' option prints command line usage.
d581 2
a582 2
'-ONAME'
'--file-format=NAME'
d584 2
a585 2
     are 'auto' (the default), 'bsd', '4.4bsd', 'magic', and 'prof' (not
     yet supported).
d587 3
a589 3
'-s'
'--sum'
     The '-s' option causes 'gprof' to summarize the information in the
d591 11
a601 11
     called 'gmon.sum', which contains all the information from the
     profile data files that 'gprof' read in.  The file 'gmon.sum' may
     be one of the specified input files; the effect of this is to merge
     the data in the other input files into 'gmon.sum'.

     Eventually you can run 'gprof' again without '-s' to analyze the
     cumulative data in the file 'gmon.sum'.

'-v'
'--version'
     The '-v' flag causes 'gprof' to print the current version number,
d604 1
d613 2
a614 2
'-e FUNCTION_NAME'
     The '-e FUNCTION' option tells 'gprof' to not print information
d617 11
a627 10
     functions that call it, but its index number will be shown as '[not
     printed]'.  More than one '-e' option may be given; only one
     FUNCTION_NAME may be indicated with each '-e' option.

'-E FUNCTION_NAME'
     The '-E FUNCTION' option works like the '-e' option, but time spent
     in the function (and children who were not called from anywhere
     else), will not be used to compute the percentages-of-time for the
     call graph.  More than one '-E' option may be given; only one
     FUNCTION_NAME may be indicated with each '-E' option.
d629 2
a630 2
'-f FUNCTION_NAME'
     The '-f FUNCTION' option causes 'gprof' to limit the call graph to
d632 10
a641 2
     children...).  More than one '-f' option may be given; only one
     FUNCTION_NAME may be indicated with each '-f' option.
a642 7
'-F FUNCTION_NAME'
     The '-F FUNCTION' option works like the '-f' option, but only time
     spent in the function and its children (and their children...) will
     be used to determine total-time and percentages-of-time for the
     call graph.  More than one '-F' option may be given; only one
     FUNCTION_NAME may be indicated with each '-F' option.  The '-F'
     option overrides the '-E' option.
d644 2
a645 2
   Note that only one function can be specified with each '-e', '-E',
'-f' or '-F' option.  To specify more than one function, use multiple
d651 1
a651 1
'foo' or 'bar' and were not reachable from 'boring'.
d670 6
a675 6
'main.c'
     Selects everything in file 'main.c'--the dot in the string tells
     'gprof' to interpret the string as a filename, rather than as a
     function name.  To select a file whose name does not contain a dot,
     a trailing colon should be specified.  For example, 'odd:' is
     interpreted as the file named 'odd'.
d677 2
a678 2
'main'
     Selects all functions named 'main'.
d687 2
a688 2
     necessary to add a leading colon to the name.  For example, ':.mul'
     selects function '.mul'.
d691 2
a692 2
     'gprof' will normally not print these underscores.  When you name a
     symbol in a symspec, you should type it exactly as 'gprof' prints
d694 2
a695 2
     '_main' from your 'main' function, 'gprof' still prints it as
     'main' in its output, so you should use 'main' in symspecs.
d697 2
a698 2
'main.c:main'
     Selects function 'main' in file 'main.c'.
d700 2
a701 2
'main.c:134'
     Selects line 134 in file 'main.c'.
d706 1
a706 1
5 Interpreting 'gprof''s Output
d709 1
a709 1
'gprof' can produce several different output styles, the most important
d722 1
a722 1
* Line-by-line::        'gprof' can analyze individual source code lines
d733 1
a733 1
executing each function.  Unless the '-z' option is given, functions
d764 1
a764 1
functions 'mcount' and 'profil' are part of the profiling apparatus and
d774 8
a781 8
'cumulative seconds' field.  Since each sample counted for 0.01 seconds,
this means only six samples were taken during the run.  Two of the
samples occurred while the program was in the 'open' function, as
indicated by the 'self seconds' field.  Each of the other four samples
occurred one each in 'offtime', 'memccpy', 'write', and 'mcount'.  Since
only six samples were taken, none of these values can be regarded as
particularly reliable.  In another run, the 'self seconds' field for
'mcount' might well be '0.00' or '0.02'.  *Note Statistical Sampling
d784 2
a785 2
   The remaining functions in the listing (those whose 'self seconds'
field is '0.00') didn't appear in the histogram samples at all.
d787 1
a787 1
they are listed, sorted in decreasing order by the 'calls' field.
d794 1
a794 1
'% time'
d798 1
a798 1
'cumulative seconds'
d803 1
a803 1
'self seconds'
d807 1
a807 1
'calls'
d813 1
a813 1
'self ms/call'
d818 1
a818 1
'total ms/call'
d825 2
a826 2
'name'
     This is the name of the function.  The flat profile is sorted by
d838 2
a839 2
they themselves may not have used much time, called other functions that
did use unusual amounts of time.
d842 1
a842 1
same 'gprof' run as the flat profile example in the previous section.
d877 4
a880 4
number in square brackets.  The end of this line says which function the
entry is for.  The preceding lines in the entry describe the callers of
this function and the following lines describe its subroutines (also
called "children" when we speak of the call graph).
d885 1
a885 1
   The internal profiling function 'mcount' (*note The Flat Profile:
d894 1
a894 1
                   such as 'a' calls 'b' calls 'a'...
d907 1
a907 1
'report' in our main example, together with the heading line that shows
d916 1
a916 1
'index'
d926 1
a926 1
'% time'
d935 1
a935 1
'self'
d937 1
a937 1
     should be identical to the number printed in the 'seconds' field
d940 5
a944 5
'children'
     This is the total amount of time spent in the subroutine calls made
     by this function.  This should be equal to the sum of all the
     'self' and 'children' entries of the children listed directly below
     this function.
d946 1
a946 1
'called'
d950 1
a950 1
     separated by a '+'.  The first number counts non-recursive calls,
d953 2
a954 2
     In the example above, the function 'report' was called once from
     'main'.
d956 1
a956 1
'name'
d963 1
a963 1
     example, if function 'gnurr' is part of cycle number one, and has
d974 3
a976 3
A function's entry has a line for each function it was called by.  These
lines' fields correspond to the fields of the primary line, but their
meanings are different because of the difference in context.
d979 1
a979 1
'report', the primary line and one caller-line preceding it, together
d987 2
a988 2
   Here are the meanings of the fields in the caller-line for 'report'
called from 'main':
d990 14
a1003 14
'self'
     An estimate of the amount of time spent in 'report' itself when it
     was called from 'main'.

'children'
     An estimate of the amount of time spent in subroutines of 'report'
     when 'report' was called from 'main'.

     The sum of the 'self' and 'children' fields is an estimate of the
     amount of time spent within calls to 'report' from 'main'.

'called'
     Two numbers: the number of times 'report' was called from 'main',
     followed by the total number of non-recursive calls to 'report'
d1006 2
a1007 2
'name and index number'
     The name of the caller of 'report' to which this line applies,
d1011 1
a1011 1
     'gprof' request the omission of certain functions.  When a caller
d1019 1
a1019 1
dummy caller-line is printed which has '<spontaneous>' as the "caller's
d1034 1
a1034 1
'main', the primary line and a line for a subroutine, together with the
d1042 2
a1043 2
   Here are the meanings of the fields in the subroutine-line for 'main'
calling 'report':
d1045 17
a1061 17
'self'
     An estimate of the amount of time spent directly within 'report'
     when 'report' was called from 'main'.

'children'
     An estimate of the amount of time spent in subroutines of 'report'
     when 'report' was called from 'main'.

     The sum of the 'self' and 'children' fields is an estimate of the
     total time spent in calls to 'report' from 'main'.

'called'
     Two numbers, the number of calls to 'report' from 'main' followed
     by the total number of non-recursive calls to 'report'.  This ratio
     is used to determine how much of 'report''s 'self' and 'children'
     time gets credited to 'main'.  *Note Estimating 'children' Times:
     Assumptions.
d1063 2
a1064 2
'name'
     The name of the subroutine of 'main' to which this line applies,
d1076 2
a1077 2
The graph may be complicated by the presence of "cycles of recursion" in
the call graph.  A cycle exists if a function calls another function
d1079 2
a1080 2
function.  For example: if 'a' calls 'b', and 'b' calls 'a', then 'a'
and 'b' form a cycle.
d1083 4
a1086 4
they belong to the same cycle.  If 'a' and 'b' call each other and 'b'
and 'c' call each other, all three make one cycle.  Note that even if
'b' only calls 'a' if it was not called from 'a', 'gprof' cannot
determine this, so 'a' and 'b' are still considered a cycle.
d1090 1
a1090 1
graph it is followed by '<cycle NUMBER>'.
d1093 4
a1096 4
call graph paradoxical.  The "time spent in children" of 'a' should
include the time spent in its subroutine 'b' and in 'b''s
subroutines--but one of 'b''s subroutines is 'a'!  How much of 'a''s
time should be included in the children of 'a', when 'a' is indirectly
d1099 1
a1099 1
   The way 'gprof' resolves this paradox is by creating a single entry
d1104 2
a1105 2
"callers" of the cycle are the functions, outside the cycle, that called
functions in the cycle.
d1108 2
a1109 2
containing functions 'a' and 'b'.  The cycle was entered by a call to
'a' from 'main'; both 'a' and 'b' called 'c'.
d1131 2
a1132 2
for 'main', which calls 'a', and an entry for 'c', with callers 'a' and
'b'.)
d1165 2
a1166 2
   The 'self' field of the cycle's primary line is the total time spent
in all the functions of the cycle.  It equals the sum of the 'self'
d1170 6
a1175 6
   The 'children' fields of the cycle's primary line and subroutine
lines count only subroutines outside the cycle.  Even though 'a' calls
'b', the time spent in those calls to 'b' is not counted in 'a''s
'children' time.  Thus, we do not encounter the problem of what to do
when the time in those calls to 'b' includes indirect recursive calls
back to 'a'.
d1177 1
a1177 1
   The 'children' field of a caller-line in the cycle's entry estimates
d1182 1
a1182 1
   The 'called' field in the primary line for the cycle has two numbers:
d1185 8
a1192 8
called by functions in the cycle (including times when a function in the
cycle calls itself).  This is a generalization of the usual split into
non-recursive and recursive calls.

   The 'called' field of a subroutine-line for a cycle member in the
cycle's entry says how many time that function was called from functions
in the cycle.  The total of all these is the second number in the
primary line's 'called' field.
d1196 4
a1199 4
These lines show how many times each function in the cycle called or was
called from each other function in the cycle.  The 'self' and 'children'
fields in these lines are blank because of the difficulty of defining
meanings for them when recursion is going on.
d1207 1
a1207 1
'gprof''s '-l' option causes the program to perform "line-by-line"
d1209 3
a1211 3
functions, but to individual lines of source code.  This only works with
programs compiled with older versions of the 'gcc' compiler.  Newer
versions of 'gcc' use a different program - 'gcov' - to display
d1214 2
a1215 2
   With the older versions of 'gcc' the program usually has to be
compiled with a '-g' option, in addition to '-pg', in order to generate
d1217 1
a1217 1
versions of 'gcc' the program had to be compiled with the '-a' command
d1222 1
a1222 1
version of 'gprof' does not propagate call graph arcs from source code
d1226 3
a1228 3
   Here is a section of 'gprof''s output, without line-by-line
profiling.  Note that 'ct_init' accounted for four histogram hits, and
13327 calls to 'init_block'.
d1251 2
a1252 3

   Now let's look at some of 'gprof''s output from the same program run,
this time with line-by-line profiling enabled.  Note that 'ct_init''s
d1255 1
a1255 1
note how 'ct_init''s 13327 calls to 'init_block' are broken down into
a1290 1

d1297 1
a1297 1
'gprof''s '-A' option triggers an annotated source listing, which lists
d1299 2
a1300 2
times it was called.  You may also need to specify the '-I' option, if
'gprof' can't find the source code files.
d1302 1
a1302 1
   With older versions of 'gcc' compiling with 'gcc ... -g -pg -a'
d1304 3
a1306 3
function counting code.  This enables 'gprof' to determine how many
times each line of code was executed.  With newer versions of 'gcc'
support for displaying basic-block counts is provided by the 'gcov'
d1332 6
a1337 7

   'updcrc' has at least five basic-blocks.  One is the function itself.
The 'if' statement on line 9 generates two more basic-blocks, one for
each branch of the 'if'.  A fourth basic-block results from the 'if' on
line 13, and the contents of the 'do' loop form the fifth basic-block.
The compiler may also generate additional basic-blocks to handle various
special cases.
d1340 3
a1342 3
'gprof -l -A'.  The '-x' option is also helpful, to ensure that each
line of code is labeled at least once.  Here is 'updcrc''s annotated
source listing for a sample 'gzip' run:
d1365 2
a1366 2
each branch of the 'if' statement.  The body of the 'do' loop was
executed a total of 26312 times.  Note how the 'while' statement is
d1374 1
a1374 1
6 Inaccuracy of 'gprof' Output
d1388 1
a1388 1
The run-time figures that 'gprof' gives you are based on a sampling
d1401 2
a1402 2
beware that the mcount counting function in glibc is _not_ thread-safe).
*Note Implementation of Profiling: Implementation.
d1411 1
a1411 1
period is 0.01 seconds and 'foo''s run-time is 1 second, N is 100
d1413 1
a1413 1
error in 'foo''s run-time is 0.1 seconds (10*0.01 seconds), or ten
d1415 5
a1419 5
seconds and 'bar''s run-time is 100 seconds, N is 10000 samples, sqrt(N)
is 100 samples, so the expected error in 'bar''s run-time is 1 second,
or one percent of the observed value.  It is likely to vary this much
_on the average_ from one profiling run to the next.  (_Sometimes_ it
will vary more.)
d1429 1
a1429 1
the data from several runs, using the '-s' option of 'gprof'.  Here is
d1434 1
a1434 1
  2. Issue the command 'mv gmon.out gmon.sum'.
d1438 1
a1438 1
  4. Merge the new data in 'gmon.out' into 'gmon.sum' with this command:
d1451 1
a1451 1
6.2 Estimating 'children' Times
d1455 2
a1456 2
'children' time values and all the time figures in caller and subroutine
lines.
d1459 1
a1459 1
profile data itself.  Instead, 'gprof' estimates them by making an
d1463 4
a1466 3
any function 'foo' is not correlated with who called 'foo'.  If 'foo'
used 5 seconds in all, and 2/5 of the calls to 'foo' came from 'a', then
'foo' contributes 2 seconds to 'a''s 'children' time, by assumption.
d1469 6
a1474 6
far from true.  Suppose that 'foo' returns very quickly when its
argument is zero; suppose that 'a' always passes zero as an argument,
while other callers of 'foo' pass other arguments.  In this program, all
the time spent in 'foo' is in the calls from callers other than 'a'.
But 'gprof' has no way of knowing this; it will blindly and incorrectly
charge 2 seconds of time in 'foo' to the children of 'a'.
d1476 1
a1476 1
   We hope some day to put more complete data into 'gmon.out', so that
a1486 1

d1488 1
a1488 1
     Because 'gprof' can only report call times and counts by function,
d1492 1
a1492 1
     artificial hot spots since compiling with '-pg' adds a significant
d1497 1
a1497 2

     Use the 'gcov' program.
d1500 1
a1500 2

     Use 'gprof -l' and lookup the function in the call graph.  The
a1503 1

d1519 1
d1523 1
a1523 1
8 Incompatibilities with Unix 'gprof'
d1526 3
a1528 3
GNU 'gprof' and Berkeley Unix 'gprof' use the same data file 'gmon.out',
and provide essentially the same information.  But there are a few
differences.
d1530 1
a1530 1
   * GNU 'gprof' uses a new, generalized file format with support for
d1532 1
a1532 1
     cookie and version number allows 'gprof' to easily identify new
d1536 3
a1538 3
   * For a recursive function, Unix 'gprof' lists the function as a
     parent and as a child, with a 'calls' field that lists the number
     of recursive calls.  GNU 'gprof' omits these lines and puts the
d1541 2
a1542 2
   * When a function is suppressed from the call graph with '-e', GNU
     'gprof' still lists it as a subroutine of functions that call it.
d1544 2
a1545 2
   * GNU 'gprof' accepts the '-k' with its argument in the form
     'from/to', instead of 'from to'.
d1547 3
a1549 3
   * In the annotated source listing, if there are multiple basic blocks
     on the same line, GNU 'gprof' prints all of their counts, separated
     by commas.
d1552 1
a1552 1
     'gprof' prints blurbs after the tables, so that you can see the
d1564 3
a1566 3
* File Format::         Format of 'gmon.out' files
* Internals::           'gprof''s internal operation
* Debugging::           Using 'gprof''s '-d' option
d1579 2
a1580 2
the '-pg' option, which causes every function to call 'mcount' (or
'_mcount', or '__mcount', depending on the OS and compiler) as one of
d1583 1
a1583 1
   The 'mcount' routine, included in the profiling library, is
d1586 3
a1588 3
done by examining the stack frame to find both the address of the child,
and the return address in the original parent.  Since this is a very
machine-dependent operation, 'mcount' itself is typically a short
d1590 4
a1593 4
and then calls '__mcount_internal' (a normal C function) with two
arguments--'frompc' and 'selfpc'.  '__mcount_internal' is responsible
for maintaining the in-memory call graph, which records 'frompc',
'selfpc', and the number of times each of these call arcs was traversed.
d1596 1
a1596 1
('__builtin_return_address'), which allows a generic 'mcount' function
d1600 1
a1600 1
'mcount' is used for performance reasons.
d1604 2
a1605 2
same as in the usual C library, but they were compiled with '-pg'.  If
you link your program with 'gcc ... -pg', it automatically uses the
d1608 5
a1612 5
   Profiling also involves watching your program as it runs, and keeping
a histogram of where the program counter happens to be every now and
then.  Typically the program counter is looked at around 100 times per
second of run time, but the exact frequency may vary from system to
system.
d1615 1
a1615 1
provide a 'profil()' system call, which registers a memory array with
d1617 7
a1623 7
address space maps into the array.  Typical scaling values cause every 2
to 8 bytes of address space to map into a single array slot.  On every
tick of the system clock (assuming the profiled program is running), the
value of the program counter is examined and the corresponding slot in
the memory array is incremented.  Since this is done in the kernel,
which had to interrupt the process anyway to handle the clock interrupt,
very little additional system overhead is required.
d1626 9
a1634 8
earlier), do not provide a 'profil()' system call.  On such a system,
arrangements are made for the kernel to periodically deliver a signal to
the process (typically via 'setitimer()'), which then performs the same
operation of examining the program counter and incrementing a slot in
the memory array.  Since this method requires a signal to be delivered
to user space every time a sample is taken, it uses considerably more
overhead than kernel-based profiling.  Also, due to the added delay
required to deliver the signal, this method is less accurate as well.
d1637 8
a1644 8
either calls 'profil()' or sets up a clock signal handler.  This routine
('monstartup') can be invoked in several ways.  On Linux systems, a
special profiling startup file 'gcrt0.o', which invokes 'monstartup'
before 'main', is used instead of the default 'crt0.o'.  Use of this
special startup file is one of the effects of using 'gcc ... -pg' to
link.  On SPARC systems, no special startup files are used.  Rather, the
'mcount' routine, when it is invoked for the first time (typically when
'main' is called), calls 'monstartup'.
d1646 1
a1646 1
   If the compiler's '-a' option was used, basic-block counting is also
d1649 1
a1649 1
basic-block begins (i.e., when an 'if' statement appears), an extra
d1656 5
a1660 5
   The profiling library also includes a function ('mcleanup') which is
typically registered using 'atexit()' to be called as the program exits,
and is responsible for writing the file 'gmon.out'.  Profiling is turned
off, various headers are output, and the histogram is written, followed
by the call-graph arcs and the basic-block counts.
d1662 1
a1662 1
   The output from 'gprof' gives no indication of parts of your program
d1664 8
a1671 8
of the program counter are taken at fixed intervals of the program's run
time.  Therefore, the time measurements in 'gprof' output say nothing
about time that your program was not running.  For example, a part of
the program that creates so much data that it cannot all fit in physical
memory at once may run very slowly due to thrashing, but 'gprof' will
say it uses little time.  On the other hand, sampling by run time has
the advantage that the amount of load due to other users won't directly
affect the output you get.
d1681 2
a1682 2
'gprof' file.  Furthermore, it does not provide a version number, thus
rendering changes to the file format almost impossible.  GNU 'gprof'
d1684 1
a1684 1
compatibility, GNU 'gprof' continues to support the old BSD-derived
d1689 1
a1689 1
   The new file format is defined in header file 'gmon_out.h'.  It
d1693 1
a1693 1
the profile was collected.  GNU 'gprof' adapts automatically to the
d1700 1
a1700 1
reading a file, GNU 'gprof' will ensure records of the same type are
d1710 15
a1724 15
spans, the size of the histogram in bytes (unlike in the old BSD format,
this does not include the size of the header), the rate of the profiling
clock, and the physical dimension that the bin counts represent after
being scaled by the profiling clock rate.  The physical dimension is
specified in two parts: a long name of up to 15 characters and a single
character abbreviation.  For example, a histogram representing real-time
would specify the long name as "seconds" and the abbreviation as "s".
This feature is useful for architectures that support performance
monitor hardware (which, fortunately, is becoming increasingly common).
For example, under DEC OSF/1, the "uprofile" command can be used to
produce a histogram of, say, instruction cache misses.  In this case,
the dimension in the histogram header could be set to "i-cache misses"
and the abbreviation could be set to "1" (because it is simply a count,
not a physical dimension).  Also, the profiling rate would have to be
set to 1 in this case.
d1737 8
a1744 8
program execution.  Arcs are specified by a pair of addresses: the first
must be within caller's function and the second must be within the
callee's function.  When performing profiling at the function level,
these addresses can point anywhere within the respective function.
However, when profiling at the line-level, it is better if the addresses
are as close to the call-site/entry-point as possible.  This will ensure
that the line-level call-graph is able to identify exactly which line of
source code performed calls to a function.
d1750 5
a1754 4
sequence of address/count pairs.  The header simply specifies the length
of the sequence.  In an address/count pair, the address identifies a
basic-block and the count specifies the number of times that basic-block
was executed.  Any address within the basic-address can be used.
d1759 1
a1759 1
9.3 'gprof''s Internal Operation
d1762 6
a1767 6
Like most programs, 'gprof' begins by processing its options.  During
this stage, it may building its symspec list ('sym_ids.c:sym_id_add'),
if options are specified which use symspecs.  'gprof' maintains a single
linked list of symspecs, which will eventually get turned into 12 symbol
tables, organized into six include/exclude pairs--one pair each for the
flat profile (INCL_FLAT/EXCL_FLAT), the call graph arcs
d1774 2
a1775 2
   After option processing, 'gprof' finishes building the symspec list
by adding all the symspecs in 'default_excluded_list' to the exclude
d1781 2
a1782 2
it is an object file, and read its symbol table ('core.c:core_init'),
using 'bfd_canonicalize_symtab' after mallocing an appropriately sized
d1784 2
a1785 2
'--file-ordering' option has been specified), and the core text space is
read into memory (if the '-c' option was given).
d1787 1
a1787 1
   'gprof''s own symbol table, an array of Sym structures, is now built.
d1789 1
a1789 1
whether line-by-line profiling ('-l' option) has been enabled.  For
d1795 4
a1798 4
the symbols.  In between the two passes, a single array of type 'Sym' is
created of the appropriate length.  Finally, 'symtab.c:symtab_finalize'
is called to sort the symbol table and remove duplicate entries (entries
with the same memory address).
d1801 3
a1803 3
the 'qsort' library function (which sorts an array) will be used to sort
the symbol table.  Also, the symbol lookup routine
('symtab.c:sym_lookup'), which finds symbols based on memory address,
d1805 1
a1805 1
sorted array.  Function symbols are indicated with an 'is_func' flag.
d1807 1
a1807 1
can have an 'is_static' flag to indicate that it is a local symbol.
d1810 11
a1820 11
Syms ('sym_ids.c:sym_id_parse').  Remember that a single symspec can
match multiple symbols.  An array of symbol tables ('syms') is created,
each entry of which is a symbol table of Syms to be included or excluded
from a particular listing.  The master symbol table and the symspecs are
examined by nested loops, and every symbol that matches a symspec is
inserted into the appropriate syms table.  This is done twice, once to
count the size of each required symbol table, and again to build the
tables, which have been malloced between passes.  From now on, to
determine whether a symbol is on an include or exclude symspec list,
'gprof' simply uses its standard symbol lookup routine on the
appropriate table in the 'syms' array.
d1823 2
a1824 2
('gmon_io.c:gmon_out_read'), first by checking for a new-style
'gmon.out' header, then assuming this is an old-style BSD 'gmon.out' if
d1827 1
a1827 1
   New-style histogram records are read by 'hist.c:hist_read_rec'.  For
d1829 6
a1834 6
bins, and read them in.  When multiple profile data files (or files with
multiple histogram records) are read, the memory ranges of each pair of
histogram records must be either equal, or non-overlapping.  For each
pair of histogram records, the resolution (memory region size divided by
the number of bins) must be the same.  The time unit must be the same
for all histogram records.  If the above containts are met, all
d1837 1
a1837 1
   As each call graph record is read ('call_graph.c:cg_read_rec'), the
d1839 2
a1840 2
call graph arc is created by 'cg_arcs.c:arc_add', unless the arc fails a
symspec check against INCL_ARCS/EXCL_ARCS. As each arc is added, a
d1845 6
a1850 6
   Basic-block records are read ('basic_blocks.c:bb_read_rec'), but only
if line-by-line profiling has been selected.  Each basic-block address
is matched to a corresponding line symbol in the symbol table, and an
entry made in the symbol's bb_addr and bb_calls arrays.  Again, if
multiple basic-block records are present for the same address, the call
counts are cumulative.
d1852 1
a1852 1
   A gmon.sum file is dumped, if requested ('gmon_io.c:gmon_out_write').
d1855 11
a1865 10
('hist.c:hist_assign_samples') by iterating over all the sample bins and
assigning them to symbols.  Since the symbol table is sorted in order of
ascending memory addresses, we can simple follow along in the symbol
table as we make our pass over the sample bins.  This step includes a
symspec check against INCL_FLAT/EXCL_FLAT. Depending on the histogram
scale factor, a sample bin may span multiple symbols, in which case a
fraction of the sample count is allocated to each symbol, proportional
to the degree of overlap.  This effect is rare for normal profiling, but
overlaps are more common during line-by-line profiling, and can cause
each of two adjacent lines to be credited with half a hit, for example.
d1867 2
a1868 2
   If call graph data is present, 'cg_arcs.c:cg_assemble' is called.
First, if '-c' was specified, a machine-dependent routine ('find_call')
d1871 19
a1889 18
A topological sort is performed by depth-first numbering all the symbols
('cg_dfn.c:cg_dfn'), so that children are always numbered less than
their parents, then making a array of pointers into the symbol table and
sorting it into numerical order, which is reverse topological order
(children appear before parents).  Cycles are also detected at this
point, all members of which are assigned the same topological number.
Two passes are now made through this sorted array of symbol pointers.
The first pass, from end to beginning (parents to children), computes
the fraction of child time to propagate to each parent and a print flag.
The print flag reflects symspec handling of INCL_GRAPH/EXCL_GRAPH, with
a parent's include or exclude (print or no print) property being
propagated to its children, unless they themselves explicitly appear in
INCL_GRAPH or EXCL_GRAPH. A second pass, from beginning to end (children
to parents) actually propagates the timings along the call graph,
subject to a check against INCL_TIME/EXCL_TIME. With the print flag,
fractions, and timings now stored in the symbol structures, the
topological sort array is now discarded, and a new array of pointers is
assembled, this time sorted by propagated time.
d1892 2
a1893 2
fairly straightforward.  The call graph ('cg_print.c:cg_print') and flat
profile ('hist.c:hist_print') are regurgitations of values already
d1895 1
a1895 1
('basic_blocks.c:print_annotated_source') uses basic-block information,
d1900 1
a1900 1
source code itself ('cg_print.c').  Basically, the functions with the
d1908 1
a1908 1
9.4 Debugging 'gprof'
d1911 4
a1914 4
If 'gprof' was compiled with debugging enabled, the '-d' option triggers
debugging output (to stdout) which can be helpful in understanding its
operation.  The debugging number specified is interpreted as a sum of
the following options:
d1918 1
d1921 1
d1925 1
d1929 1
d1933 1
d1936 1
a1936 1
     file.  For line-by-line profiling ('-l' option), also shows line
d1938 1
d1940 2
a1941 1
     Trace operation of '-c' option
d1944 1
d1947 1
d1950 2
a1951 1
     meaningful with '-l' option)
d1954 1
d1956 1
a1956 1
     Tracks operation of '-A' option
d1967 1
a1967 1
     <http://fsf.org/>
d1992 2
a1993 2
     of subject matter or whether it is published as a printed book.  We
     recommend this License principally for works whose purpose is
d1999 2
a2000 2
     that contains a notice placed by the copyright holder saying it can
     be distributed under the terms of this License.  Such a notice
d2004 3
a2006 3
     of the public is a licensee, and is addressed as "you".  You accept
     the license if you copy, modify or distribute the work in a way
     requiring permission under copyright law.
d2024 6
a2029 6
     titles are designated, as being those of Invariant Sections, in the
     notice that says that the Document is released under this License.
     If a section does not fit the above definition of Secondary then it
     is not allowed to be designated as Invariant.  The Document may
     contain zero Invariant Sections.  If the Document does not identify
     any Invariant Sections then there are none.
d2040 10
a2049 10
     straightforwardly with generic text editors or (for images composed
     of pixels) generic paint programs or (for drawings) some widely
     available drawing editor, and that is suitable for input to text
     formatters or for automatic translation to a variety of formats
     suitable for input to text formatters.  A copy made in an otherwise
     Transparent file format whose markup, or absence of markup, has
     been arranged to thwart or discourage subsequent modification by
     readers is not Transparent.  An image format is not Transparent if
     used for any substantial amount of text.  A copy that is not
     "Transparent" is called "Opaque".
d2053 8
a2060 8
     SGML or XML using a publicly available DTD, and standard-conforming
     simple HTML, PostScript or PDF designed for human modification.
     Examples of transparent image formats include PNG, XCF and JPG.
     Opaque formats include proprietary formats that can be read and
     edited only by proprietary word processors, SGML or XML for which
     the DTD and/or processing tools are not generally available, and
     the machine-generated HTML, PostScript or PDF produced by some word
     processors for output purposes only.
d2098 2
a2099 2
     distribute a large enough number of copies you must also follow the
     conditions in section 3.
d2113 6
a2118 5
     front cover must present the full title with all words of the title
     equally prominent and visible.  You may add other material on the
     covers in addition.  Copying with changes limited to the covers, as
     long as they preserve the title of the Document and satisfy these
     conditions, can be treated as verbatim copying in other respects.
d2126 12
a2137 11
     numbering more than 100, you must either include a machine-readable
     Transparent copy along with each Opaque copy, or state in or with
     each Opaque copy a computer-network location from which the general
     network-using public has access to download using public-standard
     network protocols a complete Transparent copy of the Document, free
     of added material.  If you use the latter option, you must take
     reasonably prudent steps, when you begin distribution of Opaque
     copies in quantity, to ensure that this Transparent copy will
     remain thus accessible at the stated location until at least one
     year after the last time you distribute an Opaque copy (directly or
     through your agents or retailers) of that edition to the public.
d2140 3
a2142 3
     the Document well before redistributing any large number of copies,
     to give them a chance to provide you with an updated version of the
     Document.
d2148 5
a2152 5
     release the Modified Version under precisely this License, with the
     Modified Version filling the role of the Document, thus licensing
     distribution and modification of the Modified Version to whoever
     possesses a copy of it.  In addition, you must do these things in
     the Modified Version:
d2155 5
a2159 5
          distinct from that of the Document, and from those of previous
          versions (which should, if there were any, be listed in the
          History section of the Document).  You may use the same title
          as a previous version if the original publisher of that
          version gives permission.
d2189 6
a2194 6
          authors, and publisher of the Modified Version as given on the
          Title Page.  If there is no section Entitled "History" in the
          Document, create one stating the title, year, authors, and
          publisher of the Document as given on its Title Page, then add
          an item describing the Modified Version as stated in the
          previous sentence.
d2199 5
a2203 5
          previous versions it was based on.  These may be placed in the
          "History" section.  You may omit a network location for a work
          that was published at least four years before the Document
          itself, or if the original publisher of the version it refers
          to gives permission.
d2206 2
a2207 2
          Preserve the Title of the section, and preserve in the section
          all the substance and tone of each of the contributor
d2210 4
a2213 3
       L. Preserve all the Invariant Sections of the Document, unaltered
          in their text and in their titles.  Section numbers or the
          equivalent are not considered part of the section titles.
d2226 5
a2230 5
     material copied from the Document, you may at your option designate
     some or all of these sections as invariant.  To do this, add their
     titles to the list of Invariant Sections in the Modified Version's
     license notice.  These titles must be distinct from any other
     section titles.
d2239 9
a2247 9
     and a passage of up to 25 words as a Back-Cover Text, to the end of
     the list of Cover Texts in the Modified Version.  Only one passage
     of Front-Cover Text and one of Back-Cover Text may be added by (or
     through arrangements made by) any one entity.  If the Document
     already includes a cover text for the same cover, previously added
     by you or by arrangement made by the same entity you are acting on
     behalf of, you may not add another; but you may replace the old
     one, on explicit permission from the previous publisher that added
     the old one.
d2257 2
a2258 2
     modified versions, provided that you include in the combination all
     of the Invariant Sections of all of the original documents,
d2285 2
a2286 2
     rules of this License for verbatim copying of each of the documents
     in all other respects.
d2290 3
a2292 3
     a copy of this License into the extracted document, and follow this
     License in all other respects regarding verbatim copying of that
     document.
d2297 2
a2298 2
     separate and independent documents or works, in or on a volume of a
     storage or distribution medium, is called an "aggregate" if the
d2343 2
a2344 2
     provisionally, unless and until the copyright holder explicitly and
     finally terminates your license, and (b) permanently, if the
d2356 4
a2359 4
     the licenses of parties who have received copies or rights from you
     under this License.  If your rights have been terminated and not
     permanently reinstated, receipt of a copy of some or all of the
     same material does not give you any rights to use it.
d2361 1
a2361 1
  10. FUTURE REVISIONS OF THIS LICENSE
d2367 1
a2367 1
     <http://www.gnu.org/copyleft/>.
d2374 5
a2378 5
     published (not as a draft) by the Free Software Foundation.  If the
     Document does not specify a version number of this License, you may
     choose any version ever published (not as a draft) by the Free
     Software Foundation.  If the Document specifies that a proxy can
     decide which future versions of this License can be used, that
d2382 1
a2382 1
  11. RELICENSING
d2412 1
d2429 1
a2429 1
Texts, replace the "with...Texts."  line with this:
d2440 3
a2442 3
recommend releasing these examples in parallel under your choice of free
software license, such as the GNU General Public License, to permit
their use in free software.
d2447 18
a2464 18
Node: Top719
Node: Introduction2044
Node: Compiling4535
Node: Executing8591
Node: Invoking11379
Node: Output Options12794
Node: Analysis Options19886
Node: Miscellaneous Options23806
Node: Deprecated Options25060
Node: Symspecs27123
Node: Output28949
Node: Flat Profile29989
Node: Call Graph34942
Node: Primary38174
Node: Callers40762
Node: Subroutines42880
Node: Cycles44721
Node: Line-by-line51498
d2466 11
a2476 11
Node: Inaccuracy58572
Node: Sampling Error58830
Node: Assumptions61734
Node: How do I?63204
Node: Incompatibilities64761
Node: Details66255
Node: Implementation66648
Node: File Format72547
Node: Internals76835
Node: Debugging85325
Node: GNU Free Documentation License86915
@


1.5.12.2
log
@Sync with HEAD, resolve a couple of conflicts
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 6.4 from gprof.texi.
d30 1
a30 1
   This manual is for 'gprof' (GNU Binutils) version 2.30.90.
d2428 29
a2456 29
Node: Introduction2045
Node: Compiling4536
Node: Executing8592
Node: Invoking11380
Node: Output Options12795
Node: Analysis Options19887
Node: Miscellaneous Options23807
Node: Deprecated Options25061
Node: Symspecs27124
Node: Output28950
Node: Flat Profile29990
Node: Call Graph34943
Node: Primary38175
Node: Callers40763
Node: Subroutines42881
Node: Cycles44722
Node: Line-by-line51499
Node: Annotated Source55575
Node: Inaccuracy58573
Node: Sampling Error58831
Node: Assumptions61735
Node: How do I?63205
Node: Incompatibilities64762
Node: Details66256
Node: Implementation66649
Node: File Format72548
Node: Internals76836
Node: Debugging85326
Node: GNU Free Documentation License86916
@


1.4
log
@merge conflicts, regen for x86.
@
text
@d10 1
a10 1
   Copyright (C) 1988-2015 Free Software Foundation, Inc.
d30 1
a30 1
   This manual is for `gprof' (GNU Binutils) version 2.26.
@


1.4.2.1
log
@Sync with HEAD
@
text
@d10 1
a10 1
   Copyright (C) 1988-2016 Free Software Foundation, Inc.
d30 1
a30 1
   This manual is for `gprof' (GNU Binutils) version 2.27.
@


1.3
log
@resolve conflicts
@
text
@d10 1
a10 2
   Copyright (C) 1988, 1992, 1997, 1998, 1999, 2000, 2001, 2003, 2007,
2008, 2009 Free Software Foundation, Inc.
d30 1
a30 1
   This manual is for `gprof' (GNU Binutils) version 2.23.1.
d530 5
d2447 30
a2476 30
Node: Top777
Node: Introduction2103
Node: Compiling4595
Node: Executing8651
Node: Invoking11439
Node: Output Options12854
Node: Analysis Options19943
Node: Miscellaneous Options23641
Node: Deprecated Options24896
Node: Symspecs26965
Node: Output28791
Node: Flat Profile29831
Node: Call Graph34784
Node: Primary38016
Node: Callers40604
Node: Subroutines42721
Node: Cycles44562
Node: Line-by-line51339
Node: Annotated Source55412
Node: Inaccuracy58411
Node: Sampling Error58669
Node: Assumptions61573
Node: How do I?63043
Node: Incompatibilities64597
Node: Details66091
Node: Implementation66484
Node: File Format72381
Node: Internals76671
Node: Debugging85166
Node: GNU Free Documentation License86767
@


1.2
log
@Merge new binutils. Only x86_64 works now; the rest will need to run mknative
again (at least).
@
text
@d31 1
a31 1
   This manual is for `gprof' (GNU Binutils)\ version 2.21.1.
@


1.2.8.1
log
@Rebase to HEAD as of a few days ago.
@
text
@d31 1
a31 1
   This manual is for `gprof' (GNU Binutils) version 2.23.1.
@


1.2.2.1
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@d31 1
a31 1
   This manual is for `gprof' (GNU Binutils) version 2.23.1.
@


1.1
log
@Initial revision
@
text
@d3 1
d10 2
a11 2
   Copyright (C) 1988, 92, 97, 98, 99, 2000, 2001, 2003, 2007 Free
Software Foundation, Inc.
d14 1
a14 1
under the terms of the GNU Free Documentation License, Version 1.1 or
d31 1
a31 1
   This manual is for `gprof' (GNU Binutils) version 2.18.90.
d34 2
a35 2
Documentation License.  A copy of the license is included in the
section entitled "GNU Free Documentation License".
d166 11
d546 7
d607 1
a607 2
     These options have been replaced with newer versions that use
     symspecs.
d1393 6
a1398 1
vary from run to run if your program is deterministic.
d1960 1
a1960 1
                        Version 1.1, March 2000
d1962 2
a1963 2
     Copyright (C) 2000, 2003 Free Software Foundation, Inc.
     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
a1967 1

d1971 6
a1976 6
     written document "free" in the sense of freedom: to assure everyone
     the effective freedom to copy and redistribute it, with or without
     modifying it, either commercially or noncommercially.  Secondarily,
     this License preserves for the author and publisher a way to get
     credit for their work, while not being considered responsible for
     modifications made by others.
a1991 1

d1994 9
a2002 5
     This License applies to any manual or other work that contains a
     notice placed by the copyright holder saying it can be distributed
     under the terms of this License.  The "Document", below, refers to
     any such manual or work.  Any member of the public is a licensee,
     and is addressed as "you."
d2008 10
a2017 10
     A "Secondary Section" is a named appendix or a front-matter
     section of the Document that deals exclusively with the
     relationship of the publishers or authors of the Document to the
     Document's overall subject (or to related matters) and contains
     nothing that could fall directly within that overall subject.
     (For example, if the Document is in part a textbook of
     mathematics, a Secondary Section may not explain any mathematics.)
     The relationship could be a matter of historical connection with
     the subject or with related matters, or of legal, commercial,
     philosophical, ethical or political position regarding them.
d2022 4
a2025 1
     License.
d2029 3
a2031 1
     that says that the Document is released under this License.
d2035 2
a2036 2
     general public, whose contents can be viewed and edited directly
     and straightforwardly with generic text editors or (for images
d2041 5
a2045 3
     otherwise Transparent file format whose markup has been designed
     to thwart or discourage subsequent modification by readers is not
     Transparent.  A copy that is not "Transparent" is called "Opaque."
d2050 7
a2056 6
     standard-conforming simple HTML designed for human modification.
     Opaque formats include PostScript, PDF, proprietary formats that
     can be read and edited only by proprietary word processors, SGML
     or XML for which the DTD and/or processing tools are not generally
     available, and the machine-generated HTML produced by some word
     processors for output purposes only.
d2065 19
d2102 5
a2106 4
     If you publish printed copies of the Document numbering more than
     100, and the Document's license notice requires Cover Texts, you
     must enclose the copies in covers that carry, clearly and legibly,
     all these Cover Texts: Front-Cover Texts on the front cover, and
d2124 4
a2127 5
     state in or with each Opaque copy a publicly-accessible
     computer-network location containing a complete Transparent copy
     of the Document, free of added material, which the general
     network-using public has access to download anonymously at no
     charge using public-standard network protocols.  If you use the
d2150 69
a2218 51
     A. Use in the Title Page (and on the covers, if any) a title
     distinct    from that of the Document, and from those of previous
     versions    (which should, if there were any, be listed in the
     History section    of the Document).  You may use the same title
     as a previous version    if the original publisher of that version
     gives permission.
     B. List on the Title Page, as authors, one or more persons or
     entities    responsible for authorship of the modifications in the
     Modified    Version, together with at least five of the principal
     authors of the    Document (all of its principal authors, if it
     has less than five).
     C. State on the Title page the name of the publisher of the
     Modified Version, as the publisher.
     D. Preserve all the copyright notices of the Document.
     E. Add an appropriate copyright notice for your modifications
     adjacent to the other copyright notices.
     F. Include, immediately after the copyright notices, a license
     notice    giving the public permission to use the Modified Version
     under the    terms of this License, in the form shown in the
     Addendum below.
     G. Preserve in that license notice the full lists of Invariant
     Sections    and required Cover Texts given in the Document's
     license notice.
     H. Include an unaltered copy of this License.
     I. Preserve the section entitled "History", and its title, and add
     to    it an item stating at least the title, year, new authors, and
       publisher of the Modified Version as given on the Title Page.
     If    there is no section entitled "History" in the Document,
     create one    stating the title, year, authors, and publisher of
     the Document as    given on its Title Page, then add an item
     describing the Modified    Version as stated in the previous
     sentence.
     J. Preserve the network location, if any, given in the Document for
       public access to a Transparent copy of the Document, and
     likewise    the network locations given in the Document for
     previous versions    it was based on.  These may be placed in the
     "History" section.     You may omit a network location for a work
     that was published at    least four years before the Document
     itself, or if the original    publisher of the version it refers
     to gives permission.
     K. In any section entitled "Acknowledgements" or "Dedications",
     preserve the section's title, and preserve in the section all the
      substance and tone of each of the contributor acknowledgements
     and/or dedications given therein.
     L. Preserve all the Invariant Sections of the Document,
     unaltered in their text and in their titles.  Section numbers
     or the equivalent are not considered part of the section titles.
     M. Delete any section entitled "Endorsements."  Such a section
     may not be included in the Modified Version.
     N. Do not retitle any existing section as "Endorsements"    or to
     conflict in title with any Invariant Section.
d2228 1
a2228 1
     You may add a section entitled "Endorsements", provided it contains
d2230 3
a2232 3
     parties-for example, statements of peer review or that the text has
     been approved by an organization as the authoritative definition
     of a standard.
d2256 2
a2257 1
     combined work in its license notice.
d2269 1
a2269 1
     In the combination, you must combine any sections entitled
d2271 3
a2273 3
     entitled "History"; likewise combine any sections entitled
     "Acknowledgements", and any sections entitled "Dedications."  You
     must delete all sections entitled "Endorsements."
d2294 6
a2299 7
     a storage or distribution medium, does not as a whole count as a
     Modified Version of the Document, provided no compilation
     copyright is claimed for the compilation.  Such a compilation is
     called an "aggregate", and this License does not apply to the
     other self-contained works thus compiled with the Document, on
     account of their being thus compiled, if they are not themselves
     derivative works of the Document.
d2302 6
a2307 5
     copies of the Document, then if the Document is less than one
     quarter of the entire aggregate, the Document's Cover Texts may be
     placed on covers that surround only the Document within the
     aggregate.  Otherwise they must appear on covers around the whole
     aggregate.
d2317 12
a2328 4
     translation of this License provided that you also include the
     original English version of this License.  In case of a
     disagreement between the translation and the original English
     version of this License, the original English version will prevail.
d2333 23
a2355 6
     except as expressly provided for under this License.  Any other
     attempt to copy, modify, sublicense or distribute the Document is
     void, and will automatically terminate your rights under this
     License.  However, parties who have received copies, or rights,
     from you under this License will not have their licenses
     terminated so long as such parties remain in full compliance.
d2363 1
a2363 1
     http://www.gnu.org/copyleft/.
d2373 34
a2406 1
     Free Software Foundation.
d2416 18
a2433 13
     Copyright (C)  YEAR  YOUR NAME.
     Permission is granted to copy, distribute and/or modify this document
     under the terms of the GNU Free Documentation License, Version 1.1
     or any later version published by the Free Software Foundation;
     with the Invariant Sections being LIST THEIR TITLES, with the
     Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
     A copy of the license is included in the section entitled "GNU
     Free Documentation License."

   If you have no Invariant Sections, write "with no Invariant Sections"
instead of saying which ones are invariant.  If you have no Front-Cover
Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being
LIST"; likewise for Back-Cover Texts.
d2443 30
a2472 30
Node: Top719
Node: Introduction2033
Node: Compiling4525
Node: Executing7996
Node: Invoking10784
Node: Output Options12199
Node: Analysis Options19288
Node: Miscellaneous Options22689
Node: Deprecated Options23944
Node: Symspecs26023
Node: Output27849
Node: Flat Profile28889
Node: Call Graph33842
Node: Primary37074
Node: Callers39662
Node: Subroutines41779
Node: Cycles43620
Node: Line-by-line50397
Node: Annotated Source54470
Node: Inaccuracy57469
Node: Sampling Error57727
Node: Assumptions60297
Node: How do I?61767
Node: Incompatibilities63321
Node: Details64815
Node: Implementation65208
Node: File Format71105
Node: Internals75395
Node: Debugging83890
Node: GNU Free Documentation License85491
@


1.1.1.1
log
@Import binutils 2.19.1 as requested by matt@@

OK'ed by board@@
@
text
@@


1.1.1.2
log
@from ftp.gnu.org
@
text
@a2 1
INFO-DIR-SECTION Software development
d9 2
a10 2
   Copyright (C) 1988, 1992, 1997, 1998, 1999, 2000, 2001, 2003, 2007,
2008, 2009 Free Software Foundation, Inc.
d13 1
a13 1
under the terms of the GNU Free Documentation License, Version 1.3 or
d30 1
a30 1
   This manual is for `gprof' (GNU Binutils) version 2.21.1.
d33 2
a34 2
Documentation License version 1.3.  A copy of the license is included
in the section entitled "GNU Free Documentation License".
a164 11
   If you are running the program on a system which supports shared
libraries you may run into problems with the profiling support code in
a shared library being called before that library has been fully
initialised.  This is usually detected by the program encountering a
segmentation fault as soon as it is run.  The solution is to link
against a static version of the library containing the profiling
support code, which for `gcc' users can be done via the `-static' or
`-static-libgcc' command line option.  For example:

     gcc -g -pg -static-libgcc myprog.c utils.c -o myprog

a533 7
`-SFILENAME'
`--external-symbol-table=FILENAME'
     The `-S' option causes `gprof' to read an external symbol table
     file, such as `/proc/kallsyms', rather than read the symbol table
     from the given object file (the default is `a.out'). This is useful
     for profiling kernel modules.

d588 2
a589 1
These options have been replaced with newer versions that use symspecs.
d1375 1
a1375 6
vary from run to run if your program is deterministic and single
threaded.  In multi-threaded applications, or single threaded
applications that link with multi-threaded libraries, the counts are
only deterministic if the counting function is thread-safe.  (Note:
beware that the mcount counting function in glibc is _not_
thread-safe).  *Note Implementation of Profiling: Implementation.
d1937 1
a1937 1
                     Version 1.3, 3 November 2008
d1939 2
a1940 2
     Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
     `http://fsf.org/'
d1945 1
d1949 6
a1954 6
     functional and useful document "free" in the sense of freedom: to
     assure everyone the effective freedom to copy and redistribute it,
     with or without modifying it, either commercially or
     noncommercially.  Secondarily, this License preserves for the
     author and publisher a way to get credit for their work, while not
     being considered responsible for modifications made by others.
d1970 1
d1973 5
a1977 9
     This License applies to any manual or other work, in any medium,
     that contains a notice placed by the copyright holder saying it
     can be distributed under the terms of this License.  Such a notice
     grants a world-wide, royalty-free license, unlimited in duration,
     to use that work under the conditions stated herein.  The
     "Document", below, refers to any such manual or work.  Any member
     of the public is a licensee, and is addressed as "you".  You
     accept the license if you copy, modify or distribute the work in a
     way requiring permission under copyright law.
d1983 10
a1992 10
     A "Secondary Section" is a named appendix or a front-matter section
     of the Document that deals exclusively with the relationship of the
     publishers or authors of the Document to the Document's overall
     subject (or to related matters) and contains nothing that could
     fall directly within that overall subject.  (Thus, if the Document
     is in part a textbook of mathematics, a Secondary Section may not
     explain any mathematics.)  The relationship could be a matter of
     historical connection with the subject or with related matters, or
     of legal, commercial, philosophical, ethical or political position
     regarding them.
d1997 1
a1997 4
     License.  If a section does not fit the above definition of
     Secondary then it is not allowed to be designated as Invariant.
     The Document may contain zero Invariant Sections.  If the Document
     does not identify any Invariant Sections then there are none.
d2001 1
a2001 3
     that says that the Document is released under this License.  A
     Front-Cover Text may be at most 5 words, and a Back-Cover Text may
     be at most 25 words.
d2005 2
a2006 2
     general public, that is suitable for revising the document
     straightforwardly with generic text editors or (for images
d2011 3
a2013 5
     otherwise Transparent file format whose markup, or absence of
     markup, has been arranged to thwart or discourage subsequent
     modification by readers is not Transparent.  An image format is
     not Transparent if used for any substantial amount of text.  A
     copy that is not "Transparent" is called "Opaque".
d2018 6
a2023 7
     standard-conforming simple HTML, PostScript or PDF designed for
     human modification.  Examples of transparent image formats include
     PNG, XCF and JPG.  Opaque formats include proprietary formats that
     can be read and edited only by proprietary word processors, SGML or
     XML for which the DTD and/or processing tools are not generally
     available, and the machine-generated HTML, PostScript or PDF
     produced by some word processors for output purposes only.
a2031 19
     The "publisher" means any person or entity that distributes copies
     of the Document to the public.

     A section "Entitled XYZ" means a named subunit of the Document
     whose title either is precisely XYZ or contains XYZ in parentheses
     following text that translates XYZ in another language.  (Here XYZ
     stands for a specific section name mentioned below, such as
     "Acknowledgements", "Dedications", "Endorsements", or "History".)
     To "Preserve the Title" of such a section when you modify the
     Document means that it remains a section "Entitled XYZ" according
     to this definition.

     The Document may include Warranty Disclaimers next to the notice
     which states that this License applies to the Document.  These
     Warranty Disclaimers are considered to be included by reference in
     this License, but only as regards disclaiming warranties: any other
     implication that these Warranty Disclaimers may have is void and
     has no effect on the meaning of this License.

d2050 4
a2053 5
     If you publish printed copies (or copies in media that commonly
     have printed covers) of the Document, numbering more than 100, and
     the Document's license notice requires Cover Texts, you must
     enclose the copies in covers that carry, clearly and legibly, all
     these Cover Texts: Front-Cover Texts on the front cover, and
d2071 5
a2075 4
     state in or with each Opaque copy a computer-network location from
     which the general network-using public has access to download
     using public-standard network protocols a complete Transparent
     copy of the Document, free of added material.  If you use the
d2098 51
a2148 69
       A. Use in the Title Page (and on the covers, if any) a title
          distinct from that of the Document, and from those of
          previous versions (which should, if there were any, be listed
          in the History section of the Document).  You may use the
          same title as a previous version if the original publisher of
          that version gives permission.

       B. List on the Title Page, as authors, one or more persons or
          entities responsible for authorship of the modifications in
          the Modified Version, together with at least five of the
          principal authors of the Document (all of its principal
          authors, if it has fewer than five), unless they release you
          from this requirement.

       C. State on the Title page the name of the publisher of the
          Modified Version, as the publisher.

       D. Preserve all the copyright notices of the Document.

       E. Add an appropriate copyright notice for your modifications
          adjacent to the other copyright notices.

       F. Include, immediately after the copyright notices, a license
          notice giving the public permission to use the Modified
          Version under the terms of this License, in the form shown in
          the Addendum below.

       G. Preserve in that license notice the full lists of Invariant
          Sections and required Cover Texts given in the Document's
          license notice.

       H. Include an unaltered copy of this License.

       I. Preserve the section Entitled "History", Preserve its Title,
          and add to it an item stating at least the title, year, new
          authors, and publisher of the Modified Version as given on
          the Title Page.  If there is no section Entitled "History" in
          the Document, create one stating the title, year, authors,
          and publisher of the Document as given on its Title Page,
          then add an item describing the Modified Version as stated in
          the previous sentence.

       J. Preserve the network location, if any, given in the Document
          for public access to a Transparent copy of the Document, and
          likewise the network locations given in the Document for
          previous versions it was based on.  These may be placed in
          the "History" section.  You may omit a network location for a
          work that was published at least four years before the
          Document itself, or if the original publisher of the version
          it refers to gives permission.

       K. For any section Entitled "Acknowledgements" or "Dedications",
          Preserve the Title of the section, and preserve in the
          section all the substance and tone of each of the contributor
          acknowledgements and/or dedications given therein.

       L. Preserve all the Invariant Sections of the Document,
          unaltered in their text and in their titles.  Section numbers
          or the equivalent are not considered part of the section
          titles.

       M. Delete any section Entitled "Endorsements".  Such a section
          may not be included in the Modified Version.

       N. Do not retitle any existing section to be Entitled
          "Endorsements" or to conflict in title with any Invariant
          Section.

       O. Preserve any Warranty Disclaimers.
d2158 1
a2158 1
     You may add a section Entitled "Endorsements", provided it contains
d2160 3
a2162 3
     parties--for example, statements of peer review or that the text
     has been approved by an organization as the authoritative
     definition of a standard.
d2186 1
a2186 2
     combined work in its license notice, and that you preserve all
     their Warranty Disclaimers.
d2198 1
a2198 1
     In the combination, you must combine any sections Entitled
d2200 3
a2202 3
     Entitled "History"; likewise combine any sections Entitled
     "Acknowledgements", and any sections Entitled "Dedications".  You
     must delete all sections Entitled "Endorsements."
d2223 7
a2229 6
     a storage or distribution medium, is called an "aggregate" if the
     copyright resulting from the compilation is not used to limit the
     legal rights of the compilation's users beyond what the individual
     works permit.  When the Document is included in an aggregate, this
     License does not apply to the other works in the aggregate which
     are not themselves derivative works of the Document.
d2232 5
a2236 6
     copies of the Document, then if the Document is less than one half
     of the entire aggregate, the Document's Cover Texts may be placed
     on covers that bracket the Document within the aggregate, or the
     electronic equivalent of covers if the Document is in electronic
     form.  Otherwise they must appear on printed covers that bracket
     the whole aggregate.
d2246 4
a2249 12
     translation of this License, and all the license notices in the
     Document, and any Warranty Disclaimers, provided that you also
     include the original English version of this License and the
     original versions of those notices and disclaimers.  In case of a
     disagreement between the translation and the original version of
     this License or a notice or disclaimer, the original version will
     prevail.

     If a section in the Document is Entitled "Acknowledgements",
     "Dedications", or "History", the requirement (section 4) to
     Preserve its Title (section 1) will typically require changing the
     actual title.
d2254 6
a2259 23
     except as expressly provided under this License.  Any attempt
     otherwise to copy, modify, sublicense, or distribute it is void,
     and will automatically terminate your rights under this License.

     However, if you cease all violation of this License, then your
     license from a particular copyright holder is reinstated (a)
     provisionally, unless and until the copyright holder explicitly
     and finally terminates your license, and (b) permanently, if the
     copyright holder fails to notify you of the violation by some
     reasonable means prior to 60 days after the cessation.

     Moreover, your license from a particular copyright holder is
     reinstated permanently if the copyright holder notifies you of the
     violation by some reasonable means, this is the first time you have
     received notice of violation of this License (for any work) from
     that copyright holder, and you cure the violation prior to 30 days
     after your receipt of the notice.

     Termination of your rights under this section does not terminate
     the licenses of parties who have received copies or rights from
     you under this License.  If your rights have been terminated and
     not permanently reinstated, receipt of a copy of some or all of
     the same material does not give you any rights to use it.
d2267 1
a2267 1
     `http://www.gnu.org/copyleft/'.
d2277 1
a2277 34
     Free Software Foundation.  If the Document specifies that a proxy
     can decide which future versions of this License can be used, that
     proxy's public statement of acceptance of a version permanently
     authorizes you to choose that version for the Document.

 11. RELICENSING

     "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
     World Wide Web server that publishes copyrightable works and also
     provides prominent facilities for anybody to edit those works.  A
     public wiki that anybody can edit is an example of such a server.
     A "Massive Multiauthor Collaboration" (or "MMC") contained in the
     site means any set of copyrightable works thus published on the MMC
     site.

     "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
     license published by Creative Commons Corporation, a not-for-profit
     corporation with a principal place of business in San Francisco,
     California, as well as future copyleft versions of that license
     published by that same organization.

     "Incorporate" means to publish or republish a Document, in whole or
     in part, as part of another Document.

     An MMC is "eligible for relicensing" if it is licensed under this
     License, and if all works that were first published under this
     License somewhere other than this MMC, and subsequently
     incorporated in whole or in part into the MMC, (1) had no cover
     texts or invariant sections, and (2) were thus incorporated prior
     to November 1, 2008.

     The operator of an MMC Site may republish an MMC contained in the
     site under CC-BY-SA on the same site at any time before August 1,
     2009, provided the MMC is eligible for relicensing.
d2287 13
a2299 18
       Copyright (C)  YEAR  YOUR NAME.
       Permission is granted to copy, distribute and/or modify this document
       under the terms of the GNU Free Documentation License, Version 1.3
       or any later version published by the Free Software Foundation;
       with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
       Texts.  A copy of the license is included in the section entitled ``GNU
       Free Documentation License''.

   If you have Invariant Sections, Front-Cover Texts and Back-Cover
Texts, replace the "with...Texts." line with this:

         with the Invariant Sections being LIST THEIR TITLES, with
         the Front-Cover Texts being LIST, and with the Back-Cover Texts
         being LIST.

   If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
d2309 30
a2338 30
Node: Top777
Node: Introduction2102
Node: Compiling4594
Node: Executing8650
Node: Invoking11438
Node: Output Options12853
Node: Analysis Options19942
Node: Miscellaneous Options23640
Node: Deprecated Options24895
Node: Symspecs26964
Node: Output28790
Node: Flat Profile29830
Node: Call Graph34783
Node: Primary38015
Node: Callers40603
Node: Subroutines42720
Node: Cycles44561
Node: Line-by-line51338
Node: Annotated Source55411
Node: Inaccuracy58410
Node: Sampling Error58668
Node: Assumptions61572
Node: How do I?63042
Node: Incompatibilities64596
Node: Details66090
Node: Implementation66483
Node: File Format72380
Node: Internals76670
Node: Debugging85165
Node: GNU Free Documentation License86766
@


1.1.1.3
log
@from ftp.gnu.org
@
text
@d31 1
a31 1
   This manual is for `gprof' (GNU Binutils) version 2.23.1.
@


1.1.1.4
log
@Import binutils-2.26
@
text
@d10 2
a11 1
   Copyright (C) 1988-2015 Free Software Foundation, Inc.
d31 1
a31 1
   This manual is for `gprof' (GNU Binutils) version 2.26.
a530 5
`--inline-file-names'
     This option causes `gprof' to print the source file after each
     symbol in both the flat profile and the call graph. The full path
     to the file is printed if used with the `-L' option.

d2443 30
a2472 30
Node: Top722
Node: Introduction2045
Node: Compiling4537
Node: Executing8593
Node: Invoking11381
Node: Output Options12796
Node: Analysis Options19885
Node: Miscellaneous Options23803
Node: Deprecated Options25058
Node: Symspecs27127
Node: Output28953
Node: Flat Profile29993
Node: Call Graph34946
Node: Primary38178
Node: Callers40766
Node: Subroutines42883
Node: Cycles44724
Node: Line-by-line51501
Node: Annotated Source55574
Node: Inaccuracy58573
Node: Sampling Error58831
Node: Assumptions61735
Node: How do I?63205
Node: Incompatibilities64759
Node: Details66253
Node: Implementation66646
Node: File Format72543
Node: Internals76833
Node: Debugging85328
Node: GNU Free Documentation License86929
@


1.1.1.5
log
@Import binutils-2.27 minus the testsuites
@
text
@d10 1
a10 1
   Copyright (C) 1988-2016 Free Software Foundation, Inc.
d30 1
a30 1
   This manual is for `gprof' (GNU Binutils) version 2.27.
@


1.1.1.6
log
@2018-01-10  Nick Clifton  <nickc@@redhat.com>

	* config-ml.in: Sync with gcc sources.
	* config.guess: Likewise.
	* config.sub: Likewise.
	* configure.ac: Likewise.
	* configure: Regenerate.

2017-12-14  Nick Clifton  <nickc@@redhat.com>

	* COPYING.LIBGLOSS: Update address of FSF in copyright notice.

2017-12-12  Stafford Horne  <shorne@@gmail.com>

	* configure.ac: Remove logic adding gdb to noconfigsdirs for or1k.
	* configure: Regenerate.

2017-09-15  Nick Clifton  <nickc@@redhat.com>

	* src-release.sh (LZIPPROG): New define.  Provides the name of the
	lzip program.
	(do_lz): New function.  Compresses a tarball using the lzip
	program.
	(do_compress): Add support for lzip compression.
	(usage): Mention -l option.
	(build_release): Support -l option to invoke lzip compression.

2017-09-15  Alan Modra  <amodra@@gmail.com>

	* src-release.sh (do_proto_toplev): Revert last patch.  Enable or
	disable binutils, gas, gdb, gold, gprof, ld, libdecnumber, readline,
	and sim depending on $tool and $support_files.  Echo configure line.

2017-09-14  Matt Rice <ratmice@@gmail.com>

	* src-release.sh (do_proto_toplev): Enable gold during release process.

2017-04-13  Andrew Jenner  <andrew@@codesourcery.com>

	* config.sub: Sync with master version in config project.

2017-04-03  Andrew Jenner  <andrew@@codesourcery.com>

	* config.sub: Handle ia16 in $basic_machine.

	bfd/
	* config.bfd: Handle ia16.

	gas/
	* configure.tgt: Handle ia16.

	ld/
	* configure.tgt: Handle ia16.

2017-03-22  Nick Clifton  <nickc@@redhat.com>

	* config.sub: Sync with master version in config project.
	* config.guess: Likewise.

2017-01-23  Nick Clifton  <nickc@@redhat.com>

	* configure.ac: Update year in copyright notice.
	Sync from FSF GCC mainline, bringing in the following patches.
	* Makefile.def: Likewise.
	* Makefile.tpl: Likewise.
	* configure: Regenerate.
	* Makefile.in: Regenerate.

	2016-12-21  Jakub Jelinek  <jakub@@redhat.com>

	* configure.ac: Don't bootstrap libmpx unless --with-build-config
	includes bootstrap-mpx.

	2016-12-01  Matthias Klose  <doko@@ubuntu.com>

	* configure.ac: Don't use pkg-config to check for bdw-gc.

	2016-11-30  Matthias Klose  <doko@@ubuntu.com>

	* Makefile.def: Remove reference to boehm-gc target module.
  	* configure.ac: Include pkg.m4, check for --with-target-bdw-gc
	options and for the bdw-gc pkg-config module.

	2016-11-15  Matthias Klose  <doko@@ubuntu.com>

	* config-ml.in: Remove references to GCJ.
	* configure.ac: Likewise.

	2016-09-30  Jakub Jelinek  <jakub@@redhat.com>

	* configure.ac: Add target-libffi to target_libraries.
	Readd libgcj target disablings, modified to only target-libffi.
	Readd target addition of go to unsupported languages.

	2016-09-30  Andrew Haley  <aph@@redhat.com>

	* Makefile.def: Remove libjava.
	* Makefile.tpl: Likewise.
	* configure.ac: Likewise.

	2016-09-26  Anton Kolesov  <Anton.Kolesov@@synopsys.com>

	* configure.ac: Disable "sim" directory for arc*-*-*.

	2016-09-12  Maciej W. Rozycki  <macro@@imgtec.com>

	* configure.ac: Check for the minimum in-tree MPFR version
	handled.

2016-12-31  Alan Modra  <amodra@@gmail.com>

	* config.sub: Import from upstream.

2016-12-08  Alan Modra  <amodra@@gmail.com>

	* configure: Regenerate.

2016-12-02  Josh Conner  <joshconner@@google.com>

	* configure.ac: Add fuchsia to targets that use ELF.
	* configure: Regenerated.

2016-11-07  Doug Evans  <dje@@google.com>

	* config.sub: Sync with upstream version 2016-11-03.
	git://git.sv.gnu.org/config.git
	* config.guess: Sync with upstream version 2016-10-02.

2016-09-27  Simon Marchi  <simon.marchi@@polymtl.ca>

	* .gitignore: Add archives and make stamps.

2016-07-20  Yan-Ting Lin  <currygt52@@gmail.com>

	* configure.ac (nds32*-*-*): Remove entry to enable gdb.
	* configure: Regenerated.
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 6.3 from gprof.texi.
d3 6
a8 1
This file documents the gprof profiler of the GNU system.
d10 1
a10 1
   Copyright (C) 1988-2018 Free Software Foundation, Inc.
a18 5
INFO-DIR-SECTION Software development
START-INFO-DIR-ENTRY
* gprof: (gprof).                Profiling your program's execution
END-INFO-DIR-ENTRY

d25 1
a25 1
This manual describes the GNU profiler, 'gprof', and how you can use it
d28 1
a28 1
programs.  GNU 'gprof' was written by Jay Fenlason.
d30 1
a30 1
   This manual is for 'gprof' (GNU Binutils) version 2.30.0.
d33 2
a34 2
Documentation License version 1.3.  A copy of the license is included in
the section entitled "GNU Free Documentation License".
d42 1
a42 1
* Invoking::            How to run 'gprof', and its options
d44 1
a44 1
* Output::              Interpreting 'gprof''s output
d48 1
a48 1
* Incompatibilities::   (between GNU 'gprof' and Unix 'gprof'.)
d67 6
a72 5
execution of your program, it can be used on programs that are too large
or too complex to analyze by reading the source.  However, how your
program is run will affect the information that shows up in the profile
data.  If you don't use some feature of your program while it is being
profiled, no profile information will be generated for that feature.
d82 1
a82 1
   * You must run 'gprof' to analyze the profile data.  *Note 'gprof'
d94 6
a99 5
   The "call graph" shows, for each function, which functions called it,
which other functions it called, and how many times.  There is also an
estimate of how much time was spent in the subroutines of each function.
This can suggest places where you might try to eliminate function calls
that use a lot of time.  *Note The Call Graph: Call Graph.
d118 1
a118 1
   To compile a source file for profiling, specify the '-pg' option when
d122 3
a124 3
   To link the program for profiling, if you use a compiler such as 'cc'
to do the linking, simply specify '-pg' in addition to your usual
options.  The same option, '-pg', alters either compilation or linking
d130 1
a130 1
   The '-pg' option also works with a command that both compiles and
d135 3
a137 3
   Note: The '-pg' option must be part of your compilation options as
well as your link options.  If it is not then no call-graph data will be
gathered and when you run 'gprof' you will get an error message like
d142 2
a143 2
   If you add the '-Q' switch to suppress the printing of the call graph
data you will still be able to see the time samples:
d154 8
a161 8
   If you run the linker 'ld' directly instead of through a compiler
such as 'cc', you may have to specify a profiling startup file 'gcrt0.o'
as the first input file instead of the usual startup file 'crt0.o'.  In
addition, you would probably want to specify the profiling C library,
'libc_p.a', by writing '-lc_p' instead of the usual '-lc'.  This is not
absolutely necessary, but doing this gives you number-of-calls
information for standard library functions such as 'read' and 'open'.
For example:
d166 2
a167 2
libraries you may run into problems with the profiling support code in a
shared library being called before that library has been fully
d170 3
a172 3
against a static version of the library containing the profiling support
code, which for 'gcc' users can be done via the '-static' or
'-static-libgcc' command line option.  For example:
d176 1
a176 1
   If you compile only some of the modules of the program with '-pg',
d178 6
a183 6
information about the modules that were compiled without '-pg'.  The
only information you get for the functions in those modules is the total
time spent in them; there is no record of how many times they were
called, or from where.  This will not affect the flat profile (except
that the 'calls' field for the functions will be blank), but will
greatly reduce the usefulness of the call graph.
d186 1
a186 1
'gcov' tool instead of 'gprof'.  See that tool's manual or info pages
d189 3
a191 3
   Note, older versions of 'gcc' produce line-by-line profiling
information that works with 'gprof' rather than 'gcov' so there is still
support for displaying this kind of information in 'gprof'.  *Note
d194 5
a198 5
   It also worth noting that 'gcc' implements a '-finstrument-functions'
command line option which will insert calls to special user supplied
instrumentation routines at the entry and exit of every function in
their program.  This can be used to implement an alternative profiling
scheme.
d207 1
a207 1
generate the information that 'gprof' needs.  Simply run the program as
d221 2
a222 2
'gmon.out' just before exiting.  If there is already a file called
'gmon.out', its contents are overwritten.  There is currently no way to
d227 3
a229 3
   In order to write the 'gmon.out' file properly, your program must
exit normally: by returning from 'main' or by calling 'exit'.  Calling
the low-level function '_exit' does not write the profile data, and
d232 1
a232 1
   The 'gmon.out' file is written in the program's _current working
d234 2
a235 2
'chdir', the 'gmon.out' file will be left in the last directory your
program 'chdir''d to.  If you don't have permission to write in this
d239 1
a239 1
called 'bb.out'.  This file, if present, contains an human-readable
d241 4
a244 4
appearance of a human-readable 'bb.out' means the basic-block counts
didn't get written into 'gmon.out'.  The Perl script 'bbconv.pl',
included with the 'gprof' source distribution, will convert a 'bb.out'
file into a format readable by 'gprof'.  Invoke it like this:
d248 2
a249 2
   This translates the information in 'bb.out' into a form that 'gprof'
can understand.  But you still need to tell 'gprof' about the existence
d251 1
a251 1
'gprof' command line, _along with 'gmon.out'_, like this:
d258 1
a258 1
4 'gprof' Command Summary
d261 2
a262 2
After you have a profile data file 'gmon.out', you can run 'gprof' to
interpret the information in it.  The 'gprof' program prints a flat
d264 1
a264 1
redirect the output of 'gprof' into a file with '>'.
d266 1
a266 1
   You run 'gprof' like this:
d272 5
a276 4
   If you omit the executable file name, the file 'a.out' is used.  If
you give no profile data file name, the file 'gmon.out' is used.  If any
file is not in the proper format, or if the profile data file does not
appear to belong to the executable file, an error message is printed.
d286 2
a287 2
* Output Options::      Controlling 'gprof''s output style
* Analysis Options::    Controlling how 'gprof' analyzes its data
d299 1
a299 1
These options specify which of several output formats 'gprof' should
d302 4
a305 4
   Many of these options take an optional "symspec" to specify functions
to be included or excluded.  These options can be specified multiple
times, with different symspecs, to include or exclude sets of symbols.
*Note Symspecs: Symspecs.
d307 1
a307 1
   Specifying any of these options overrides the default ('-p -q'),
d310 3
a312 3
'-A[SYMSPEC]'
'--annotated-source[=SYMSPEC]'
     The '-A' option causes 'gprof' to print annotated source code.  If
d316 3
a318 3
'-b'
'--brief'
     If the '-b' option is given, 'gprof' doesn't print the verbose
d323 3
a325 3
'-C[SYMSPEC]'
'--exec-counts[=SYMSPEC]'
     The '-C' option causes 'gprof' to print a tally of functions and
d330 1
a330 1
     specifying the '-l' option, along with '-C', will cause basic-block
d333 9
a341 9
'-i'
'--file-info'
     The '-i' option causes 'gprof' to display summary information about
     the profile data file(s) and then exit.  The number of histogram,
     call graph, and basic-block count records is displayed.

'-I DIRS'
'--directory-path=DIRS'
     The '-I' option specifies a list of search directories in which to
d346 4
a349 4
'-J[SYMSPEC]'
'--no-annotated-source[=SYMSPEC]'
     The '-J' option causes 'gprof' not to print annotated source code.
     If SYMSPEC is specified, 'gprof' prints annotated source, but
d352 2
a353 2
'-L'
'--print-path'
d355 1
a355 1
     suppressed.  The '-L' option causes 'gprof' to print the full
d360 10
a369 10
'-p[SYMSPEC]'
'--flat-profile[=SYMSPEC]'
     The '-p' option causes 'gprof' to print a flat profile.  If SYMSPEC
     is specified, print flat profile only for matching symbols.  *Note
     The Flat Profile: Flat Profile.

'-P[SYMSPEC]'
'--no-flat-profile[=SYMSPEC]'
     The '-P' option causes 'gprof' to suppress printing a flat profile.
     If SYMSPEC is specified, 'gprof' prints a flat profile, but
d372 3
a374 3
'-q[SYMSPEC]'
'--graph[=SYMSPEC]'
     The '-q' option causes 'gprof' to print the call graph analysis.
d378 4
a381 4
'-Q[SYMSPEC]'
'--no-graph[=SYMSPEC]'
     The '-Q' option causes 'gprof' to suppress printing the call graph.
     If SYMSPEC is specified, 'gprof' prints a call graph, but excludes
d384 3
a386 3
'-t'
'--table-length=NUM'
     The '-t' option causes the NUM most active source lines in each
d390 2
a391 2
'-y'
'--separate-files'
d393 1
a393 1
     'gprof' prints annotated source files to standard-output.  If this
d395 9
a403 9
     'path/FILENAME' is generated in the file 'FILENAME-ann'.  If the
     underlying file system would truncate 'FILENAME-ann' so that it
     overwrites the original 'FILENAME', 'gprof' generates annotated
     source in the file 'FILENAME.ann' instead (if the original file
     name has an extension, that extension is _replaced_ with '.ann').

'-Z[SYMSPEC]'
'--no-exec-counts[=SYMSPEC]'
     The '-Z' option causes 'gprof' not to print a tally of functions
d407 3
a409 3
'-r'
'--function-ordering'
     The '--function-ordering' option causes 'gprof' to print a
d419 7
a425 7
'-R MAP_FILE'
'--file-ordering MAP_FILE'
     The '--file-ordering' option causes 'gprof' to print a suggested .o
     link line ordering for the program based on profiling data.  This
     option suggests an ordering which may improve paging, tlb and cache
     behavior for the program on systems which do not support arbitrary
     ordering of functions in an executable.
d427 1
a427 1
     Use of the '-a' argument is highly recommended with this option.
d431 1
a431 1
     similar to the output of the program 'nm'.
d442 1
a442 2

     To create a MAP_FILE with GNU 'nm', type a command like 'nm
d445 4
a448 4
'-T'
'--traditional'
     The '-T' option causes 'gprof' to print its output in "traditional"
     BSD style.
d450 2
a451 2
'-w WIDTH'
'--width=WIDTH'
d455 7
a461 7
'-x'
'--all-lines'
     This option affects annotated source output only.  By default, only
     the lines at the beginning of a basic-block are annotated.  If this
     option is specified, every line in a basic-block is annotated by
     repeating the annotation for the first line.  This behavior is
     similar to 'tcov''s '-a'.
d463 2
a464 2
'--demangle[=STYLE]'
'--no-demangle'
d467 1
a467 1
     '--no-demangle' option may be used to turn off demangling.
d478 3
a480 3
'-a'
'--no-static'
     The '-a' option causes 'gprof' to suppress the printing of
d486 2
a487 2
     the executable file.  This option affects both the flat profile and
     the call graph.
d489 3
a491 3
'-c'
'--static-call-graph'
     The '-c' option causes the call graph of the program to be
d496 12
a507 12
     have been called, but never were.  Calls to functions that were not
     compiled with profiling enabled are also identified, but only if
     symbol table entries are present for them.  Calls to dynamic
     library routines are typically _not_ found by this option.  Parents
     or children identified via this heuristic are indicated in the call
     graph with call counts of '0'.

'-D'
'--ignore-non-functions'
     The '-D' option causes 'gprof' to ignore symbols which are not
     known to be functions.  This option will give more accurate profile
     data on systems where it is supported (Solaris and HPUX for
d510 2
a511 2
'-k FROM/TO'
     The '-k' option allows you to delete from the call graph any arcs
d514 3
a516 3
'-l'
'--line'
     The '-l' option enables line-by-line profiling, which causes
d519 2
a520 2
     compiled by older versions of the 'gcc' compiler.  Newer versions
     of 'gcc' are designed to work with the 'gcov' tool instead.
d522 5
a526 5
     If the program was compiled with basic-block counting enabled, this
     option will also identify how many times each line of code was
     executed.  While line-by-line profiling can help isolate where in a
     large function a program is spending its time, it also
     significantly increases the running time of 'gprof', and magnifies
d530 4
a533 4
'--inline-file-names'
     This option causes 'gprof' to print the source file after each
     symbol in both the flat profile and the call graph.  The full path
     to the file is printed if used with the '-L' option.
d535 2
a536 2
'-m NUM'
'--min-count=NUM'
d540 8
a547 3
'-nSYMSPEC'
'--time=SYMSPEC'
     The '-n' option causes 'gprof', in its call graph analysis, to only
d550 13
a562 4
'-NSYMSPEC'
'--no-time=SYMSPEC'
     The '-n' option causes 'gprof', in its call graph analysis, not to
     propagate times for symbols matching SYMSPEC.
a563 13
'-SFILENAME'
'--external-symbol-table=FILENAME'
     The '-S' option causes 'gprof' to read an external symbol table
     file, such as '/proc/kallsyms', rather than read the symbol table
     from the given object file (the default is 'a.out').  This is
     useful for profiling kernel modules.

'-z'
'--display-unused-functions'
     If you give the '-z' option, 'gprof' will mention all functions in
     the flat profile, even those that were never called, and that had
     no time spent in them.  This is useful in conjunction with the '-c'
     option for discovering which routines were never called.
d571 4
a574 4
'-d[NUM]'
'--debug[=NUM]'
     The '-d NUM' option specifies debugging options.  If NUM is not
     specified, enable all debugging.  *Note Debugging 'gprof':
d577 3
a579 3
'-h'
'--help'
     The '-h' option prints command line usage.
d581 2
a582 2
'-ONAME'
'--file-format=NAME'
d584 2
a585 2
     are 'auto' (the default), 'bsd', '4.4bsd', 'magic', and 'prof' (not
     yet supported).
d587 3
a589 3
'-s'
'--sum'
     The '-s' option causes 'gprof' to summarize the information in the
d591 11
a601 11
     called 'gmon.sum', which contains all the information from the
     profile data files that 'gprof' read in.  The file 'gmon.sum' may
     be one of the specified input files; the effect of this is to merge
     the data in the other input files into 'gmon.sum'.

     Eventually you can run 'gprof' again without '-s' to analyze the
     cumulative data in the file 'gmon.sum'.

'-v'
'--version'
     The '-v' flag causes 'gprof' to print the current version number,
d604 1
d613 2
a614 2
'-e FUNCTION_NAME'
     The '-e FUNCTION' option tells 'gprof' to not print information
d617 11
a627 10
     functions that call it, but its index number will be shown as '[not
     printed]'.  More than one '-e' option may be given; only one
     FUNCTION_NAME may be indicated with each '-e' option.

'-E FUNCTION_NAME'
     The '-E FUNCTION' option works like the '-e' option, but time spent
     in the function (and children who were not called from anywhere
     else), will not be used to compute the percentages-of-time for the
     call graph.  More than one '-E' option may be given; only one
     FUNCTION_NAME may be indicated with each '-E' option.
d629 2
a630 2
'-f FUNCTION_NAME'
     The '-f FUNCTION' option causes 'gprof' to limit the call graph to
d632 10
a641 2
     children...).  More than one '-f' option may be given; only one
     FUNCTION_NAME may be indicated with each '-f' option.
a642 7
'-F FUNCTION_NAME'
     The '-F FUNCTION' option works like the '-f' option, but only time
     spent in the function and its children (and their children...) will
     be used to determine total-time and percentages-of-time for the
     call graph.  More than one '-F' option may be given; only one
     FUNCTION_NAME may be indicated with each '-F' option.  The '-F'
     option overrides the '-E' option.
d644 2
a645 2
   Note that only one function can be specified with each '-e', '-E',
'-f' or '-F' option.  To specify more than one function, use multiple
d651 1
a651 1
'foo' or 'bar' and were not reachable from 'boring'.
d670 6
a675 6
'main.c'
     Selects everything in file 'main.c'--the dot in the string tells
     'gprof' to interpret the string as a filename, rather than as a
     function name.  To select a file whose name does not contain a dot,
     a trailing colon should be specified.  For example, 'odd:' is
     interpreted as the file named 'odd'.
d677 2
a678 2
'main'
     Selects all functions named 'main'.
d687 2
a688 2
     necessary to add a leading colon to the name.  For example, ':.mul'
     selects function '.mul'.
d691 2
a692 2
     'gprof' will normally not print these underscores.  When you name a
     symbol in a symspec, you should type it exactly as 'gprof' prints
d694 2
a695 2
     '_main' from your 'main' function, 'gprof' still prints it as
     'main' in its output, so you should use 'main' in symspecs.
d697 2
a698 2
'main.c:main'
     Selects function 'main' in file 'main.c'.
d700 2
a701 2
'main.c:134'
     Selects line 134 in file 'main.c'.
d706 1
a706 1
5 Interpreting 'gprof''s Output
d709 1
a709 1
'gprof' can produce several different output styles, the most important
d722 1
a722 1
* Line-by-line::        'gprof' can analyze individual source code lines
d733 1
a733 1
executing each function.  Unless the '-z' option is given, functions
d764 1
a764 1
functions 'mcount' and 'profil' are part of the profiling apparatus and
d774 8
a781 8
'cumulative seconds' field.  Since each sample counted for 0.01 seconds,
this means only six samples were taken during the run.  Two of the
samples occurred while the program was in the 'open' function, as
indicated by the 'self seconds' field.  Each of the other four samples
occurred one each in 'offtime', 'memccpy', 'write', and 'mcount'.  Since
only six samples were taken, none of these values can be regarded as
particularly reliable.  In another run, the 'self seconds' field for
'mcount' might well be '0.00' or '0.02'.  *Note Statistical Sampling
d784 2
a785 2
   The remaining functions in the listing (those whose 'self seconds'
field is '0.00') didn't appear in the histogram samples at all.
d787 1
a787 1
they are listed, sorted in decreasing order by the 'calls' field.
d794 1
a794 1
'% time'
d798 1
a798 1
'cumulative seconds'
d803 1
a803 1
'self seconds'
d807 1
a807 1
'calls'
d813 1
a813 1
'self ms/call'
d818 1
a818 1
'total ms/call'
d825 2
a826 2
'name'
     This is the name of the function.  The flat profile is sorted by
d838 2
a839 2
they themselves may not have used much time, called other functions that
did use unusual amounts of time.
d842 1
a842 1
same 'gprof' run as the flat profile example in the previous section.
d877 4
a880 4
number in square brackets.  The end of this line says which function the
entry is for.  The preceding lines in the entry describe the callers of
this function and the following lines describe its subroutines (also
called "children" when we speak of the call graph).
d885 1
a885 1
   The internal profiling function 'mcount' (*note The Flat Profile:
d894 1
a894 1
                   such as 'a' calls 'b' calls 'a'...
d907 1
a907 1
'report' in our main example, together with the heading line that shows
d916 1
a916 1
'index'
d926 1
a926 1
'% time'
d935 1
a935 1
'self'
d937 1
a937 1
     should be identical to the number printed in the 'seconds' field
d940 5
a944 5
'children'
     This is the total amount of time spent in the subroutine calls made
     by this function.  This should be equal to the sum of all the
     'self' and 'children' entries of the children listed directly below
     this function.
d946 1
a946 1
'called'
d950 1
a950 1
     separated by a '+'.  The first number counts non-recursive calls,
d953 2
a954 2
     In the example above, the function 'report' was called once from
     'main'.
d956 1
a956 1
'name'
d963 1
a963 1
     example, if function 'gnurr' is part of cycle number one, and has
d974 3
a976 3
A function's entry has a line for each function it was called by.  These
lines' fields correspond to the fields of the primary line, but their
meanings are different because of the difference in context.
d979 1
a979 1
'report', the primary line and one caller-line preceding it, together
d987 2
a988 2
   Here are the meanings of the fields in the caller-line for 'report'
called from 'main':
d990 14
a1003 14
'self'
     An estimate of the amount of time spent in 'report' itself when it
     was called from 'main'.

'children'
     An estimate of the amount of time spent in subroutines of 'report'
     when 'report' was called from 'main'.

     The sum of the 'self' and 'children' fields is an estimate of the
     amount of time spent within calls to 'report' from 'main'.

'called'
     Two numbers: the number of times 'report' was called from 'main',
     followed by the total number of non-recursive calls to 'report'
d1006 2
a1007 2
'name and index number'
     The name of the caller of 'report' to which this line applies,
d1011 1
a1011 1
     'gprof' request the omission of certain functions.  When a caller
d1019 1
a1019 1
dummy caller-line is printed which has '<spontaneous>' as the "caller's
d1034 1
a1034 1
'main', the primary line and a line for a subroutine, together with the
d1042 2
a1043 2
   Here are the meanings of the fields in the subroutine-line for 'main'
calling 'report':
d1045 17
a1061 17
'self'
     An estimate of the amount of time spent directly within 'report'
     when 'report' was called from 'main'.

'children'
     An estimate of the amount of time spent in subroutines of 'report'
     when 'report' was called from 'main'.

     The sum of the 'self' and 'children' fields is an estimate of the
     total time spent in calls to 'report' from 'main'.

'called'
     Two numbers, the number of calls to 'report' from 'main' followed
     by the total number of non-recursive calls to 'report'.  This ratio
     is used to determine how much of 'report''s 'self' and 'children'
     time gets credited to 'main'.  *Note Estimating 'children' Times:
     Assumptions.
d1063 2
a1064 2
'name'
     The name of the subroutine of 'main' to which this line applies,
d1076 2
a1077 2
The graph may be complicated by the presence of "cycles of recursion" in
the call graph.  A cycle exists if a function calls another function
d1079 2
a1080 2
function.  For example: if 'a' calls 'b', and 'b' calls 'a', then 'a'
and 'b' form a cycle.
d1083 4
a1086 4
they belong to the same cycle.  If 'a' and 'b' call each other and 'b'
and 'c' call each other, all three make one cycle.  Note that even if
'b' only calls 'a' if it was not called from 'a', 'gprof' cannot
determine this, so 'a' and 'b' are still considered a cycle.
d1090 1
a1090 1
graph it is followed by '<cycle NUMBER>'.
d1093 4
a1096 4
call graph paradoxical.  The "time spent in children" of 'a' should
include the time spent in its subroutine 'b' and in 'b''s
subroutines--but one of 'b''s subroutines is 'a'!  How much of 'a''s
time should be included in the children of 'a', when 'a' is indirectly
d1099 1
a1099 1
   The way 'gprof' resolves this paradox is by creating a single entry
d1104 2
a1105 2
"callers" of the cycle are the functions, outside the cycle, that called
functions in the cycle.
d1108 2
a1109 2
containing functions 'a' and 'b'.  The cycle was entered by a call to
'a' from 'main'; both 'a' and 'b' called 'c'.
d1131 2
a1132 2
for 'main', which calls 'a', and an entry for 'c', with callers 'a' and
'b'.)
d1165 2
a1166 2
   The 'self' field of the cycle's primary line is the total time spent
in all the functions of the cycle.  It equals the sum of the 'self'
d1170 6
a1175 6
   The 'children' fields of the cycle's primary line and subroutine
lines count only subroutines outside the cycle.  Even though 'a' calls
'b', the time spent in those calls to 'b' is not counted in 'a''s
'children' time.  Thus, we do not encounter the problem of what to do
when the time in those calls to 'b' includes indirect recursive calls
back to 'a'.
d1177 1
a1177 1
   The 'children' field of a caller-line in the cycle's entry estimates
d1182 1
a1182 1
   The 'called' field in the primary line for the cycle has two numbers:
d1185 8
a1192 8
called by functions in the cycle (including times when a function in the
cycle calls itself).  This is a generalization of the usual split into
non-recursive and recursive calls.

   The 'called' field of a subroutine-line for a cycle member in the
cycle's entry says how many time that function was called from functions
in the cycle.  The total of all these is the second number in the
primary line's 'called' field.
d1196 4
a1199 4
These lines show how many times each function in the cycle called or was
called from each other function in the cycle.  The 'self' and 'children'
fields in these lines are blank because of the difficulty of defining
meanings for them when recursion is going on.
d1207 1
a1207 1
'gprof''s '-l' option causes the program to perform "line-by-line"
d1209 3
a1211 3
functions, but to individual lines of source code.  This only works with
programs compiled with older versions of the 'gcc' compiler.  Newer
versions of 'gcc' use a different program - 'gcov' - to display
d1214 2
a1215 2
   With the older versions of 'gcc' the program usually has to be
compiled with a '-g' option, in addition to '-pg', in order to generate
d1217 1
a1217 1
versions of 'gcc' the program had to be compiled with the '-a' command
d1222 1
a1222 1
version of 'gprof' does not propagate call graph arcs from source code
d1226 3
a1228 3
   Here is a section of 'gprof''s output, without line-by-line
profiling.  Note that 'ct_init' accounted for four histogram hits, and
13327 calls to 'init_block'.
d1251 2
a1252 3

   Now let's look at some of 'gprof''s output from the same program run,
this time with line-by-line profiling enabled.  Note that 'ct_init''s
d1255 1
a1255 1
note how 'ct_init''s 13327 calls to 'init_block' are broken down into
a1290 1

d1297 1
a1297 1
'gprof''s '-A' option triggers an annotated source listing, which lists
d1299 2
a1300 2
times it was called.  You may also need to specify the '-I' option, if
'gprof' can't find the source code files.
d1302 1
a1302 1
   With older versions of 'gcc' compiling with 'gcc ... -g -pg -a'
d1304 3
a1306 3
function counting code.  This enables 'gprof' to determine how many
times each line of code was executed.  With newer versions of 'gcc'
support for displaying basic-block counts is provided by the 'gcov'
d1332 6
a1337 7

   'updcrc' has at least five basic-blocks.  One is the function itself.
The 'if' statement on line 9 generates two more basic-blocks, one for
each branch of the 'if'.  A fourth basic-block results from the 'if' on
line 13, and the contents of the 'do' loop form the fifth basic-block.
The compiler may also generate additional basic-blocks to handle various
special cases.
d1340 3
a1342 3
'gprof -l -A'.  The '-x' option is also helpful, to ensure that each
line of code is labeled at least once.  Here is 'updcrc''s annotated
source listing for a sample 'gzip' run:
d1365 2
a1366 2
each branch of the 'if' statement.  The body of the 'do' loop was
executed a total of 26312 times.  Note how the 'while' statement is
d1374 1
a1374 1
6 Inaccuracy of 'gprof' Output
d1388 1
a1388 1
The run-time figures that 'gprof' gives you are based on a sampling
d1401 2
a1402 2
beware that the mcount counting function in glibc is _not_ thread-safe).
*Note Implementation of Profiling: Implementation.
d1411 1
a1411 1
period is 0.01 seconds and 'foo''s run-time is 1 second, N is 100
d1413 1
a1413 1
error in 'foo''s run-time is 0.1 seconds (10*0.01 seconds), or ten
d1415 5
a1419 5
seconds and 'bar''s run-time is 100 seconds, N is 10000 samples, sqrt(N)
is 100 samples, so the expected error in 'bar''s run-time is 1 second,
or one percent of the observed value.  It is likely to vary this much
_on the average_ from one profiling run to the next.  (_Sometimes_ it
will vary more.)
d1429 1
a1429 1
the data from several runs, using the '-s' option of 'gprof'.  Here is
d1434 1
a1434 1
  2. Issue the command 'mv gmon.out gmon.sum'.
d1438 1
a1438 1
  4. Merge the new data in 'gmon.out' into 'gmon.sum' with this command:
d1451 1
a1451 1
6.2 Estimating 'children' Times
d1455 2
a1456 2
'children' time values and all the time figures in caller and subroutine
lines.
d1459 1
a1459 1
profile data itself.  Instead, 'gprof' estimates them by making an
d1463 4
a1466 3
any function 'foo' is not correlated with who called 'foo'.  If 'foo'
used 5 seconds in all, and 2/5 of the calls to 'foo' came from 'a', then
'foo' contributes 2 seconds to 'a''s 'children' time, by assumption.
d1469 6
a1474 6
far from true.  Suppose that 'foo' returns very quickly when its
argument is zero; suppose that 'a' always passes zero as an argument,
while other callers of 'foo' pass other arguments.  In this program, all
the time spent in 'foo' is in the calls from callers other than 'a'.
But 'gprof' has no way of knowing this; it will blindly and incorrectly
charge 2 seconds of time in 'foo' to the children of 'a'.
d1476 1
a1476 1
   We hope some day to put more complete data into 'gmon.out', so that
a1486 1

d1488 1
a1488 1
     Because 'gprof' can only report call times and counts by function,
d1492 1
a1492 1
     artificial hot spots since compiling with '-pg' adds a significant
d1497 1
a1497 2

     Use the 'gcov' program.
d1500 1
a1500 2

     Use 'gprof -l' and lookup the function in the call graph.  The
a1503 1

d1519 1
d1523 1
a1523 1
8 Incompatibilities with Unix 'gprof'
d1526 3
a1528 3
GNU 'gprof' and Berkeley Unix 'gprof' use the same data file 'gmon.out',
and provide essentially the same information.  But there are a few
differences.
d1530 1
a1530 1
   * GNU 'gprof' uses a new, generalized file format with support for
d1532 1
a1532 1
     cookie and version number allows 'gprof' to easily identify new
d1536 3
a1538 3
   * For a recursive function, Unix 'gprof' lists the function as a
     parent and as a child, with a 'calls' field that lists the number
     of recursive calls.  GNU 'gprof' omits these lines and puts the
d1541 2
a1542 2
   * When a function is suppressed from the call graph with '-e', GNU
     'gprof' still lists it as a subroutine of functions that call it.
d1544 2
a1545 2
   * GNU 'gprof' accepts the '-k' with its argument in the form
     'from/to', instead of 'from to'.
d1547 3
a1549 3
   * In the annotated source listing, if there are multiple basic blocks
     on the same line, GNU 'gprof' prints all of their counts, separated
     by commas.
d1552 1
a1552 1
     'gprof' prints blurbs after the tables, so that you can see the
d1564 3
a1566 3
* File Format::         Format of 'gmon.out' files
* Internals::           'gprof''s internal operation
* Debugging::           Using 'gprof''s '-d' option
d1579 2
a1580 2
the '-pg' option, which causes every function to call 'mcount' (or
'_mcount', or '__mcount', depending on the OS and compiler) as one of
d1583 1
a1583 1
   The 'mcount' routine, included in the profiling library, is
d1586 3
a1588 3
done by examining the stack frame to find both the address of the child,
and the return address in the original parent.  Since this is a very
machine-dependent operation, 'mcount' itself is typically a short
d1590 4
a1593 4
and then calls '__mcount_internal' (a normal C function) with two
arguments--'frompc' and 'selfpc'.  '__mcount_internal' is responsible
for maintaining the in-memory call graph, which records 'frompc',
'selfpc', and the number of times each of these call arcs was traversed.
d1596 1
a1596 1
('__builtin_return_address'), which allows a generic 'mcount' function
d1600 1
a1600 1
'mcount' is used for performance reasons.
d1604 2
a1605 2
same as in the usual C library, but they were compiled with '-pg'.  If
you link your program with 'gcc ... -pg', it automatically uses the
d1608 5
a1612 5
   Profiling also involves watching your program as it runs, and keeping
a histogram of where the program counter happens to be every now and
then.  Typically the program counter is looked at around 100 times per
second of run time, but the exact frequency may vary from system to
system.
d1615 1
a1615 1
provide a 'profil()' system call, which registers a memory array with
d1617 7
a1623 7
address space maps into the array.  Typical scaling values cause every 2
to 8 bytes of address space to map into a single array slot.  On every
tick of the system clock (assuming the profiled program is running), the
value of the program counter is examined and the corresponding slot in
the memory array is incremented.  Since this is done in the kernel,
which had to interrupt the process anyway to handle the clock interrupt,
very little additional system overhead is required.
d1626 9
a1634 8
earlier), do not provide a 'profil()' system call.  On such a system,
arrangements are made for the kernel to periodically deliver a signal to
the process (typically via 'setitimer()'), which then performs the same
operation of examining the program counter and incrementing a slot in
the memory array.  Since this method requires a signal to be delivered
to user space every time a sample is taken, it uses considerably more
overhead than kernel-based profiling.  Also, due to the added delay
required to deliver the signal, this method is less accurate as well.
d1637 8
a1644 8
either calls 'profil()' or sets up a clock signal handler.  This routine
('monstartup') can be invoked in several ways.  On Linux systems, a
special profiling startup file 'gcrt0.o', which invokes 'monstartup'
before 'main', is used instead of the default 'crt0.o'.  Use of this
special startup file is one of the effects of using 'gcc ... -pg' to
link.  On SPARC systems, no special startup files are used.  Rather, the
'mcount' routine, when it is invoked for the first time (typically when
'main' is called), calls 'monstartup'.
d1646 1
a1646 1
   If the compiler's '-a' option was used, basic-block counting is also
d1649 1
a1649 1
basic-block begins (i.e., when an 'if' statement appears), an extra
d1656 5
a1660 5
   The profiling library also includes a function ('mcleanup') which is
typically registered using 'atexit()' to be called as the program exits,
and is responsible for writing the file 'gmon.out'.  Profiling is turned
off, various headers are output, and the histogram is written, followed
by the call-graph arcs and the basic-block counts.
d1662 1
a1662 1
   The output from 'gprof' gives no indication of parts of your program
d1664 8
a1671 8
of the program counter are taken at fixed intervals of the program's run
time.  Therefore, the time measurements in 'gprof' output say nothing
about time that your program was not running.  For example, a part of
the program that creates so much data that it cannot all fit in physical
memory at once may run very slowly due to thrashing, but 'gprof' will
say it uses little time.  On the other hand, sampling by run time has
the advantage that the amount of load due to other users won't directly
affect the output you get.
d1681 2
a1682 2
'gprof' file.  Furthermore, it does not provide a version number, thus
rendering changes to the file format almost impossible.  GNU 'gprof'
d1684 1
a1684 1
compatibility, GNU 'gprof' continues to support the old BSD-derived
d1689 1
a1689 1
   The new file format is defined in header file 'gmon_out.h'.  It
d1693 1
a1693 1
the profile was collected.  GNU 'gprof' adapts automatically to the
d1700 1
a1700 1
reading a file, GNU 'gprof' will ensure records of the same type are
d1710 15
a1724 15
spans, the size of the histogram in bytes (unlike in the old BSD format,
this does not include the size of the header), the rate of the profiling
clock, and the physical dimension that the bin counts represent after
being scaled by the profiling clock rate.  The physical dimension is
specified in two parts: a long name of up to 15 characters and a single
character abbreviation.  For example, a histogram representing real-time
would specify the long name as "seconds" and the abbreviation as "s".
This feature is useful for architectures that support performance
monitor hardware (which, fortunately, is becoming increasingly common).
For example, under DEC OSF/1, the "uprofile" command can be used to
produce a histogram of, say, instruction cache misses.  In this case,
the dimension in the histogram header could be set to "i-cache misses"
and the abbreviation could be set to "1" (because it is simply a count,
not a physical dimension).  Also, the profiling rate would have to be
set to 1 in this case.
d1737 8
a1744 8
program execution.  Arcs are specified by a pair of addresses: the first
must be within caller's function and the second must be within the
callee's function.  When performing profiling at the function level,
these addresses can point anywhere within the respective function.
However, when profiling at the line-level, it is better if the addresses
are as close to the call-site/entry-point as possible.  This will ensure
that the line-level call-graph is able to identify exactly which line of
source code performed calls to a function.
d1750 5
a1754 4
sequence of address/count pairs.  The header simply specifies the length
of the sequence.  In an address/count pair, the address identifies a
basic-block and the count specifies the number of times that basic-block
was executed.  Any address within the basic-address can be used.
d1759 1
a1759 1
9.3 'gprof''s Internal Operation
d1762 6
a1767 6
Like most programs, 'gprof' begins by processing its options.  During
this stage, it may building its symspec list ('sym_ids.c:sym_id_add'),
if options are specified which use symspecs.  'gprof' maintains a single
linked list of symspecs, which will eventually get turned into 12 symbol
tables, organized into six include/exclude pairs--one pair each for the
flat profile (INCL_FLAT/EXCL_FLAT), the call graph arcs
d1774 2
a1775 2
   After option processing, 'gprof' finishes building the symspec list
by adding all the symspecs in 'default_excluded_list' to the exclude
d1781 2
a1782 2
it is an object file, and read its symbol table ('core.c:core_init'),
using 'bfd_canonicalize_symtab' after mallocing an appropriately sized
d1784 2
a1785 2
'--file-ordering' option has been specified), and the core text space is
read into memory (if the '-c' option was given).
d1787 1
a1787 1
   'gprof''s own symbol table, an array of Sym structures, is now built.
d1789 1
a1789 1
whether line-by-line profiling ('-l' option) has been enabled.  For
d1795 4
a1798 4
the symbols.  In between the two passes, a single array of type 'Sym' is
created of the appropriate length.  Finally, 'symtab.c:symtab_finalize'
is called to sort the symbol table and remove duplicate entries (entries
with the same memory address).
d1801 3
a1803 3
the 'qsort' library function (which sorts an array) will be used to sort
the symbol table.  Also, the symbol lookup routine
('symtab.c:sym_lookup'), which finds symbols based on memory address,
d1805 1
a1805 1
sorted array.  Function symbols are indicated with an 'is_func' flag.
d1807 1
a1807 1
can have an 'is_static' flag to indicate that it is a local symbol.
d1810 11
a1820 11
Syms ('sym_ids.c:sym_id_parse').  Remember that a single symspec can
match multiple symbols.  An array of symbol tables ('syms') is created,
each entry of which is a symbol table of Syms to be included or excluded
from a particular listing.  The master symbol table and the symspecs are
examined by nested loops, and every symbol that matches a symspec is
inserted into the appropriate syms table.  This is done twice, once to
count the size of each required symbol table, and again to build the
tables, which have been malloced between passes.  From now on, to
determine whether a symbol is on an include or exclude symspec list,
'gprof' simply uses its standard symbol lookup routine on the
appropriate table in the 'syms' array.
d1823 2
a1824 2
('gmon_io.c:gmon_out_read'), first by checking for a new-style
'gmon.out' header, then assuming this is an old-style BSD 'gmon.out' if
d1827 1
a1827 1
   New-style histogram records are read by 'hist.c:hist_read_rec'.  For
d1829 6
a1834 6
bins, and read them in.  When multiple profile data files (or files with
multiple histogram records) are read, the memory ranges of each pair of
histogram records must be either equal, or non-overlapping.  For each
pair of histogram records, the resolution (memory region size divided by
the number of bins) must be the same.  The time unit must be the same
for all histogram records.  If the above containts are met, all
d1837 1
a1837 1
   As each call graph record is read ('call_graph.c:cg_read_rec'), the
d1839 2
a1840 2
call graph arc is created by 'cg_arcs.c:arc_add', unless the arc fails a
symspec check against INCL_ARCS/EXCL_ARCS. As each arc is added, a
d1845 6
a1850 6
   Basic-block records are read ('basic_blocks.c:bb_read_rec'), but only
if line-by-line profiling has been selected.  Each basic-block address
is matched to a corresponding line symbol in the symbol table, and an
entry made in the symbol's bb_addr and bb_calls arrays.  Again, if
multiple basic-block records are present for the same address, the call
counts are cumulative.
d1852 1
a1852 1
   A gmon.sum file is dumped, if requested ('gmon_io.c:gmon_out_write').
d1855 11
a1865 10
('hist.c:hist_assign_samples') by iterating over all the sample bins and
assigning them to symbols.  Since the symbol table is sorted in order of
ascending memory addresses, we can simple follow along in the symbol
table as we make our pass over the sample bins.  This step includes a
symspec check against INCL_FLAT/EXCL_FLAT. Depending on the histogram
scale factor, a sample bin may span multiple symbols, in which case a
fraction of the sample count is allocated to each symbol, proportional
to the degree of overlap.  This effect is rare for normal profiling, but
overlaps are more common during line-by-line profiling, and can cause
each of two adjacent lines to be credited with half a hit, for example.
d1867 2
a1868 2
   If call graph data is present, 'cg_arcs.c:cg_assemble' is called.
First, if '-c' was specified, a machine-dependent routine ('find_call')
d1871 19
a1889 18
A topological sort is performed by depth-first numbering all the symbols
('cg_dfn.c:cg_dfn'), so that children are always numbered less than
their parents, then making a array of pointers into the symbol table and
sorting it into numerical order, which is reverse topological order
(children appear before parents).  Cycles are also detected at this
point, all members of which are assigned the same topological number.
Two passes are now made through this sorted array of symbol pointers.
The first pass, from end to beginning (parents to children), computes
the fraction of child time to propagate to each parent and a print flag.
The print flag reflects symspec handling of INCL_GRAPH/EXCL_GRAPH, with
a parent's include or exclude (print or no print) property being
propagated to its children, unless they themselves explicitly appear in
INCL_GRAPH or EXCL_GRAPH. A second pass, from beginning to end (children
to parents) actually propagates the timings along the call graph,
subject to a check against INCL_TIME/EXCL_TIME. With the print flag,
fractions, and timings now stored in the symbol structures, the
topological sort array is now discarded, and a new array of pointers is
assembled, this time sorted by propagated time.
d1892 2
a1893 2
fairly straightforward.  The call graph ('cg_print.c:cg_print') and flat
profile ('hist.c:hist_print') are regurgitations of values already
d1895 1
a1895 1
('basic_blocks.c:print_annotated_source') uses basic-block information,
d1900 1
a1900 1
source code itself ('cg_print.c').  Basically, the functions with the
d1908 1
a1908 1
9.4 Debugging 'gprof'
d1911 4
a1914 4
If 'gprof' was compiled with debugging enabled, the '-d' option triggers
debugging output (to stdout) which can be helpful in understanding its
operation.  The debugging number specified is interpreted as a sum of
the following options:
d1918 1
d1921 1
d1925 1
d1929 1
d1933 1
d1936 1
a1936 1
     file.  For line-by-line profiling ('-l' option), also shows line
d1938 1
d1940 2
a1941 1
     Trace operation of '-c' option
d1944 1
d1947 1
d1950 2
a1951 1
     meaningful with '-l' option)
d1954 1
d1956 1
a1956 1
     Tracks operation of '-A' option
d1967 1
a1967 1
     <http://fsf.org/>
d1992 2
a1993 2
     of subject matter or whether it is published as a printed book.  We
     recommend this License principally for works whose purpose is
d1999 2
a2000 2
     that contains a notice placed by the copyright holder saying it can
     be distributed under the terms of this License.  Such a notice
d2004 3
a2006 3
     of the public is a licensee, and is addressed as "you".  You accept
     the license if you copy, modify or distribute the work in a way
     requiring permission under copyright law.
d2024 6
a2029 6
     titles are designated, as being those of Invariant Sections, in the
     notice that says that the Document is released under this License.
     If a section does not fit the above definition of Secondary then it
     is not allowed to be designated as Invariant.  The Document may
     contain zero Invariant Sections.  If the Document does not identify
     any Invariant Sections then there are none.
d2040 10
a2049 10
     straightforwardly with generic text editors or (for images composed
     of pixels) generic paint programs or (for drawings) some widely
     available drawing editor, and that is suitable for input to text
     formatters or for automatic translation to a variety of formats
     suitable for input to text formatters.  A copy made in an otherwise
     Transparent file format whose markup, or absence of markup, has
     been arranged to thwart or discourage subsequent modification by
     readers is not Transparent.  An image format is not Transparent if
     used for any substantial amount of text.  A copy that is not
     "Transparent" is called "Opaque".
d2053 8
a2060 8
     SGML or XML using a publicly available DTD, and standard-conforming
     simple HTML, PostScript or PDF designed for human modification.
     Examples of transparent image formats include PNG, XCF and JPG.
     Opaque formats include proprietary formats that can be read and
     edited only by proprietary word processors, SGML or XML for which
     the DTD and/or processing tools are not generally available, and
     the machine-generated HTML, PostScript or PDF produced by some word
     processors for output purposes only.
d2098 2
a2099 2
     distribute a large enough number of copies you must also follow the
     conditions in section 3.
d2113 6
a2118 5
     front cover must present the full title with all words of the title
     equally prominent and visible.  You may add other material on the
     covers in addition.  Copying with changes limited to the covers, as
     long as they preserve the title of the Document and satisfy these
     conditions, can be treated as verbatim copying in other respects.
d2126 12
a2137 11
     numbering more than 100, you must either include a machine-readable
     Transparent copy along with each Opaque copy, or state in or with
     each Opaque copy a computer-network location from which the general
     network-using public has access to download using public-standard
     network protocols a complete Transparent copy of the Document, free
     of added material.  If you use the latter option, you must take
     reasonably prudent steps, when you begin distribution of Opaque
     copies in quantity, to ensure that this Transparent copy will
     remain thus accessible at the stated location until at least one
     year after the last time you distribute an Opaque copy (directly or
     through your agents or retailers) of that edition to the public.
d2140 3
a2142 3
     the Document well before redistributing any large number of copies,
     to give them a chance to provide you with an updated version of the
     Document.
d2148 5
a2152 5
     release the Modified Version under precisely this License, with the
     Modified Version filling the role of the Document, thus licensing
     distribution and modification of the Modified Version to whoever
     possesses a copy of it.  In addition, you must do these things in
     the Modified Version:
d2155 5
a2159 5
          distinct from that of the Document, and from those of previous
          versions (which should, if there were any, be listed in the
          History section of the Document).  You may use the same title
          as a previous version if the original publisher of that
          version gives permission.
d2189 6
a2194 6
          authors, and publisher of the Modified Version as given on the
          Title Page.  If there is no section Entitled "History" in the
          Document, create one stating the title, year, authors, and
          publisher of the Document as given on its Title Page, then add
          an item describing the Modified Version as stated in the
          previous sentence.
d2199 5
a2203 5
          previous versions it was based on.  These may be placed in the
          "History" section.  You may omit a network location for a work
          that was published at least four years before the Document
          itself, or if the original publisher of the version it refers
          to gives permission.
d2206 2
a2207 2
          Preserve the Title of the section, and preserve in the section
          all the substance and tone of each of the contributor
d2210 4
a2213 3
       L. Preserve all the Invariant Sections of the Document, unaltered
          in their text and in their titles.  Section numbers or the
          equivalent are not considered part of the section titles.
d2226 5
a2230 5
     material copied from the Document, you may at your option designate
     some or all of these sections as invariant.  To do this, add their
     titles to the list of Invariant Sections in the Modified Version's
     license notice.  These titles must be distinct from any other
     section titles.
d2239 9
a2247 9
     and a passage of up to 25 words as a Back-Cover Text, to the end of
     the list of Cover Texts in the Modified Version.  Only one passage
     of Front-Cover Text and one of Back-Cover Text may be added by (or
     through arrangements made by) any one entity.  If the Document
     already includes a cover text for the same cover, previously added
     by you or by arrangement made by the same entity you are acting on
     behalf of, you may not add another; but you may replace the old
     one, on explicit permission from the previous publisher that added
     the old one.
d2257 2
a2258 2
     modified versions, provided that you include in the combination all
     of the Invariant Sections of all of the original documents,
d2285 2
a2286 2
     rules of this License for verbatim copying of each of the documents
     in all other respects.
d2290 3
a2292 3
     a copy of this License into the extracted document, and follow this
     License in all other respects regarding verbatim copying of that
     document.
d2297 2
a2298 2
     separate and independent documents or works, in or on a volume of a
     storage or distribution medium, is called an "aggregate" if the
d2343 2
a2344 2
     provisionally, unless and until the copyright holder explicitly and
     finally terminates your license, and (b) permanently, if the
d2356 4
a2359 4
     the licenses of parties who have received copies or rights from you
     under this License.  If your rights have been terminated and not
     permanently reinstated, receipt of a copy of some or all of the
     same material does not give you any rights to use it.
d2361 1
a2361 1
  10. FUTURE REVISIONS OF THIS LICENSE
d2367 1
a2367 1
     <http://www.gnu.org/copyleft/>.
d2374 5
a2378 5
     published (not as a draft) by the Free Software Foundation.  If the
     Document does not specify a version number of this License, you may
     choose any version ever published (not as a draft) by the Free
     Software Foundation.  If the Document specifies that a proxy can
     decide which future versions of this License can be used, that
d2382 1
a2382 1
  11. RELICENSING
d2412 1
d2429 1
a2429 1
Texts, replace the "with...Texts."  line with this:
d2440 3
a2442 3
recommend releasing these examples in parallel under your choice of free
software license, such as the GNU General Public License, to permit
their use in free software.
d2447 18
a2464 18
Node: Top719
Node: Introduction2044
Node: Compiling4535
Node: Executing8591
Node: Invoking11379
Node: Output Options12794
Node: Analysis Options19886
Node: Miscellaneous Options23806
Node: Deprecated Options25060
Node: Symspecs27123
Node: Output28949
Node: Flat Profile29989
Node: Call Graph34942
Node: Primary38174
Node: Callers40762
Node: Subroutines42880
Node: Cycles44721
Node: Line-by-line51498
d2466 11
a2476 11
Node: Inaccuracy58572
Node: Sampling Error58830
Node: Assumptions61734
Node: How do I?63204
Node: Incompatibilities64761
Node: Details66255
Node: Implementation66648
Node: File Format72547
Node: Internals76835
Node: Debugging85325
Node: GNU Free Documentation License86915
@


1.1.1.7
log
@2018-07-18  Nick Clifton  <nickc@@redhat.com>

	2.31.1 Release point.

2018-07-18  Nick Clifton  <nickc@@redhat.com>

	* (DEVO_SUPPORT): Fix typo in previous delta.
	(do_proto_toplev): Add --quiet option to configure command line.

2018-07-16  Nick Clifton  <nickc@@redhat.com>

	* src-release.sh (DEVO_SUPPORT): Add test-driver and ar-lib.

2018-07-06  Sebastian Huber  <sebastian.huber@@embedded-brains.de>

	* config.sub: Sync with upstream version 2018-07-03.

2018-07-05  Sebastian Huber  <sebastian.huber@@embedded-brains.de>

	* config.guess: Sync with upstream version 2018-06-26.
	* config.sub: Sync with upstream version 2018-07-02.

2018-06-24  Nick Clifton  <nickc@@redhat.com>

	* configure: Regenerate.

2018-06-19  Simon Marchi  <simon.marchi@@ericsson.com>

	* libtool.m4: Use AC_LANG_SOURCE.
	* configure.ac: Remove AC_PREREQ, use AC_LANG_SOURCE.
	* README-maintainer-mode: Update version requirements.
	* ar-lib: New file.
	* test-driver: New file.
	* configure: Re-generate.

2018-06-18  Eric Botcazou  <ebotcazou@@adacore.com>

	* Makefile.def (fortran): Add check-target-libgomp-fortran.
	* Makefile.tpl (check-target-libgomp-fortran): New phony target.
	* Makefile.in: Regenerate.

	* configure: Regenerate.

2018-06-18  Simon Marchi  <simon.marchi@@ericsson.com>

	* configure.ac: Sync with GCC, remove MPX-related things.

2018-05-01  Nick Clifton  <nickc@@redhat.com>

	* config.guess: Synchronize with config project master sources.
	* config.sub: Likewise.

2018-05-01  Francois H. Theron  <francois.theron@@netronome.com>

	* configure.ac: Added "nfp" target.
	* configure: Regenerate.

2018-02-13  Maciej W. Rozycki  <macro@@mips.com>

	* configure.ac <wasm32-*-*> (noconfigdirs): Add `ld'.
	* configure: Regenerate.

2018-01-30  Nick Clifton  <nickc@@redhat.com>

	* src-release.sh (do_proto_toplev): Add patterns for more junk files
	to delete before creating the tarball.

2018-01-29  Nick Clifton  <nickc@@redhat.com>

	* src-release.sh (do_proto_toplev): Strip patch remnant files from
	the sources before creating the tarball.

2018-01-13  Nick Clifton  <nickc@@redhat.com>

	* src-release.sh: Update copyright notice.  Change reference to devo
	to be a reference to root.
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 6.4 from gprof.texi.
d30 1
a30 1
   This manual is for 'gprof' (GNU Binutils) version 2.30.90.
d2428 29
a2456 29
Node: Introduction2045
Node: Compiling4536
Node: Executing8592
Node: Invoking11380
Node: Output Options12795
Node: Analysis Options19887
Node: Miscellaneous Options23807
Node: Deprecated Options25061
Node: Symspecs27124
Node: Output28950
Node: Flat Profile29990
Node: Call Graph34943
Node: Primary38175
Node: Callers40763
Node: Subroutines42881
Node: Cycles44722
Node: Line-by-line51499
Node: Annotated Source55575
Node: Inaccuracy58573
Node: Sampling Error58831
Node: Assumptions61735
Node: How do I?63205
Node: Incompatibilities64762
Node: Details66256
Node: Implementation66649
Node: File Format72548
Node: Internals76836
Node: Debugging85326
Node: GNU Free Documentation License86916
@


1.1.1.8
log
@Import binutils-2.34

2020-01-18  Nick Clifton  <nickc@@redhat.com>

	Binutils 2.34 branch created.

2020-01-18  Nick Clifton  <nickc@@redhat.com>

	Synchronize top level configure files with master version:

	2020-01-01  Ben Elliston  <bje@@gnu.org>

	* config.guess: Update copyright years.
	* config.sub: Likewise.

	2019-12-21  Ben Elliston  <bje@@gnu.org>

	* config.guess (set_cc_for_build): Prevent multiple calls by
	checking if $tmp is already set. We can't check CC_FOR_BUILD as
	the user may set it externally. Thanks to Torbjörn Granlund for
	the bug report.

	2019-12-21  Torbjörn Granlund  <tg@@gmplib.org>

	* config.guess (alpha:Linux:*:*): Guard against missing
	/proc/cpuinfo by redirecting standard error to /dev/null.

	2019-09-12  Daniel Bittman  <danielbittman1@@gmail.com>

	* config.guess (*:Twizzler:*:*): New.
	* config.sub (-twizzler*): New.

	2019-07-24  Ben Elliston  <bje@@gnu.org>

	* config.guess (mips:OSF1:*.*): Whitespace cleanup.

	2019-06-30  Ben Elliston  <bje@@gnu.org>

	* config.sub (case $os): Match nsk* and powerunix. Don't later
	match nsk* and set os=nsk which removes the OS version number.

	2019-06-30  Ben Elliston  <bje@@gnu.org>

	* config.sub: Recognise os108*.

	2019-06-26  Ben Elliston  <bje@@gnu.org>

	* config.sub (hp300): Set $os to hpux.

	2019-06-26  Ben Elliston  <bje@@gnu.org>

	* config.sub (vsta): Move into alphabetical order.

	2019-06-10  Ben Elliston  <bje@@gnu.org>

	* config.guess (*:OS108:*:*): Recognise new OS.

	2019-05-28  Ben Elliston  <bje@@gnu.org>

	* config.guess (*:Darwin:*:*): Run xcode-select to determine if a
	system compiler is installed. If not, do not run set_cc_for_build,
	as the default cc will open a dialog box asking to install
	Xcode. If no C compiler is available, guess based on uname -p and
	uname -m.

	2019-05-28  Ben Elliston  <bje@@gnu.org>

	* config.guess (*:Darwin:*:*): Simplify UNAME_PROCESSOR.

2020-01-17  Simon Marchi  <simon.marchi@@efficios.com>

	* Makefile.def: Add dependencies of all-gdbsupport on all-bfd.
	* Makefile.in: Re-generate.

2020-01-14  Tom Tromey  <tom@@tromey.com>

	* src-release.sh (GDB_SUPPORT_DIRS): Add gdbsupport.
	* MAINTAINERS: Add gdbsupport.
	* configure: Rebuild.
	* configure.ac (configdirs): Add gdbsupport.
	* gdbsupport: New directory, move from gdb/gdbsupport.
	* Makefile.def (host_modules, dependencies): Add gnulib.
	* Makefile.in: Rebuild.

2020-01-09  Aaron Merey  <amerey@@redhat.com>

        * config/debuginfod.m4: New file. Add macro AC_DEBUGINFOD. Adds
        new configure option --with-debuginfod.
        * configure: Regenerate.
        * configure.ac: Call AC_DEBUGINFOD.

2019-12-26  Christian Biesinger  <cbiesinger@@google.com>

	* .gitignore: Add perf.data and perf.data.old.

2019-10-17  Sergio Durigan Junior  <sergiodj@@redhat.com>

	* src-release.sh (GDB_SUPPORT_DIRS): Add libctf.

2019-10-17  Alan Modra  <amodra@@gmail.com>

	PR 29
	* src-release.sh (getver): Replace "head -1" with "head -n 1".

2019-07-30  Nick Alcock  <nick.alcock@@oracle.com>

	* Makefile.def (host_modules): libctf is no longer no_install.
	* Makefile.in: Regenerated.

2019-07-13  Nick Alcock  <nick.alcock@@oracle.com>

	* Makefile.def (dependencies): all-ld depends on all-libctf.
	* Makefile.in: Regenerated.

2019-09-09  Phil Blundell  <pb@@pbcl.net>

	binutils 2.33 branch created

2019-08-19  Tom Tromey  <tom@@tromey.com>

	* configure: Rebuild.
	* configure.ac: Add --with-static-standard-libraries.

2019-08-09  Nick Clifton  <nickc@@redhat.com>

	* libiberty: Sync with gcc.  Bring in:
	2019-08-08  Martin Liska  <mliska@@suse.cz>

	PR bootstrap/91352
	* lrealpath.c (is_valid_fd): New function.

	2019-07-24  Martin Liska  <mliska@@suse.cz>

	PR lto/91228
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Find first '\0' starting from gnu_lto + 1.

	2019-07-12  Ren Kimura  <rkx1209dev@@gmail.com>

	* simple-object-elf.c (simple_object_elf_match): Check zero value shstrndx.
	This fixes a Bug 90924.

	2019-07-22  Martin Liska  <mliska@@suse.cz>

	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Do not search for gnu_lto_v1, but search for first '\0'.

	2019-07-18  Eduard-Mihai Burtescu  <eddyb@@lyken.rs>

	* cplus-dem.c: Include rust-demangle.h.
	* rust-demangle.c: Include rust-demangle.h.
	* rust-demangle.h: New file.

	2019-05-31  Michael Forney  <mforney@@mforney.org>

	* cp-demangle.c: Don't define CP_DYNAMIC_ARRAYS if __STDC_NO_VLA__
	is non-zero.

	2019-04-30  Ben L  <bobsayshilol@@live.co.uk>

	* d-demangle.c (dlang_parse_assocarray): Correctly handle error result.
	* testsuite/d-demangle-expected: Add testcase.

	* d-demangle.c (dlang_parse_tuple): Correctly handle error result.
	* testsuite/d-demangle-expected: Add testcase.

	* d-demangle.c (dlang_parse_structlit): Correctly handle error result.
	* testsuite/d-demangle-expected: Add testcase.

	* d-demangle.c (dlang_parse_arrayliteral): Correctly handle error result.
	* testsuite/d-demangle-expected: Add testcase.

	* d-demangle.c (dlang_parse_integer): Fix stack underflow.
	* testsuite/d-demangle-expected: Add testcase.

	* cp-demangle (d_print_comp_inner): Guard against a NULL 'typed_name'.
	* testsuite/demangle-expected: Add testcase.

	* cp-demangle.c (d_encoding): Guard against NULL return values from
	d_right (dc).
	* testsuite/demangle-expected: Add testcase.

	2019-04-29  Ben L  <bobsayshilol@@live.co.uk>

	* cp-demangle.c (d_expression_1): Don't peek ahead unless the current
	char is valid.
	* testsuite/demangle-expected: Add testcase.

	2019-04-10  Nick Clifton  <nickc@@redhat.com>

	PR 89394
	* cp-demangle.c (cplus_demangle_fill_name): Reject negative
	lengths.
	(d_count_templates_scopes): Replace num_templates and num_scopes
	parameters with a struct d_print_info pointer parameter.  Adjust
	body of the function accordingly.  Add recursion counter and check
	that the recursion limit is not reached.
	(d_print_init): Pass dpi parameter to d_count_templates_scopes.
	Reset recursion counter afterwards, unless the recursion limit was
	reached.

2019-07-13  Joel Brobecker  <brobecker@@adacore.com>

	* src-release (getver): If $tool/gdbsupport/create-version.sh
	exists, use that to determine the version number.

2019-06-21  Andreas Schwab  <schwab@@linux-m68k.org>

	* src-release.sh (GDB_SUPPORT_DIRS): Add gnulib.

2019-06-14  Tom Tromey  <tom@@tromey.com>

	* MAINTAINERS: Add gnulib.
	* gnulib: New directory, move from gdb/gnulib.
	* configure.ac (host_libs): Add gnulib.
	* configure: Rebuild.
	* Makefile.def (host_modules, dependencies): Add gnulib.
	* Makefile.in: Rebuild.

2019-06-03  Nick Clifton  <nickc@@redhat.com>

	Revert:
	2019-05-29  Nick Clifton  <nickc@@redhat.com>

	* configure.ac (noconfigdirs): Add libctf if the target does not use
	the ELF file format.
	* configure: Regenerate.

2019-05-29  Nick Clifton  <nickc@@redhat.com>

	* src-release.sh (do_proto_toplev): Add libctf to list of
	directories that can be disabled.

2019-05-29  Nick Clifton  <nickc@@redhat.com>

	* configure.ac (noconfigdirs): Add libctf if the target does not use
	the ELF file format.
	* configure: Regenerate.

2019-05-28  Nick Alcock  <nick.alcock@@oracle.com>

	* Makefile.def (dependencies): configure-libctf depends on all-bfd
	and all its deps.
	* Makefile.in: Regenerated.

2019-05-28  Nick Alcock  <nick.alcock@@oracle.com>

	* MAINTAINERS: Add libctf.

2019-05-28  Nick Alcock  <nick.alcock@@oracle.com>

	* Makefile.def (host_modules): Add libctf.
	* Makefile.def (dependencies): Likewise.
	libctf depends on zlib, libiberty, and bfd.
	* Makefile.in: Regenerated.
	* configure.ac (host_libs): Add libctf.
	* configure: Regenerated.

2019-05-23  Jose E. Marchesi  <jose.marchesi@@oracle.com>

	* config.guess: Synchronize with config project master sources.
	* config.sub: Likewise.
	* readline/support/config.guess: Likewise.
	* readline/support/config.sub: Likewise.

2019-04-10  Nick Clifton  <nickc@@redhat.com>

	* libiberty: Sync with gcc.  Bring in:
	2019-04-10  Nick Clifton  <nickc@@redhat.com>

	PR 89394
	* cp-demangle.c (cplus_demangle_fill_name): Reject negative
	lengths.
	(d_count_templates_scopes): Replace num_templates and num_scopes
	parameters with a struct d_print_info pointer parameter.  Adjust
	body of the function accordingly.  Add recursion counter and check
	that the recursion limit is not reached.
	(d_print_init): Pass dpi parameter to d_count_templates_scopes.
	Reset recursion counter afterwards, unless the recursion limit was
	reached.

2018-06-24  Nick Clifton  <nickc@@redhat.com>

	2.32 branch created.

2019-01-14  Rainer Orth  <ro@@CeBiTec.Uni-Bielefeld.DE>

	Merge from GCC:
	PR target/88535
	* config.guess: Import upstream version 2019-01-03.
	* config.sub: Import upstream version 2019-01-01.

2019-01-10  Nick Clifton  <nickc@@redhat.com>

	* libiberty: Sync with gcc.  Bring in:
	2019-01-09  Sandra Loosemore  <sandra@@codesourcery.com>

	PR other/16615

	* cp-demangle.c: Mechanically replace "can not" with "cannot".
	* floatformat.c: Likewise.
	* strerror.c: Likewise.

	2018-12-22  Jason Merrill  <jason@@redhat.com>

	Remove support for demangling GCC 2.x era mangling schemes.
	* cplus-dem.c: Remove cplus_mangle_opname, cplus_demangle_opname,
	internal_cplus_demangle, and all subroutines.
	(libiberty_demanglers): Remove entries for ancient GNU (pre-3.0),
	Lucid, ARM, HP, and EDG demangling styles.
	(cplus_demangle): Remove 'work' variable.  Don't call
	internal_cplus_demangle.

2019-01-03  Дилян Палаузов  <dilyan.palauzov@@aegee.org>

	* configure.ac: Don't configure readline if --with-system-readline is
	used.
	* configure: Re-generate.

2018-10-31  Joseph Myers  <joseph@@codesourcery.com>

	Merge from GCC:
	PR bootstrap/82856
	* multilib.am: New file.  From automake.

2018-09-12  Sergio Durigan Junior  <sergiodj@@redhat.com>

	* src-release.sh (GDB_SUPPORT_DIRS): Add "contrib".

2018-07-16  Nick Clifton  <nickc@@redhat.com>

@@ -20,6 +338,18 @@@@
	* config.guess: Sync with upstream version 2018-06-26.
	* config.sub: Sync with upstream version 2018-07-02.

2018-06-29  Alexandre Oliva <oliva@@adacore.com>

	* configure.ac: Introduce support for @@unless/@@endunless.
	* Makefile.tpl (dep-kind): Rewrite with cond; return
	postbootstrap in some cases.
	(make-postboot-dep, postboot-targets): New.
	(dependencies): Do not output postbootstrap dependencies at
	first.  Output non-target ones changed for configure to depend
	on stage_last @@if gcc-bootstrap, and the original deps @@unless
	gcc-bootstrap.
	* configure.in, Makefile.in: Rebuilt.

2018-06-24  Nick Clifton  <nickc@@redhat.com>

	* configure: Regenerate.
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 6.5 from gprof.texi.
d5 1
a5 1
   Copyright (C) 1988-2020 Free Software Foundation, Inc.
d30 1
a30 1
   This manual is for 'gprof' (GNU Binutils) version 2.34.
d170 1
a170 1
'-static-libgcc' command-line option.  For example:
d193 1
a193 1
command-line option which will insert calls to special user supplied
d1211 2
a1212 2
versions of 'gcc' the program had to be compiled with the '-a'
command-line option as well.
d2428 29
a2456 29
Node: Introduction2042
Node: Compiling4533
Node: Executing8589
Node: Invoking11377
Node: Output Options12792
Node: Analysis Options19884
Node: Miscellaneous Options23804
Node: Deprecated Options25058
Node: Symspecs27121
Node: Output28947
Node: Flat Profile29987
Node: Call Graph34940
Node: Primary38172
Node: Callers40760
Node: Subroutines42878
Node: Cycles44719
Node: Line-by-line51496
Node: Annotated Source55572
Node: Inaccuracy58570
Node: Sampling Error58828
Node: Assumptions61732
Node: How do I?63202
Node: Incompatibilities64759
Node: Details66253
Node: Implementation66646
Node: File Format72545
Node: Internals76833
Node: Debugging85323
Node: GNU Free Documentation License86913
@


1.1.1.9
log
@Update binutils from 2.34 to 2.39

2022-07-08  Nick Clifton  <nickc@@redhat.com>

	* 2.39 branch created.

2022-07-04  Nick Clifton  <nickc@@redhat.com>

	* libiberty: Synchronize with GCC.  Bring in:
	2022-07-01  Nick Clifton  <nickc@@redhat.com>

	PR demangler/105039
	* rust-demangle.c (demangle_const): Add recursion limit.

	2022-06-26  Simon Marchi  <simon.marchi@@efficios.com>

	* configure.ac: Add AC_CONFIG_MACRO_DIRS call.
	* configure: Re-generate.

2022-04-12  Nick Clifton  <nickc@@redhat.com>

	* zlib: Rebase to the 1.2.12 release.

2022-04-08  Simon Marchi  <simon.marchi@@efficios.com>

	* configure.ac: Add AC_SUBST(PKG_CONFIG_PATH).
	* configure: Re-generate.
	* Makefile.tpl (HOST_EXPORTS): Pass PKG_CONFIG_PATH.
	(PKG_CONFIG_PATH): New.
	* Makefile.in: Re-generate.

2022-03-15  Jose E. Marchesi  <jose.marchesi@@oracle.com>

	* gprofng/src/gp-collect-app.cc (collect::check_args): Use
	fallthrough comment instead of attribute.

2022-03-11  Vladimir Mezentsev  <vladimir.mezentsev@@oracle.com>

	* Makefile.def: Add gprofng module.
	* configure.ac: Add --enable-gprofng option.
	* src-release.sh: Add gprofng.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* gprofng: New directory.

2022-01-22  Nick Clifton  <nickc@@redhat.com>

	* 2.38 release branch created.

2022-01-17  Nick Clifton  <nickc@@redhat.com>

	Update config.[guess|sub] from upstream:

	2022-01-09  Idan Horowitz  <idan.horowitz@@gmail.com>

	config.guess: recognize SerenityOS
	* config.guess (*:SerenityOS:*:*): Recognize.
	(timestamp): Update.

	2022-01-03  Bernhard Voelker  <mail@@bernhard-voelker.de>

	Fix GPLv3 license headers to use a comma instead of semicolon
	See: https://www.gnu.org/licenses/gpl-3.0.html#howto

	Update license headers automatically using the following script:

	  $ git grep -l 'Foundation; either version 3' \
	    | xargs sed -i '/Foundation; either version 3/ s/n; e/n, e/'

	* config.guess: Adjust via the above command.
	(timestamp): Update.
	* config.sub: Likewise.
	* doc/config.guess.1: Regenerate.
	* doc/config.sub.1: Likewise.

	2022-01-01  Dmitry V. Levin  <ldv@@altlinux.org>

	Update copyright years
	* config.guess: Update copyright years.
	* config.sub: Likewise.

	2021-12-25  Dmitry V. Levin  <ldv@@altlinux.org>

	config.sub: alias armh to armv7l
	ALT uses armh as an alias for armv7l-alt-linux-gnueabihf since 2012.

	* config.sub (armh-unknown|armh-alt): Set cpu, vendor, and basic_os.
	(timestamp): Update.

	2021-12-24  Dmitry V. Levin  <ldv@@altlinux.org>

	config.sub: alias aarch64le to aarch64
	Apparently, QNX reports aarch64 as aarch64le on little-endian machines.

	* config.sub (aarch64le-*): Set cpu to aarch64.
	(timestamp): Update.

	2021-12-13  Dmitry V. Levin  <ldv@@altlinux.org>

	config.sub: fix typo in timestamp
	* config.sub: Fix timestamp.

	2021-11-30  Andreas F. Borchert  <github@@andreas-borchert.de>

	config.guess: x86_64-pc-solaris2.11 is not properly recognized
	config.guess guesses Solaris 11 to run on a 32-bit platform
	despite Solaris 11 no longer supporting any 32-bit platform.

	See the following code at lines 434 to 445:

	| SUN_ARCH=i386
	| # If there is a compiler, see if it is configured for 64-bit objects.
	| # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
	| # This test works for both compilers.
	| if test "$CC_FOR_BUILD" != no_compiler_found; then
	|     if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
	|         (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
	|         grep IS_64BIT_ARCH >/dev/null
	|     then
	|         SUN_ARCH=x86_64
	|     fi
	| fi

	If "cc" is installed, i.e. the Oracle Studio compiler, this one is
	chosen for $CC_FOR_BUILD.  This compiler, the gcc provided by Oracle
	and also gcc bootstrapped from sources on that platform with a default
	configuration will by default generate 32-bit binaries -- even on
	a 64-bit platform.  And __amd64 will not be defined for compilations
	targeting a 32-bit platform.  This is different from the corresponding
	behaviour on GNU/Linux systems where the local platform is targeted by
	default.

	Thus, as long as you do not add "-m64" or if you have a custom-built
	gcc which defaults to 64 bit, you will get 32-bit binaries on Solaris
	despite living on a 64-bit platform.

	* config.guess (i86pc:SunOS:5.*:* || i86xen:SunOS:5.*:*): Adapt the
	test by adding the "-m64" flag.  This will work properly for Solaris
	10 as well (the last Solaris release that supported x86 32-bit
	platforms).

	2021-10-27  Jordi Sanfeliu  <jordi@@fibranet.cat>

	Recognize Fiwix
	$ make check
	cd testsuite && bash config-guess.sh && rm uname
	PASS: config.guess checks (137 tests)
	cd testsuite && bash config-sub.sh
	PASS: config.sub checks (882 tests)
	PASS: config.sub idempotency checks (819 tests)
	PASS: config.sub canonicalise each config.guess testcase (137 tests)

	* config.guess (i*86:Fiwix:*:*): Recognize.
	* config.sub (fiwix*): Likewise.

	2021-10-18  Kinshuk Dua  <kinshukdua@@gmail.com>

	config.sub: Fix typo in comment
	Fixes: 5e531d391852a54e7fab2d8ff55625fca514b305

	2021-08-14  Nick Bowler  <nbowler@@draconx.ca>

	config.sub: work around command assignment bug in some shells
	When combining variable assignments with a shell command, some older
	shells (notably heirloom-sh and presumably also Solaris 10 /bin/sh)
	have a bug which causes the assignment to alter the current execution
	environment whenever the command is a shell built-in.  For example:

	  % dash -c 'x=good; x=bad echo >/dev/null; echo $x'
	  good

	  % jsh -c 'x=good; x=bad echo >/dev/null; echo $x'
	  bad

	The config.sub script contains a few commands of the form:

	  IFS=- read ...

	which triggers this bug, causing the IFS assignment to persist for the
	remainder of the script.  This can cause misbehaviour in certain cases,
	for example:

	  % jsh config.sub i386-linux-gnu
	  config.sub: test: unknown operator gnu

	  % jsh config.sub i386-gnu/linux
	  sed: can't read s|gnu/linux|gnu|: No such file or directory
	  Invalid configuration `i386-gnu/linux': OS `' not recognized

	* config.sub: Save and restore IFS explicitly to avoid shell bugs.
	* doc/config.sub.1: Regenerate.

	2021-08-04  Jeremy Soller  <jackpot51@@gmail.com>

	config.sub: add Linux Relibc Target
	$ make check
	cd testsuite && bash config-guess.sh && rm uname
	PASS: config.guess checks (136 tests)
	cd testsuite && bash config-sub.sh
	PASS: config.sub checks (881 tests)
	PASS: config.sub idempotency checks (818 tests)
	PASS: config.sub canonicalise each config.guess testcase (136 tests)

	* config.sub (relibc*): Recognize.
	* doc/config.sub.1: Regenerate.
	* testsuite/config-sub.data (x86_64-linux-relibc): New test.

	2021-07-06  Stephanos Ioannidis  <root@@stephanos.io>

	config.sub: add Zephyr RTOS support
	This adds the Zephyr RTOS targets in preparation for implementing the
	Zephyr RTOS-specific toolchain support.

	$ make check
	cd testsuite && bash config-guess.sh && rm uname
	PASS: config.guess checks (136 tests)
	cd testsuite && bash config-sub.sh
	PASS: config.sub checks (880 tests)
	PASS: config.sub idempotency checks (817 tests)
	PASS: config.sub canonicalise each config.guess testcase (136 tests)

	* config.sub (zephyr*): Recognize.
	* doc/config.sub.1: Regenerate.
	* testsuite/config-sub.data: Add testcases for *-zephyr.

	2021-07-03  Ozkan Sezer  <sezero@@users.sourceforge.net>

	config.sub: disable shellcheck SC2006 / SC2268 warnings
	This is in line with the recent config.guess change in commit
	12fcf67c9108f4c4b581eaa302088782f0ee40ea

	* config.sub (shellcheck disable): Add SC2006,SC2268.

	Suggested-by: Jacob Bachmeyer <jcb@@gnu.org>

	2021-07-03  Ozkan Sezer  <sezero@@users.sourceforge.net>

	config.sub: normalize the quoting in the `echo FOO | sed ...`
	Some cases quote the argument to echo and some do not.  At runtime
	it probably does not matter because the substituted values will never
	contain whitespace, but quoting them all would make shellcheck more
	useful.

	* config.sub: Consistently quote the argument of echo.
	* doc/config.sub.1: Regenerate.

	Suggested-by: Jacob Bachmeyer <jcb@@gnu.org>

	2021-07-02  Ozkan Sezer  <sezero@@users.sourceforge.net>

	config.sub: replace POSIX $( ) with classic ` ` throughout
	This is in line with the recent config.guess change in commit
	d70c4fa934de164178054c3a60aaa0024ed07c91.

	The patch was generated using patch-6.gawk script introduced in that
	commit.

	* config.sub: Revert POSIX command substitutions to classic form.

	2021-06-04  Vineet Gupta  <Vineet.Gupta1@@synopsys.com>

	Recognize arc32
	This is the 32-bit variant of ARCv3 ISA (which is not compatible with the
	32-bit ARCv2 ISA)

	| make check
	| cd testsuite && bash config-guess.sh && rm uname
	| PASS: config.guess checks (136 tests)
	| cd testsuite && bash config-sub.sh
	| PASS: config.sub checks (864 tests)
	| PASS: config.sub idempotency checks (801 tests)
	| PASS: config.sub canonicalise each config.guess testcase (136 tests)

	* config.guess (arc32:Linux:*:*): Recognize.
	* config.sub (arc32): Likewise.

	2021-05-27  Jacob Bachmeyer  <jcb@@gnu.org>

	Remove automatic patch generators
	These tools have served their purposes and need not be kept outside of
	the repository history any longer.  This patch as a diff also collects
	the contents of the various tools in one convenient place.

	* patch-1.gawk: Remove.
	* patch-3.gawk: Likewise.
	* patch-6.gawk: Likewise.

	2021-05-26  Jacob Bachmeyer  <jcb@@gnu.org>

	config.guess: manual fixups after previous automatic patch
	The tool could not handle command substitutions that span lines, but
	fortunately there were only two such substitutions in the script.

	The test for which universe is active on Pyramid is rewritten into a
	case block because it was the only use of a command substitution as an
	argument to the test command, which would require quoting.

	* config.guess: Rewrite "if" for Pyramid systems to "case".

	2021-05-26  Jacob Bachmeyer  <jcb@@gnu.org>

	config.guess: replace POSIX $( ) with classic ` ` throughout
	The previous replacement of backticks with POSIX command substitutions
	was ill-considered and illogical: this script recognizes many archaic
	machine types that probably never had POSIX shells, therefore it needs
	to be able to run successfully under pre-POSIX shells.

	This patch was generated using the included GNU Awk program.

	* config.guess: Revert POSIX command substitutions to classic form.
	* patch-6.gawk: Store the tool that produced the automated patch.

	2021-05-26  Jacob Bachmeyer  <jcb@@gnu.org>

	config.guess: manual fixup after previous automated patches
	This patch provides the special handling for the GNU system.  As these
	were two small and unique edits, they were not included in the scripts.

	This patch also cleans up other minor issues that must be addressed
	before reverting to classic command substitutions and updates
	"shellcheck" directives to account for changes in this script and the
	change in "shellcheck" towards reporting individual portability issues.

	2021-05-26  Jacob Bachmeyer  <jcb@@gnu.org>

	config.guess: automatic fixups after previous automated patch
	This patch was generated using the following command:

	  sed -i config.guess \
	      -e '/="[^"]\+"\(-\|$\)/s/="\([^"([:space:])]\+\)"/=\1/' \
	      -e '/="[^"]\+"[[:alnum:]]/s/="\$\([^([:space:])]\+\)"/=${\1}/' \
	      -e \
	'/\$(echo[^|]\+|/s/\([^[:space:]]\)[[:space:]]*|[[:space:]]*sed/\1 | sed/g'

	* config.guess: Remove unneeded quotes in other variable assignments,
	standardize spacing for "echo ... | sed" substitutions.

	2021-05-26  Jacob Bachmeyer  <jcb@@gnu.org>

	config.guess: remove unneeded quotes and factor command substitutions
	This is further cleanup and simplifies some constructs that can confuse
	Emacs' syntax highlighting while generally reducing required quoting.

	This patch was generated using the included GNU Awk program.

	* config.guess: Remove unneeded variable quotes and factor out command
	substitutions when setting GUESS.
	* patch-3.gawk: Store the tool that produced the automated patch.

	2021-05-25  Jacob Bachmeyer  <jcb@@gnu.org>

	config.guess: manual fixups after previous automatic patch
	* config.guess: Adjust a few "leftover" cases that the tool could not
	easily recognize and fixes comment indentation in a few other special
	cases.

	2021-05-25  Jacob Bachmeyer  <jcb@@gnu.org>

	config.guess: use intermediate variable with uname results
	This will allow quoting to be significantly simplified in another
	pass through the file.

	This patch was generated using the included GNU Awk program.

	* config.guess: Use GUESS variable to hold results of uname analysis.
	* patch-1.gawk: Store the tool that produced the automated patch.

	2021-05-25  Jacob Bachmeyer  <jcb@@gnu.org>

	config.guess: introduce intermediate variable with uname results
	This will allow quoting to be significantly simplified in another
	pass through the file.

	* config.guess: Introduce GUESS variable to hold results of uname analysis.

	2021-05-24  Dmitry V. Levin  <ldv@@altlinux.org>

	config.guess: fix shellcheck warning SC2154
	While, according to Plan 9 documentation, the environment variable
	$cputype is set to the name of the kernel's CPU's architecture,
	shellcheck warns that cputype is referenced but not assigned.
	Be on the safe side and do not use cputype if it is not defined
	or empty.

	* config.guess (*:Plan9:*:*): Fix shellcheck warning SC2154.

	2021-05-24  Dmitry V. Levin  <ldv@@altlinux.org>

	config.guess: remove redundant quotes in case commands
	According to the GNU Autoconf Portable Shell Programming manual,
	the Bourne shell does not systematically split variables and back-quoted
	expressions, in particular on the right-hand side of assignments and in
	the argument of 'case'.

	The change is made automatically using the following command:
	$ sed -E -i 's/(\<case )"(\$[^"]+)"( in\>)/\1\2\3/' config.guess

	* config.guess: Simplify case commands by removing quotes around the
	argument.

	Suggested-by: Jacob Bachmeyer <jcb@@gnu.org>

	2021-05-24  Dmitry V. Levin  <ldv@@altlinux.org>

	config.guess: simplify exit status workaround on alphaev67-dec-osf5.1
	Commit 29865ea8a5622cdd80b7a69a0afa78004b4cd311 introduced an exit trap
	reset before exiting to avoid a spurious non-zero exit status on
	alphaev67-dec-osf5.1.  Simplify that code a bit by moving the exit trap
	reset around.

	* config.guess (alpha:OSF1:*:*): Reset exit trap earlier.
	* doc/config.guess.1: Regenerate.

2021-10-29  Eli Zaretskii  <eliz@@gnu.org>

	* gdb/doc/gdb.texinfo (Command Options): (Data): Document
	'-memory-tag-violations'.  Update the example.

2021-09-28  Andrew Burgess  <andrew.burgess@@embecosm.com>

	* src-release.sh (GDB_SUPPPORT_DIRS): Add libbacktrace.

2021-09-27  Nick Alcock  <nick.alcock@@oracle.com>

	PR libctf/27967
	* libtool.m4 (LT_PATH_NM): Try BSDization flags with a user-provided
	NM, if there is one.  Run nm on itself, not on /dev/null, to avoid
	errors from nms that refuse to work on non-regular files.  Remove
	other workarounds for this problem.  Strip out blank lines from the
	nm output.

2021-09-27  Nick Alcock  <nick.alcock@@oracle.com>

	PR libctf/27967
	* libtool.m4 (lt_cv_sys_global_symbol_pipe): Augment symcode for
	Solaris 11.

2021-07-03  Nick Clifton  <nickc@@redhat.com>

	* 2.37 release branch created.

2021-07-03  Nick Clifton  <nickc@@redhat.com>

	* libiberty: Sync with gcc.  Bring in:
	2021-06-30  Gerald Pfeifer  <gerald@@pfeifer.com>

	* make-temp-file.c (usrtmp): Remove.
	(choose_tmpdir): Remove use of usrtmp.

	2021-06-28  Indu Bhagat  <indu.bhagat@@oracle.com>

	* simple-object.c (handle_lto_debug_sections): Copy over .BTF section.

	2021-06-28  Indu Bhagat  <indu.bhagat@@oracle.com>
	    David Faust  <david.faust@@oracle.com>
	    Jose E. Marchesi  <jose.marchesi@@oracle.com>
	    Weimin Pan  <weimin.pan@@oracle.com>

	* simple-object.c (handle_lto_debug_sections): Copy over .ctf
	sections.

	2021-06-05  John David Anglin  <danglin@@gcc.gnu.org>

	PR target/100734
	* configure.ac: Use libiberty snprintf and vsnprintf on
	hppa*-*-hpux*.
	* configure: Regenerate.

	2021-05-06  Tom Tromey  <tom@@tromey.com>

	* hashtab.c (htab_eq_string): New function.

	2021-05-04  Eric Botcazou  <ebotcazou@@adacore.com>

	* configure.ac: Make test for variables more robust.
	* configure: Regenerate.

	2021-05-03  H.J. Lu  <hjl.tools@@gmail.com>

	PR bootstrap/99703
	* configure: Regenerated.

	2021-04-21  Andreas Schwab  <schwab@@linux-m68k.org>

	PR demangler/100177
	* rust-demangle.c (demangle_const_char): Properly print the
	character value.

	2021-03-31  Patrick Palka  <ppalka@@redhat.com>

	PR c++/88115
	* cp-demangle.c (d_dump, d_make_comp, d_expression_1)
	(d_count_templates_scopes): Handle DEMANGLE_COMPONENT_VENDOR_EXPR.
	(d_print_comp_inner): Likewise.
	<case DEMANGLE_COMPONENT_EXTENDED_OPERATOR>: Revert r11-4926
	change.
	<case DEMANGLE_COMPONENT_UNARY>: Likewise.
	* testsuite/demangle-expected: Adjust __alignof__ tests.

	2021-03-16  Nick Clifton  <nickc@@redhat.com>

	* sha1.c (sha1_process_bytes): Use memmove in place of memcpy.

	2021-02-20  Mike Frysinger  <vapier@@gentoo.org>

	* Makefile.in (ACLOCAL, ACLOCAL_AMFLAGS, $(srcdir)/aclocal.m4): Define.
	(configure_deps): Rename to ...
	(aclocal_deps): ... this.  Replace aclocal.m4 with acinclude.m4.
	($(srcdir)/configure): Replace $(configure_deps) with
	$(srcdir)/aclocal.m4.
	* aclocal.m4: Move libiberty macros to acinclude.m4, then regenerate.
	* acinclude.m4: New file.
	* configure: Regenerate.

	2021-02-19  Ayush Mittal  <ayush.m@@samsung.com>

	* argv.c (expandargv): free allocated buffer if read fails.

	2021-02-01  Martin Sebor  <msebor@@redhat.com>

	* dyn-string.c (dyn_string_insert_cstr): Use memcpy instead of strncpy
	to avoid -Wstringop-truncation.

2021-05-29  Mike Frysinger  <vapier@@gentoo.org>

	* configure.ac: Add gnulib to configdirs for sim.
	* configure: Regenerate.

2021-05-24  Maciej W. Rozycki  <macro@@orcam.me.uk>

	* MAINTAINERS: Update path to readline config.{sub,guess} files.

2021-05-24  Maciej W. Rozycki  <macro@@orcam.me.uk>

	* config.guess: Import from upstream.
	* config.sub: Likewise.

2021-05-18  Mike Frysinger  <vapier@@gentoo.org>

	* Makefile.def: Add configure-sim dependency on all-gnulib.
	* Makefile.in: Regenerated.

2021-05-04  Nick Clifton  <nickc@@redhat.com>

	* configure.ac (AC_PROG_CC): Replace with AC_PROG_CC_C99.
	* configure: Regenerate.

2021-03-18  Nick Alcock  <nick.alcock@@oracle.com>

	PR libctf/27482
	* Makefile.def: Add install-bfd dependencies for install-libctf and
	install-ld, and install-strip-bfd dependencies for
	install-strip-libctf and install-strip-ld; move the install-ld
	dependency on install-libctf to join it.
	* Makefile.in: Regenerated.

2021-03-12  Mike Frysinger  <vapier@@gentoo.org>

	* Makefile.def: Remove all-sim dependency on configure-gdb.
	* Makefile.in: Regenerated.

2021-02-28  H.J. Lu  <hongjiu.lu@@intel.com>

	PR binutils/26766
	* Makefile.tpl (PGO_BUILD_TRAINING_FLAGS_TO_PASS): Add
	PGO_BUILD_TRAINING=yes.
	(PGO_BUILD_TRAINING_MFLAGS): New.
	(all): Pass $(PGO_BUILD_TRAINING_MFLAGS) to the PGO build.

2021-02-09  Alan Modra  <amodra@@gmail.com>

	* configure.ac: Delete arm*-*-symbianelf* entry.
	* configure: Regenerate.

2021-01-26  Nick Alcock  <nick.alcock@@oracle.com>

	* Makefile.def: Add install-libctf dependency to install-ld.
	* Makefile.in: Regenerated.

2021-01-12  Mike Frysinger  <vapier@@gentoo.org>

	* src-release.sh (do_proto_toplev): Rewrite indentation.

2021-01-11  H.J. Lu  <hongjiu.lu@@intel.com>

	PR binutils/26766
	* configure.ac:
	* configure: Regenerated.

2021-01-11  H.J. Lu  <hongjiu.lu@@intel.com>

	PR ld/27173
	* configure: Regenerated.
	* libtool.m4 (_LT_CMD_OLD_ARCHIVE): Check if AR works with
	--plugin and rc before enabling --plugin.

2021-01-09  H.J. Lu  <hongjiu.lu@@intel.com>

	PR binutils/26766
	* Makefile.tpl (BUILD_CFLAGS): New.
	(CFLAGS): Append $(BUILD_CFLAGS).
	(CXXFLAGS): Likewise.
	(PGO_BUILD_GEN_FLAGS_TO_PASS): New.
	(PGO_BUILD_TRAINING_CFLAGS): Likewise.
	(PGO_BUILD_TRAINING_CXXFLAGS): Likewise.
	(PGO_BUILD_TRAINING_FLAGS_TO_PASS): Likewise.
	(PGO_BUILD_TRAINING_MFLAGS): Likewise.
	(PGO_BUILD_USE_FLAGS_TO_PASS): Likewise.
	(PGO-TRAINING-TARGETS): Likewise.
	(PGO_BUILD_TRAINING): Likewise.
	(all): Add '+' to the command line for recursive make.  Support
	the PGO build.
	* configure.ac: Add --enable-pgo-build[=lto].
	AC_SUBST PGO_BUILD_GEN_CFLAGS, PGO_BUILD_USE_CFLAGS and
	PGO_BUILD_LTO_CFLAGS.  Enable the PGO build in Makefile.
	* Makefile.in: Regenerated.
	* configure: Likewise.

2021-01-09  H.J. Lu  <hongjiu.lu@@intel.com>

	* Makefile.tpl (AR): Add @@AR_PLUGIN_OPTION@@
	(RANLIB): Add @@RANLIB_PLUGIN_OPTION@@.
	* configure.ac: Include config/gcc-plugin.m4.
	AC_SUBST AR_PLUGIN_OPTION and RANLIB_PLUGIN_OPTION.
	* libtool.m4 (_LT_CMD_OLD_ARCHIVE): Pass --plugin to AR and
	RANLIB if possible.
	* Makefile.in: Regenerated.
	* configure: Likewise.

2021-01-09  Nick Clifton  <nickc@@redhat.com>

	* 2.36 release branch crated.

2021-01-07  Samuel Thibault  <samuel.thibault@@gnu.org>

	* libtool.m4: Match gnu* along with other GNU systems.

2021-01-07  Alan Modra  <amodra@@gmail.com>

	* config.sub: Accept OS of eabi* and gnueabi*.

2021-01-05  Nick Alcock  <nick.alcock@@oracle.com>

	* Makefile.def (libctf): No longer no_check.  Checking depends on
	all-ld.
	* Makefile.in: Regenerated.

2021-01-05  Nick Clifton  <nickc@@redhat.com>

	* libiberty: Sync with gcc.  Bring in:
	2021-01-04  Martin Liska  <mliska@@suse.cz>

	* strverscmp.c: Convert to utf8 from iso8859.

	2020-12-22  Jason Merrill  <jason@@redhat.com>

	PR c++/67343
	* cp-demangle.h (struct d_info): Add unresolved_name_state.
	* cp-demangle.c (d_prefix): Add subst parm.
	(d_nested_name): Pass it.
	(d_unresolved_name): Split out from...
	(d_expression_1): ...here.
	(d_demangle_callback): Maybe retry with old sr mangling.
	* testsuite/demangle-expected: Add test.

	2020-12-21  Jason Merrill  <jason@@redhat.com>

	* cp-demangle.c (d_expression_1): Recognize qualified-id
	on RHS of dt/pt.
	* testsuite/demangle-expected: Add test.

	2020-12-21  Jason Merrill  <jason@@redhat.com>

	* cp-demangle.c (d_unqualified_name): Clear is_expression.
	* testsuite/demangle-expected: Add tests.

	2020-11-25  Matthew Malcomson  <matthew.malcomson@@arm.com>

	* configure: Regenerate.
	* configure.ac: Avoid using sanitizer.

	2020-11-13  Eduard-Mihai Burtescu  <eddyb@@lyken.rs>

	* rust-demangle.c (struct rust_demangler): Add
	skipping_printing and bound_lifetime_depth fields.
	(eat): Add (v0-only).
	(parse_integer_62): Add (v0-only).
	(parse_opt_integer_62): Add (v0-only).
	(parse_disambiguator): Add (v0-only).
	(struct rust_mangled_ident): Add punycode{,_len} fields.
	(parse_ident): Support v0 identifiers.
	(print_str): Respect skipping_printing.
	(print_uint64): Add (v0-only).
	(print_uint64_hex): Add (v0-only).
	(print_ident): Respect skipping_printing,
	Support v0 identifiers.
	(print_lifetime_from_index): Add (v0-only).
	(demangle_binder): Add (v0-only).
	(demangle_path): Add (v0-only).
	(demangle_generic_arg): Add (v0-only).
	(demangle_type): Add (v0-only).
	(demangle_path_maybe_open_generics): Add (v0-only).
	(demangle_dyn_trait): Add (v0-only).
	(demangle_const): Add (v0-only).
	(demangle_const_uint): Add (v0-only).
	(basic_type): Add (v0-only).
	(rust_demangle_callback): Support v0 symbols.
	* testsuite/rust-demangle-expected: Add v0 testcases.

	2020-11-13  Seija Kijin  <doremylover456@@gmail.com>

	* strstr.c (strstr): Make implementation ANSI/POSIX compliant.

	2020-11-11  Patrick Palka  <ppalka@@redhat.com>

	PR c++/88115
	* cp-demangle.c (d_print_comp_inner)
	<case DEMANGLE_COMPONENT_EXTENDED_OPERATOR>: Don't print the
	"operator " prefix for __alignof__.
	<case DEMANGLE_COMPONENT_UNARY>: Always print parens around the
	operand of __alignof__.
	* testsuite/demangle-expected: Test demangling for __alignof__.

	2020-11-09  Christophe Lyon  <christophe.lyon@@linaro.org>

	* pex-win32.c (pex_win32_exec_child): Initialize orig_err.

	2020-10-06  Martin Liska  <mliska@@suse.cz>

	PR lto/97290
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Use sh_link of a .symtab_shndx section.

2021-01-05  Alan Modra  <amodra@@gmail.com>

	* config.guess: Import from upstream.
	* config.sub: Likewise.

2020-12-16  Martin Liska  <mliska@@suse.cz>
	    Tom de Vries  <tdevries@@suse.de>

	* gdb/debuginfod-support.c (struct user_data): Remove has_printed
	field.  Add meter field.
	(progressfn): Print progress using meter.

2020-12-02  Enze Li  <lienze2010@@hotmail.com>

	* .gitignore: Add gnu global outputs.

2020-12-02  Simon Marchi  <simon.marchi@@polymtl.ca>

	* .gitignore: Sync with gcc.

2020-10-26  Andreas Rammhold <andreas@@rammhold.de>

	* src-release.sh: Use sha256sum instead of md5sum.

2020-10-14  Andrew Burgess  <andrew.burgess@@embecosm.com>

	* Makefile.in: Rebuild.
	* Makefile.def: Make distclean-gnulib depend on distclean-gdb and
	distclean-gdbserver.

2020-07-24  Aaron Merey  <amerey@@redhat.com>

	* configure: Rebuild.
	* configure.ac: Remove AC_DEBUGINFOD.

2020-07-04  Nick Clifton  <nickc@@redhat.com>

	Binutils 2.35 branch created.

2020-04-21  Stephen Casner  <casner@@acm.org>

	PR 25830
	* configure.ac (noconfigdirs): Exclude gdb & gprof for pdp11.
	* configure: Rebuild.

2020-03-12  Tom Tromey  <tom@@tromey.com>

	* Makefile.in: Rebuild.
	* Makefile.def (gdbserver): Depend on gdbsupport.

2020-03-12  Tom Tromey  <tom@@tromey.com>

	* Makefile.in: Rebuild.
	* Makefile.def (gdbsupport): Don't depend on bfd.

2020-03-12  Tom Tromey  <tom@@tromey.com>

	* Makefile.in: Rebuild.
	* Makefile.def (gdbsupport): Depend on intl.

2020-02-17  Tom Tromey  <tom@@tromey.com>

	* configure: Rebuild.
	* configure.ac (configdirs): Add gnulib and gdbsupport when building
	gdbserver.

2020-02-14  Tom Tromey  <tom@@tromey.com>

	* Makefile.in: Rebuild.
	* Makefile.def: Make gdbserver require gnulib and libiberty.

2020-02-07  Tom Tromey  <tom@@tromey.com>
	    Pedro Alves  <palves@@redhat.com>

	* src-release.sh (GDB_SUPPORT_DIRS): Add gdbserver.
	* gdbserver: New directory, moved from gdb/gdbserver.
	* configure.ac (host_tools): Add gdbserver.
	Only build gdbserver on certain systems.
	* Makefile.in, configure: Rebuild.
	* Makefile.def (host_modules, dependencies): Add gdbserver.
	* MAINTAINERS: Add gdbserver.

2020-01-28  Sergio Durigan Junior  <sergiodj@@redhat.com>

	* src-release.sh (getver): Look for gdbsupport's
	create-version.sh script at the current directory if tool is
	"gdb".

2020-01-19  Simon Marchi  <simon.marchi@@polymtl.ca>

	* remote-sim.c (gdbsim_target::wait): Return
	sim_data->remote_sim_ptid instead of inferior_ptid.
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 6.8 from gprof.texi.
d5 1
a5 1
   Copyright (C) 1988-2022 Free Software Foundation, Inc.
d30 1
a30 1
   This manual is for 'gprof' (GNU Binutils) version 2.39.
d220 4
a223 5
'gmon.out', its contents are overwritten.  You can rename the file
afterwards if you are concerned that it may be overwritten.  If your
system libc allows you may be able to write the profile data under a
different name.  Set the GMON_OUT_PREFIX environment variable; this name
will be appended with the PID of the running program.
d1678 1
a1678 1
magic cookie that allows one to check whether a data file really is a
d2431 26
a2456 26
Node: Invoking11482
Node: Output Options12897
Node: Analysis Options19989
Node: Miscellaneous Options23909
Node: Deprecated Options25163
Node: Symspecs27226
Node: Output29052
Node: Flat Profile30092
Node: Call Graph35045
Node: Primary38277
Node: Callers40865
Node: Subroutines42983
Node: Cycles44824
Node: Line-by-line51601
Node: Annotated Source55677
Node: Inaccuracy58675
Node: Sampling Error58933
Node: Assumptions61837
Node: How do I?63307
Node: Incompatibilities64864
Node: Details66358
Node: Implementation66751
Node: File Format72650
Node: Internals76942
Node: Debugging85432
Node: GNU Free Documentation License87022
a2458 5


Local Variables:
coding: utf-8
End:
@


1.1.1.10
log
@Import binutils-2.42 (last was 2.39)

2024-01-15  Nick Clifton  <nickc@@redhat.com>

	* 2.42 branch point.

2023-11-15  Arsen Arsenović  <arsen@@aarsen.me>

	* intl: Remove directory.  Replaced with out-of-tree GNU
	gettext.
	* .gitignore: Add '/gettext*'.
	* configure.ac (host_libs): Replace intl with gettext.
	(hbaseargs, bbaseargs, baseargs): Split baseargs into
	{h,b}baseargs.
	(skip_barg): New flag.  Skips appending current flag to
	bbaseargs.
	<library exemptions>: Exempt --with-libintl-{type,prefix} from
	target and build machine argument passing.
	* configure: Regenerate.
	* Makefile.def (host_modules): Replace intl module with gettext
	module.
	(configure-ld): Depend on configure-gettext.
	* Makefile.in: Regenerate.
	* src-release.sh: Remove references to the intl/ directory.

2023-07-03  Nick Clifton  <nickc@@redhat.com>

	2.41 Branch Point.

2023-06-26  Nick Clifton  <nickc@@redhat.com>

	* Import these updates to the config scripts

	commit 4ad4bb7c30aca1e705448ba8d51a210bbd47bb52
	Author: Paul Eggert <eggert@@cs.ucla.edu>
	Date:   Fri Jun 23 09:55:10 2023 -0700

		Quote 'like this', not `like this'.

	commit 63acb96f92473ceb5e21d873d7c0aee266b3d6d3
	Author: Paul Eggert <eggert@@cs.ucla.edu>
	Date:   Sat Jan 21 00:15:01 2023 -0600

		Fix config.sub spelling typo for "athlon"

	commit 4ce12a5c9125cedc0d0ba584444a6865396923ec
	Author: Dmitry V. Levin <ldv@@altlinux.org>
	Date:   Sun Jan 1 08:00:00 2023 +0000

		Update copyright years

	commit c397e2c040bce50bcdccb131f90115ba7e8bfc19
	Author: Arsen Arsenovi <arsen@@aarsen.me>
	Date:   Sat Sep 17 23:34:48 2022 +0200

		config.sub: add linux-mlibc targets

	commit 9f9f9b0b13197269848c76e3e057a3ed0680b4bf
	Author: Arsen Arsenovi <arsen@@aarsen.me>
	Date:   Sat Sep 17 23:34:47 2022 +0200

		config.guess: support running on Managarm systems

	commit 87e6687749da7bb2ab158a79fa83721c19ed9246
	Author: Arsen Arsenovi <arsen@@aarsen.me>
	Date:   Sat Sep 17 23:34:46 2022 +0200

		config.sub: add managarm-{mlibc,kernel} targets

	commit 20403c5701973a4cbd7e0b4bbeb627fcd424a0f1
	Author: Xiaotian Wu <wuxiaotian@@loongson.cn>
	Date:   Mon Aug 1 16:05:29 2022 +0800

		Remove loongarchx32

	commit 02ba26b218d3d3db6c56e014655faf463cefa983
	Author: Alexander von Gluck IV <kallisti5@@unixzen.com>
	Date:   Wed May 25 15:43:13 2022 -0500

		config.guess: Update Haiku guesses

	commit f56a7140386d08a531bcfd444d632b28c61a6329
	Author: Bruno Haible <bruno@@clisp.org>
	Date:   Sun May 8 19:08:08 2022 +0200

		config.guess (x86_64:Linux:*:*): Detect 32-bit ABI.

2023-04-20  Nick Clifton  <nickc@@redhat.com>

	* SECURITY.txt: New file.
	* src-release.sh (DEVO_SUPPORT): Add SECURITY.txt.

2022-12-31  Nick Clifton  <nickc@@redhat.com>

	* 2.40 binutils branch created.

2022-10-10  Nick Clifton  <nickc@@redhat.com>

	* src-release.sh: Add "-r <date>" option to create reproducible
	tarballs based upon a fixed timestamp of <date>.
	* binutils/README-how-to-make-a-release: Add a line showing how to
	use -r <date> when creating a binutils release.

2022-10-04  Nick Clifton  <nickc@@redhat.com>

	* README-maintainer-mode: Add a minimum version of dejagnu
	requirement.

2022-09-08  Nick Clifton  <nickc@@redhat.com>

	* README-maintainer-mode: Update minimum version  of gettext
	required.
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 7.0.2 from gprof.texi.
d5 1
a5 1
   Copyright © 1988-2024 Free Software Foundation, Inc.
d11 2
a12 2
Texts.  A copy of the license is included in the section entitled “GNU
Free Documentation License”.
d16 1
a16 1
* gprof: (gprof).                Profiling your program’s execution
d25 1
a25 1
This manual describes the GNU profiler, ‘gprof’, and how you can use it
d28 1
a28 1
programs.  GNU ‘gprof’ was written by Jay Fenlason.
d30 1
a30 1
   This manual is for ‘gprof’ (GNU Binutils) version 2.42.
d34 1
a34 1
the section entitled “GNU Free Documentation License”.
d42 1
a42 1
* Invoking::            How to run ‘gprof’, and its options
d44 1
a44 1
* Output::              Interpreting ‘gprof’’s output
d48 1
a48 1
* Incompatibilities::   (between GNU ‘gprof’ and Unix ‘gprof’.)
d70 1
a70 1
data.  If you don’t use some feature of your program while it is being
d75 1
a75 1
   • You must compile and link your program with profiling enabled.
d78 1
a78 1
   • You must execute your program to generate a profile data file.
d81 1
a81 1
   • You must run ‘gprof’ to analyze the profile data.  *Note ‘gprof’
d88 1
a88 1
   The “flat profile” shows how much time your program spent in each
d93 1
a93 1
   The “call graph” shows, for each function, which functions called it,
d99 1
a99 1
   The “annotated source” listing is a copy of the program’s source
d116 1
a116 1
   To compile a source file for profiling, specify the ‘-pg’ option when
d120 3
a122 3
   To link the program for profiling, if you use a compiler such as ‘cc’
to do the linking, simply specify ‘-pg’ in addition to your usual
options.  The same option, ‘-pg’, alters either compilation or linking
d128 1
a128 1
   The ‘-pg’ option also works with a command that both compiles and
d133 1
a133 1
   Note: The ‘-pg’ option must be part of your compilation options as
d135 1
a135 1
gathered and when you run ‘gprof’ you will get an error message like
d140 1
a140 1
   If you add the ‘-Q’ switch to suppress the printing of the call graph
d152 3
a154 3
   If you run the linker ‘ld’ directly instead of through a compiler
such as ‘cc’, you may have to specify a profiling startup file ‘gcrt0.o’
as the first input file instead of the usual startup file ‘crt0.o’.  In
d156 1
a156 1
‘libc_p.a’, by writing ‘-lc_p’ instead of the usual ‘-lc’.  This is not
d158 1
a158 1
information for standard library functions such as ‘read’ and ‘open’.
d169 2
a170 2
code, which for ‘gcc’ users can be done via the ‘-static’ or
‘-static-libgcc’ command-line option.  For example:
d174 3
a176 3
   If you compile only some of the modules of the program with ‘-pg’,
you can still profile the program, but you won’t get complete
information about the modules that were compiled without ‘-pg’.  The
d180 1
a180 1
that the ‘calls’ field for the functions will be blank), but will
d184 1
a184 1
‘gcov’ tool instead of ‘gprof’.  See that tool’s manual or info pages
d187 3
a189 3
   Note, older versions of ‘gcc’ produce line-by-line profiling
information that works with ‘gprof’ rather than ‘gcov’ so there is still
support for displaying this kind of information in ‘gprof’.  *Note
d192 1
a192 1
   It also worth noting that ‘gcc’ implements a ‘-finstrument-functions’
d205 1
a205 1
generate the information that ‘gprof’ needs.  Simply run the program as
d211 2
a212 2
   The way you run the program—the arguments and input that you give
it—may have a dramatic effect on what the profile information shows.
d219 2
a220 2
‘gmon.out’ just before exiting.  If there is already a file called
‘gmon.out’, its contents are overwritten.  You can rename the file
d226 3
a228 3
   In order to write the ‘gmon.out’ file properly, your program must
exit normally: by returning from ‘main’ or by calling ‘exit’.  Calling
the low-level function ‘_exit’ does not write the profile data, and
d231 1
a231 1
   The ‘gmon.out’ file is written in the program’s _current working
d233 2
a234 2
‘chdir’, the ‘gmon.out’ file will be left in the last directory your
program ‘chdir’’d to.  If you don’t have permission to write in this
d238 1
a238 1
called ‘bb.out’.  This file, if present, contains an human-readable
d240 4
a243 4
appearance of a human-readable ‘bb.out’ means the basic-block counts
didn’t get written into ‘gmon.out’.  The Perl script ‘bbconv.pl’,
included with the ‘gprof’ source distribution, will convert a ‘bb.out’
file into a format readable by ‘gprof’.  Invoke it like this:
d247 2
a248 2
   This translates the information in ‘bb.out’ into a form that ‘gprof’
can understand.  But you still need to tell ‘gprof’ about the existence
d250 1
a250 1
‘gprof’ command line, _along with ‘gmon.out’_, like this:
d257 1
a257 1
4 ‘gprof’ Command Summary
d260 2
a261 2
After you have a profile data file ‘gmon.out’, you can run ‘gprof’ to
interpret the information in it.  The ‘gprof’ program prints a flat
d263 1
a263 1
redirect the output of ‘gprof’ into a file with ‘>’.
d265 1
a265 1
   You run ‘gprof’ like this:
d271 2
a272 2
   If you omit the executable file name, the file ‘a.out’ is used.  If
you give no profile data file name, the file ‘gmon.out’ is used.  If any
d284 2
a285 2
* Output Options::      Controlling ‘gprof’’s output style
* Analysis Options::    Controlling how ‘gprof’ analyzes its data
d297 1
a297 1
These options specify which of several output formats ‘gprof’ should
d300 1
a300 1
   Many of these options take an optional “symspec” to specify functions
d305 1
a305 1
   Specifying any of these options overrides the default (‘-p -q’),
d308 3
a310 3
‘-A[SYMSPEC]’
‘--annotated-source[=SYMSPEC]’
     The ‘-A’ option causes ‘gprof’ to print annotated source code.  If
d314 3
a316 3
‘-b’
‘--brief’
     If the ‘-b’ option is given, ‘gprof’ doesn’t print the verbose
d321 3
a323 6
‘-B’
     The ‘-B’ option causes ‘gprof’ to print the call graph analysis.

‘-C[SYMSPEC]’
‘--exec-counts[=SYMSPEC]’
     The ‘-C’ option causes ‘gprof’ to print a tally of functions and
d328 1
a328 1
     specifying the ‘-l’ option, along with ‘-C’, will cause basic-block
d331 3
a333 3
‘-i’
‘--file-info’
     The ‘-i’ option causes ‘gprof’ to display summary information about
d337 3
a339 3
‘-I DIRS’
‘--directory-path=DIRS’
     The ‘-I’ option specifies a list of search directories in which to
d344 4
a347 4
‘-J[SYMSPEC]’
‘--no-annotated-source[=SYMSPEC]’
     The ‘-J’ option causes ‘gprof’ not to print annotated source code.
     If SYMSPEC is specified, ‘gprof’ prints annotated source, but
d350 2
a351 2
‘-L’
‘--print-path’
d353 1
a353 1
     suppressed.  The ‘-L’ option causes ‘gprof’ to print the full
d358 3
a360 3
‘-p[SYMSPEC]’
‘--flat-profile[=SYMSPEC]’
     The ‘-p’ option causes ‘gprof’ to print a flat profile.  If SYMSPEC
d364 4
a367 4
‘-P[SYMSPEC]’
‘--no-flat-profile[=SYMSPEC]’
     The ‘-P’ option causes ‘gprof’ to suppress printing a flat profile.
     If SYMSPEC is specified, ‘gprof’ prints a flat profile, but
d370 3
a372 3
‘-q[SYMSPEC]’
‘--graph[=SYMSPEC]’
     The ‘-q’ option causes ‘gprof’ to print the call graph analysis.
d376 4
a379 4
‘-Q[SYMSPEC]’
‘--no-graph[=SYMSPEC]’
     The ‘-Q’ option causes ‘gprof’ to suppress printing the call graph.
     If SYMSPEC is specified, ‘gprof’ prints a call graph, but excludes
d382 3
a384 3
‘-t’
‘--table-length=NUM’
     The ‘-t’ option causes the NUM most active source lines in each
d388 2
a389 2
‘-y’
‘--separate-files’
d391 1
a391 1
     ‘gprof’ prints annotated source files to standard-output.  If this
d393 9
a401 9
     ‘path/FILENAME’ is generated in the file ‘FILENAME-ann’.  If the
     underlying file system would truncate ‘FILENAME-ann’ so that it
     overwrites the original ‘FILENAME’, ‘gprof’ generates annotated
     source in the file ‘FILENAME.ann’ instead (if the original file
     name has an extension, that extension is _replaced_ with ‘.ann’).

‘-Z[SYMSPEC]’
‘--no-exec-counts[=SYMSPEC]’
     The ‘-Z’ option causes ‘gprof’ not to print a tally of functions
d405 3
a407 3
‘-r’
‘--function-ordering’
     The ‘--function-ordering’ option causes ‘gprof’ to print a
d417 3
a419 3
‘-R MAP_FILE’
‘--file-ordering MAP_FILE’
     The ‘--file-ordering’ option causes ‘gprof’ to print a suggested .o
d425 1
a425 1
     Use of the ‘-a’ argument is highly recommended with this option.
d429 1
a429 1
     similar to the output of the program ‘nm’.
d441 2
a442 2
     To create a MAP_FILE with GNU ‘nm’, type a command like ‘nm
     --extern-only --defined-only -v --print-file-name program-name’.
d444 3
a446 3
‘-T’
‘--traditional’
     The ‘-T’ option causes ‘gprof’ to print its output in “traditional”
d449 2
a450 2
‘-w WIDTH’
‘--width=WIDTH’
d454 2
a455 2
‘-x’
‘--all-lines’
d460 1
a460 1
     similar to ‘tcov’’s ‘-a’.
d462 2
a463 2
‘--demangle[=STYLE]’
‘--no-demangle’
d466 1
a466 1
     ‘--no-demangle’ option may be used to turn off demangling.
d477 3
a479 3
‘-a’
‘--no-static’
     The ‘-a’ option causes ‘gprof’ to suppress the printing of
d488 3
a490 3
‘-c’
‘--static-call-graph’
     The ‘-c’ option causes the call graph of the program to be
d500 1
a500 1
     graph with call counts of ‘0’.
d502 3
a504 3
‘-D’
‘--ignore-non-functions’
     The ‘-D’ option causes ‘gprof’ to ignore symbols which are not
d509 2
a510 2
‘-k FROM/TO’
     The ‘-k’ option allows you to delete from the call graph any arcs
d513 3
a515 3
‘-l’
‘--line’
     The ‘-l’ option enables line-by-line profiling, which causes
d518 2
a519 2
     compiled by older versions of the ‘gcc’ compiler.  Newer versions
     of ‘gcc’ are designed to work with the ‘gcov’ tool instead.
d525 1
a525 1
     significantly increases the running time of ‘gprof’, and magnifies
d529 2
a530 2
‘--inline-file-names’
     This option causes ‘gprof’ to print the source file after each
d532 1
a532 1
     to the file is printed if used with the ‘-L’ option.
d534 2
a535 2
‘-m NUM’
‘--min-count=NUM’
d539 3
a541 3
‘-nSYMSPEC’
‘--time=SYMSPEC’
     The ‘-n’ option causes ‘gprof’, in its call graph analysis, to only
d544 3
a546 3
‘-NSYMSPEC’
‘--no-time=SYMSPEC’
     The ‘-n’ option causes ‘gprof’, in its call graph analysis, not to
d549 5
a553 5
‘-SFILENAME’
‘--external-symbol-table=FILENAME’
     The ‘-S’ option causes ‘gprof’ to read an external symbol table
     file, such as ‘/proc/kallsyms’, rather than read the symbol table
     from the given object file (the default is ‘a.out’).  This is
d556 3
a558 3
‘-z’
‘--display-unused-functions’
     If you give the ‘-z’ option, ‘gprof’ will mention all functions in
d560 1
a560 1
     no time spent in them.  This is useful in conjunction with the ‘-c’
d569 4
a572 4
‘-d[NUM]’
‘--debug[=NUM]’
     The ‘-d NUM’ option specifies debugging options.  If NUM is not
     specified, enable all debugging.  *Note Debugging ‘gprof’:
d575 3
a577 3
‘-h’
‘--help’
     The ‘-h’ option prints command line usage.
d579 2
a580 2
‘-ONAME’
‘--file-format=NAME’
d582 1
a582 1
     are ‘auto’ (the default), ‘bsd’, ‘4.4bsd’, ‘magic’, and ‘prof’ (not
d585 3
a587 3
‘-s’
‘--sum’
     The ‘-s’ option causes ‘gprof’ to summarize the information in the
d589 2
a590 2
     called ‘gmon.sum’, which contains all the information from the
     profile data files that ‘gprof’ read in.  The file ‘gmon.sum’ may
d592 1
a592 1
     the data in the other input files into ‘gmon.sum’.
d594 2
a595 2
     Eventually you can run ‘gprof’ again without ‘-s’ to analyze the
     cumulative data in the file ‘gmon.sum’.
d597 3
a599 3
‘-v’
‘--version’
     The ‘-v’ flag causes ‘gprof’ to print the current version number,
d610 2
a611 2
‘-e FUNCTION_NAME’
     The ‘-e FUNCTION’ option tells ‘gprof’ to not print information
d614 3
a616 3
     functions that call it, but its index number will be shown as ‘[not
     printed]’.  More than one ‘-e’ option may be given; only one
     FUNCTION_NAME may be indicated with each ‘-e’ option.
d618 2
a619 2
‘-E FUNCTION_NAME’
     The ‘-E FUNCTION’ option works like the ‘-e’ option, but time spent
d622 2
a623 2
     call graph.  More than one ‘-E’ option may be given; only one
     FUNCTION_NAME may be indicated with each ‘-E’ option.
d625 2
a626 2
‘-f FUNCTION_NAME’
     The ‘-f FUNCTION’ option causes ‘gprof’ to limit the call graph to
d628 2
a629 2
     children...).  More than one ‘-f’ option may be given; only one
     FUNCTION_NAME may be indicated with each ‘-f’ option.
d631 2
a632 2
‘-F FUNCTION_NAME’
     The ‘-F FUNCTION’ option works like the ‘-f’ option, but only time
d635 3
a637 3
     call graph.  More than one ‘-F’ option may be given; only one
     FUNCTION_NAME may be indicated with each ‘-F’ option.  The ‘-F’
     option overrides the ‘-E’ option.
d639 2
a640 2
   Note that only one function can be specified with each ‘-e’, ‘-E’,
‘-f’ or ‘-F’ option.  To specify more than one function, use multiple
d646 1
a646 1
‘foo’ or ‘bar’ and were not reachable from ‘boring’.
d655 1
a655 1
using “symspecs” (symbol specifications), which observe the following
d665 3
a667 3
‘main.c’
     Selects everything in file ‘main.c’—the dot in the string tells
     ‘gprof’ to interpret the string as a filename, rather than as a
d669 2
a670 2
     a trailing colon should be specified.  For example, ‘odd:’ is
     interpreted as the file named ‘odd’.
d672 2
a673 2
‘main’
     Selects all functions named ‘main’.
d682 2
a683 2
     necessary to add a leading colon to the name.  For example, ‘:.mul’
     selects function ‘.mul’.
d686 2
a687 2
     ‘gprof’ will normally not print these underscores.  When you name a
     symbol in a symspec, you should type it exactly as ‘gprof’ prints
d689 2
a690 2
     ‘_main’ from your ‘main’ function, ‘gprof’ still prints it as
     ‘main’ in its output, so you should use ‘main’ in symspecs.
d692 2
a693 2
‘main.c:main’
     Selects function ‘main’ in file ‘main.c’.
d695 2
a696 2
‘main.c:134’
     Selects line 134 in file ‘main.c’.
d701 1
a701 1
5 Interpreting ‘gprof’’s Output
d704 1
a704 1
‘gprof’ can produce several different output styles, the most important
d717 1
a717 1
* Line-by-line::        ‘gprof’ can analyze individual source code lines
d727 2
a728 2
The “flat profile” shows the total amount of time your program spent
executing each function.  Unless the ‘-z’ option is given, functions
d731 1
a731 1
and didn’t run long enough to show up on the program counter histogram,
d759 1
a759 1
functions ‘mcount’ and ‘profil’ are part of the profiling apparatus and
d764 1
a764 1
much time each sample counted as.  This “sampling period” estimates the
d768 2
a769 2
program’s total execution time was 0.06 seconds, as indicated by the
‘cumulative seconds’ field.  Since each sample counted for 0.01 seconds,
d771 3
a773 3
samples occurred while the program was in the ‘open’ function, as
indicated by the ‘self seconds’ field.  Each of the other four samples
occurred one each in ‘offtime’, ‘memccpy’, ‘write’, and ‘mcount’.  Since
d775 2
a776 2
particularly reliable.  In another run, the ‘self seconds’ field for
‘mcount’ might well be ‘0.00’ or ‘0.02’.  *Note Statistical Sampling
d779 2
a780 2
   The remaining functions in the listing (those whose ‘self seconds’
field is ‘0.00’) didn’t appear in the histogram samples at all.
d782 1
a782 1
they are listed, sorted in decreasing order by the ‘calls’ field.
d789 1
a789 1
‘% time’
d793 1
a793 1
‘cumulative seconds’
d798 1
a798 1
‘self seconds’
d802 1
a802 1
‘calls’
d806 1
a806 1
     compiled with profiling enabled), the “calls” field is blank.
d808 1
a808 1
‘self ms/call’
d813 1
a813 1
‘total ms/call’
d820 1
a820 1
‘name’
d822 1
a822 1
     this field alphabetically after the “self seconds” and “calls”
d831 1
a831 1
The “call graph” shows how much time was spent in each function and its
d837 1
a837 1
same ‘gprof’ run as the flat profile example in the previous section.
d868 1
a868 1
   The lines full of dashes divide this table into “entries”, one for
d875 1
a875 1
called “children” when we speak of the call graph).
d880 1
a880 1
   The internal profiling function ‘mcount’ (*note The Flat Profile:
d885 3
a887 3
* Primary::       Details of the primary line’s contents.
* Callers::       Details of caller-lines’ contents.
* Subroutines::   Details of subroutine-lines’ contents.
d889 1
a889 1
                   such as ‘a’ calls ‘b’ calls ‘a’...
d897 1
a897 1
The “primary line” in a call graph entry is the line that describes the
d902 1
a902 1
‘report’ in our main example, together with the heading line that shows
d911 1
a911 1
‘index’
d921 1
a921 1
‘% time’
d930 1
a930 1
‘self’
d932 1
a932 1
     should be identical to the number printed in the ‘seconds’ field
d935 1
a935 1
‘children’
d938 1
a938 1
     ‘self’ and ‘children’ entries of the children listed directly below
d941 1
a941 1
‘called’
d945 1
a945 1
     separated by a ‘+’.  The first number counts non-recursive calls,
d948 2
a949 2
     In the example above, the function ‘report’ was called once from
     ‘main’.
d951 1
a951 1
‘name’
d956 1
a956 1
     is printed between the function’s name and the index number (*note
d958 1
a958 1
     example, if function ‘gnurr’ is part of cycle number one, and has
d966 1
a966 1
5.2.2 Lines for a Function’s Callers
d969 2
a970 2
A function’s entry has a line for each function it was called by.  These
lines’ fields correspond to the fields of the primary line, but their
d974 1
a974 1
‘report’, the primary line and one caller-line preceding it, together
d982 2
a983 2
   Here are the meanings of the fields in the caller-line for ‘report’
called from ‘main’:
d985 14
a998 14
‘self’
     An estimate of the amount of time spent in ‘report’ itself when it
     was called from ‘main’.

‘children’
     An estimate of the amount of time spent in subroutines of ‘report’
     when ‘report’ was called from ‘main’.

     The sum of the ‘self’ and ‘children’ fields is an estimate of the
     amount of time spent within calls to ‘report’ from ‘main’.

‘called’
     Two numbers: the number of times ‘report’ was called from ‘main’,
     followed by the total number of non-recursive calls to ‘report’
d1001 3
a1003 3
‘name and index number’
     The name of the caller of ‘report’ to which this line applies,
     followed by the caller’s index number.
d1006 1
a1006 1
     ‘gprof’ request the omission of certain functions.  When a caller
d1014 2
a1015 2
dummy caller-line is printed which has ‘<spontaneous>’ as the “caller’s
name” and all other fields blank.  This can happen for signal handlers.
d1020 1
a1020 1
5.2.3 Lines for a Function’s Subroutines
d1023 2
a1024 2
A function’s entry has a line for each of its subroutines—in other
words, a line for each other function that it called.  These lines’
d1029 1
a1029 1
‘main’, the primary line and a line for a subroutine, together with the
d1037 2
a1038 2
   Here are the meanings of the fields in the subroutine-line for ‘main’
calling ‘report’:
d1040 16
a1055 16
‘self’
     An estimate of the amount of time spent directly within ‘report’
     when ‘report’ was called from ‘main’.

‘children’
     An estimate of the amount of time spent in subroutines of ‘report’
     when ‘report’ was called from ‘main’.

     The sum of the ‘self’ and ‘children’ fields is an estimate of the
     total time spent in calls to ‘report’ from ‘main’.

‘called’
     Two numbers, the number of calls to ‘report’ from ‘main’ followed
     by the total number of non-recursive calls to ‘report’.  This ratio
     is used to determine how much of ‘report’’s ‘self’ and ‘children’
     time gets credited to ‘main’.  *Note Estimating ‘children’ Times:
d1058 3
a1060 3
‘name’
     The name of the subroutine of ‘main’ to which this line applies,
     followed by the subroutine’s index number.
d1071 1
a1071 1
The graph may be complicated by the presence of “cycles of recursion” in
d1074 2
a1075 2
function.  For example: if ‘a’ calls ‘b’, and ‘b’ calls ‘a’, then ‘a’
and ‘b’ form a cycle.
d1078 4
a1081 4
they belong to the same cycle.  If ‘a’ and ‘b’ call each other and ‘b’
and ‘c’ call each other, all three make one cycle.  Note that even if
‘b’ only calls ‘a’ if it was not called from ‘a’, ‘gprof’ cannot
determine this, so ‘a’ and ‘b’ are still considered a cycle.
d1085 1
a1085 1
graph it is followed by ‘<cycle NUMBER>’.
d1088 4
a1091 4
call graph paradoxical.  The “time spent in children” of ‘a’ should
include the time spent in its subroutine ‘b’ and in ‘b’’s
subroutines—but one of ‘b’’s subroutines is ‘a’!  How much of ‘a’’s time
should be included in the children of ‘a’, when ‘a’ is indirectly
d1094 1
a1094 1
   The way ‘gprof’ resolves this paradox is by creating a single entry
d1097 1
a1097 1
“subroutines” of the cycle are the individual functions of the cycle,
d1099 1
a1099 1
“callers” of the cycle are the functions, outside the cycle, that called
d1103 2
a1104 2
containing functions ‘a’ and ‘b’.  The cycle was entered by a call to
‘a’ from ‘main’; both ‘a’ and ‘b’ called ‘c’.
d1126 2
a1127 2
for ‘main’, which calls ‘a’, and an entry for ‘c’, with callers ‘a’ and
‘b’.)
d1160 2
a1161 2
   The ‘self’ field of the cycle’s primary line is the total time spent
in all the functions of the cycle.  It equals the sum of the ‘self’
d1165 6
a1170 6
   The ‘children’ fields of the cycle’s primary line and subroutine
lines count only subroutines outside the cycle.  Even though ‘a’ calls
‘b’, the time spent in those calls to ‘b’ is not counted in ‘a’’s
‘children’ time.  Thus, we do not encounter the problem of what to do
when the time in those calls to ‘b’ includes indirect recursive calls
back to ‘a’.
d1172 1
a1172 1
   The ‘children’ field of a caller-line in the cycle’s entry estimates
d1177 1
a1177 1
   The ‘called’ field in the primary line for the cycle has two numbers:
d1184 2
a1185 2
   The ‘called’ field of a subroutine-line for a cycle member in the
cycle’s entry says how many time that function was called from functions
d1187 1
a1187 1
primary line’s ‘called’ field.
d1192 1
a1192 1
called from each other function in the cycle.  The ‘self’ and ‘children’
d1202 1
a1202 1
‘gprof’’s ‘-l’ option causes the program to perform “line-by-line”
d1205 2
a1206 2
programs compiled with older versions of the ‘gcc’ compiler.  Newer
versions of ‘gcc’ use a different program - ‘gcov’ - to display
d1209 2
a1210 2
   With the older versions of ‘gcc’ the program usually has to be
compiled with a ‘-g’ option, in addition to ‘-pg’, in order to generate
d1212 1
a1212 1
versions of ‘gcc’ the program had to be compiled with the ‘-a’
d1216 2
a1217 2
mode.  The call graph isn’t as useful as normal, since the current
version of ‘gprof’ does not propagate call graph arcs from source code
d1221 3
a1223 3
   Here is a section of ‘gprof’’s output, without line-by-line
profiling.  Note that ‘ct_init’ accounted for four histogram hits, and
13327 calls to ‘init_block’.
d1247 3
a1249 3
   Now let’s look at some of ‘gprof’’s output from the same program run,
this time with line-by-line profiling enabled.  Note that ‘ct_init’’s
four histogram hits are broken down into four lines of source code—one
d1251 1
a1251 1
note how ‘ct_init’’s 13327 calls to ‘init_block’ are broken down into
d1294 4
a1297 4
‘gprof’’s ‘-A’ option triggers an annotated source listing, which lists
the program’s source code, each function labeled with the number of
times it was called.  You may also need to specify the ‘-I’ option, if
‘gprof’ can’t find the source code files.
d1299 1
a1299 1
   With older versions of ‘gcc’ compiling with ‘gcc ... -g -pg -a’
d1301 3
a1303 3
function counting code.  This enables ‘gprof’ to determine how many
times each line of code was executed.  With newer versions of ‘gcc’
support for displaying basic-block counts is provided by the ‘gcov’
d1330 4
a1333 4
   ‘updcrc’ has at least five basic-blocks.  One is the function itself.
The ‘if’ statement on line 9 generates two more basic-blocks, one for
each branch of the ‘if’.  A fourth basic-block results from the ‘if’ on
line 13, and the contents of the ‘do’ loop form the fifth basic-block.
d1338 3
a1340 3
‘gprof -l -A’.  The ‘-x’ option is also helpful, to ensure that each
line of code is labeled at least once.  Here is ‘updcrc’’s annotated
source listing for a sample ‘gzip’ run:
d1363 2
a1364 2
each branch of the ‘if’ statement.  The body of the ‘do’ loop was
executed a total of 26312 times.  Note how the ‘while’ statement is
d1372 1
a1372 1
6 Inaccuracy of ‘gprof’ Output
d1386 1
a1386 1
The run-time figures that ‘gprof’ gives you are based on a sampling
d1402 1
a1402 1
   The “sampling period” that is printed at the beginning of the flat
d1409 1
a1409 1
period is 0.01 seconds and ‘foo’’s run-time is 1 second, N is 100
d1411 1
a1411 1
error in ‘foo’’s run-time is 0.1 seconds (10*0.01 seconds), or ten
d1413 2
a1414 2
seconds and ‘bar’’s run-time is 100 seconds, N is 10000 samples, sqrt(N)
is 100 samples, so the expected error in ‘bar’’s run-time is 1 second,
d1420 1
a1420 1
information.  If the program’s _total_ run-time is large, a small
d1422 1
a1422 1
insignificant fraction of the whole program’s time.  Usually this means
d1427 1
a1427 1
the data from several runs, using the ‘-s’ option of ‘gprof’.  Here is
d1432 1
a1432 1
  2. Issue the command ‘mv gmon.out gmon.sum’.
d1436 1
a1436 1
  4. Merge the new data in ‘gmon.out’ into ‘gmon.sum’ with this command:
d1449 1
a1449 1
6.2 Estimating ‘children’ Times
d1452 2
a1453 2
Some of the figures in the call graph are estimates—for example, the
‘children’ time values and all the time figures in caller and subroutine
d1457 1
a1457 1
profile data itself.  Instead, ‘gprof’ estimates them by making an
d1461 3
a1463 3
any function ‘foo’ is not correlated with who called ‘foo’.  If ‘foo’
used 5 seconds in all, and 2/5 of the calls to ‘foo’ came from ‘a’, then
‘foo’ contributes 2 seconds to ‘a’’s ‘children’ time, by assumption.
d1466 6
a1471 6
far from true.  Suppose that ‘foo’ returns very quickly when its
argument is zero; suppose that ‘a’ always passes zero as an argument,
while other callers of ‘foo’ pass other arguments.  In this program, all
the time spent in ‘foo’ is in the calls from callers other than ‘a’.
But ‘gprof’ has no way of knowing this; it will blindly and incorrectly
charge 2 seconds of time in ‘foo’ to the children of ‘a’.
d1473 1
a1473 1
   We hope some day to put more complete data into ‘gmon.out’, so that
d1486 1
a1486 1
     Because ‘gprof’ can only report call times and counts by function,
d1490 1
a1490 1
     artificial hot spots since compiling with ‘-pg’ adds a significant
d1496 1
a1496 1
     Use the ‘gcov’ program.
d1500 1
a1500 1
     Use ‘gprof -l’ and lookup the function in the call graph.  The
d1523 1
a1523 1
8 Incompatibilities with Unix ‘gprof’
d1526 1
a1526 1
GNU ‘gprof’ and Berkeley Unix ‘gprof’ use the same data file ‘gmon.out’,
d1530 1
a1530 1
   • GNU ‘gprof’ uses a new, generalized file format with support for
d1532 1
a1532 1
     cookie and version number allows ‘gprof’ to easily identify new
d1536 3
a1538 3
   • For a recursive function, Unix ‘gprof’ lists the function as a
     parent and as a child, with a ‘calls’ field that lists the number
     of recursive calls.  GNU ‘gprof’ omits these lines and puts the
d1541 2
a1542 2
   • When a function is suppressed from the call graph with ‘-e’, GNU
     ‘gprof’ still lists it as a subroutine of functions that call it.
d1544 2
a1545 2
   • GNU ‘gprof’ accepts the ‘-k’ with its argument in the form
     ‘from/to’, instead of ‘from to’.
d1547 2
a1548 2
   • In the annotated source listing, if there are multiple basic blocks
     on the same line, GNU ‘gprof’ prints all of their counts, separated
d1551 2
a1552 2
   • The blurbs, field widths, and output formats are different.  GNU
     ‘gprof’ prints blurbs after the tables, so that you can see the
d1564 3
a1566 3
* File Format::         Format of ‘gmon.out’ files
* Internals::           ‘gprof’’s internal operation
* Debugging::           Using ‘gprof’’s ‘-d’ option
d1579 2
a1580 2
the ‘-pg’ option, which causes every function to call ‘mcount’ (or
‘_mcount’, or ‘__mcount’, depending on the OS and compiler) as one of
d1583 1
a1583 1
   The ‘mcount’ routine, included in the profiling library, is
d1585 1
a1585 1
parent routine (the child) and its parent’s parent.  This is typically
d1588 1
a1588 1
machine-dependent operation, ‘mcount’ itself is typically a short
d1590 4
a1593 4
and then calls ‘__mcount_internal’ (a normal C function) with two
arguments—‘frompc’ and ‘selfpc’.  ‘__mcount_internal’ is responsible for
maintaining the in-memory call graph, which records ‘frompc’, ‘selfpc’,
and the number of times each of these call arcs was traversed.
d1596 1
a1596 1
(‘__builtin_return_address’), which allows a generic ‘mcount’ function
d1600 1
a1600 1
‘mcount’ is used for performance reasons.
d1604 2
a1605 2
same as in the usual C library, but they were compiled with ‘-pg’.  If
you link your program with ‘gcc ... -pg’, it automatically uses the
d1615 2
a1616 2
provide a ‘profil()’ system call, which registers a memory array with
the kernel, along with a scale factor that determines how the program’s
d1626 1
a1626 1
earlier), do not provide a ‘profil()’ system call.  On such a system,
d1628 1
a1628 1
the process (typically via ‘setitimer()’), which then performs the same
d1636 5
a1640 5
either calls ‘profil()’ or sets up a clock signal handler.  This routine
(‘monstartup’) can be invoked in several ways.  On Linux systems, a
special profiling startup file ‘gcrt0.o’, which invokes ‘monstartup’
before ‘main’, is used instead of the default ‘crt0.o’.  Use of this
special startup file is one of the effects of using ‘gcc ... -pg’ to
d1642 2
a1643 2
‘mcount’ routine, when it is invoked for the first time (typically when
‘main’ is called), calls ‘monstartup’.
d1645 1
a1645 1
   If the compiler’s ‘-a’ option was used, basic-block counting is also
d1648 1
a1648 1
basic-block begins (i.e., when an ‘if’ statement appears), an extra
d1655 3
a1657 3
   The profiling library also includes a function (‘mcleanup’) which is
typically registered using ‘atexit()’ to be called as the program exits,
and is responsible for writing the file ‘gmon.out’.  Profiling is turned
d1661 1
a1661 1
   The output from ‘gprof’ gives no indication of parts of your program
d1663 2
a1664 2
of the program counter are taken at fixed intervals of the program’s run
time.  Therefore, the time measurements in ‘gprof’ output say nothing
d1667 1
a1667 1
memory at once may run very slowly due to thrashing, but ‘gprof’ will
d1669 1
a1669 1
the advantage that the amount of load due to other users won’t directly
d1680 2
a1681 2
‘gprof’ file.  Furthermore, it does not provide a version number, thus
rendering changes to the file format almost impossible.  GNU ‘gprof’
d1683 1
a1683 1
compatibility, GNU ‘gprof’ continues to support the old BSD-derived
d1688 1
a1688 1
   The new file format is defined in header file ‘gmon_out.h’.  It
d1692 1
a1692 1
the profile was collected.  GNU ‘gprof’ adapts automatically to the
d1699 1
a1699 1
reading a file, GNU ‘gprof’ will ensure records of the same type are
d1715 1
a1715 1
would specify the long name as “seconds” and the abbreviation as “s”.
d1718 1
a1718 1
For example, under DEC OSF/1, the “uprofile” command can be used to
d1720 2
a1721 2
the dimension in the histogram header could be set to “i-cache misses”
and the abbreviation could be set to “1” (because it is simply a count,
d1737 2
a1738 2
must be within caller’s function and the second must be within the
callee’s function.  When performing profiling at the function level,
d1757 1
a1757 1
9.3 ‘gprof’’s Internal Operation
d1760 3
a1762 3
Like most programs, ‘gprof’ begins by processing its options.  During
this stage, it may building its symspec list (‘sym_ids.c:sym_id_add’),
if options are specified which use symspecs.  ‘gprof’ maintains a single
d1764 1
a1764 1
tables, organized into six include/exclude pairs—one pair each for the
d1772 2
a1773 2
   After option processing, ‘gprof’ finishes building the symspec list
by adding all the symspecs in ‘default_excluded_list’ to the exclude
d1779 2
a1780 2
it is an object file, and read its symbol table (‘core.c:core_init’),
using ‘bfd_canonicalize_symtab’ after mallocing an appropriately sized
d1782 2
a1783 2
‘--file-ordering’ option has been specified), and the core text space is
read into memory (if the ‘-c’ option was given).
d1785 1
a1785 1
   ‘gprof’’s own symbol table, an array of Sym structures, is now built.
d1787 1
a1787 1
whether line-by-line profiling (‘-l’ option) has been enabled.  For
d1791 1
a1791 1
either case, two passes are made through the symbol table—one to count
d1793 2
a1794 2
the symbols.  In between the two passes, a single array of type ‘Sym’ is
created of the appropriate length.  Finally, ‘symtab.c:symtab_finalize’
d1799 1
a1799 1
the ‘qsort’ library function (which sorts an array) will be used to sort
d1801 1
a1801 1
(‘symtab.c:sym_lookup’), which finds symbols based on memory address,
d1803 1
a1803 1
sorted array.  Function symbols are indicated with an ‘is_func’ flag.
d1805 1
a1805 1
can have an ‘is_static’ flag to indicate that it is a local symbol.
d1808 2
a1809 2
Syms (‘sym_ids.c:sym_id_parse’).  Remember that a single symspec can
match multiple symbols.  An array of symbol tables (‘syms’) is created,
d1817 2
a1818 2
‘gprof’ simply uses its standard symbol lookup routine on the
appropriate table in the ‘syms’ array.
d1821 2
a1822 2
(‘gmon_io.c:gmon_out_read’), first by checking for a new-style
‘gmon.out’ header, then assuming this is an old-style BSD ‘gmon.out’ if
d1825 1
a1825 1
   New-style histogram records are read by ‘hist.c:hist_read_rec’.  For
d1835 1
a1835 1
   As each call graph record is read (‘call_graph.c:cg_read_rec’), the
d1837 1
a1837 1
call graph arc is created by ‘cg_arcs.c:arc_add’, unless the arc fails a
d1839 3
a1841 3
linked list is maintained of the parent’s child arcs, and of the child’s
parent arcs.  Both the child’s call count and the arc’s call count are
incremented by the record’s call count.
d1843 1
a1843 1
   Basic-block records are read (‘basic_blocks.c:bb_read_rec’), but only
d1846 1
a1846 1
entry made in the symbol’s bb_addr and bb_calls arrays.  Again, if
d1850 1
a1850 1
   A gmon.sum file is dumped, if requested (‘gmon_io.c:gmon_out_write’).
d1853 1
a1853 1
(‘hist.c:hist_assign_samples’) by iterating over all the sample bins and
d1864 3
a1866 3
   If call graph data is present, ‘cg_arcs.c:cg_assemble’ is called.
First, if ‘-c’ was specified, a machine-dependent routine (‘find_call’)
scans through each symbol’s machine code, looking for subroutine call
d1869 1
a1869 1
(‘cg_dfn.c:cg_dfn’), so that children are always numbered less than
d1878 1
a1878 1
a parent’s include or exclude (print or no print) property being
d1888 2
a1889 2
fairly straightforward.  The call graph (‘cg_print.c:cg_print’) and flat
profile (‘hist.c:hist_print’) are regurgitations of values already
d1891 1
a1891 1
(‘basic_blocks.c:print_annotated_source’) uses basic-block information,
d1896 1
a1896 1
source code itself (‘cg_print.c’).  Basically, the functions with the
d1904 1
a1904 1
9.4 Debugging ‘gprof’
d1907 1
a1907 1
If ‘gprof’ was compiled with debugging enabled, the ‘-d’ option triggers
d1927 1
a1927 1
     file.  For line-by-line profiling (‘-l’ option), also shows line
d1930 1
a1930 1
     Trace operation of ‘-c’ option
d1937 1
a1937 1
     meaningful with ‘-l’ option)
d1941 1
a1941 1
     Tracks operation of ‘-A’ option
d1951 1
a1951 1
     Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
d1960 1
a1960 1
     functional and useful document “free” in the sense of freedom: to
d1967 1
a1967 1
     This License is a kind of “copyleft”, which means that derivative
d1988 2
a1989 2
     “Document”, below, refers to any such manual or work.  Any member
     of the public is a licensee, and is addressed as “you”.  You accept
d1993 1
a1993 1
     A “Modified Version” of the Document means any work containing the
d1997 1
a1997 1
     A “Secondary Section” is a named appendix or a front-matter section
d1999 1
a1999 1
     publishers or authors of the Document to the Document’s overall
d2008 1
a2008 1
     The “Invariant Sections” are certain Secondary Sections whose
d2016 1
a2016 1
     The “Cover Texts” are certain short passages of text that are
d2022 1
a2022 1
     A “Transparent” copy of the Document means a machine-readable copy,
d2034 1
a2034 1
     “Transparent” is called “Opaque”.
d2047 1
a2047 1
     The “Title Page” means, for a printed book, the title page itself,
d2050 3
a2052 3
     works in formats which do not have any title page as such, “Title
     Page” means the text near the most prominent appearance of the
     work’s title, preceding the beginning of the body of the text.
d2054 1
a2054 1
     The “publisher” means any person or entity that distributes copies
d2057 1
a2057 1
     A section “Entitled XYZ” means a named subunit of the Document
d2061 3
a2063 3
     “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.)
     To “Preserve the Title” of such a section when you modify the
     Document means that it remains a section “Entitled XYZ” according
d2093 1
a2093 1
     the Document’s license notice requires Cover Texts, you must
d2165 1
a2165 1
          Sections and required Cover Texts given in the Document’s
d2170 1
a2170 1
       I. Preserve the section Entitled “History”, Preserve its Title,
d2173 1
a2173 1
          Title Page.  If there is no section Entitled “History” in the
d2183 1
a2183 1
          “History” section.  You may omit a network location for a work
d2188 1
a2188 1
       K. For any section Entitled “Acknowledgements” or “Dedications”,
d2197 1
a2197 1
       M. Delete any section Entitled “Endorsements”.  Such a section
d2201 1
a2201 1
          “Endorsements” or to conflict in title with any Invariant
d2210 1
a2210 1
     titles to the list of Invariant Sections in the Modified Version’s
d2214 1
a2214 1
     You may add a section Entitled “Endorsements”, provided it contains
d2216 3
a2218 3
     parties—for example, statements of peer review or that the text has
     been approved by an organization as the authoritative definition of
     a standard.
d2256 4
a2259 4
     “History” in the various original documents, forming one section
     Entitled “History”; likewise combine any sections Entitled
     “Acknowledgements”, and any sections Entitled “Dedications”.  You
     must delete all sections Entitled “Endorsements.”
d2280 1
a2280 1
     storage or distribution medium, is called an “aggregate” if the
d2282 1
a2282 1
     legal rights of the compilation’s users beyond what the individual
d2289 1
a2289 1
     of the entire aggregate, the Document’s Cover Texts may be placed
d2311 2
a2312 2
     If a section in the Document is Entitled “Acknowledgements”,
     “Dedications”, or “History”, the requirement (section 4) to
d2353 1
a2353 1
     version of this License “or any later version” applies to it, you
d2361 1
a2361 1
     proxy’s public statement of acceptance of a version permanently
d2366 1
a2366 1
     “Massive Multiauthor Collaboration Site” (or “MMC Site”) means any
d2370 1
a2370 1
     A “Massive Multiauthor Collaboration” (or “MMC”) contained in the
d2374 1
a2374 1
     “CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0
d2380 1
a2380 1
     “Incorporate” means to publish or republish a Document, in whole or
d2383 1
a2383 1
     An MMC is “eligible for relicensing” if it is licensed under this
d2410 1
a2410 1
Texts, replace the “with...Texts.” line with this:
d2428 30
a2457 30
Node: Top726
Node: Introduction2083
Node: Compiling4604
Node: Executing8788
Node: Invoking11783
Node: Output Options13244
Node: Analysis Options20804
Node: Miscellaneous Options24904
Node: Deprecated Options26274
Node: Symspecs28457
Node: Output30372
Node: Flat Profile31426
Node: Call Graph36501
Node: Primary39771
Node: Callers42421
Node: Subroutines44641
Node: Cycles46597
Node: Line-by-line53625
Node: Annotated Source57792
Node: Inaccuracy60882
Node: Sampling Error61144
Node: Assumptions64104
Node: How do I?65657
Node: Incompatibilities67230
Node: Details68804
Node: Implementation69217
Node: File Format75279
Node: Internals79619
Node: Debugging88287
Node: GNU Free Documentation License89905
@


1.1.1.11
log
@Import binutils 2.45 (previous was 2.42)

2.45 Release Notes
------------------

Assembler:

  All sframe information generated by the assembler is now in compliance
  with the SFrame V2 specification.

  The assembler now supports .errif and .warnif directives, permitting
  user-controlled diagnostics with conditionals that are evaluated only
  at the end of assembly.

  The assembler predefines the symbol "GAS(version)".

  The assembler now supports the generation of SFrame stack trace
  information (.sframe) from CFI directives on s390 64-bit (s390x).

  For RISC-V, the ".option arch, -ext" format is deprecated due to its
  controversial use.

  For RISC-V, stop generating mapping symbols $x and replace with $x<isa>.  The
  $x was defined to have the same ISA as previous $x<isa>, but now is defined
  to have the same ISA as elf architecture attribute.  Once both used .option
  arch/rvc/norvc/push/pop directives (some code have different architectures
  with file attribute) and data directives in text, then the file need to be
  rebuilt since 2.45.

  The assembler supports the latest architecture extensions for the
  RISC-V, LoongArch and AArch64 architectures.

Linker:

  The linker's --stats option can take an optional argument which if used is
  interpreted as a filename into which resource usage information should be
  stored.  As an alternative mechanism the LD_STATS environment variable can
  also be used to achieve the same results.  Resource usage information for
  various phases of the linking operation is now included in the report.
  If a map file is being produced then the information is also included there.
  The --no-stats option can be used to disable stat reporting, should it have
  been enabled.

  On s390 64-bit (s390x), generate SFrame stack trace information (.sframe)
  for the linker generated .plt section.  On s390 32-bit, generate
  ".eh_frame" unwind information for the linker generated .plt section.
  Both features are enabled by default and can be disabled using linker
  option --no-ld-generated-unwind-info.

  On RISC-V, add new PLT formats, and GNU property merge rules for zicfiss and
  zicfilp extensions.

  On AVR, the default linker scripts now assert that the .progmem sections
  don't extend past 0xffff since they are accessed by means of LPM.
  For data in program memory that may be located past 0xffff, a .progmemx
  section should be used.

  On LoongArch, linker relaxation time complexity is no longer quadratic with
  respect to relocation counts.  Linking time of large software should be
  improved.  In addition  R_LARCH_32_PCREL records are now checked for
  overflow.

Other binary utilities:

  New versioned release of libsframe: libsframe.so.2.  This release introduces
  versioned symbols with version node name LIBSFRAME_2.0.  Some new symbols
  have been added to support the new flag SFRAME_F_FDE_FUNC_START_PCREL and
  retrieving flags from SFrame decoder and encoder objects:
    - Addition of sframe_decoder_get_flags,
      sframe_decoder_get_offsetof_fde_start_addr, sframe_encoder_get_flags,
      sframe_encoder_get_offsetof_fde_start_addr.
  This release also includes backward-incompatible ABI changes:
    - Removal of sframe_get_funcdesc_with_addr.
    - Change in the behavior of sframe_decoder_get_funcdesc_v2,
      sframe_encoder_add_funcdesc_v2 and sframe_encoder_write.

  For SFrame stack trace format, the function start address in each SFrame
  FDE has a changed encoding:  The 32-bit signed integer now holds the offset
  of the start PC of the associated function from the sfde_func_start_address
  field itself (instead of the earlier where it was the offset from the start
  of the SFrame section itself).  All SFrame sections generated by gas and ld
  now default to this new encoding, setting the (new)
  SFRAME_F_FDE_FUNC_START_PCREL flag.

  Relocatable SFrame links are now fixed.

 Readelf now recognizes RISC-V GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS and
  GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED for zicfiss and zicfilp
  extensions.

  The LoongArch disassembler now properly accepts multiple disassembly
  options given by -M, such as "-M no-aliases,numeric".  (Previously only the
  first option took effect.)


2.44 Release Notes
------------------

   Assembler:
      Support for new architecture extensions for AArch64, Risc-V and
      x86.

    Linker:
      The default maximum page size was changed from 16KiB to 64KiB for
      LoongArch.

      This now supports mixed LTO and non-LTO object files in
      relocatable output.

      The ELF forms of the linker support a --image-base=<ADDR> option
      for compatibility with LLD.

      The --build-id= option now accepts an argument of "xx" which
      enables the use of the xxhash library.  This produces a 128-bit
      hash and is 2-4x faster than md5 or sha1.

      The ELF linker option --package-metadata supports percent-encoded
      and %[string] encoded JSON payloads.

    Disassembler:
      The RISC-V disassembler now supports -M,max option like QEMU to
      dump instruction without checking architecture support as usual.

    GprofNG:
      Support added for hardware event counters for Neoverse-N1,
      Ampere-1, and Appliedmicro processors.

    Support for the Nios II target has been removed.

2.43 Release Notes
------------------

    Assembler:

* Add a .base64 directive to the assembler which allows base64 encoded
  binary data to be provided as strings.

* Assembler macros as well as the bodies of .irp / .irpc / .rept can now use
  the syntax \+ to access the number of times a given macro has been executed.
  This is similar to the already existing \@@ syntax, except that the count is
  maintained on a per-macro basis.

* References to FB and dollar labels, when supported, are no longer permitted
  in a radix other than 10.  (Note that definitions of such labels were
  already thus restricted, except that leading zeroes were permitted).

    Linker:

* Add support for DT_RELR type compressed runtime relocations for the
  AArch64 and LoongArch architectures.

* Add --rosegment option which changes the -z separate-code option so that
  only one read-only segment is created (instead of two).

* Add --section-ordering-file <FILE> option to add extra mapping of input
  sections to output sections.

* Add -plugin-save-temps to store plugin intermediate files permanently.

    Utilities:

* Readelf will now display DT_RELR relocations in full detail.

* Readelf now has a -j/--display-section option which takes the name
  or index of a section and displays its contents according to its
  type.  The option can be used multiple times on the command line to
  display multiple sections.

* When objdump or readelf are used to display the contents of a
  .eh_frame section they will now also display the contents of the
  .eh_frame_hdr section, if present.

    Gprofng:

* Improved the support for hardware event counters:
    - Re-designed and streamlined the implementation.
    - Defined a common set of events for ARM processors.
    - Added specific events for AMD ZEN3 / ZEN4, and Intel
      Ice Lake processors.
* Added a minimal support for RISC-V.

    General:

* Target specific improvements for many architectures.
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 7.1.1 from gprof.texi.
d5 1
a5 1
   Copyright © 1988-2025 Free Software Foundation, Inc.
d11 2
a12 2
Texts.  A copy of the license is included in the section entitled "GNU
Free Documentation License".
d16 1
a16 1
* gprof: (gprof).                Profiling your program's execution
d30 1
a30 1
   This manual is for ‘gprof’ (GNU Binutils) version 2.45.
d34 1
a34 1
the section entitled "GNU Free Documentation License".
d44 1
a44 1
* Output::              Interpreting ‘gprof’'s output
d70 1
a70 1
data.  If you don't use some feature of your program while it is being
d99 1
a99 1
   The “annotated source” listing is a copy of the program's source
d175 1
a175 1
you can still profile the program, but you won't get complete
d184 1
a184 1
‘gcov’ tool instead of ‘gprof’.  See that tool's manual or info pages
d211 2
a212 2
   The way you run the program--the arguments and input that you give
it--may have a dramatic effect on what the profile information shows.
d231 1
a231 1
   The ‘gmon.out’ file is written in the program's _current working
d234 1
a234 1
program ‘chdir’'d to.  If you don't have permission to write in this
d241 1
a241 1
didn't get written into ‘gmon.out’.  The Perl script ‘bbconv.pl’,
d284 1
a284 1
* Output Options::      Controlling ‘gprof’'s output style
d316 1
a316 1
     If the ‘-b’ option is given, ‘gprof’ doesn't print the verbose
d449 1
a449 1
     The ‘-T’ option causes ‘gprof’ to print its output in "traditional"
d463 1
a463 1
     similar to ‘tcov’'s ‘-a’.
d669 1
a669 1
     Selects everything in file ‘main.c’--the dot in the string tells
d704 1
a704 1
5 Interpreting ‘gprof’'s Output
d734 1
a734 1
and didn't run long enough to show up on the program counter histogram,
d771 1
a771 1
program's total execution time was 0.06 seconds, as indicated by the
d783 1
a783 1
field is ‘0.00’) didn't appear in the histogram samples at all.
d888 3
a890 3
* Primary::       Details of the primary line's contents.
* Callers::       Details of caller-lines' contents.
* Subroutines::   Details of subroutine-lines' contents.
d959 1
a959 1
     is printed between the function's name and the index number (*note
d969 1
a969 1
5.2.2 Lines for a Function's Callers
d972 2
a973 2
A function's entry has a line for each function it was called by.  These
lines' fields correspond to the fields of the primary line, but their
d1006 1
a1006 1
     followed by the caller's index number.
d1017 2
a1018 2
dummy caller-line is printed which has ‘<spontaneous>’ as the "caller's
name" and all other fields blank.  This can happen for signal handlers.
d1023 1
a1023 1
5.2.3 Lines for a Function's Subroutines
d1026 2
a1027 2
A function's entry has a line for each of its subroutines--in other
words, a line for each other function that it called.  These lines'
d1057 1
a1057 1
     is used to determine how much of ‘report’'s ‘self’ and ‘children’
d1063 1
a1063 1
     followed by the subroutine's index number.
d1091 4
a1094 4
call graph paradoxical.  The "time spent in children" of ‘a’ should
include the time spent in its subroutine ‘b’ and in ‘b’'s
subroutines--but one of ‘b’'s subroutines is ‘a’!  How much of ‘a’'s
time should be included in the children of ‘a’, when ‘a’ is indirectly
d1100 1
a1100 1
"subroutines" of the cycle are the individual functions of the cycle,
d1102 1
a1102 1
"callers" of the cycle are the functions, outside the cycle, that called
d1163 1
a1163 1
   The ‘self’ field of the cycle's primary line is the total time spent
d1168 1
a1168 1
   The ‘children’ fields of the cycle's primary line and subroutine
d1170 1
a1170 1
‘b’, the time spent in those calls to ‘b’ is not counted in ‘a’'s
d1175 1
a1175 1
   The ‘children’ field of a caller-line in the cycle's entry estimates
d1188 1
a1188 1
cycle's entry says how many time that function was called from functions
d1190 1
a1190 1
primary line's ‘called’ field.
d1205 1
a1205 1
‘gprof’'s ‘-l’ option causes the program to perform “line-by-line”
d1219 1
a1219 1
mode.  The call graph isn't as useful as normal, since the current
d1224 1
a1224 1
   Here is a section of ‘gprof’'s output, without line-by-line
d1250 3
a1252 3
   Now let's look at some of ‘gprof’'s output from the same program run,
this time with line-by-line profiling enabled.  Note that ‘ct_init’'s
four histogram hits are broken down into four lines of source code--one
d1254 1
a1254 1
note how ‘ct_init’'s 13327 calls to ‘init_block’ are broken down into
d1297 2
a1298 2
‘gprof’'s ‘-A’ option triggers an annotated source listing, which lists
the program's source code, each function labeled with the number of
d1300 1
a1300 1
‘gprof’ can't find the source code files.
d1342 1
a1342 1
line of code is labeled at least once.  Here is ‘updcrc’'s annotated
d1412 1
a1412 1
period is 0.01 seconds and ‘foo’'s run-time is 1 second, N is 100
d1414 1
a1414 1
error in ‘foo’'s run-time is 0.1 seconds (10*0.01 seconds), or ten
d1416 2
a1417 2
seconds and ‘bar’'s run-time is 100 seconds, N is 10000 samples, sqrt(N)
is 100 samples, so the expected error in ‘bar’'s run-time is 1 second,
d1423 1
a1423 1
information.  If the program's _total_ run-time is large, a small
d1425 1
a1425 1
insignificant fraction of the whole program's time.  Usually this means
d1455 1
a1455 1
Some of the figures in the call graph are estimates--for example, the
d1466 1
a1466 1
‘foo’ contributes 2 seconds to ‘a’'s ‘children’ time, by assumption.
d1568 2
a1569 2
* Internals::           ‘gprof’'s internal operation
* Debugging::           Using ‘gprof’'s ‘-d’ option
d1588 1
a1588 1
parent routine (the child) and its parent's parent.  This is typically
d1594 3
a1596 3
arguments--‘frompc’ and ‘selfpc’.  ‘__mcount_internal’ is responsible
for maintaining the in-memory call graph, which records ‘frompc’,
‘selfpc’, and the number of times each of these call arcs was traversed.
d1619 1
a1619 1
the kernel, along with a scale factor that determines how the program's
d1648 1
a1648 1
   If the compiler's ‘-a’ option was used, basic-block counting is also
d1666 1
a1666 1
of the program counter are taken at fixed intervals of the program's run
d1672 1
a1672 1
the advantage that the amount of load due to other users won't directly
d1718 1
a1718 1
would specify the long name as "seconds" and the abbreviation as "s".
d1721 1
a1721 1
For example, under DEC OSF/1, the "uprofile" command can be used to
d1723 2
a1724 2
the dimension in the histogram header could be set to "i-cache misses"
and the abbreviation could be set to "1" (because it is simply a count,
d1740 2
a1741 2
must be within caller's function and the second must be within the
callee's function.  When performing profiling at the function level,
d1760 1
a1760 1
9.3 ‘gprof’'s Internal Operation
d1767 1
a1767 1
tables, organized into six include/exclude pairs--one pair each for the
d1788 1
a1788 1
   ‘gprof’'s own symbol table, an array of Sym structures, is now built.
d1794 1
a1794 1
either case, two passes are made through the symbol table--one to count
d1842 3
a1844 3
linked list is maintained of the parent's child arcs, and of the child's
parent arcs.  Both the child's call count and the arc's call count are
incremented by the record's call count.
d1849 1
a1849 1
entry made in the symbol's bb_addr and bb_calls arrays.  Again, if
d1869 1
a1869 1
scans through each symbol's machine code, looking for subroutine call
d1881 1
a1881 1
a parent's include or exclude (print or no print) property being
d1970 1
a1970 1
     This License is a kind of "copyleft", which means that derivative
d1991 2
a1992 2
     "Document", below, refers to any such manual or work.  Any member
     of the public is a licensee, and is addressed as "you".  You accept
d1996 1
a1996 1
     A "Modified Version" of the Document means any work containing the
d2000 1
a2000 1
     A "Secondary Section" is a named appendix or a front-matter section
d2002 1
a2002 1
     publishers or authors of the Document to the Document's overall
d2011 1
a2011 1
     The "Invariant Sections" are certain Secondary Sections whose
d2019 1
a2019 1
     The "Cover Texts" are certain short passages of text that are
d2025 1
a2025 1
     A "Transparent" copy of the Document means a machine-readable copy,
d2037 1
a2037 1
     "Transparent" is called "Opaque".
d2050 1
a2050 1
     The "Title Page" means, for a printed book, the title page itself,
d2053 3
a2055 3
     works in formats which do not have any title page as such, "Title
     Page" means the text near the most prominent appearance of the
     work's title, preceding the beginning of the body of the text.
d2057 1
a2057 1
     The "publisher" means any person or entity that distributes copies
d2060 1
a2060 1
     A section "Entitled XYZ" means a named subunit of the Document
d2064 3
a2066 3
     "Acknowledgements", "Dedications", "Endorsements", or "History".)
     To "Preserve the Title" of such a section when you modify the
     Document means that it remains a section "Entitled XYZ" according
d2096 1
a2096 1
     the Document's license notice requires Cover Texts, you must
d2168 1
a2168 1
          Sections and required Cover Texts given in the Document's
d2173 1
a2173 1
       I. Preserve the section Entitled "History", Preserve its Title,
d2176 1
a2176 1
          Title Page.  If there is no section Entitled "History" in the
d2186 1
a2186 1
          "History" section.  You may omit a network location for a work
d2191 1
a2191 1
       K. For any section Entitled "Acknowledgements" or "Dedications",
d2200 1
a2200 1
       M. Delete any section Entitled "Endorsements".  Such a section
d2204 1
a2204 1
          "Endorsements" or to conflict in title with any Invariant
d2213 1
a2213 1
     titles to the list of Invariant Sections in the Modified Version's
d2217 1
a2217 1
     You may add a section Entitled "Endorsements", provided it contains
d2219 3
a2221 3
     parties--for example, statements of peer review or that the text
     has been approved by an organization as the authoritative
     definition of a standard.
d2259 4
a2262 4
     "History" in the various original documents, forming one section
     Entitled "History"; likewise combine any sections Entitled
     "Acknowledgements", and any sections Entitled "Dedications".  You
     must delete all sections Entitled "Endorsements."
d2283 1
a2283 1
     storage or distribution medium, is called an "aggregate" if the
d2285 1
a2285 1
     legal rights of the compilation's users beyond what the individual
d2292 1
a2292 1
     of the entire aggregate, the Document's Cover Texts may be placed
d2314 2
a2315 2
     If a section in the Document is Entitled "Acknowledgements",
     "Dedications", or "History", the requirement (section 4) to
d2356 1
a2356 1
     version of this License "or any later version" applies to it, you
d2364 1
a2364 1
     proxy's public statement of acceptance of a version permanently
d2369 1
a2369 1
     "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
d2373 1
a2373 1
     A "Massive Multiauthor Collaboration" (or "MMC") contained in the
d2377 1
a2377 1
     "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
d2383 1
a2383 1
     "Incorporate" means to publish or republish a Document, in whole or
d2386 1
a2386 1
     An MMC is "eligible for relicensing" if it is licensed under this
d2413 1
a2413 1
Texts, replace the "with...Texts."  line with this:
d2431 30
a2460 30
Node: Top720
Node: Introduction2071
Node: Compiling4588
Node: Executing8768
Node: Invoking11753
Node: Output Options13212
Node: Analysis Options20764
Node: Miscellaneous Options24864
Node: Deprecated Options26234
Node: Symspecs28417
Node: Output30331
Node: Flat Profile31383
Node: Call Graph36452
Node: Primary39716
Node: Callers42364
Node: Subroutines44570
Node: Cycles46515
Node: Line-by-line53512
Node: Annotated Source57664
Node: Inaccuracy60746
Node: Sampling Error61008
Node: Assumptions63956
Node: How do I?65506
Node: Incompatibilities67079
Node: Details68653
Node: Implementation69062
Node: File Format75113
Node: Internals79429
Node: Debugging88075
Node: GNU Free Documentation License89693
@


1.1.1.12
log
@Import binutils-2.46.0 (previous was 2.45)

Changes in 2.45:

* New versioned release of libsframe: libsframe.so.2.  This release introduces
  versioned symbols with version node name LIBSFRAME_2.0.  Some new symbols
  have been added to support the new flag SFRAME_F_FDE_FUNC_START_PCREL and
  retrieving flags from SFrame decoder and encoder objects:
    - Addition of sframe_decoder_get_flags,
      sframe_decoder_get_offsetof_fde_start_addr, sframe_encoder_get_flags,
      sframe_encoder_get_offsetof_fde_start_addr.
  This release also includes backward-incompatible ABI changes:
    - Removal of sframe_get_funcdesc_with_addr.
    - Change in the behavior of sframe_decoder_get_funcdesc_v2,
      sframe_encoder_add_funcdesc_v2 and sframe_encoder_write.

* On s390 64-bit (s390x), gas, ld, objdump, and readelf now support generating
  and processing SFrame V2 stack trace information (.sframe).  The assembler
  generates SFrame info from CFI directives with option "--gsframe".  The
  linker generates SFrame info for the linker-generated .plt section and merges
  all .sframe sections.  Both objdump and readelf dump SFrame info with option
  "--sframe[=<section-name>]".

* For SFrame stack trace format, the function start address in each SFrame
  FDE has a changed encoding:  The 32-bit signed integer now holds the offset
  of the start PC of the associated function from the sfde_func_start_address
  field itself (instead of the earlier where it was the offset from the start
  of the SFrame section itself).  All SFrame sections generated by gas and ld
  now default to this new encoding, setting the (new)
  SFRAME_F_FDE_FUNC_START_PCREL flag.

  Relocatable SFrame links are now fixed.

* Readelf now recognizes RISC-V GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS and
  GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED for zicfiss and zicfilp
  extensions.

* For RISC-V dis-assembler, the definition of mapping symbol $x is changed,
  so the file needs to be rebuilt since 2.45 once used .option arch directives.

* The LoongArch disassembler now properly accepts multiple disassembly
  options given by -M, such as "-M no-aliases,numeric".  (Previously only the
  first option took effect.)
@
text
@d1 1
a1 1
This is gprof.info, produced by makeinfo version 7.2 from gprof.texi.
d5 1
a5 1
   Copyright © 1988-2026 Free Software Foundation, Inc.
d30 1
a30 1
   This manual is for ‘gprof’ (GNU Binutils) version 2.46.0.
a264 4
   Note that ‘gprofng’, a more modern profiler which is also part of
binutils, can also read gmon files and provides more functionality than
‘gprof’.

d443 1
d1249 1
d1290 1
d1332 1
d2428 1
d2431 1
a2431 1
Node: Top718
d2436 25
a2460 25
Node: Output Options13371
Node: Analysis Options20922
Node: Miscellaneous Options25022
Node: Deprecated Options26392
Node: Symspecs28575
Node: Output30489
Node: Flat Profile31541
Node: Call Graph36610
Node: Primary39874
Node: Callers42522
Node: Subroutines44728
Node: Cycles46673
Node: Line-by-line53670
Node: Annotated Source57820
Node: Inaccuracy60901
Node: Sampling Error61163
Node: Assumptions64111
Node: How do I?65661
Node: Incompatibilities67234
Node: Details68808
Node: Implementation69217
Node: File Format75268
Node: Internals79584
Node: Debugging88230
Node: GNU Free Documentation License89848
@


