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