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