]> git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfs_dbg.h
15d5a914f9851529c0b5a9e72bba4034cfe28508
[apple/xnu.git] / bsd / hfs / hfs_dbg.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /* hfs_dbg.h
24 *
25 * (c) 1997 Apple Computer, Inc. All Rights Reserved
26 *
27 * hfs_dbg.h -- debugging macros for HFS file system.
28 *
29 * HISTORY
30 * 10-Nov-1998 Pat Dirks Cleaned up definition of DBG_ASSERT to handle embedded '%' correctly.
31 * 28-Apr-1998 Scott Roberts Reorganized and added HFS_DEBUG_STAGE
32 * 17-Nov-1997 Pat Dirks Pat Dirks at Apple Computer
33 * Derived from old hfs version.
34 */
35
36 struct componentname;
37
38 /* Define the debugging stage...
39 4 -> Do all, aggresive, call_kdp
40 3 -> debug asserts and debug err, panic instead of call_kdp
41 2 -> debug error, no kdb
42 1 -> very little, panic only
43 */
44 #ifndef HFS_DIAGNOSTIC
45 #define HFS_DIAGNOSTIC 0
46 #endif /* HFS_DIAGNOSTIC */
47
48 #ifndef HFS_DEBUG_STAGE
49 #if HFS_DIAGNOSTIC
50 #define HFS_DEBUG_STAGE 4
51 #else
52 #define HFS_DEBUG_STAGE 1
53 #endif /* KERNEL */
54 #endif /* HFS_DEBUG_STAGE */
55
56 #ifdef KERNEL
57 #define PRINTIT kprintf
58 #else /* KERNEL */
59 #define PRINTIT printf
60 #endif /* KERNEL */
61
62 #if (HFS_DEBUG_STAGE > 3)
63 #define DEBUG_BREAK Debugger("");
64 #else
65 #define DEBUG_BREAK
66 #endif
67
68 #if (HFS_DEBUG_STAGE == 4)
69 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { PRINTIT PRINTF_ARGS; DEBUG_BREAK };
70 #elif (HFS_DEBUG_STAGE == 3)
71 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { panic PRINTF_ARGS;};
72 #else
73 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { PRINTIT PRINTF_ARGS; };
74 #endif
75
76
77 //#define PRINT_DELAY (void) tsleep((caddr_t)&lbolt, PPAUSE, "hfs kprintf", 0)
78 #define PRINT_DELAY
79
80 /*
81 * Debugging macros.
82 */
83 #if HFS_DIAGNOSTIC
84 extern int hfs_dbg_all;
85 extern int hfs_dbg_err;
86
87 #ifdef KERNEL
88 #if (HFS_DEBUG_STAGE == 4)
89 char gDebugAssertStr[255];
90 #define DBG_ASSERT(a) { if (!(a)) { \
91 sprintf(gDebugAssertStr,"Oops - File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); \
92 Debugger(gDebugAssertStr); } }
93 #else
94 #define DBG_ASSERT(a) { if (!(a)) { panic("File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } }
95 #endif /* HFS_DEBUG_STAGE */
96 #else
97 #define DBG_ASSERT(a) assert(a)
98 #endif /* KERNEL */
99
100 #define DBG_ERR(x) { \
101 if(hfs_dbg_all || hfs_dbg_err) { \
102 PRINTIT("%X: ", proc_selfpid()); \
103 PRINTIT("HFS ERROR: "); \
104 PRINTIT x; \
105 PRINT_DELAY; \
106 }; \
107 }
108
109 #else /* HFS_DIAGNOSTIC */
110
111 #define DBG_ASSERT(a)
112 #define DBG_ERR(x)
113
114 #endif /* HFS_DIAGNOSTIC */
115