os/graphics/graphicscomposition/openwfcompositionengine/common/include/owfdebug.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /* Copyright (c) 2009 The Khronos Group Inc.
     2  * Portions copyright (c) 2009-2010  Nokia Corporation and/or its subsidiary(-ies)
     3  *
     4  * Permission is hereby granted, free of charge, to any person obtaining a
     5  * copy of this software and/or associated documentation files (the
     6  * "Materials"), to deal in the Materials without restriction, including
     7  * without limitation the rights to use, copy, modify, merge, publish,
     8  * distribute, sublicense, and/or sell copies of the Materials, and to
     9  * permit persons to whom the Materials are furnished to do so, subject to
    10  * the following conditions:
    11  *
    12  * The above copyright notice and this permission notice shall be included
    13  * in all copies or substantial portions of the Materials.
    14  *
    15  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    21  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
    22  */
    23 
    24 /*
    25  * owfdebug.h
    26  *
    27  */
    28 
    29 #ifndef OWFDEBUG_H_
    30 #define OWFDEBUG_H_
    31 
    32 #ifdef __cplusplus
    33 extern "C"
    34 {
    35 #endif
    36 
    37 /* Enable platform specific library cleanup */
    38 int xatexit(void (*func)(void));
    39 
    40 #ifdef _DEBUG
    41 
    42 #undef DEBUG
    43 #define DEBUG
    44 
    45 #ifndef DEBUG_DONOT_LOG
    46 #undef DEBUG_LOG
    47 #define DEBUG_LOG
    48 #endif
    49 
    50 #endif
    51 
    52 #ifdef DEBUG
    53 #include <assert.h>
    54 #define OWF_ASSERT(c)    assert(c);
    55 #else
    56 #define OWF_ASSERT(c)    ;
    57 #endif
    58 
    59 #ifdef DEBUG_LOG
    60 
    61 #include <stdio.h>
    62 #include <stdarg.h>
    63 #include <string.h>
    64 
    65 #include "owftypes.h"
    66 
    67 /* Defining DEBUG_LOG enables all log file output. Do this in the command-line, make or .MMP file
    68  * The file output can be filtered by filename or by function name in the same way:
    69  *   Defining DEBUG_LOG_FUNCTION=fnname will filter for all functions STARTING with the name fnname
    70  *   Defining DEBUG_LOG_FILE=filename will filter for all functions ending with the name filename
    71  * These filters utilise the predefined macros __FILE__ and __FUNCTION__ which are defined in current standards,
    72  * but may contain platform-specific features such as path names, or linkage decoration,
    73  * so the filter-string may require some platform-specific tuning.
    74  * If the macros are not predefined in a useful way, or not defined at all, then you won't be able to filter, sorry.
    75  */
    76 #if defined(DEBUG_LOG_FILE)
    77 #define   DPRINT(x)         if (OWF_Debug_DoLog(__FILE__,sizeof(__FILE__)-1)) OWF_Debug_Print x
    78 #elif defined(DEBUG_LOG_FUNCTION)
    79 #define   DPRINT(x)         if (OWF_Debug_DoLog(__FUNCTION__,sizeof(__FUNCTION__)-1)) OWF_Debug_Print x
    80 #else
    81 #define DPRINT(x)           OWF_Debug_Print x
    82 #endif
    83 
    84 #define NFPRINT(x)       DPRINT(x)
    85 #define ENTER(x)         DPRINT(("%s:", #x))
    86 #define LEAVE(x)
    87 #define TRACE(x)         OWF_Debug_Trace x
    88 #define INDENT           OWF_Debug_TraceIndent()
    89 #define UNDENT           OWF_Debug_TraceUndent()
    90 
    91 int  OWF_Debug_DoLog(const char* symbol,int symlen);
    92 void OWF_Debug_Print(const char* format, ...);
    93 void OWF_Debug_Trace(const char* fmt, ...);
    94 void OWF_Debug_TraceIndent();
    95 void OWF_Debug_TraceUndent();
    96 
    97 #else /* NOT DEBUG */
    98 
    99 #define DPRINT(x)     /* do nothing */
   100 #define NFPRINT(x)
   101 #define ENTER(x)
   102 #define LEAVE(x)
   103 #define TRACE(x)
   104 #define INDENT
   105 #define UNDENT
   106 
   107 #endif /* DEBUG */
   108 
   109 
   110 #ifdef __cplusplus
   111 }
   112 #endif
   113 
   114 
   115 #endif /* OWFDEBUG_H_ */