kerndebug.h revision 1.1 1 /* $NetBSD: kerndebug.h,v 1.1 2002/02/10 01:57:26 thorpej Exp $ */
2
3 /*
4 * Copyright 1997
5 * Digital Equipment Corporation. All rights reserved.
6 *
7 * This software is furnished under license and may be used and
8 * copied only in accordance with the following terms and conditions.
9 * Subject to these conditions, you may download, copy, install,
10 * use, modify and distribute this software in source and/or binary
11 * form. No title or ownership is transferred hereby.
12 *
13 * 1) Any source code used, modified or distributed must reproduce
14 * and retain this copyright notice and list of conditions as
15 * they appear in the source file.
16 *
17 * 2) No right is granted to use any trade name, trademark, or logo of
18 * Digital Equipment Corporation. Neither the "Digital Equipment
19 * Corporation" name nor any trademark or logo of Digital Equipment
20 * Corporation may be used to endorse or promote products derived
21 * from this software without the prior written permission of
22 * Digital Equipment Corporation.
23 *
24 * 3) This software is provided "AS-IS" and any express or implied
25 * warranties, including but not limited to, any implied warranties
26 * of merchantability, fitness for a particular purpose, or
27 * non-infringement are disclaimed. In no event shall DIGITAL be
28 * liable for any damages whatsoever, and in particular, DIGITAL
29 * shall not be liable for special, indirect, consequential, or
30 * incidental damages or damages for lost profits, loss of
31 * revenue or loss of use, whether such damages arise in contract,
32 * negligence, tort, under statute, in equity, at law or otherwise,
33 * even if advised of the possibility of such damage.
34 */
35
36 /*
37 **++
38 ** FACILITY:
39 **
40 ** kerndebug.h
41 **
42 **
43 ** ABSTRACT:
44 **
45 ** This header provides generic debugging capabilities using printf.
46 ** All debugging can be compiled out by not defining the
47 ** KERNEL_DEBUG macro. In addition the amount of debug output is
48 ** defined by individual variables controlled by each subsystem
49 ** using this utility. Finally note that the two middle bytes of
50 ** the kern debug flags (bits 16 to 23) are free for individual
51 ** subsystems to use as they please (eg. define switches for
52 ** individual functions etc).
53 **
54 ** AUTHORS:
55 **
56 ** John Court
57 **
58 ** CREATION DATE: 2-Feb-1992
59 **
60 ** MODIFICATION HISTORY:
61 **
62 **--
63 */
64 #ifndef _KERNDEBUG_H_
65 #define _KERNDEBUG_H_
66
67 #define KERN_DEBUG_INFO 0x00000001
68 #define KERN_DEBUG_WARNING 0x00000002
69 #define KERN_DEBUG_ERROR 0x00000010
70 #define KERN_DEBUG_SMP 0x00000020
71 #define KERN_DEBUG_PANIC 0x40000000
72 #define KERN_REAL_PANIC 0x80000000
73 #define KERN_DEBUG_ALL KERN_DEBUG_INFO | KERN_DEBUG_WARNING | \
74 KERN_DEBUG_ERROR | KERN_DEBUG_PANIC
75 /*
76 ** Define the type for debugging flag subsystem variables
77 */
78 typedef unsigned int Kern_Debug_Flags;
79 /*
80 ** Set up source line location macro for extra debugging and panics
81 */
82 #ifdef __FILE__
83 #define KERN_DEBUG_LOC ":%s:%d:=\n\t",__FILE__,__LINE__
84 #else
85 #define KERN_DEBUG_LOC ":__FILE__ not supported :=\n\t"
86 #endif
87
88 /*
89 ** This is real nasty in that it requires several printf's but is
90 ** unavoidable due to the differences between
91 ** preprocessors supporting standard ANSI C and others.
92 **
93 ** NOTE: The format of calls to this macro must be
94 **
95 ** KERN_DEBUG((Kern_Debug_Flags)CntrlVar, KERN_DEBUG_xxxx,
96 ** (normal printf arguments));
97 **
98 ** pay special attention to the extra set of () around the
99 ** final arguement.
100 **
101 */
102 #ifdef KERNEL_DEBUG
103 #define KERN_DEBUG(CntrlVar,Level,Output) \
104 { \
105 if ( (CntrlVar) & (Level) ) \
106 { \
107 if ( (CntrlVar) & (Level) & KERN_DEBUG_PANIC ) \
108 { \
109 printf ("KERNEL:DEBUG PANIC"); \
110 printf (KERN_DEBUG_LOC); \
111 printf Output; \
112 panic("KERN_DEBUG Panicing"); \
113 } \
114 else \
115 { \
116 printf Output; \
117 } \
118 } \
119 }
120 #else /* else KERNEL_DEBUG not defined */
121 #define KERN_DEBUG(CntrlVar,Level,Output)
122 #endif /* end else KERNEL_DEBUG not defined */
123
124 #endif /* _KERNDEBUG_H_ */
125
126
127
128
129
130
131
132
133