1MONITOR(3) Library Functions Manual MONITOR(3)
2
3
4
6 monitor - prepare execution profile
7
9 monitor(lowpc, highpc, buffer, bufsize, nfunc)
10 int (*lowpc)( ), (*highpc)( );
11 short buffer[ ];
12
14 An executable program created by `cc -p' automatically includes calls
15 for monitor with default parameters; monitor needn't be called explic‐
16 itly except to gain fine control over profiling.
17
18 Monitor is an interface to profil(2). Lowpc and highpc are the
19 addresses of two functions; buffer is the address of a (user supplied)
20 array of bufsize short integers. Monitor arranges to record a his‐
21 togram of periodically sampled values of the program counter, and of
22 counts of calls of certain functions, in the buffer. The lowest
23 address sampled is that of lowpc and the highest is just below highpc.
24 At most nfunc call counts can be kept; only calls of functions compiled
25 with the profiling option -p of cc(1) are recorded. For the results to
26 be significant, especially where there are small, heavily used rou‐
27 tines, it is suggested that the buffer be no more than a few times
28 smaller than the range of locations sampled.
29
30 To profile the entire program, it is sufficient to use
31
32 extern etext();
33 ...
34 monitor((int)2, etext, buf, bufsize, nfunc);
35
36 Etext lies just above all the program text, see end(3).
37
38 To stop execution monitoring and write the results on the file mon.out,
39 use
40
41 monitor(0);
42
43 then prof(1) can be used to examine the results.
44
46 mon.out
47
49 prof(1), profil(2), cc(1)
50
51
52
53 MONITOR(3)