- Correct use of the err() family (err() -> errx())
[dragonfly.git] / sys / sys / ktr.h
... / ...
CommitLineData
1/*-
2 * Copyright (c) 1996 Berkeley Software Design, Inc. 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. Berkeley Software Design Inc's name may not be used to endorse or
13 * promote products derived from this software without specific prior
14 * written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * from BSDI $Id: ktr.h,v 1.10.2.7 2000/03/16 21:44:42 cp Exp $
29 * $FreeBSD: /repoman/r/ncvs/src/sys/sys/ktr.h,v 1.21 2003/03/11 20:07:22 jhb Exp $
30 * $DragonFly: src/sys/sys/ktr.h,v 1.2 2005/02/12 21:09:46 eirikn Exp $
31 */
32
33/*
34 * Wraparound kernel trace buffer support.
35 */
36
37#ifndef _SYS_KTR_H_
38#define _SYS_KTR_H_
39
40#include "opt_ktr.h"
41
42/*
43 * Trace classes
44 */
45#define KTR_GEN 0x00000001 /* General (TR) */
46#define KTR_NET 0x00000002 /* Network */
47#define KTR_DEV 0x00000004 /* Device driver */
48#define KTR_LOCK 0x00000008 /* MP locking */
49#define KTR_SMP 0x00000010 /* MP general */
50#define KTR_FS 0x00000020 /* Filesystem */
51#define KTR_PMAP 0x00000040 /* Pmap tracing */
52#define KTR_MALLOC 0x00000080 /* Malloc tracing */
53#define KTR_TRAP 0x00000100 /* Trap processing */
54#define KTR_INTR 0x00000200 /* Interrupt tracing */
55#define KTR_SIG 0x00000400 /* Signal processing */
56#define KTR_CLK 0x00000800 /* hardclock verbose */
57#define KTR_PROC 0x00001000 /* Process scheduling */
58#define KTR_SYSC 0x00002000 /* System call */
59#define KTR_INIT 0x00004000 /* System initialization */
60#define KTR_KGDB 0x00008000 /* Trace kgdb internals */
61#define KTR_IO 0x00010000 /* Upper I/O */
62#define KTR_EVH 0x00020000 /* Eventhandler */
63#define KTR_NFS 0x00040000 /* The obvious */
64#define KTR_VOP 0x00080000 /* The obvious */
65#define KTR_VM 0x00100000 /* The virtual memory system */
66#define KTR_WITNESS 0x00200000
67#define KTR_RUNQ 0x00400000 /* Run queue */
68#define KTR_CONTENTION 0x00800000 /* Lock contention */
69#define KTR_ALL 0x00ffffff
70
71/*
72 * Trace classes which can be assigned to particular use at compile time
73 * These must remain in high 22 as some assembly code counts on it
74 */
75#define KTR_CT1 0x01000000
76#define KTR_CT2 0x02000000
77#define KTR_CT3 0x04000000
78#define KTR_CT4 0x08000000
79#define KTR_CT5 0x10000000
80#define KTR_CT6 0x20000000
81#define KTR_CT7 0x40000000
82#define KTR_CT8 0x80000000
83
84/* Trace classes to compile in */
85#ifndef KTR_COMPILE
86#define KTR_COMPILE (KTR_ALL)
87#endif
88
89/*
90 * Version number for ktr_entry struct. Increment this when you break binary
91 * compatibility.
92 */
93#define KTR_VERSION 1
94
95#define KTR_PARMS 6
96
97#ifndef LOCORE
98
99struct ktr_entry {
100 u_int64_t ktr_timestamp;
101 int ktr_cpu;
102 int ktr_line;
103 const char *ktr_file;
104 const char *ktr_desc;
105 u_long ktr_parms[KTR_PARMS];
106};
107
108extern int ktr_cpumask;
109extern int ktr_mask;
110extern int ktr_entries;
111extern int ktr_verbose;
112
113extern volatile int ktr_idx[MAXCPU];
114extern struct ktr_entry *ktr_buf[MAXCPU];
115
116#endif /* !LOCORE */
117
118#ifdef KTR
119
120void ktr_tracepoint(u_int mask, const char *file, int line,
121 const char *format, u_long arg1, u_long arg2, u_long arg3,
122 u_long arg4, u_long arg5, u_long arg6);
123
124#define CTR6(m, format, p1, p2, p3, p4, p5, p6) do { \
125 if (KTR_COMPILE & (m)) \
126 ktr_tracepoint((m), __FILE__, __LINE__, format, \
127 (u_long)(p1), (u_long)(p2), (u_long)(p3), \
128 (u_long)(p4), (u_long)(p5), (u_long)(p6)); \
129 } while(0)
130#define CTR0(m, format) CTR6(m, format, 0, 0, 0, 0, 0, 0)
131#define CTR1(m, format, p1) CTR6(m, format, p1, 0, 0, 0, 0, 0)
132#define CTR2(m, format, p1, p2) CTR6(m, format, p1, p2, 0, 0, 0, 0)
133#define CTR3(m, format, p1, p2, p3) CTR6(m, format, p1, p2, p3, 0, 0, 0)
134#define CTR4(m, format, p1, p2, p3, p4) CTR6(m, format, p1, p2, p3, p4, 0, 0)
135#define CTR5(m, format, p1, p2, p3, p4, p5) CTR6(m, format, p1, p2, p3, p4, p5, 0)
136#else /* KTR */
137#undef KTR_COMPILE
138#define KTR_COMPILE 0
139#define CTR0(m, d)
140#define CTR1(m, d, p1)
141#define CTR2(m, d, p1, p2)
142#define CTR3(m, d, p1, p2, p3)
143#define CTR4(m, d, p1, p2, p3, p4)
144#define CTR5(m, d, p1, p2, p3, p4, p5)
145#define CTR6(m, d, p1, p2, p3, p4, p5, p6)
146#endif /* KTR */
147
148#define TR0(d) CTR0(KTR_GEN, d)
149#define TR1(d, p1) CTR1(KTR_GEN, d, p1)
150#define TR2(d, p1, p2) CTR2(KTR_GEN, d, p1, p2)
151#define TR3(d, p1, p2, p3) CTR3(KTR_GEN, d, p1, p2, p3)
152#define TR4(d, p1, p2, p3, p4) CTR4(KTR_GEN, d, p1, p2, p3, p4)
153#define TR5(d, p1, p2, p3, p4, p5) CTR5(KTR_GEN, d, p1, p2, p3, p4, p5)
154#define TR6(d, p1, p2, p3, p4, p5, p6) CTR6(KTR_GEN, d, p1, p2, p3, p4, p5, p6)
155
156/*
157 * Trace initialization events, similar to CTR with KTR_INIT, but
158 * completely ifdef'ed out if KTR_INIT isn't in KTR_COMPILE (to
159 * save string space, the compiler doesn't optimize out strings
160 * for the conditional ones above).
161 */
162#if (KTR_COMPILE & KTR_INIT) != 0
163#define ITR0(d) CTR0(KTR_INIT, d)
164#define ITR1(d, p1) CTR1(KTR_INIT, d, p1)
165#define ITR2(d, p1, p2) CTR2(KTR_INIT, d, p1, p2)
166#define ITR3(d, p1, p2, p3) CTR3(KTR_INIT, d, p1, p2, p3)
167#define ITR4(d, p1, p2, p3, p4) CTR4(KTR_INIT, d, p1, p2, p3, p4)
168#define ITR5(d, p1, p2, p3, p4, p5) CTR5(KTR_INIT, d, p1, p2, p3, p4, p5)
169#define ITR6(d, p1, p2, p3, p4, p5, p6) CTR6(KTR_INIT, d, p1, p2, p3, p4, p5, p6)
170#else
171#define ITR0(d)
172#define ITR1(d, p1)
173#define ITR2(d, p1, p2)
174#define ITR3(d, p1, p2, p3)
175#define ITR4(d, p1, p2, p3, p4)
176#define ITR5(d, p1, p2, p3, p4, p5)
177#define ITR6(d, p1, p2, p3, p4, p5, p6)
178#endif
179
180#endif /* !_SYS_KTR_H_ */