smonitor.3c (2010 09)
s
smonitor(3C) smonitor(3C)
NAME
smonitor( ) - prepare execution profile
SYNOPSIS
#include <mon.h>
#include <sys/profil.h>
void smonitor(
struct text_region *regions,
int nregions,
void *buffer,
size_t bufsize,
int nfunc,
unsigned flags
);
DESCRIPTION
smonitor() is an interface to sprofil(2) for collecting sampling information for execution profiles.
To use
smonitor(), link in the
gprof library by specifying -lgprof on the linker command line or
-G on the compiler command line. See gprof (1).
For any application compiled with the
-G option, the gprof library collects profiling sampling informa-
tion. But if an application requires finer control over profiling, the gprof library yields control to an
application that uses smonitor().
To stop the collection of sampling information, use:
smonitor(0, 0, 0, 0, 0, 0);
Use gprof (1) to examine the results.
Parameters
regions is an array of text_region structures describing the regions to be profiled. It is defined in
header <mon.h>. The text_region structure has the following fields:
unsigned long text_start;
unsigned long text_end;
char *name;
The fields are as follows:
text_start is the start address of the text segment of the load module.
text_end is the end address of the text segment of the load module.
name is the name of the load module (not the path name). The name of the load module should be
the same as recorded in the executable by ld.
nregions is the number of elements in the array regions.
buffer is the starting address a buffer to collect sampling information.
bufsize is the length of buffer. buffer is the only memory region used by smonitor() to col-
lect profiling information, so it should be big enough for all specified regions. smonitor() does not
initialize buffer. With more than one call to smonitor() in the same process, smonitor() dumps
the sampling information collected with the last call. smonitor() does not discard the information
collected in previous calls if it is present in the buffer passed to last call of smonitor().
nfunc is unused and kept for future usage.
flags is used to choose 16-bit or 32-bit buckets to collect sampling information. If flags is set to
PROF_USHORT, smonitor() treats the buffer as an array of 16-bit buckets; if set to PROF_UINT,
smonitor() treats the buffer as an array of 32-bit buckets. For more information refer to sprofil(2).
EXTERNAL INFLUENCES
Environment Variables
The behavior of
smonitor() is controlled by the LD_PROFILE environment variable. See gprof (1).
smonitor() behaves with different settings of LD_PROFILE as follows:
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1