HPlogo HP-UX Reference Volume 4 of 5 > m

monitor(3C)

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

NAME

monitor() — prepare execution profile

SYNOPSIS

#include <mon.h> void monitor( void (*lowpc)(), void (*highpc)(), WORD *buffer, int bufsize, int nfunc );

DESCRIPTION

An executable program created by cc -p automatically includes calls for monitor() with default parameters; monitor() need not be called explicitly except to gain fine control over profiling.

monitor() is an interface to profil(2). lowpc and highpc are the addresses of two functions; buffer is the address of a (user-supplied) array of bufsize WORDs (defined in the <mon.h> header file). monitor() arranges to record in the buffer a histogram of periodically sampled values of the program counter, and of counts of calls of certain functions. The lowest address sampled is that of lowpc and the highest is just below highpc. lowpc must not equal 0 for this use of monitor. Not more than nfunc call counts can be kept; only calls of functions compiled with the profiling option -p of cc(1) are recorded. (The C Library and Math Library supplied when cc -p is used also have call counts recorded.)

For 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.

To profile the entire program, it is sufficient to use

extern etext; ... monitor ((int (*)())2, ((int(*)())& etext, buf, bufsize, nfunc);

etext lies just above all the program text (see end(3C)).

To stop execution monitoring and write the results on file mon.out, use

monitor ((int (*)())0, (int(*)())0, 0, 0, 0);

prof(1) can then be used to examine the results.

FILES

/usr/lib/libc.a /usr/lib/libm.a mon.out

SEE ALSO

cc(1), prof(1), profil(2), end(3C).

STANDARDS CONFORMANCE

monitor(): SVID2, SVID3, XPG2

© Hewlett-Packard Development Company, L.P.