X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/5c19dc3ae3bd8e40a9c028b0deddd50ff337692c..dd5fb164cf5b32c462296bc65e289e100f74b59a:/OSX/libsecurity_utilities/lib/debugging_internal.h?ds=inline diff --git a/OSX/libsecurity_utilities/lib/debugging_internal.h b/OSX/libsecurity_utilities/lib/debugging_internal.h index f4e7cb85..a33ee7c2 100644 --- a/OSX/libsecurity_utilities/lib/debugging_internal.h +++ b/OSX/libsecurity_utilities/lib/debugging_internal.h @@ -1,6 +1,6 @@ /* - * Copyright (c) 2012,2014 Apple Inc. All Rights Reserved. - * + * Copyright (c) 2000-2004,2011-2012,2014 Apple Inc. All Rights Reserved. + * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code @@ -22,40 +22,121 @@ */ -#ifndef libsecurity_utilities_debugging_internal_h -#define libsecurity_utilities_debugging_internal_h - +// +// debugging_internal - non-trivial debug support +// +// everything in this file is deprecated. Try not to use it. +// +#ifndef _H_DEBUGGING +#define _H_DEBUGGING #ifdef __cplusplus -extern "C" + +#include +#include +#include + +namespace Security { +namespace Debug { + + +// +// Debug-dumping functions always exist. They may be stubs depending on build options. +// +bool dumping(const char *scope); +void dump(const char *format, ...) __attribute((format(printf,1,2))); +void dumpData(const void *data, size_t length); +void dumpData(const char *title, const void *data, size_t length); +template inline void dumpData(const Data &obj) +{ dumpData(obj.data(), obj.length()); } +template inline void dumpData(const char *title, const Data &obj) +{ dumpData(title, obj.data(), obj.length()); } + + +// +// The following functions perform runtime recovery of type names. +// This is meant for debugging ONLY. Don't even THINK of depending +// on this for program correctness. For all you know, we may replace +// all those names with "XXX" tomorrow. +// +string makeTypeName(const type_info &info); + +template +string typeName(const Object &obj) { -#endif // __cplusplus + return makeTypeName(typeid(obj)); +} + +template +string typeName() +{ + return makeTypeName(typeid(Object)); +} + // -// Include DTrace static probe definitions +// We are still conditionally emitting debug-dumping code // -typedef const void *DTException; +#undef DEBUGGING +#if !defined(NDEBUG) +# define DEBUGGING 1 +# define DEBUGDUMP 1 +#else //NDEBUG +# define DEBUGGING 0 +#endif //NDEBUG + +#if defined(DEBUGDUMP) +# define IFDUMP(code) code +# define IFDUMPING(scope,code) if (Debug::dumping(scope)) code; else /* no */ +#else +# define IFDUMP(code) /* no-op */ +# define IFDUMPING(scope,code) /* no-op */ +#endif -#include // -// The debug-log macro is now unconditionally emitted as a DTrace static probe point. +// We have some very, very old customers who call old debug facilities. +// Dummy them out for now. // +inline bool debugging(const char *scope) DEPRECATED_ATTRIBUTE; +inline void debug(const char *scope, const char *format, ...) DEPRECATED_ATTRIBUTE; +inline void vdebug(const char *scope, const char *format, va_list args) DEPRECATED_ATTRIBUTE; + +inline bool debugging(const char *scope) { return false; } +inline void debug(const char *scope, const char *format, ...) { } +inline void vdebug(const char *scope, const char *format, va_list args) { } + -void secdebug_internal(const char* scope, const char* format, ...); -#define secdebug(scope, format...) secdebug_internal(scope, format) -#define secdebugf(scope, __msg) SECURITY_DEBUG_LOG((char *)(scope), (__msg)) + + +} // end namespace Debug +} // end namespace Security + +// leak debug() into the global namespace because URLAccess et al rely on that +using Security::Debug::debug; + +__BEGIN_DECLS // -// The old secdelay() macro is also emitted as a DTrace probe (use destructive actions to handle this). -// Secdelay() should be considered a legacy feature; just put a secdebug at the intended delay point. +// Include DTrace static probe definitions // -#define secdelay(file) SECURITY_DEBUG_DELAY((char *)(file)) +typedef const void *DTException; +#include +// The following are deprecated functions. Don't use them (but they need to be here for symbol reasons). +void secdebug_internal(const char* scope, const char* format, ...); +void secdebugfunc_internal(const char* scope, const char* functionname, const char* format, ...); -#ifdef __cplusplus -}; -#endif // __cplusplus +__END_DECLS -#endif +#else //__cplusplus + +#include + +#endif //__cplusplus + +#include + + +#endif //_H_DEBUGGING