xref: /original-bsd/lib/libc/gmon/moncontrol.3 (revision 3b3772fe)
1.\" Copyright (c) 1980, 1991, 1992 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.proprietary.roff%
5.\"
6.\"	@(#)moncontrol.3	6.4 (Berkeley) 07/15/92
7.\"
8.Dd
9.Dt MONCONTROL 3
10.Os BSD 4
11.Sh NAME
12.Nm moncontrol ,
13.Nm monstartup
14.Nd prepare execution profile
15.Sh SYNOPSIS
16.Fn moncontrol "int mode"
17.Fn monstartup lowpc highpc
18.Fn int *lowpc
19.Sh DESCRIPTION
20An executable program created by:
21.Pp
22.Dl cc \-pg ...
23.Pp
24automatically includes calls to collect statistics for the
25.Xr gprof 1
26call-graph execution profiler.
27In typical operation, profiling begins at program startup
28and ends when the program calls exit.
29When the program exits, the profiling data are written to the file
30.Em gmon.out ,
31then
32.Xr gprof 1
33can be used to examine the results.
34.Pp
35.Fn moncontrol
36selectively controls profiling within a program.
37When the program starts, profiling begins.
38To stop the collection of histogram ticks and call counts use
39.Fn moncontrol 0 ;
40to resume the collection of histogram ticks and call counts use
41.Fn moncontrol 1 .
42This allows the cost of particular operations to be measured.
43Note that an output file will be produced on program exit
44regardless of the state of
45.Fn moncontrol .
46.Pp
47Programs that are not loaded with
48.Pp
49.Dl cc \-pg ...
50.Pp
51may selectively collect profiling statistics by calling
52.Fn monstartup
53with the range of addresses to be profiled.
54.Fa lowpc
55and
56.Fa highpc
57specify the address range that is to be sampled;
58the lowest address sampled is that of
59.Fa lowpc
60and the highest is just below
61.Fa highpc .
62Only functions in that range that have been compiled with the
63.Fl p
64option to
65.Em cc 1
66will appear in the call graph part of the output;
67however, all functions in that address range will
68have their execution time measured.
69Profiling begins on return from
70.Fn monstartup .
71.Pp
72To stop execution monitoring and write the results on the file
73.Em gmon.out ,
74use
75.Pp
76.Fn _mcleanup
77.Pp
78then
79.Xr gprof 1
80can be used to examine the results.
81.Sh FILES
82.Bl -tag -width Pa -compact
83.It Pa gmon.out
84.El
85.Sh SEE ALSO
86.Xr cc 1 ,
87.Xr gprof 1 ,
88.Xr profil 2
89