]>
git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_utilities/debugging.h
2 * Copyright (c) 2000-2001 Apple Computer, 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.
20 // debugging - non-trivial debug support
25 #include <Security/utilities.h>
39 // Debug to standard target
40 void debug(const char *scope
, const char *format
, ...) __attribute__((format(printf
,2,3)));
41 void vdebug(const char *scope
, const char *format
, va_list args
);
42 bool debugging(const char *scope
);
44 // Stream dumping to standard target
45 bool dumping(const char *scope
);
46 void dump(const char *format
, ...) __attribute((format(printf
,1,2)));
47 void dumpData(const void *data
, size_t length
);
48 void dumpData(const char *title
, const void *data
, size_t length
);
49 template <class Data
> inline void dumpData(const Data
&obj
)
50 { dumpData(obj
.data(), obj
.length()); }
51 template <class Data
> inline void dumpData(const char *title
, const Data
&obj
)
52 { dumpData(title
, obj
.data(), obj
.length()); }
54 #if defined(DEBUGDUMP)
55 # define IFDUMP(code) code
56 # define IFDUMPING(scope,code) if (Debug::dumping(scope)) code; else /* no */
58 # define IFDUMP(code) /* no-op */
59 # define IFDUMPING(scope,code) /* no-op */
64 // A (prepared) debug scope object.
68 Scope(const char *string
) { mScope
= string
; }
70 void operator () (const char *format
, ...);
81 // If NDEBUG is defined, we try to make all debugging functions weightless
83 inline void debug(const char *, const char *, ...) { }
84 inline void vdebug(const char *, const char *, va_list) { }
85 inline bool debugging(const char *) { return false; }
89 Scope(const char *) { }
90 void operator () (const char *, ...) { }
93 inline bool dumping(const char *) { return false; }
94 inline void dump(const char *, ...) { }
95 inline void dumpData(const void *, size_t) { }
96 void dumpData(const char *, const void *, size_t);
97 template <class Data
> inline void dumpData(const Data
&) { }
98 template <class Data
> inline void dumpData(const char *, const Data
&) { }
100 // debugdumping is forced off
101 #if defined(DEBUGDUMP)
104 # define IFDUMP(code) /* no-op */
105 # define IFDUMPING(scope,code) /* no-op */
110 } // end namespace Debug
112 } // end namespace Security
114 // We intentionally leak a few functions into the global namespace
115 using Security::Debug::debug
;
118 #ifdef _CPP_DEBUGGING
122 #endif //_H_DEBUGGING