Commit | Line | Data |
---|---|---|
e6817382 BJ |
1 | .TH MONITOR 3 |
2 | .SH NAME | |
3 | monitor \- prepare execution profile | |
4 | .SH SYNOPSIS | |
5 | .B monitor(lowpc, highpc, buffer, bufsize, nfunc) | |
6 | .br | |
7 | .B | |
8 | int (*lowpc)( ), (*highpc)( ); | |
9 | .br | |
10 | .B short buffer[ ]; | |
11 | .SH DESCRIPTION | |
12 | An executable program created by | |
13 | `cc \-p' automatically includes calls for | |
14 | .I monitor | |
15 | with default parameters; | |
16 | .I monitor | |
17 | needn't be called explicitly | |
18 | except to gain fine control over profiling. | |
19 | .PP | |
20 | .I Monitor | |
21 | is an interface to | |
22 | .IR profil (2). | |
23 | .I Lowpc | |
24 | and | |
25 | .I highpc | |
26 | are the addresses of two functions; | |
27 | .I buffer | |
28 | is the address of a (user supplied) | |
29 | array of | |
30 | .I bufsize | |
31 | short integers. | |
32 | .I Monitor | |
33 | arranges to record a histogram of | |
34 | periodically sampled values of the program counter, | |
35 | and of counts of calls | |
36 | of certain functions, in the buffer. | |
37 | The lowest address sampled | |
38 | is that of | |
39 | .I lowpc | |
40 | and the highest is | |
41 | just below | |
42 | .IR highpc . | |
43 | At most | |
44 | .I nfunc | |
45 | call counts can be kept; only calls of functions | |
46 | compiled with the profiling option | |
47 | .B \-p | |
48 | of | |
49 | .IR cc (1) | |
50 | are recorded. | |
51 | For the results to be significant, | |
52 | especially where there are small, heavily | |
53 | used routines, | |
54 | it is suggested that the buffer be no more | |
55 | than a few times smaller than the range | |
56 | of locations sampled. | |
57 | .PP | |
58 | To profile the entire program, | |
59 | it is sufficient to use | |
60 | .PP | |
61 | extern etext(); | |
62 | .br | |
63 | ... | |
64 | .br | |
65 | monitor((int)2, etext, buf, bufsize, nfunc); | |
66 | .PP | |
67 | .I Etext | |
68 | lies just above all the | |
69 | program text, see | |
70 | .IR end (3). | |
71 | .PP | |
72 | To stop execution monitoring and write the results | |
73 | on the file | |
74 | .I mon.out, | |
75 | use | |
76 | .PP | |
77 | monitor(0); | |
78 | .LP | |
79 | then | |
80 | .IR prof (1) | |
81 | can be used | |
82 | to examine the results. | |
83 | .SH FILES | |
84 | mon.out | |
85 | .SH "SEE ALSO" | |
86 | prof(1), profil(2), cc(1) |