]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000, 2005 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 | ||
41 | struct componentname; | |
42 | extern void Debugger(const char *message); | |
43 | ||
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 | |
49 | */ | |
50 | #ifndef HFS_DIAGNOSTIC | |
51 | #define HFS_DIAGNOSTIC 0 | |
52 | #endif /* HFS_DIAGNOSTIC */ | |
53 | ||
54 | #ifndef HFS_DEBUG_STAGE | |
55 | #if HFS_DIAGNOSTIC | |
56 | #define HFS_DEBUG_STAGE 4 | |
57 | #else | |
58 | #define HFS_DEBUG_STAGE 1 | |
59 | #endif /* KERNEL */ | |
60 | #endif /* HFS_DEBUG_STAGE */ | |
61 | ||
62 | #ifdef KERNEL | |
63 | #define PRINTIT kprintf | |
64 | #else /* KERNEL */ | |
65 | #define PRINTIT printf | |
66 | #endif /* KERNEL */ | |
67 | ||
68 | #if (HFS_DEBUG_STAGE > 3) | |
69 | #define DEBUG_BREAK Debugger(""); | |
70 | #else | |
71 | #define DEBUG_BREAK | |
72 | #endif | |
73 | ||
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;}; | |
78 | #else | |
79 | #define DEBUG_BREAK_MSG(PRINTF_ARGS) { PRINTIT PRINTF_ARGS; }; | |
80 | #endif | |
81 | ||
82 | ||
83 | //#define PRINT_DELAY (void) tsleep((caddr_t)&lbolt, PPAUSE, "hfs kprintf", 0) | |
84 | #define PRINT_DELAY | |
85 | ||
86 | /* | |
87 | * Debugging macros. | |
88 | */ | |
89 | #if HFS_DIAGNOSTIC | |
90 | extern int hfs_dbg_all; | |
91 | extern int hfs_dbg_err; | |
92 | ||
93 | #ifdef KERNEL | |
94 | #if (HFS_DEBUG_STAGE == 4) | |
95 | char gDebugAssertStr[255]; | |
96 | #define DBG_ASSERT(a) { if (!(a)) { \ | |
97 | snprintf(gDebugAssertStr, sizeof (gDebugAssertStr), "Oops - File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); \ | |
98 | Debugger(gDebugAssertStr); } } | |
99 | #else | |
100 | #define DBG_ASSERT(a) { if (!(a)) { panic("File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } } | |
101 | #endif /* HFS_DEBUG_STAGE */ | |
102 | #else | |
103 | #define DBG_ASSERT(a) assert(a) | |
104 | #endif /* KERNEL */ | |
105 | ||
106 | #define DBG_ERR(x) { \ | |
107 | if(hfs_dbg_all || hfs_dbg_err) { \ | |
108 | PRINTIT("%X: ", proc_selfpid()); \ | |
109 | PRINTIT("HFS ERROR: "); \ | |
110 | PRINTIT x; \ | |
111 | PRINT_DELAY; \ | |
112 | }; \ | |
113 | } | |
114 | ||
115 | #else /* HFS_DIAGNOSTIC */ | |
116 | ||
117 | #define DBG_ASSERT(a) | |
118 | #define DBG_ERR(x) | |
119 | ||
120 | #endif /* HFS_DIAGNOSTIC */ | |
121 |