]> git.saurik.com Git - apple/xnu.git/blame - bsd/hfs/hfs_dbg.h
xnu-792.13.8.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_dbg.h
CommitLineData
1c79356b 1/*
5d5c5d0d
A
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
8ad349bb 4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
1c79356b 5 *
8ad349bb
A
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
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
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.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
1c79356b
A
29 */
30/* hfs_dbg.h
31 *
32 * (c) 1997 Apple Computer, Inc. All Rights Reserved
33 *
34 * hfs_dbg.h -- debugging macros for HFS file system.
35 *
36 * HISTORY
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.
41 */
42
43struct componentname;
44
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
50*/
51#ifndef HFS_DIAGNOSTIC
52 #define HFS_DIAGNOSTIC 0
53#endif /* HFS_DIAGNOSTIC */
54
55#ifndef HFS_DEBUG_STAGE
56#if HFS_DIAGNOSTIC
57 #define HFS_DEBUG_STAGE 4
58#else
59 #define HFS_DEBUG_STAGE 1
60#endif /* KERNEL */
61#endif /* HFS_DEBUG_STAGE */
62
63#ifdef KERNEL
64 #define PRINTIT kprintf
65#else /* KERNEL */
66 #define PRINTIT printf
67#endif /* KERNEL */
68
69#if (HFS_DEBUG_STAGE > 3)
70#define DEBUG_BREAK Debugger("");
71#else
72#define DEBUG_BREAK
73#endif
74
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;};
79#else
80 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { PRINTIT PRINTF_ARGS; };
81#endif
82
83
84//#define PRINT_DELAY (void) tsleep((caddr_t)&lbolt, PPAUSE, "hfs kprintf", 0)
85#define PRINT_DELAY
86
87/*
88 * Debugging macros.
89 */
90#if HFS_DIAGNOSTIC
91extern int hfs_dbg_all;
1c79356b 92extern int hfs_dbg_err;
1c79356b
A
93
94#ifdef KERNEL
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); } }
100 #else
101#define DBG_ASSERT(a) { if (!(a)) { panic("File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } }
102 #endif /* HFS_DEBUG_STAGE */
103#else
104 #define DBG_ASSERT(a) assert(a)
105#endif /* KERNEL */
106
1c79356b
A
107#define DBG_ERR(x) { \
108 if(hfs_dbg_all || hfs_dbg_err) { \
91447636 109 PRINTIT("%X: ", proc_selfpid()); \
1c79356b
A
110 PRINTIT("HFS ERROR: "); \
111 PRINTIT x; \
112 PRINT_DELAY; \
113 }; \
114}
1c79356b 115
9bccf70c 116#else /* HFS_DIAGNOSTIC */
1c79356b 117
9bccf70c
A
118#define DBG_ASSERT(a)
119#define DBG_ERR(x)
1c79356b 120
9bccf70c 121#endif /* HFS_DIAGNOSTIC */
1c79356b 122