DSMCC  22.11.0
All Classes Files Functions Typedefs
dsmDbg.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright � 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright � 2004 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  *******************************************************************************/
24 #ifndef _DSMDBG_H_
25 #define _DSMDBG_H_
26 
27 /*-------------------------------- Includes ----------------------------------*/
28 #include "cldsmdbg.h"
29 
30 /*-------------------------------- Defines -----------------------------------*/
31 /* -- DEBUG PRINT DEFINITIONS */
32 
33 /* -- All debug output goes to stdout (printf) only
34 ***** Because currently we don't know how to use memory based DPs in DVP/MIPS!
35 */
36 
37 #if (defined(NDEBUG) || defined(NO_DP)) /* -- ie. retail and/or assert build */
38  #define dsmAssert( assertion )
39  #define ASSERT(condition)
40  #ifdef DSM_DP_LEVEL
41  #undef DSM_DP_LEVEL
42  #endif
43  #define DSM_DP_LEVEL 0
44 #else
45  #ifdef DEBUG_ASSERT
46  #include "stb_debug.h"
47  #define dsmAssert( assertion ) if (!assertion) STB_SPDebugAssertFail(__FILE__, __LINE__, # assertion);
48  #define ASSERT(condition) if (!(condition)) STB_SPDebugAssertFail(__FILE__, __LINE__, # condition);
49  #else
50  #include <assert.h>
51  #define dsmAssert( assertion ) assert assertion
52  #define ASSERT(condition) assert(condition);
53  #endif
54 
55  #ifndef DSM_DP_LEVEL
56  #define DSM_DP_LEVEL (1) /* -- default */
57  #endif
58 #endif
59 
60 /* -- Level 1 Debug Print
61 *
62 * For fatal errors and conditions that should not occur frequently.
63 *
64 * eg.
65 * - Internal and API errors (optional since also assert)
66 * - Runtime errors
67 * - Fatal data errors
68 * - Critical debug info
69 *
70 * NB. Directed to a both debug print ports for high visibility.
71 *
72 */
73 #if DSM_DP_LEVEL >= 1
74  #define DBGCODE( x ) x
75  #define dsmDP1( x ) if (DBG_ErrorPrintfFunc) DBG_ErrorPrintfFunc x
76  #define ERRPRINT(x, ...) \
77  if (DBG_ErrorPrintfFunc) DBG_ErrorPrintfFunc("%s:%d ERROR: " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
78  #define DBG1(f, x, ...) \
79  if (DBG_ErrorPrintfFunc && (f & dsmDbgState)) DBG_ErrorPrintfFunc("%s:%d " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
80  #define ERRLOG(f, x, ...) \
81  if (DBG_ErrorPrintfFunc) DBG_ErrorPrintfFunc("%s:%d " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
82  #define DBGLOG(f, x, ...) \
83  if (DBG_ErrorPrintfFunc && (f & idp->dbgMask)) DBG_ErrorPrintfFunc("%s:%d " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
84  #define DBGERRCHK(err) if (err) { ERRPRINT("err=%d",err) }
85  #else
86  #define DBGCODE( x )
87  #define dsmDP1( x )
88  #define ERRPRINT(x, ...)
89  #define DBG1(f, x, ...)
90  #define ERRLOG(f, x, ...)
91  #define DBGLOG(f, x, ...)
92  #define DBGERRCHK(err)
93 #endif
94 
95 /* -- Level 2 Debug Print
96 *
97 * For warnings, conditions etc. that may occur more frequently.
98 *
99 * eg.
100 * - Non-fatal data errors (ie. warnings)
101 * - API Function entry/exit print
102 *
103 */
104 #if DSM_DP_LEVEL >= 2
105  #define DBGCODE2( x ) x
106  #define dsmDP2( x ) if (DBG_WarnPrintfFunc) DBG_WarnPrintfFunc x
107  #define DBG2(f, x, ...) \
108  if (DBG_WarnPrintfFunc && (f & dsmDbgState)) DBG_WarnPrintfFunc("%s:%d " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
109  #define DBGHEX2(p,s) if (DBG_WarnPrintfFunc) DBG_HexDump(p,s);
110 void DBG_HexDump(U8BIT *data, U32BIT size );
111 #else
112  #define DBGCODE2( x )
113  #define dsmDP2( x )
114  #define DBG2(f, x, ...)
115  #define DBGHEX2(p,s)
116 #endif
117 
118 
119 /* -- Level 3 Debug Print
120 *
121 * For general debug info and conditions that occur fairly frequently
122 * but only print limited output.
123 *
124 * eg. - Lower level function entry/exit points
125 *
126 */
127 #if DSM_DP_LEVEL >= 3
128  #define DBGCODE3( x ) x
129  #define dsmDP3( x ) if (DBG_DebugPrintfFunc) DBG_DebugPrintfFunc x
130  #define DBG3(f, x, ...) \
131  if (DBG_DebugPrintfFunc && (f & dsmDbgState)) DBG_DebugPrintfFunc("%s:%d " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
132  #define DBGHEX3(p,s) if (DBG_WarnPrintfFunc) DBG_HexDump(p,s);
133 #else
134  #define DBGCODE3( x )
135  #define dsmDP3( x )
136  #define DBG3(f, x, ...)
137  #define DBGHEX3(p,s)
138 #endif
139 
140 
141 /* -- Level 4 Debug Print
142 *
143 * For detailed debug info and conditions that occur VERY frequently
144 * and/or print large amounts of output.
145 *
146 * eg. - Very low level function entry/exit points
147 * - Data array values printed from loop
148 *
149 */
150 #if DSM_DP_LEVEL >= 4
151  #define dsmDP4( x ) if (DBG_InfoPrintfFunc) DBG_InfoPrintfFunc x
152  #define DBG4(f, x, ...) \
153  if (DBG_InfoPrintfFunc && (f & dsmDbgState)) DBG_InfoPrintfFunc("%s:%d " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
154 
155 #else
156  #define dsmDP4( x )
157  #define DBG4(f, x, ...)
158 #endif
159 
160 
161 /*-------------------------------- Types -------------------------------------*/
162 
163 
164 /*------------------------------ Exported Data -----------------------------*/
165 
166 #if (!defined(NDEBUG) && !defined(NO_DP))
167 extern F_Printf DBG_ErrorPrintfFunc;
168 extern F_Printf DBG_WarnPrintfFunc;
169 extern F_Printf DBG_DebugPrintfFunc;
170 extern F_Printf DBG_InfoPrintffunc;
171 extern U32BIT dsmDbgState;
172 #endif
173 
174 /*------------------------------ Prototypes ----------------------------------*/
175 
176 
177 /*----------------------------------------------------------------------------*/
178 
179 #endif /* _DSMDBG_H_ */
180 
Interface to platform debug functions.
DSM Debug API header.