Go to the documentation of this file.
10 #define _DEBUG_DEFINED
33 #if defined( __WINCE__ ) && _WIN32_WCE < 400
39 #define _ASSERTE( expr ) \
40 ( void )( ( expr ) || ( NKDbgPrintfW( #expr ) ) )
43 #define assert( expr ) _ASSERTE( expr )
49 DEBUGMSG( !( x ), ( TEXT( "Assert failed in %s line %d: %s" ), TEXT( __FILE__ ), __LINE__, TEXT( #x ) ) )
67 #define ASSERT_CONCAT_( a, b ) a##b
68 #define ASSERT_CONCAT( a, b ) ASSERT_CONCAT_( a, b )
73 #define __COUNTER__ __LINE__
75 #if defined( _MSC_VER )
76 #if VC_GE_2010( _MSC_VER )
78 #elif VC_GE_2008( _MSC_VER )
79 #define static_assert( expr, string ) _STATIC_ASSERT( expr )
81 #define static_assert( expr, string ) \
82 { enum { ASSERT_CONCAT( static_assert_, __COUNTER__ ) = 1 / ( !!( expr ) ) }; }
84 #define static_assert_opt( expr, string ) \
87 #define static_assert( expr, string ) \
88 { enum { ASSERT_CONCAT( static_assert_, __COUNTER__ ) = 1 / ( !!( expr ) ) }; }
89 #define static_assert_opt( expr, string ) \
114 #if !defined( NDEBUG ) && \
115 ( defined( __WIN32__ ) || defined( CONFIG_SUITEB_TESTS ) )
116 #define DEBUG_DIAGNOSTIC_ENABLE
126 #if defined( NDEBUG ) && !defined( DEBUG_DIAGNOSTIC_ENABLE )
127 #define DEBUG_PRINT( x )
128 #define DEBUG_OUT( string )
129 #elif defined( __WIN32__ )
130 int debugPrintf(
const char *format, ... );
132 #define DEBUG_PRINT( x ) debugPrintf x
133 #define DEBUG_OUT( string ) OutputDebugString( string )
134 #elif defined( __WINCE__ )
135 int debugPrintf(
const char *format, ... );
137 #define DEBUG_PRINT( x ) debugPrintf x
138 #define DEBUG_OUT( string ) NKDbgPrintfW( L"%s", string )
139 #elif defined( __ECOS__ )
140 #define DEBUG_PRINT( x ) diag_printf x
141 #define DEBUG_OUT( string ) diag_printf( "%s", string )
142 #elif defined( __UNIX__ )
143 int debugPrintf(
const char *format, ... );
145 #define DEBUG_PRINT( x ) debugPrintf x
146 #define DEBUG_OUT( string ) debugPrintf( "%s", string )
149 #define DEBUG_PRINT( x ) printf x
150 #define DEBUG_OUT( string ) printf( "%s", string )
156 #if defined( __GNUC__ ) || ( defined( _MSC_VER ) && VC_GE_2005( _MSC_VER ) )
158 #if defined( __GNUC__ ) && ( __STDC_VERSION__ < 199901L )
160 #define __FUNCTION__ __func__
162 #define __FUNCTION__ "<unknown>"
166 #define DEBUG_ENTER() DEBUG_PRINT(( "Enter %s:%s:%d.\n", __FILE__, __FUNCTION__, __LINE__ ))
167 #define DEBUG_IN() DEBUG_PRINT(( "In %s:%s:%d.\n", __FILE__, __FUNCTION__, __LINE__ ))
168 #define DEBUG_EXIT() DEBUG_PRINT(( "Exit %s:%s:%d, status %d.\n", __FILE__, __FUNCTION__, __LINE__, status ))
169 #define DEBUG_EXIT_NONE() \
170 DEBUG_PRINT(( "Exit %s:%s:%d.\n", __FILE__, __FUNCTION__, __LINE__ ))
172 #define DEBUG_DIAG( x ) \
173 DEBUG_PRINT(( "%s:%s:%d: ", __FILE__, __FUNCTION__, __LINE__ )); \
175 DEBUG_PRINT(( ".\n" ))
177 #define DEBUG_ENTER() DEBUG_PRINT(( "Enter %s:%d.\n", __FILE__, __LINE__ ))
178 #define DEBUG_IN() DEBUG_PRINT(( "In %s:%d.\n", __FILE__, __LINE__ ))
179 #define DEBUG_EXIT() DEBUG_PRINT(( "Exit %s:%d, status %d.\n", __FILE__, __LINE__, status ))
180 #define DEBUG_EXIT_NONE() \
181 DEBUG_PRINT(( "Exit %s:%d.\n", __FILE__, __LINE__ ))
183 #define DEBUG_DIAG( x ) \
184 DEBUG_PRINT(( "%s:%d: ", __FILE__, __LINE__ )); \
186 DEBUG_PRINT(( ".\n" ))
211 #if defined( NDEBUG ) && !defined( DEBUG_DIAGNOSTIC_ENABLE )
212 #define DEBUG_DUMP_FILE( name, data, length )
213 #define DEBUG_DUMP_CERT( name, data, length )
214 #define DEBUG_DUMP_HEX( dumpPrefix, dumpBuf, dumpLen )
215 #define DEBUG_DUMP_DATA( dumpBuf, dumpLen )
216 #define DEBUG_DUMP_STREAM( stream, position, length )
217 #define DEBUG_GET_STREAMBYTE( stream, position ) 0
219 #define DEBUG_DUMP_FILE debugDumpFile
220 #define DEBUG_DUMP_CERT debugDumpFileCert
221 #define DEBUG_DUMP_HEX debugDumpHex
222 #define DEBUG_DUMP_DATA debugDumpData
223 #define DEBUG_DUMP_STREAM debugDumpStream
224 #define DEBUG_GET_STREAMBYTE debugGetStreamByte
231 void debugDumpFileCert(
IN_STRING const char *fileName,
234 void debugDumpHex(
IN_STRING const char *prefixString,
252 #if defined( NDEBUG ) && !defined( DEBUG_DIAGNOSTIC_ENABLE )
253 #define DEBUG_DUMP_LIST( label, listHead, listTail, listType )
255 #define DEBUG_DUMP_LIST( label, listHead, listTail, listType ) \
259 DEBUG_PRINT(( "%s: Walking list beginning at %lX.\n", \
260 label, ( listHead ) )); \
261 for( listPtr = ( listHead ); \
262 listPtr != NULL; listPtr = listPtr->next ) \
264 DEBUG_PRINT(( " Ptr = %lX, prev = %lX, next = %lX.\n", \
265 listPtr, listPtr->prev, listPtr->next )); \
267 if( ( listHead ) != NULL ) \
268 DEBUG_PRINT(( " List tail = %lX.\n", ( listTail ) )); \
269 DEBUG_PRINT(( "Finished walking list beginning at %lX.\n", ( listHead ) )); \
292 #ifdef CONFIG_DEBUG_MALLOC
295 #define clAlloc( string, size ) \
296 clAllocFn( __FILE__, ( string ), __LINE__, ( size ) )
297 #define clFree( string, memblock ) \
298 clFreeFn( __FILE__, ( string ), __LINE__, ( memblock ) )
299 void *clAllocFn(
const char *fileName,
const char *fnName,
300 const int lineNo,
size_t size );
301 void clFreeFn(
const char *fileName,
const char *fnName,
304 #define clAlloc( string, size ) malloc( size )
305 #define clFree( string, memblock ) free( memblock )
307 #ifdef CONFIG_NO_DYNALLOC
308 #define clDynAlloc( string, size ) NULL
310 #define clDynAlloc( string, size ) clAlloc( string, size )
319 #ifdef CONFIG_FAULT_MALLOC
322 #define clAlloc( string, size ) \
323 clFaultAllocFn( __FILE__, ( string ), __LINE__, ( size ) )
324 #define clFree( string, memblock ) free( memblock )
325 void *clFaultAllocFn(
const char *fileName,
const char *fnName,
326 const int lineNo,
size_t size );
327 void clFaultSet(
const int number );