HP-UX Reference (11i v2 03/08) - 1 User Commands A-M (vol 1)
g
gprof(1) gprof(1)
-f name Print only the graph profile entry of the specified routine name and its descendants.
More than one
-f option can be given. Only one name can be given with each
-f
option.
-F name Print only the graph profile entry of the routine name and its descendants (as
-f
above) and also use only the times of the printed routines in total time and percen-
tage computations. More than one
-F option can be given. Only one name can be
given with each
-F option. The -F option overrides the
-E option.
-p Produce just the flat profile output exactly similar to one given by
prof (see
prof(1)).
-s Produce a profile file
gmon.sum that represents the sum of the profile information
in all specified profile files. This summary profile file can be given to subsequent
executions of
gprof (probably also with a
-s option) to accumulate profile data
across several runs of an
a.out file.
LD_PROFILE should be set to the same
string for all the runs.
-t Produce just the static output in
gprof. This is used for testing purposes. It elim-
inates all the timing information from normal
gprof output and reports only the
call count part.
-z Display routines that have zero usage (as indicated by call counts and accumulated
time).
EXTERNAL INFLUENCES
Environment Variables
LD_PROFILE determines the modules to be profiled as follows.
LD_PROFILE=ALL
Profile all load modules. That is, report timing and call count information for all loadable
modules, including a.out.
LD_PROFILE=ldm1:ldm2
Profile only loadable modules ldm1 and ldm2. ldm1 and ldm2 are not full pathnames; they
are the names recorded in the executables, which can be displayed using chatr(1).
On Itanium-based system, if
LD_PROFILE
is not set, gprof behaves as though LD_PROFILE=ALL.
On PA-RISC,
LD_PROFILE has to be set for any profiling to occur.
LD_PROFILEBUCKET_SIZE
controls the size of profiling counters. The acceptable value for this vari-
able is 16 or 32. Counter size can also be specified at compile time using the
+profilebucketsize
option. The runtime value overrides the compile time value. A warning is issued if the counter size is set
to a value other than 16 or 32; in this case the value specified at compile time is used. The default value
of the counter is 16, which is used if a valid value is not specified. See the description of the cc(1)
+pro-
filebucketsize option for more details.
GPROFDIR controls the name of the file created by a profiled program. If GPROFDIR is not set,
gmon.out is produced in the current directory when the program terminates. If GPROFDIR=string,
string/pid.progname is produced, where progname is argv[0] with any path prefix removed, and pid
is the program’s process ID. If GPROFDIR is set to a null string, no profiling output is produced.
EXAMPLES
To profile
a.out and libtest.so on Itanium-based systems. PA-RISC profiling is also done in the
same way.
$ cat > test.c
void a()
{
printf("I in a\n");
}
$ cc -c +Z -G test.c
$ ld -b -o libtest.so.1 test.o
$ ln -s ./libtest.so.1 libtest.so
$ cat main.c
extern void a();
main()
Section 1−−342 Hewlett-Packard Company − 2 − HP-UX 11i Version 2: August 2003