MHEG  17.9.0
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Pages
glue_debug.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2011 Ocean Blue Software Ltd
4  *
5  * This file is part of a DTVKit Software Component
6  * You are permitted to copy, modify or distribute this file subject to the terms
7  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
8  *
9  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * If you or your organisation is not a member of DTVKit then you have access
14  * to this source code outside of the terms of the licence agreement
15  * and you are expected to delete this and any associated files immediately.
16  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
17  *******************************************************************************/
25 #ifndef _GLUE_DEBUG_H
26 #define _GLUE_DEBUG_H
27 
28 #include "stb_debug.h"
29 #include "techtype.h"
30 #include "glue_assert.h"
31 #include "mheg5_debug.h"
32 
33 #ifdef TRACING
34  #ifndef F_IDENT
35  #define F_IDENT __FUNCTION__
36  #endif
37  #ifndef T_NL
38  #define T_NL "\n"
39  #endif
40 extern void trace_set_time(void);
41 extern unsigned long trace_time(void);
42 extern void trace_dump_chars(unsigned char *data, unsigned int len);
43 extern void trace_dump_uints(U32BIT *data, unsigned int len, unsigned int pitch);
44 extern void trace_unicode(U16BIT *data, unsigned int len);
45 
46 extern U32BIT mheg_trace_debug;
47 
48  #define TERROR 0
49  #define TALWAYS 0x00ffffff
50  #define TWARN (1 << 30)
51 
52  #define TSTATE MHDBG_TSTATE
53  #define TTUNE MHDBG_TTUNE
54  #define TMEMORY MHDBG_TMEMORY
55  #define TKEYS MHDBG_TKEYS
56 
57  #define TMHBOOT MHDBG_TMHBOOT
58  #define TSTRM MHDBG_TSTRM
59  #define TFILE MHDBG_TFILE
60  #define TDSMFG MHDBG_TDSMFG
61 
62  #define TMHAPI MHDBG_TMHAPI
63  #define TSERVICE MHDBG_TSERVICE
64  #define TICS MHDBG_TICS
65  #define TQUEUE MHDBG_TQUEUE
66 
67  #define TEVNTS MHDBG_TEVNTS
68  #define TACTIONS MHDBG_TACTIONS
69  #define TTIME MHDBG_TTIME
70  #define TPERFORM MHDBG_TPERFORM
71 
72  #define TGRAPHICS MHDBG_TGRAPHICS
73  #define TFONT MHDBG_TFONT
74  #define TTEXT MHDBG_TTEXT
75  #define TFONTCACHE MHDBG_TFONTCACHE
76 
77 #if TRACE_TIMING == 2
78 extern unsigned long last_trace_time;
79  #define TRACETIME() if (last_trace_time + 100 < trace_time()) { last_trace_time = trace_time(); \
80  STB_SPDebugWrite("TRACE TIME= %d.%02d secs", last_trace_time / 100, last_trace_time % 100); }
81  #define TERPRINT(s, ...) STB_SPDebugWrite("ERROR-%s:%d " s, F_IDENT, __LINE__, ##__VA_ARGS__)
82  #define TRCPRINT(s, ...) STB_SPDebugWrite("%s:%d " s, F_IDENT, __LINE__, ##__VA_ARGS__)
83  #define TRACE_SET_TIME()
84 #elif TRACE_TIMING == 1
85  #define TRACETIME()
86  #define TERPRINT(s, ...) STB_SPDebugWrite("ERROR-%s:%d (%ld) " s, F_IDENT, __LINE__, trace_time(), ##__VA_ARGS__)
87  #define TRCPRINT(s, ...) STB_SPDebugWrite("%s:%d (%ld) " s, F_IDENT, __LINE__, trace_time(), ##__VA_ARGS__)
88  #define TRACE_SET_TIME() trace_set_time()
89 #else
90  #define TRACETIME()
91  #define TERPRINT(s, ...) STB_SPDebugWrite("ERROR-%s:%d " s, F_IDENT, __LINE__, ##__VA_ARGS__)
92  #define TRCPRINT(s, ...) STB_SPDebugWrite("%s:%d " s, F_IDENT, __LINE__, ##__VA_ARGS__)
93  #define TRACE_SET_TIME()
94 #endif
95 
96  #define TRACE(t, x) TRACETIME() if ((t) == TERROR) { TERPRINT x; } \
97  else if ((t) & mheg_trace_debug) { TRCPRINT x; }
98 
99  #define TPRINT(t, x) if ((t) & mheg_trace_debug) STB_SPDebugNoCnWrite x;
100  #define TRACE_BUFF(t, d, l) if ((t) & mheg_trace_debug) trace_dump_chars(d, l);
101  #define TRACE_UINT(t, d, l, p) if ((t) & mheg_trace_debug) trace_dump_uints(d, l, p);
102  #define TRACE_UNIC(t, d, l) if ((t) & mheg_trace_debug) trace_unicode(d, l);
103 
104  #undef ERROR_PRINT
105  #undef WARNING_PRINT
106  #define ERROR_PRINT(x) STB_SPDebugNoCnWrite x
107  #define WARNING_PRINT(x) if (mheg_trace_debug) STB_SPDebugNoCnWrite x
108  #define TRACER(x) x
109  #define TRACE_MEM() if (TMEMORY & mheg_trace_debug) MHG_DebugMemStats(__LINE__)
110 
111  #define DBGTRACE(t, x, ...) if ((t) == TERROR || ((t) & mheg_trace_debug)) { \
112  STB_SPDebugWrite( "T%05x-%s:%d " x, t, F_IDENT, __LINE__, ##__VA_ARGS__); }
113 
114  #define DBG_PRINTF STB_SPDebugNoCnWrite
115 
116 #else
118  #define TRACE(t, x)
119  #define TPRINT(t, x)
120  #define TRACE_BUFF(t, d, l)
121  #define TRACE_UINT(t, d, l, p)
122  #define TRACE_UNIC(t, d, l)
123  #define TRACER(x)
124  #define TRACE_MEM()
125  #define TRACE_SET_TIME()
126  #define DBGTRACE(...)
127  #define DBG_PRINTF(...)
128 
129 #endif /*TRACING*/
130 
131 #if !defined(NDEBUG) && defined(STACK_DEBUGGING)
132 void STB_OSTaskAddFunc(const char *func);
133 void STB_OSTaskRemFunc(const char *func);
134  #ifndef DBG_ID_FUNC
135  #define DECLARE_NAME(x) const char *func_name = F_IDENT;
136  #else
137  #define DECLARE_NAME(x) const char func_name[] = #x;
138  #endif
139  #define FUNCTION_START(x) DECLARE_NAME(x) STB_OSTaskAddFunc(func_name);
140  #define FUNCTION_FINISH(x) STB_OSTaskRemFunc(func_name);
141 #else
142  #define FUNCTION_START(name)
143  #define FUNCTION_FINISH(name)
144 #endif
145 
146 #if defined(NDEBUG) && !defined(OVERRIDE_DEBUG_PRINTS)
147 
148 /* Disable debug prints for retail build */
149  #define DPLEVEL 0
150 
151  #define DPL1(x)
152  #define DPL2(x)
153  #define DPL3(x)
154  #define DPL4(x)
155  #define DPL5(x)
156 
157 #else /* #if defined( NDEBUG ) && ! defined( OVERRIDE_DEBUG_PRINTS ) */
158 
159  #ifndef DPLEVEL
160 /* Default to show warnings and error messages */
161  #define DPLEVEL DBG_LEVEL
162  #endif
163 
164  #if (DPLEVEL >= 5)
165  #define DPL5(x) STB_SPDebugNoCnWrite x
166  #else
167  #define DPL5(x)
168  #endif
169 
170  #if (DPLEVEL >= 4)
171  #define DPL4(x) STB_SPDebugNoCnWrite x
172  #else
173  #define DPL4(x)
174  #endif
175 
176  #if (DPLEVEL >= 3)
177  #define DPL3(x) STB_SPDebugNoCnWrite x
178  #else
179  #define DPL3(x)
180  #endif
181 
182  #if (DPLEVEL >= 2)
183  #define DPL2(x) STB_SPDebugNoCnWrite x
184  #else
185  #define DPL2(x)
186  #endif
187 
188  #if (DPLEVEL >= 1)
189  #define DPL1(x) STB_SPDebugNoCnWrite x
190  #else
191  #define DPL1(x)
192  #endif
193 #endif /* #if defined( NDEBUG ) && ! defined( OVERRIDE_DEBUG_PRINTS ) #else */
194 
195 void MHG_DebugMemStats(int line);
196 
197 #endif /*_GLUE_DEBUG_H*/
This file provides control debug prints for MHEG5 engine.
Debug functions required by MHEG5 engine in debug builds.
System Wide Global Technical Data Type Definitions.
define asserts