]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
37839358 A |
6 | * The contents of this file constitute Original Code as defined in and |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
1c79356b | 11 | * |
37839358 A |
12 | * This Original Code and all software distributed under the License are |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
37839358 A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* hfs_dbg.h | |
23 | * | |
24 | * (c) 1997 Apple Computer, Inc. All Rights Reserved | |
25 | * | |
26 | * hfs_dbg.h -- debugging macros for HFS file system. | |
27 | * | |
28 | * HISTORY | |
29 | * 10-Nov-1998 Pat Dirks Cleaned up definition of DBG_ASSERT to handle embedded '%' correctly. | |
30 | * 28-Apr-1998 Scott Roberts Reorganized and added HFS_DEBUG_STAGE | |
31 | * 17-Nov-1997 Pat Dirks Pat Dirks at Apple Computer | |
32 | * Derived from old hfs version. | |
33 | */ | |
34 | ||
35 | struct componentname; | |
36 | ||
37 | /* Define the debugging stage... | |
38 | 4 -> Do all, aggresive, call_kdp | |
39 | 3 -> debug asserts and debug err, panic instead of call_kdp | |
40 | 2 -> debug error, no kdb | |
41 | 1 -> very little, panic only | |
42 | */ | |
43 | #ifndef HFS_DIAGNOSTIC | |
44 | #define HFS_DIAGNOSTIC 0 | |
45 | #endif /* HFS_DIAGNOSTIC */ | |
46 | ||
47 | #ifndef HFS_DEBUG_STAGE | |
48 | #if HFS_DIAGNOSTIC | |
49 | #define HFS_DEBUG_STAGE 4 | |
50 | #else | |
51 | #define HFS_DEBUG_STAGE 1 | |
52 | #endif /* KERNEL */ | |
53 | #endif /* HFS_DEBUG_STAGE */ | |
54 | ||
55 | #ifdef KERNEL | |
56 | #define PRINTIT kprintf | |
57 | #else /* KERNEL */ | |
58 | #define PRINTIT printf | |
59 | #endif /* KERNEL */ | |
60 | ||
61 | #if (HFS_DEBUG_STAGE > 3) | |
62 | #define DEBUG_BREAK Debugger(""); | |
63 | #else | |
64 | #define DEBUG_BREAK | |
65 | #endif | |
66 | ||
67 | #if (HFS_DEBUG_STAGE == 4) | |
68 | #define DEBUG_BREAK_MSG(PRINTF_ARGS) { PRINTIT PRINTF_ARGS; DEBUG_BREAK }; | |
69 | #elif (HFS_DEBUG_STAGE == 3) | |
70 | #define DEBUG_BREAK_MSG(PRINTF_ARGS) { panic PRINTF_ARGS;}; | |
71 | #else | |
72 | #define DEBUG_BREAK_MSG(PRINTF_ARGS) { PRINTIT PRINTF_ARGS; }; | |
73 | #endif | |
74 | ||
75 | ||
76 | //#define PRINT_DELAY (void) tsleep((caddr_t)&lbolt, PPAUSE, "hfs kprintf", 0) | |
77 | #define PRINT_DELAY | |
78 | ||
79 | /* | |
80 | * Debugging macros. | |
81 | */ | |
82 | #if HFS_DIAGNOSTIC | |
83 | extern int hfs_dbg_all; | |
1c79356b | 84 | extern int hfs_dbg_err; |
1c79356b A |
85 | |
86 | #ifdef KERNEL | |
87 | #if (HFS_DEBUG_STAGE == 4) | |
88 | char gDebugAssertStr[255]; | |
89 | #define DBG_ASSERT(a) { if (!(a)) { \ | |
90 | sprintf(gDebugAssertStr,"Oops - File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); \ | |
91 | Debugger(gDebugAssertStr); } } | |
92 | #else | |
93 | #define DBG_ASSERT(a) { if (!(a)) { panic("File "__FILE__", line %d: assertion '%s' failed.\n", __LINE__, #a); } } | |
94 | #endif /* HFS_DEBUG_STAGE */ | |
95 | #else | |
96 | #define DBG_ASSERT(a) assert(a) | |
97 | #endif /* KERNEL */ | |
98 | ||
1c79356b A |
99 | #define DBG_ERR(x) { \ |
100 | if(hfs_dbg_all || hfs_dbg_err) { \ | |
91447636 | 101 | PRINTIT("%X: ", proc_selfpid()); \ |
1c79356b A |
102 | PRINTIT("HFS ERROR: "); \ |
103 | PRINTIT x; \ | |
104 | PRINT_DELAY; \ | |
105 | }; \ | |
106 | } | |
1c79356b | 107 | |
9bccf70c | 108 | #else /* HFS_DIAGNOSTIC */ |
1c79356b | 109 | |
9bccf70c A |
110 | #define DBG_ASSERT(a) |
111 | #define DBG_ERR(x) | |
1c79356b | 112 | |
9bccf70c | 113 | #endif /* HFS_DIAGNOSTIC */ |
1c79356b | 114 |