Sun Studio 12: C++ User's Guide

A.2.160 –xpg

Compiles for profiling with the gprof profiler.

The– xpg option compiles self-profiling code to collect data for profiling with gprof. This option invokes a runtime recording mechanism that produces a gmon.out file when the program normally terminates.

Note –

There is no advantage for -xprofile if you specify -xpg. The two do not prepare or use data provided by the other.

Profiles are generated by using prof(1) or gprof(1) on 64 bit Solaris platforms or just gprof on 32 bit Solaris platforms and include approximate user CPU times. These times are derived from PC sample data (see pcsample(2)) for routines in the main executable and routines in shared libraries specified as linker arguments when the executable is linked. Other shared libraries (libraries opened after process startup using dlopen(3DL)) are not profiled.

On 32 bit Solaris systems, profiles generated using prof(1) are limited to routines in the executable. 32 bit shared libraries can be profiled by linking the executable with -xpg and using gprof(1).

The Solaris 10 software does not include system libraries compiled with -p. As a result, profiles collected on Solaris 10 platforms do not include call counts for system library routines.

A.2.160.1 Warnings

If you compile and link separately, and you compile with –xpg, be sure to link with –xpg. See 3.3.3 Compile-Time and Link-Time Options for a complete list of options that must be specified at both compile time and link time.

See also

–xprofile=p, the analyzer(1) man page, and the Performance Analyzer manual.