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: src/lib/libc/gmon/moncontrol.3,v 1.6.2.5 2001/12/14 18:33:54 ru Exp $ 34.\" $DragonFly: src/lib/libc/gmon/moncontrol.3,v 1.2 2003/06/17 04:26:42 dillon Exp $ 35.\" 36.Dd June 4, 1993 37.Dt MONCONTROL 3 38.Os 39.Sh NAME 40.Nm moncontrol , 41.Nm monstartup 42.Nd control execution profile 43.Sh LIBRARY 44.Lb libc 45.Sh SYNOPSIS 46.In sys/types.h 47.Ft int 48.Fn moncontrol "int mode" 49.Ft int 50.Fn monstartup "u_long *lowpc" "u_long *highpc" 51.Sh DESCRIPTION 52An executable program compiled using the 53.Fl pg 54option to 55.Xr cc 1 56automatically includes calls to collect statistics for the 57.Xr gprof 1 58call-graph execution profiler. 59In typical operation, profiling begins at program startup 60and ends when the program calls exit. 61When the program exits, the profiling data are written to the file 62.Em progname.gmon , 63where progname is the name of the program, then 64.Xr gprof 1 65can be used to examine the results. 66.Pp 67.Fn moncontrol 68selectively controls profiling within a program. 69When the program starts, profiling begins. 70To stop the collection of histogram ticks and call counts use 71.Fn moncontrol 0 ; 72to resume the collection of histogram ticks and call counts use 73.Fn moncontrol 1 . 74This feature allows the cost of particular operations to be measured. 75Note that an output file will be produced on program exit 76regardless of the state of 77.Fn moncontrol . 78.Pp 79Programs that are not loaded with 80.Fl pg 81may selectively collect profiling statistics by calling 82.Fn monstartup 83with the range of addresses to be profiled. 84.Fa lowpc 85and 86.Fa highpc 87specify the address range that is to be sampled; 88the lowest address sampled is that of 89.Fa lowpc 90and the highest is just below 91.Fa highpc . 92Only functions in that range that have been compiled with the 93.Fl pg 94option to 95.Xr cc 1 96will appear in the call graph part of the output; 97however, all functions in that address range will 98have their execution time measured. 99Profiling begins on return from 100.Fn monstartup . 101.Sh FILES 102.Bl -tag -width progname.gmon -compact 103.It Pa progname.gmon 104execution data file 105.El 106.Sh SEE ALSO 107.Xr cc 1 , 108.Xr gprof 1 , 109.Xr profil 2 , 110.Xr clocks 7 111