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