]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/gmon/moncontrol.3
merge fix for boot-time hang on centos' xen
[FreeBSD/FreeBSD.git] / lib / libc / gmon / moncontrol.3
1 .\" Copyright (c) 1980, 1991, 1992, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)moncontrol.3        8.1 (Berkeley) 6/4/93
33 .\" $FreeBSD$
34 .\"
35 .Dd June 14, 2004
36 .Dt MONCONTROL 3
37 .Os
38 .Sh NAME
39 .Nm moncontrol ,
40 .Nm monstartup
41 .Nd control execution profile
42 .Sh LIBRARY
43 .Lb libc
44 .Sh SYNOPSIS
45 .In sys/types.h
46 .In sys/gmon.h
47 .Ft void
48 .Fn moncontrol "int mode"
49 .Ft void
50 .Fn monstartup "u_long lowpc" "u_long highpc"
51 .Sh DESCRIPTION
52 An executable program compiled using the
53 .Fl pg
54 option to
55 .Xr cc 1
56 automatically includes calls to collect statistics for the
57 .Xr gprof 1
58 call-graph execution profiler.
59 In typical operation, profiling begins at program startup
60 and ends when the program calls exit.
61 When the program exits, the profiling data are written to the file
62 .Ar progname Ns Pa .gmon ,
63 where progname is the name of the program, then
64 .Xr gprof 1
65 can be used to examine the results.
66 .Pp
67 The
68 .Fn moncontrol
69 function
70 selectively controls profiling within a program.
71 When the program starts, profiling begins.
72 To stop the collection of histogram ticks and call counts use
73 .Fn moncontrol 0 ;
74 to resume the collection of histogram ticks and call counts use
75 .Fn moncontrol 1 .
76 This feature allows the cost of particular operations to be measured.
77 Note that an output file will be produced on program exit
78 regardless of the state of
79 .Fn moncontrol .
80 .Pp
81 Programs that are not loaded with
82 .Fl pg
83 may selectively collect profiling statistics by calling
84 .Fn monstartup
85 with the range of addresses to be profiled.
86 The
87 .Fa lowpc
88 and
89 .Fa highpc
90 arguments
91 specify the address range that is to be sampled;
92 the lowest address sampled is that of
93 .Fa lowpc
94 and the highest is just below
95 .Fa highpc .
96 Only functions in that range that have been compiled with the
97 .Fl pg
98 option to
99 .Xr cc 1
100 will appear in the call graph part of the output;
101 however, all functions in that address range will
102 have their execution time measured.
103 Profiling begins on return from
104 .Fn monstartup .
105 .Sh FILES
106 .Bl -tag -width progname.gmon -compact
107 .It Pa progname.gmon
108 execution data file
109 .El
110 .Sh SEE ALSO
111 .Xr cc 1 ,
112 .Xr gprof 1 ,
113 .Xr profil 2 ,
114 .Xr clocks 7