]>
git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfs_dbg.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
32 * (c) 1997 Apple Computer, Inc. All Rights Reserved
34 * hfs_dbg.h -- debugging macros for HFS file system.
37 * 10-Nov-1998 Pat Dirks Cleaned up definition of DBG_ASSERT to handle embedded '%' correctly.
38 * 28-Apr-1998 Scott Roberts Reorganized and added HFS_DEBUG_STAGE
39 * 17-Nov-1997 Pat Dirks Pat Dirks at Apple Computer
40 * Derived from old hfs version.
45 /* Define the debugging stage...
46 4 -> Do all, aggresive, call_kdp
47 3 -> debug asserts and debug err, panic instead of call_kdp
48 2 -> debug error, no kdb
49 1 -> very little, panic only
51 #ifndef HFS_DIAGNOSTIC
52 #define HFS_DIAGNOSTIC 0
53 #endif /* HFS_DIAGNOSTIC */
55 #ifndef HFS_DEBUG_STAGE
57 #define HFS_DEBUG_STAGE 4
59 #define HFS_DEBUG_STAGE 1
61 #endif /* HFS_DEBUG_STAGE */
64 #define PRINTIT kprintf
66 #define PRINTIT printf
69 #if (HFS_DEBUG_STAGE > 3)
70 #define DEBUG_BREAK Debugger("");
75 #if (HFS_DEBUG_STAGE == 4)
76 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { PRINTIT PRINTF_ARGS; DEBUG_BREAK };
77 #elif (HFS_DEBUG_STAGE == 3)
78 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { panic PRINTF_ARGS;};
80 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { PRINTIT PRINTF_ARGS; };
84 //#define PRINT_DELAY (void) tsleep((caddr_t)&lbolt, PPAUSE, "hfs kprintf", 0)
91 extern int hfs_dbg_all
;
92 extern int hfs_dbg_err
;
95 #if (HFS_DEBUG_STAGE == 4)
96 char gDebugAssertStr
[255];
97 #define DBG_ASSERT(a) { if (!(a)) { \
98 sprintf(gDebugAssertStr,"Oops - File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); \
99 Debugger(gDebugAssertStr); } }
101 #define DBG_ASSERT(a) { if (!(a)) { panic("File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } }
102 #endif /* HFS_DEBUG_STAGE */
104 #define DBG_ASSERT(a) assert(a)
107 #define DBG_ERR(x) { \
108 if(hfs_dbg_all || hfs_dbg_err) { \
109 PRINTIT("%X: ", proc_selfpid()); \
110 PRINTIT("HFS ERROR: "); \
116 #else /* HFS_DIAGNOSTIC */
118 #define DBG_ASSERT(a)
121 #endif /* HFS_DIAGNOSTIC */