]>
git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfs_dbg.h
2 * Copyright (c) 2000, 2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 * (c) 1997 Apple Computer, Inc. All Rights Reserved
32 * hfs_dbg.h -- debugging macros for HFS file system.
35 * 10-Nov-1998 Pat Dirks Cleaned up definition of DBG_ASSERT to handle embedded '%' correctly.
36 * 28-Apr-1998 Scott Roberts Reorganized and added HFS_DEBUG_STAGE
37 * 17-Nov-1997 Pat Dirks Pat Dirks at Apple Computer
38 * Derived from old hfs version.
42 extern void Debugger(const char *message
);
44 /* Define the debugging stage...
45 4 -> Do all, aggresive, call_kdp
46 3 -> debug asserts and debug err, panic instead of call_kdp
47 2 -> debug error, no kdb
48 1 -> very little, panic only
50 #ifndef HFS_DIAGNOSTIC
51 #define HFS_DIAGNOSTIC 0
52 #endif /* HFS_DIAGNOSTIC */
54 #ifndef HFS_DEBUG_STAGE
56 #define HFS_DEBUG_STAGE 4
58 #define HFS_DEBUG_STAGE 1
60 #endif /* HFS_DEBUG_STAGE */
63 #define PRINTIT kprintf
65 #define PRINTIT printf
68 #if (HFS_DEBUG_STAGE > 3)
69 #define DEBUG_BREAK Debugger("");
74 #if (HFS_DEBUG_STAGE == 4)
75 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { PRINTIT PRINTF_ARGS; DEBUG_BREAK };
76 #elif (HFS_DEBUG_STAGE == 3)
77 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { panic PRINTF_ARGS;};
79 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { PRINTIT PRINTF_ARGS; };
89 extern int hfs_dbg_all
;
90 extern int hfs_dbg_err
;
93 #if (HFS_DEBUG_STAGE == 4)
94 char gDebugAssertStr
[255];
95 #define DBG_ASSERT(a) { if (!(a)) { \
96 snprintf(gDebugAssertStr, sizeof (gDebugAssertStr), "Oops - File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); \
97 Debugger(gDebugAssertStr); } }
99 #define DBG_ASSERT(a) { if (!(a)) { panic("File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } }
100 #endif /* HFS_DEBUG_STAGE */
102 #define DBG_ASSERT(a) assert(a)
105 #define DBG_ERR(x) { \
106 if(hfs_dbg_all || hfs_dbg_err) { \
107 PRINTIT("%X: ", proc_selfpid()); \
108 PRINTIT("HFS ERROR: "); \
114 #else /* HFS_DIAGNOSTIC */
116 #define DBG_ASSERT(a)
119 #endif /* HFS_DIAGNOSTIC */