]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_apple_csp/lib/cspdebugging.h
2 * Copyright (c) 2000-2001,2011,2013-2014 Apple Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
22 Contains: Debugging macros.
25 Copyright (c) 1998,2011,2013-2014 Apple Inc. All Rights Reserved.
27 Change History (most recent first):
29 06/02/98 dpm Added DEBUG_THREAD_YIELD.
34 #ifndef _CSPDEBUGGING_H_
35 #define _CSPDEBUGGING_H_
38 #define DEBUG_ENABLE 0
39 #define ERROR_LOG_ENABLE 0
41 #define DEBUG_ENABLE 1
42 #define ERROR_LOG_ENABLE 1
46 #define LOG_VIA_PRINTF 1
48 #if DEBUG_ENABLE || ERROR_LOG_ENABLE
55 #error Hey, figure out a debug mechanism
58 #include <TextUtils.h>
60 /* common log macros */
62 /* remaining ones can take constant strings */
68 extern void dblog0(char *str
);
69 extern void dblog1(char *str
, void * arg1
);
70 extern void dblog2(char *str
, void * arg1
, void * arg2
);
71 extern void dblog3(char *str
, void * arg1
, void * arg2
, void * arg3
);
72 extern void dblog4(char *str
, void * arg1
, void * arg2
, void * arg3
, void * arg4
);
79 #else /* LOG_VIA_PRINTF */
81 #define dblog0(str) printf(str)
82 #define dblog1(str, arg1) printf(str, arg1)
83 #define dblog2(str, arg1, arg2) printf(str, arg1, arg2)
84 #define dblog3(str, arg1, arg2, arg3) printf(str, arg1, arg2, arg3)
85 #define dblog4(str, arg1, arg2, arg3, arg4) printf(str, arg1, arg2, arg3, arg4)
87 #endif /* LOG_VIA_PRINTF */
89 #else /* log macros disabled */
92 #define dblog1(str, arg1)
93 #define dblog2(str, arg1, arg2)
94 #define dblog3(str, arg1, arg2, arg3)
95 #define dblog4(str, arg1, arg2, arg3, arg4)
97 #endif /* DEBUG_ENABLE || ERROR_LOG_ENABLE */
101 #define dprintf0(str) dblog0(str)
102 #define dprintf1(str, arg1) dblog1(str, arg1)
103 #define dprintf2(str, arg1, arg2) dblog2(str, arg1, arg2)
104 #define dprintf3(str, arg1, arg2, arg3) dblog3(str, arg1, arg2, arg3)
105 #define dprintf4(str, arg1, arg2, arg3, arg4) dblog4(str, arg1, arg2, arg3, arg4)
111 #include <CrashReporterClient.h>
113 static inline void _panic(const char *str
)
116 CRSetCrashLogMessage(str
);
124 #define CASSERT(expression) \
125 ((expression) ? (void)0 : \
126 (dprintf1 ("Assertion failed: " #expression \
127 ", file " __FILE__ ", line %d.\n", __LINE__), \
128 _panic("Assertion Failure")))
130 #else /* DEBUG_ENABLE */
132 #define dprintf0(str)
133 #define dprintf1(str, arg1)
134 #define dprintf2(str, arg1, arg2)
135 #define dprintf3(str, arg1, arg2, arg3)
136 #define dprintf4(str, arg1, arg2, arg3, arg4)
138 #define CASSERT(expression)
140 #endif /* DEBUG_ENABLE */
143 * Error logging. This may well be platform dependent.
146 #define errorLog0(str) dblog0(str);
147 #define errorLog1(str, arg1) dblog1(str, arg1)
148 #define errorLog2(str, arg1, arg2) dblog2(str, arg1, arg2)
149 #define errorLog3(str, arg1, arg2, arg3) dblog3(str, arg1, arg2, arg3)
150 #define errorLog4(str, arg1, arg2, arg3, arg4) dblog4(str, arg1, arg2, arg3, arg4)
152 #else /* ERROR_LOG_ENABLE */
154 #define errorLog0(str)
155 #define errorLog1(str, arg1)
156 #define errorLog2(str, arg1, arg2)
157 #define errorLog3(str, arg1, arg2, arg3)
158 #define errorLog4(str, arg1, arg2, arg3, arg4)
160 #endif /* ERROR_LOG_ENABLE */
162 #endif /* _CSPDEBUGGING_H_ */