MHEG5  15.3.0
source/glue/inc/glue_debug.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
00003  * Copyright © 2011 Ocean Blue Software Ltd
00004  *
00005  * This file is part of a DTVKit Software Component
00006  * You are permitted to copy, modify or distribute this file subject to the terms
00007  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
00008  *
00009  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00010  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00011  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00012  *
00013  * If you or your organisation is not a member of DTVKit then you have access
00014  * to this source code outside of the terms of the licence agreement
00015  * and you are expected to delete this and any associated files immediately.
00016  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
00017  *******************************************************************************/
00025 #ifndef _GLUE_DEBUG_H
00026 #define _GLUE_DEBUG_H
00027 
00028 #include "stb_debug.h"
00029 #include "techtype.h"
00030 #include "glue_assert.h"
00031 #include "mheg5_debug.h"
00032 
00033 #ifdef TRACING
00034    #ifndef F_IDENT
00035    #define F_IDENT __FUNCTION__
00036    #endif
00037    #ifndef T_NL
00038    #define T_NL "\n"
00039    #endif
00040 extern void trace_set_time(void);
00041 extern unsigned long trace_time(void);
00042 extern void trace_dump_chars(unsigned char *data, unsigned int len);
00043 extern void trace_dump_uints(U32BIT *data, unsigned int len, unsigned int pitch);
00044 extern void trace_unicode(U16BIT *data, unsigned int len);
00045 
00046 extern U32BIT mheg_trace_debug;
00047 
00048    #define TERROR       0
00049    #define TALWAYS      0x00ffffff
00050    #define TWARN        (1 << 30)
00051 
00052    #define TSTATE       MHDBG_TSTATE
00053    #define TTUNE        MHDBG_TTUNE
00054    #define TMEMORY      MHDBG_TMEMORY
00055    #define TKEYS        MHDBG_TKEYS
00056 
00057    #define TMHBOOT      MHDBG_TMHBOOT
00058    #define TSTRM        MHDBG_TSTRM
00059    #define TFILE        MHDBG_TFILE
00060    #define TDSMFG       MHDBG_TDSMFG
00061 
00062    #define TMHAPI       MHDBG_TMHAPI
00063    #define TSERVICE     MHDBG_TSERVICE
00064    #define TICS         MHDBG_TICS
00065    #define TQUEUE       MHDBG_TQUEUE
00066 
00067    #define TEVNTS       MHDBG_TEVNTS
00068    #define TACTIONS     MHDBG_TACTIONS
00069    #define TTIME        MHDBG_TTIME
00070    #define TPERFORM     MHDBG_TPERFORM
00071 
00072    #define TGRAPHICS    MHDBG_TGRAPHICS
00073    #define TFONT        MHDBG_TFONT
00074    #define TTEXT        MHDBG_TTEXT
00075    #define TFONTCACHE   MHDBG_TFONTCACHE
00076 
00077 #if TRACE_TIMING == 2
00078 extern unsigned long last_trace_time;
00079    #define TRACETIME()     if (last_trace_time + 100 < trace_time()) { last_trace_time = trace_time(); \
00080                                                                        STB_SPDebugWrite("TRACE TIME= %d.%02d secs", last_trace_time / 100, last_trace_time % 100); }
00081    #define TERPRINT(s, ...) STB_SPDebugWrite("ERROR-%s:%d " s, F_IDENT, __LINE__, ##__VA_ARGS__)
00082    #define TRCPRINT(s, ...) STB_SPDebugWrite("%s:%d " s, F_IDENT, __LINE__, ##__VA_ARGS__)
00083    #define TRACE_SET_TIME()
00084 #elif TRACE_TIMING == 1
00085    #define TRACETIME()
00086    #define TERPRINT(s, ...) STB_SPDebugWrite("ERROR-%s:%d (%ld) " s, F_IDENT, __LINE__, trace_time(), ##__VA_ARGS__)
00087    #define TRCPRINT(s, ...) STB_SPDebugWrite("%s:%d (%ld) " s, F_IDENT, __LINE__, trace_time(), ##__VA_ARGS__)
00088    #define TRACE_SET_TIME()   trace_set_time()
00089 #else
00090    #define TRACETIME()
00091    #define TERPRINT(s, ...) STB_SPDebugWrite("ERROR-%s:%d " s, F_IDENT, __LINE__, ##__VA_ARGS__)
00092    #define TRCPRINT(s, ...) STB_SPDebugWrite("%s:%d " s, F_IDENT, __LINE__, ##__VA_ARGS__)
00093    #define TRACE_SET_TIME()
00094 #endif
00095 
00096    #define TRACE(t, x)   TRACETIME() if ((t) == TERROR) { TERPRINT x; } \
00097    else if ((t) & mheg_trace_debug) { TRCPRINT x; }
00098 
00099    #define TPRINT(t, x)  if ((t) & mheg_trace_debug) STB_SPDebugNoCnWrite x;
00100    #define TRACE_BUFF(t, d, l)  if ((t) & mheg_trace_debug) trace_dump_chars(d, l);
00101    #define TRACE_UINT(t, d, l, p)  if ((t) & mheg_trace_debug) trace_dump_uints(d, l, p);
00102    #define TRACE_UNIC(t, d, l)  if ((t) & mheg_trace_debug) trace_unicode(d, l);
00103 
00104    #undef ERROR_PRINT
00105    #undef WARNING_PRINT
00106    #define ERROR_PRINT(x)     STB_SPDebugNoCnWrite x
00107    #define WARNING_PRINT(x)   if (mheg_trace_debug) STB_SPDebugNoCnWrite x
00108    #define TRACER(x)          x
00109    #define TRACE_MEM()        if (TMEMORY & mheg_trace_debug) MHG_DebugMemStats(__LINE__)
00110 
00111    #define DBGTRACE(t, x, ...)  if ((t) == TERROR || ((t) & mheg_trace_debug)) { \
00112       STB_SPDebugWrite( "T%05x-%s:%d " x, t, F_IDENT, __LINE__, ##__VA_ARGS__); }
00113 
00114    #define DBG_PRINTF STB_SPDebugNoCnWrite
00115 
00116 #else 
00118    #define TRACE(t, x)
00119    #define TPRINT(t, x)
00120    #define TRACE_BUFF(t, d, l)
00121    #define TRACE_UINT(t, d, l, p)
00122    #define TRACE_UNIC(t, d, l)
00123    #define TRACER(x)
00124    #define TRACE_MEM()
00125    #define TRACE_SET_TIME()
00126    #define DBGTRACE(...)
00127    #define DBG_PRINTF(...)
00128 
00129 #endif /*TRACING*/
00130 
00131 #if !defined(NDEBUG) && defined(STACK_DEBUGGING)
00132 void STB_OSTaskAddFunc(const char *func);
00133 void STB_OSTaskRemFunc(const char *func);
00134    #ifndef DBG_ID_FUNC
00135       #define DECLARE_NAME(x)   const char *func_name = F_IDENT;
00136    #else
00137       #define DECLARE_NAME(x)   const char func_name[] = #x;
00138    #endif
00139    #define FUNCTION_START(x)    DECLARE_NAME(x) STB_OSTaskAddFunc(func_name);
00140    #define FUNCTION_FINISH(x)   STB_OSTaskRemFunc(func_name);
00141 #else
00142    #define FUNCTION_START(name)
00143    #define FUNCTION_FINISH(name)
00144 #endif
00145 
00146 #if defined(NDEBUG) && !defined(OVERRIDE_DEBUG_PRINTS)
00147 
00148 /* Disable debug prints for retail build */
00149     #define DPLEVEL 0
00150 
00151     #define DPL1(x)
00152     #define DPL2(x)
00153     #define DPL3(x)
00154     #define DPL4(x)
00155     #define DPL5(x)
00156 
00157 #else   /* #if defined( NDEBUG ) && ! defined( OVERRIDE_DEBUG_PRINTS ) */
00158 
00159     #ifndef DPLEVEL
00160 /* Default to show warnings and error messages */
00161         #define DPLEVEL DBG_LEVEL
00162     #endif
00163 
00164     #if (DPLEVEL >= 5)
00165         #define DPL5(x)     STB_SPDebugNoCnWrite x
00166     #else
00167         #define DPL5(x)
00168     #endif
00169 
00170     #if (DPLEVEL >= 4)
00171         #define DPL4(x)     STB_SPDebugNoCnWrite x
00172     #else
00173         #define DPL4(x)
00174     #endif
00175 
00176     #if (DPLEVEL >= 3)
00177         #define DPL3(x)     STB_SPDebugNoCnWrite x
00178     #else
00179         #define DPL3(x)
00180     #endif
00181 
00182     #if (DPLEVEL >= 2)
00183         #define DPL2(x)     STB_SPDebugNoCnWrite x
00184     #else
00185         #define DPL2(x)
00186     #endif
00187 
00188     #if (DPLEVEL >= 1)
00189         #define DPL1(x)     STB_SPDebugNoCnWrite x
00190     #else
00191         #define DPL1(x)
00192     #endif
00193 #endif  /* #if defined( NDEBUG ) && ! defined( OVERRIDE_DEBUG_PRINTS ) #else */
00194 
00195 void MHG_DebugMemStats(int line);
00196 
00197 #endif /*_GLUE_DEBUG_H*/
 All Data Structures Files Functions Variables Typedefs Defines