]> git.saurik.com Git - apple/xnu.git/blame_incremental - bsd/hfs/hfs_dbg.h
xnu-792.21.3.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_dbg.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_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. 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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/* hfs_dbg.h
29 *
30 * (c) 1997 Apple Computer, Inc. All Rights Reserved
31 *
32 * hfs_dbg.h -- debugging macros for HFS file system.
33 *
34 * HISTORY
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.
39 */
40
41struct componentname;
42
43/* Define the debugging stage...
44 4 -> Do all, aggresive, call_kdp
45 3 -> debug asserts and debug err, panic instead of call_kdp
46 2 -> debug error, no kdb
47 1 -> very little, panic only
48*/
49#ifndef HFS_DIAGNOSTIC
50 #define HFS_DIAGNOSTIC 0
51#endif /* HFS_DIAGNOSTIC */
52
53#ifndef HFS_DEBUG_STAGE
54#if HFS_DIAGNOSTIC
55 #define HFS_DEBUG_STAGE 4
56#else
57 #define HFS_DEBUG_STAGE 1
58#endif /* KERNEL */
59#endif /* HFS_DEBUG_STAGE */
60
61#ifdef KERNEL
62 #define PRINTIT kprintf
63#else /* KERNEL */
64 #define PRINTIT printf
65#endif /* KERNEL */
66
67#if (HFS_DEBUG_STAGE > 3)
68#define DEBUG_BREAK Debugger("");
69#else
70#define DEBUG_BREAK
71#endif
72
73#if (HFS_DEBUG_STAGE == 4)
74 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { PRINTIT PRINTF_ARGS; DEBUG_BREAK };
75#elif (HFS_DEBUG_STAGE == 3)
76 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { panic PRINTF_ARGS;};
77#else
78 #define DEBUG_BREAK_MSG(PRINTF_ARGS) { PRINTIT PRINTF_ARGS; };
79#endif
80
81
82//#define PRINT_DELAY (void) tsleep((caddr_t)&lbolt, PPAUSE, "hfs kprintf", 0)
83#define PRINT_DELAY
84
85/*
86 * Debugging macros.
87 */
88#if HFS_DIAGNOSTIC
89extern int hfs_dbg_all;
90extern int hfs_dbg_err;
91
92#ifdef KERNEL
93 #if (HFS_DEBUG_STAGE == 4)
94 char gDebugAssertStr[255];
95 #define DBG_ASSERT(a) { if (!(a)) { \
96 sprintf(gDebugAssertStr,"Oops - File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); \
97 Debugger(gDebugAssertStr); } }
98 #else
99#define DBG_ASSERT(a) { if (!(a)) { panic("File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } }
100 #endif /* HFS_DEBUG_STAGE */
101#else
102 #define DBG_ASSERT(a) assert(a)
103#endif /* KERNEL */
104
105#define DBG_ERR(x) { \
106 if(hfs_dbg_all || hfs_dbg_err) { \
107 PRINTIT("%X: ", proc_selfpid()); \
108 PRINTIT("HFS ERROR: "); \
109 PRINTIT x; \
110 PRINT_DELAY; \
111 }; \
112}
113
114#else /* HFS_DIAGNOSTIC */
115
116#define DBG_ASSERT(a)
117#define DBG_ERR(x)
118
119#endif /* HFS_DIAGNOSTIC */
120