sl@0: /* Copyright (c) 2009 The Khronos Group Inc. sl@0: * Portions copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies) sl@0: * sl@0: * Permission is hereby granted, free of charge, to any person obtaining a sl@0: * copy of this software and/or associated documentation files (the sl@0: * "Materials"), to deal in the Materials without restriction, including sl@0: * without limitation the rights to use, copy, modify, merge, publish, sl@0: * distribute, sublicense, and/or sell copies of the Materials, and to sl@0: * permit persons to whom the Materials are furnished to do so, subject to sl@0: * the following conditions: sl@0: * sl@0: * The above copyright notice and this permission notice shall be included sl@0: * in all copies or substantial portions of the Materials. sl@0: * sl@0: * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, sl@0: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF sl@0: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. sl@0: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY sl@0: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, sl@0: * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE sl@0: * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. sl@0: */ sl@0: sl@0: /* sl@0: * owfdebug.h sl@0: * sl@0: */ sl@0: sl@0: #ifndef OWFDEBUG_H_ sl@0: #define OWFDEBUG_H_ sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" sl@0: { sl@0: #endif sl@0: sl@0: /* Enable platform specific library cleanup */ sl@0: int xatexit(void (*func)(void)); sl@0: sl@0: #ifdef _DEBUG sl@0: sl@0: #undef DEBUG sl@0: #define DEBUG sl@0: sl@0: #ifndef DEBUG_DONOT_LOG sl@0: #undef DEBUG_LOG sl@0: #define DEBUG_LOG sl@0: #endif sl@0: sl@0: #endif sl@0: sl@0: #ifdef DEBUG sl@0: #include sl@0: #define OWF_ASSERT(c) assert(c); sl@0: #else sl@0: #define OWF_ASSERT(c) ; sl@0: #endif sl@0: sl@0: #ifdef DEBUG_LOG sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "owftypes.h" sl@0: sl@0: /* Defining DEBUG_LOG enables all log file output. Do this in the command-line, make or .MMP file sl@0: * The file output can be filtered by filename or by function name in the same way: sl@0: * Defining DEBUG_LOG_FUNCTION=fnname will filter for all functions STARTING with the name fnname sl@0: * Defining DEBUG_LOG_FILE=filename will filter for all functions ending with the name filename sl@0: * These filters utilise the predefined macros __FILE__ and __FUNCTION__ which are defined in current standards, sl@0: * but may contain platform-specific features such as path names, or linkage decoration, sl@0: * so the filter-string may require some platform-specific tuning. sl@0: * If the macros are not predefined in a useful way, or not defined at all, then you won't be able to filter, sorry. sl@0: */ sl@0: #if defined(DEBUG_LOG_FILE) sl@0: #define DPRINT(x) if (OWF_Debug_DoLog(__FILE__,sizeof(__FILE__)-1)) OWF_Debug_Print x sl@0: #elif defined(DEBUG_LOG_FUNCTION) sl@0: #define DPRINT(x) if (OWF_Debug_DoLog(__FUNCTION__,sizeof(__FUNCTION__)-1)) OWF_Debug_Print x sl@0: #else sl@0: #define DPRINT(x) OWF_Debug_Print x sl@0: #endif sl@0: sl@0: #define NFPRINT(x) DPRINT(x) sl@0: #define ENTER(x) DPRINT(("%s:", #x)) sl@0: #define LEAVE(x) sl@0: #define TRACE(x) OWF_Debug_Trace x sl@0: #define INDENT OWF_Debug_TraceIndent() sl@0: #define UNDENT OWF_Debug_TraceUndent() sl@0: sl@0: int OWF_Debug_DoLog(const char* symbol,int symlen); sl@0: void OWF_Debug_Print(const char* format, ...); sl@0: void OWF_Debug_Trace(const char* fmt, ...); sl@0: void OWF_Debug_TraceIndent(); sl@0: void OWF_Debug_TraceUndent(); sl@0: sl@0: #else /* NOT DEBUG */ sl@0: sl@0: #define DPRINT(x) /* do nothing */ sl@0: #define NFPRINT(x) sl@0: #define ENTER(x) sl@0: #define LEAVE(x) sl@0: #define TRACE(x) sl@0: #define INDENT sl@0: #define UNDENT sl@0: sl@0: #endif /* DEBUG */ sl@0: sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: sl@0: sl@0: #endif /* OWFDEBUG_H_ */