monitor(3)monitor(3)Name
monitor, monstartup, moncontrol - prepare execution profile
Syntax
void monitor(lowpc, highpc, buffer, bufsize, nfunc)
int (*lowpc)(), (*highpc)();
short buffer[];
void monstartup(lowpc, highpc)
int (*lowpc)(), (*highpc)();
void moncontrol(mode)Description
There are two different forms of monitoring available: An executable
program created by:
cc -p . . .
automatically includes calls for the monitor and includes an initial
call to its start-up routine with default parameters; need not be
called explicitly except to gain fine control over profil buffer allo‐
cation. An executable program created by:
cc -pg . . .
automatically includes calls for the monitor.
The is a high level interface to The lowpc and highpc specify the
address range that is to be sampled; the lowest address sampled is that
of lowpc and the highest is just below highpc. The subroutine allo‐
cates space using and passes it to (see below) to record a histogram of
periodically sampled values of the program counter, and of counts of
calls of certain functions, in the buffer. Only calls of functions
compiled with the profiling option -p of are recorded.
To profile the entire program, it is sufficient to use
extern etext();
monstartup((int) 2, etext);
The etext lies just above all the program text, see end(3).
To stop execution monitoring and write the results on the file use
monitor(0);
then can be used to examine the results.
The subroutine is used to selectively control profiling within a pro‐
gram. This works with either or type profiling. When the program
starts, profiling begins. To stop the collection of histogram ticks
and call counts use moncontrol(0); to resume the collection of his‐
togram ticks and call counts use moncontrol(1). This allows the cost
of particular operations to be measured. Note that an output file will
be produced upon program exit regardless of the state of
The subroutine is a low level interface to The lowpc and highpc are the
addresses of two functions; buffer is the address of a (user supplied)
array of bufsize short integers. At most nfunc call counts can be
kept. For the results to be significant, especially where there are
small, heavily used routines, it is suggested that the buffer be no
more than a few times smaller than the range of locations sampled. The
subroutine divides the buffer into space to record the histogram of
program counter samples over the range lowpc to highpc, and space to
record call counts of functions compiled with the -p option to
To profile the entire program, it is sufficient to use
extern etext();
monitor((int) 2, etext, buf, bufsize, nfunc);
Files
mon.out
See Alsocc(1), gprof(1), prof(1), profil(2), sbrk(2)
VAX monitor(3)