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