1.\" $OpenBSD: kgmon.8,v 1.12 2013/02/12 08:06:22 mpi Exp $ 2.\" Copyright (c) 1983, 1991, 1993 3.\" The Regents of the University of California. All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 3. Neither the name of the University nor the names of its contributors 14.\" may be used to endorse or promote products derived from this software 15.\" without specific prior written permission. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.\" from: @(#)kgmon.8 8.1 (Berkeley) 6/6/93 30.\" $Id: kgmon.8,v 1.12 2013/02/12 08:06:22 mpi Exp $ 31.\" 32.Dd $Mdocdate: February 12 2013 $ 33.Dt KGMON 8 34.Os 35.Sh NAME 36.Nm kgmon 37.Nd generate a dump of the operating system's profile buffers 38.Sh SYNOPSIS 39.Nm kgmon 40.Op Fl bhpr 41.Op Fl M Ar core 42.Op Fl N Ar system 43.Sh DESCRIPTION 44.Nm kgmon 45is a tool used when profiling the operating system. 46When no arguments are supplied, 47.Nm kgmon 48indicates the state of operating system profiling as 49.Dq running , 50.Dq off , 51or 52.Dq not configured 53(see 54.Xr config 8 ) . 55If the 56.Fl p 57flag is specified, 58.Nm kgmon 59extracts profile data from the operating system and produces a file for each 60CPU suitable for later analysis by 61.Xr gprof 1 . 62.Pp 63The options are as follows: 64.Bl -tag -width Ds 65.It Fl b 66Resume the collection of profile data. 67.It Fl c Ar cpuid 68Operate on the CPU specified by 69.Pa cpuid , 70instead of all of them. 71.It Fl h 72Stop the collection of profile data. 73.It Fl M Ar core 74Extract values associated with the name list from the specified 75.Ar core 76instead of the default 77.Pa /dev/kmem . 78.It Fl N Ar system 79Extract the name list from the specified 80.Ar system 81instead of the default 82.Pa /bsd . 83.It Fl p 84Dump the contents of the profile buffers into a 85.Pa gmon-<id>.out 86file, where 87.Dq id 88is the ID of the CPU. 89.It Fl r 90Reset all the profile buffers. 91If the 92.Fl p 93flag is also specified, the profile files are generated before the buffers are 94reset. 95.El 96.Pp 97If neither 98.Fl b 99nor 100.Fl h 101is specified, the state of profiling collection remains unchanged. 102For example, if the 103.Fl p 104flag is specified and profile data is being collected, 105profiling will be momentarily suspended, 106the operating system profile buffers will be dumped, 107and profiling will be immediately resumed. 108.Sh FILES 109.Bl -tag -width /dev/kmemx -compact 110.It Pa /bsd 111default system 112.It Pa /dev/kmem 113default memory 114.El 115.Sh DIAGNOSTICS 116Users with only read permission on 117.Pa /dev/kmem 118cannot change the state 119of profiling collection. 120They can get a 121.Pa gmon.out 122file with the warning that the data may be 123inconsistent if profiling is in progress. 124.Sh SEE ALSO 125.Xr gprof 1 , 126.Xr config 8 127.Sh HISTORY 128The 129.Nm 130command appeared in 131.Bx 4.2 . 132