DSMCC  15.3.1
source/dscore/src/dsmDbg.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
00003  * Copyright © 2004 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  *******************************************************************************/
00024 #ifndef _DSMDBG_H_
00025 #define _DSMDBG_H_
00026 
00027 /*-------------------------------- Includes ----------------------------------*/
00028 #include "cldsmdbg.h"
00029 
00030 /*-------------------------------- Defines -----------------------------------*/
00031 /* -- DEBUG PRINT DEFINITIONS */
00032 
00033 /* -- All debug output goes to stdout (printf) only
00034 ***** Because currently we don't know how to use memory based DPs in DVP/MIPS!
00035 */
00036 
00037 #if (defined(NDEBUG) || defined(NO_DP)) /* -- ie. retail and/or assert build */
00038   #define dsmAssert( assertion )
00039   #define ASSERT(condition)
00040   #ifdef DSM_DP_LEVEL
00041     #undef DSM_DP_LEVEL
00042   #endif
00043   #define DSM_DP_LEVEL 0
00044 #else
00045  #ifdef DEBUG_ASSERT
00046   #include "stb_debug.h"
00047   #define dsmAssert( assertion )    if(!assertion) STB_SPDebugAssertFail(__FILE__, __LINE__,#assertion);
00048   #define ASSERT(condition)         if (!(condition)) STB_SPDebugAssertFail(__FILE__, __LINE__,#condition);
00049  #else
00050   #include <assert.h>
00051   #define dsmAssert( assertion )    assert assertion
00052   #define ASSERT(condition)         assert(condition);
00053  #endif
00054 
00055   #ifndef DSM_DP_LEVEL
00056     #define DSM_DP_LEVEL  ( 1 ) /* -- default */
00057   #endif
00058 #endif
00059 
00060 /* -- Level 1 Debug Print
00061 *
00062 * For fatal errors and conditions that should not occur frequently.
00063 *
00064 * eg.
00065 * - Internal and API errors (optional since also assert)
00066 * - Runtime errors
00067 * - Fatal data errors
00068 * - Critical debug info
00069 *
00070 * NB. Directed to a both debug print ports for high visibility.
00071 *
00072 */
00073 #if DSM_DP_LEVEL >= 1
00074   #define dsmDP1( x )     if (DBG_ErrorPrintfFunc) DBG_ErrorPrintfFunc x
00075   #define ERRPRINT(x, ...) \
00076       if (DBG_ErrorPrintfFunc) DBG_ErrorPrintfFunc("%s:%d " x "\n",__FUNCTION__,__LINE__, ##__VA_ARGS__);
00077   #define DBGERROR(f,x, ...) \
00078       if (DBG_ErrorPrintfFunc && (f & dsmDbgState)) DBG_ErrorPrintfFunc("%s:%d " x "\n",__FUNCTION__,__LINE__, ##__VA_ARGS__);
00079 #else
00080   #define dsmDP1( x )
00081   #define ERRPRINT(x, ...)
00082   #define DBGERROR(f,x, ...)
00083 #endif
00084 
00085 /* -- Level 2 Debug Print
00086 *
00087 * For warnings, conditions etc. that may occur more frequently.
00088 *
00089 * eg.
00090 * - Non-fatal data errors (ie. warnings)
00091 * - API Function entry/exit print
00092 *
00093 */
00094 #if DSM_DP_LEVEL >= 2
00095   #define dsmDP2( x )     if (DBG_WarnPrintfFunc) DBG_WarnPrintfFunc x
00096   #define DBGWARN(f,x, ...) \
00097       if (DBG_WarnPrintfFunc && (f & dsmDbgState))  DBG_WarnPrintfFunc("%s:%d " x "\n",__FUNCTION__,__LINE__, ##__VA_ARGS__);
00098 #else
00099   #define dsmDP2( x )
00100   #define DBGWARN(f,x, ...)
00101 #endif
00102 
00103 
00104 /* -- Level 3 Debug Print
00105 *
00106 * For general debug info and conditions that occur fairly frequently
00107 * but only print limited output.
00108 *
00109 * eg. - Lower level function entry/exit points
00110 *
00111 */
00112 #if DSM_DP_LEVEL >= 3
00113   #define dsmDP3( x )   if (DBG_DebugPrintfFunc) DBG_DebugPrintfFunc x
00114   #define DBGPRINT(f,x, ...) \
00115       if (DBG_DebugPrintfFunc && (f & dsmDbgState)) DBG_DebugPrintfFunc("%s:%d " x "\n",__FUNCTION__,__LINE__, ##__VA_ARGS__);
00116 #else
00117   #define dsmDP3( x )
00118   #define DBGPRINT(f,x, ...)
00119 #endif
00120 
00121 
00122 /* -- Level 4 Debug Print
00123 *
00124 * For detailed debug info and conditions that occur VERY frequently
00125 * and/or print large amounts of output.
00126 *
00127 * eg. - Very low level function entry/exit points
00128 *     - Data array values printed from loop
00129 *
00130 */
00131 #if DSM_DP_LEVEL >= 4
00132   #define dsmDP4( x )   if (DBG_InfoPrintfFunc) DBG_InfoPrintfFunc x
00133   #define DBGINFO(f,x, ...) \
00134       if (DBG_InfoPrintfFunc && (f & dsmDbgState))  DBG_InfoPrintfFunc("%s:%d " x "\n",__FUNCTION__,__LINE__, ##__VA_ARGS__);
00135 
00136 #else
00137   #define dsmDP4( x )
00138   #define DBGINFO(f,x, ...)
00139 #endif
00140 
00141 
00142 
00143 /*-------------------------------- Types -------------------------------------*/
00144 
00145 
00146 /*------------------------------  Exported Data  -----------------------------*/
00147 
00148 #if (!defined(NDEBUG) && !defined(NO_DP))
00149 extern F_Printf DBG_ErrorPrintfFunc;
00150 extern F_Printf DBG_WarnPrintfFunc;
00151 extern F_Printf DBG_DebugPrintfFunc;
00152 extern F_Printf DBG_InfoPrintffunc;
00153 extern U32BIT dsmDbgState;
00154 #endif
00155 
00156 /*------------------------------ Prototypes ----------------------------------*/
00157 
00158 
00159 /*----------------------------------------------------------------------------*/
00160 
00161 #endif /* _DSMDBG_H_ */
00162 
 All Data Structures Files Functions Typedefs