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