1 .\" Copyright (c) 2001 John H. Baldwin <jhb@FreeBSD.org>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" $FreeBSD: src/share/man/man9/ktr.9,v 1.8 2005/03/08 01:37:36 hmp Exp $
26 .\" $DragonFly: src/share/man/man9/ktr.9,v 1.10 2007/01/07 11:26:56 swildner Exp $
36 .Nd kernel tracing facility
39 .Vt "extern int ktr_entries" ;
40 .Vt "extern int ktr_verbose" ;
41 .Vt "extern struct ktr_entry *ktr_buf[MAXCPU]" ;
42 .Fn KTR_INFO_MASTER "master"
43 .Fn KTR_INFO "compile" "master" "name" "maskbit" "format" "datasize"
44 .Fn KTR_LOG "info" "arg ..."
45 .Fn KTR_LOG_PTR "info" "ptr"
49 facility provides a circular buffer of events that can be logged in a
52 These events can then be dumped with
59 declares a new master variable
60 .Dv ktr Ns _ Ns Fa master Ns _ Ns Dv enable
61 that is used to turn on and off event logging.
65 macro registers a new event
67 that will be controlled by the
70 Code for logging this event will be compiled in when
77 style format string used to build the text of the event log message while
79 specifies the size of the data to be logged, either the total size of the
80 arguments required by the
82 string or the size of the data pointer
84 For logging a fixed string with
90 is currently unused and can be set to 0.
92 Kernel events are logged via the
99 parameter is an identifier of the format
100 .Fa master Ns _ Ns Fa name .
102 accepts zero or more additional
104 arguments as required by the
106 string passed to the associated
111 macro behaves similarly but takes a single data pointer
117 variable contains the number of entries in the
120 These variables are mostly useful for post-mortem crash dump tools to locate
121 the base of the circular trace buffer and its length.
125 variable stores the verbose flag that controls whether events are logged to
126 the console in addition to the event buffer.
128 This example demonstrates a simple usage of the KTR facility:
130 .Bd -literal -compact
131 KTR_INFO_MASTER(ktrtest);
132 KTR_INFO(KTR_TEST, ktrtest, t1, 0, "func() called", 0);
152 kernel tracing facility first appeared in
154 and was imported into
158 It was completely rewritten by Matthew Dillon in