DSMCC  17.9.0
 All Data Structures 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 dsmDP1( x ) if (DBG_ErrorPrintfFunc) DBG_ErrorPrintfFunc x
75  #define ERRPRINT(x, ...) \
76  if (DBG_ErrorPrintfFunc) DBG_ErrorPrintfFunc("%s:%d ERROR: " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
77  #define DBG1(f, x, ...) \
78  if (DBG_ErrorPrintfFunc && (f & dsmDbgState)) DBG_ErrorPrintfFunc("%s:%d " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
79  #define ERRLOG(f, x, ...) \
80  if (DBG_ErrorPrintfFunc) DBG_ErrorPrintfFunc("%s:%d " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
81  #define DBGLOG(f, x, ...) \
82  if (DBG_ErrorPrintfFunc && (f & idp->dbgMask)) DBG_ErrorPrintfFunc("%s:%d " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
83  #define DBGERRCHK(err) if (err) { ERRPRINT("err=%d",err) }
84  #else
85  #define dsmDP1( x )
86  #define ERRPRINT(x, ...)
87  #define DBG1(f, x, ...)
88  #define ERRLOG(f, x, ...)
89  #define DBGLOG(f, x, ...)
90  #define DBGERRCHK(err)
91 #endif
92 
93 /* -- Level 2 Debug Print
94 *
95 * For warnings, conditions etc. that may occur more frequently.
96 *
97 * eg.
98 * - Non-fatal data errors (ie. warnings)
99 * - API Function entry/exit print
100 *
101 */
102 #if DSM_DP_LEVEL >= 2
103  #define dsmDP2( x ) if (DBG_WarnPrintfFunc) DBG_WarnPrintfFunc x
104  #define DBG2(f, x, ...) \
105  if (DBG_WarnPrintfFunc && (f & dsmDbgState)) DBG_WarnPrintfFunc("%s:%d " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
106 #else
107  #define dsmDP2( x )
108  #define DBG2(f, x, ...)
109 #endif
110 
111 
112 /* -- Level 3 Debug Print
113 *
114 * For general debug info and conditions that occur fairly frequently
115 * but only print limited output.
116 *
117 * eg. - Lower level function entry/exit points
118 *
119 */
120 #if DSM_DP_LEVEL >= 3
121  #define dsmDP3( x ) if (DBG_DebugPrintfFunc) DBG_DebugPrintfFunc x
122  #define DBG3(f, x, ...) \
123  if (DBG_DebugPrintfFunc && (f & dsmDbgState)) DBG_DebugPrintfFunc("%s:%d " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
124 #else
125  #define dsmDP3( x )
126  #define DBG3(f, x, ...)
127 #endif
128 
129 
130 /* -- Level 4 Debug Print
131 *
132 * For detailed debug info and conditions that occur VERY frequently
133 * and/or print large amounts of output.
134 *
135 * eg. - Very low level function entry/exit points
136 * - Data array values printed from loop
137 *
138 */
139 #if DSM_DP_LEVEL >= 4
140  #define dsmDP4( x ) if (DBG_InfoPrintfFunc) DBG_InfoPrintfFunc x
141  #define DBG4(f, x, ...) \
142  if (DBG_InfoPrintfFunc && (f & dsmDbgState)) DBG_InfoPrintfFunc("%s:%d " x "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__);
143 
144 #else
145  #define dsmDP4( x )
146  #define DBG4(f, x, ...)
147 #endif
148 
149 
150 void STB_SPDumpWrite (U8BIT *data, U32BIT size );
151 
152 /*-------------------------------- Types -------------------------------------*/
153 
154 
155 /*------------------------------ Exported Data -----------------------------*/
156 
157 #if (!defined(NDEBUG) && !defined(NO_DP))
158 extern F_Printf DBG_ErrorPrintfFunc;
159 extern F_Printf DBG_WarnPrintfFunc;
160 extern F_Printf DBG_DebugPrintfFunc;
161 extern F_Printf DBG_InfoPrintffunc;
162 extern U32BIT dsmDbgState;
163 #endif
164 
165 /*------------------------------ Prototypes ----------------------------------*/
166 
167 
168 /*----------------------------------------------------------------------------*/
169 
170 #endif /* _DSMDBG_H_ */
171 
Interface to platform debug functions.
DSM Debug API header.