CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
FxDebug.h
Go to the documentation of this file.
1//
2// (C) Copyright 2005-2023 by Graebert GmbH.
3//
4// Permission to use, copy, modify, and distribute this software in
5// object code form for any purpose and without fee is hereby granted,
6// provided that the above copyright notice appears in all copies and
7// that both that copyright notice and the limited warranty and
8// restricted rights notice below appear in all supporting
9// documentation.
10//
11// GRAEBERT PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
12// GRAEBERT SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
13// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. GRAEBERT GMBH
14// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
15// UNINTERRUPTED OR ERROR FREE.
16
17#pragma once
18
19#include "DDKERNEL.h"
20
21#ifdef _MSC_VER
22 #include <tchar.h>
23#endif
24
25#include "FxPragmaPush.h"
26
27inline void FxNoop() {}
28
29#if defined(DDKERNEL_BREAK_POINT_DUMMY_ENABLED)
30void DDKERNEL_API BreakPointDummy();
31#endif
32
34 const char* cpFile,
35 const int iLine,
36 const char* cpExpr,
37 const char* cpComment,
38 bool * pbIgnoreThis = 0 );
39
40#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(_WIN32_WCE)
42 const __wchar_t* cpFile,
43 const int iLine,
44 const __wchar_t* cpExpr,
45 const __wchar_t* cpComment,
46 bool * pbIgnoreThis = 0 );
47#endif
48
50 const OdChar* cpFile,
51 const int iLine,
52 const OdChar* cpExpr,
53 const OdChar* cpComment,
54 bool * pbIgnoreThis = 0 );
55
57 bool exp,
58 const char* cpFile,
59 const int iLine,
60 const char* cpExpr,
61 const char* cpComment );
62
63#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(_WIN32_WCE)
65 bool exp,
66 const __wchar_t* cpFile,
67 const int iLine,
68 const __wchar_t* cpExpr,
69 const __wchar_t* cpComment );
70#endif
71
73 bool exp,
74 const OdChar* cpFile,
75 const int iLine,
76 const OdChar* cpExpr,
77 const OdChar* cpComment );
78
85{
86public:
87#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(_WIN32_WCE)
88 CFxTrace( const __wchar_t* pszFileName, const int iLineNumber );
89#endif
90 CFxTrace( const OdChar* pszFileName, const int iLineNumber );
91
92#ifdef _UNICODE
93 void operator()(const char *pszFmt, ...) const;
94#endif
95#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(_WIN32_WCE)
96 void operator()(const __wchar_t *pszFmt, ...) const;
97#endif
98 void operator()(const OdChar *pszFmt, ...) const;
99
100private:
101 const OdChar* m_pszFileName;
102 const int m_iLineNumber;
103};
104
105void DDKERNEL_API SetIgnoreAll( bool bIgnore );
107
110
111#if (defined(_DEBUG) || defined(QT_DEBUG)) && !defined(ARGON_FULL_DEBUG)
112 #define ARGON_FULL_DEBUG
113#endif
114
115#if defined(ARGON_FULL_DEBUG)
116
117 #undef ASSERT
118 #undef ASSERTMSG
119 #undef TRACE
120 #undef FXVERIFY //Like ASSERT, but inlined and always returns result of expression.
121
122 #define TT(x) L ## x
123
124 #define RR(x) TT(x)
125
126 #if !defined(_UNICODE)
127
128 #if !defined(DDKERNEL_BREAK_POINT_DUMMY_ENABLED)
129 #define ASSERT(x) do{ \
130 static bool bIgnoreThis = false; \
131 if ( !(x) ) \
132 ArgonAssertFuncA( __FILE__, __LINE__, #x, 0, &bIgnoreThis ); \
133 } while(0)
134
135 #define ASSERTMSG(x,c) do{ \
136 static bool bIgnoreThis = false; \
137 if(!(x)) \
138 ArgonAssertFuncA( __FILE__, __LINE__, #x, c, &bIgnoreThis ); \
139 }while(0)
140
141 #define ASSERT_ONCE(x) do{ \
142 static bool bIgnoreThis = false; \
143 static bool bWasHere = false; \
144 if (!bWasHere && !(x) ) \
145 { bWasHere = true;\
146 ArgonAssertFuncA( __FILE__, __LINE__, #x, 0, &bIgnoreThis ); \
147 }\
148 } while(0)
149
150 #define FXVERIFY(x) ArgonVerifyFuncA( !!(x), __FILE__, __LINE__, #x, 0 )
151 #else
152 #define ASSERT(x) do{ \
153 static bool bIgnoreThis = false; \
154 BreakPointDummy(); \
155 if ( !(x) ) \
156 ArgonAssertFuncA( __FILE__, __LINE__, #x, 0, &bIgnoreThis ); \
157 } while(0)
158
159 #define ASSERTMSG(x,c) do{ \
160 static bool bIgnoreThis = false; \
161 BreakPointDummy(); \
162 if(!(x)) \
163 ArgonAssertFuncA( __FILE__, __LINE__, #x, c, &bIgnoreThis ); \
164 }while(0)
165
166 #define ASSERT_ONCE(x) do{ \
167 static bool bIgnoreThis = false; \
168 static bool bWasHere = false; \
169 if (!bWasHere && !(x) ) \
170 { bWasHere = true;\
171 ArgonAssertFuncA( __FILE__, __LINE__, #x, 0, &bIgnoreThis ); \
172 }\
173 } while(0)
174
175 #define FXVERIFY(x) ArgonVerifyFuncA( !!(x), __FILE__, __LINE__, #x, 0 )
176 #endif
177
178 #else
179 #if !defined(DDKERNEL_BREAK_POINT_DUMMY_ENABLED)
180 #define ASSERT(x) do{ \
181 static bool bIgnoreThis = false; \
182 if ( !(x) ) \
183 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, 0, &bIgnoreThis ); \
184 } while(0)
185
186 #define ASSERTMSG(x,c) do{ \
187 static bool bIgnoreThis = false; \
188 if(!(x)) \
189 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, c, &bIgnoreThis ); \
190 }while(0)
191
192 #define ASSERT_ONCE(x) do{ \
193 static bool bIgnoreThis = false; \
194 static bool bWasHere = false; \
195 if (!bWasHere && !(x) ) \
196 { bWasHere = true;\
197 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, 0, &bIgnoreThis ); \
198 }\
199 } while(0)
200
201 #define ASSERTMSG(x,c) do{ \
202 static bool bIgnoreThis = false; \
203 if(!(x)) \
204 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, c, &bIgnoreThis ); \
205 }while(0)
206
207 #define FXVERIFY(x) ArgonVerifyFuncW( !!(x), RR(__FILE__), __LINE__, L ## #x, 0 )
208 #else
209 #define ASSERT(x) do{ \
210 static bool bIgnoreThis = false; \
211 BreakPointDummy(); \
212 if ( !(x) ) \
213 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, 0, &bIgnoreThis ); \
214 } while(0)
215
216 #define ASSERTMSG(x,c) do{ \
217 static bool bIgnoreThis = false; \
218 BreakPointDummy(); \
219 if(!(x)) \
220 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, c, &bIgnoreThis ); \
221 }while(0)
222
223 #define ASSERT_ONCE(x) do{ \
224 static bool bIgnoreThis = false; \
225 static bool bWasHere = false; \
226 BreakPointDummy(); \
227 if (!bWasHere && !(x) ) \
228 { bWasHere = true;\
229 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, 0, &bIgnoreThis ); \
230 }\
231 } while(0)
232
233 #define ASSERTMSG(x,c) do{ \
234 static bool bIgnoreThis = false; \
235 BreakPointDummy(); \
236 if(!(x)) \
237 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, c, &bIgnoreThis ); \
238 }while(0)
239
240 #define FXVERIFY(x) ArgonVerifyFuncW( !!(x), RR(__FILE__), __LINE__, L ## #x, 0 )
241 #endif
242 #endif
243
244 #define TRACE CFxTrace( RR(__FILE__), __LINE__ )
245
246#else //ARGON_FULL_DEBUG
247
248 #ifdef _MSC_VER
249 #ifndef ASSERT
250 #define ASSERT(x) __noop
251 #endif
252 #define ASSERT_ONCE(x) __noop
253 #define ASSERTMSG(x,c) __noop
254 #define TRACE __noop
255 #define FXVERIFY(x) (x)
256 #else
257 #define ASSERT(x) FxNoop()
258 #define ASSERT_ONCE(x) FxNoop()
259 #define ASSERTMSG(x,c) FxNoop()
260 #define TRACE(...) FxNoop()
261 #define FXVERIFY(x) (x)
262 #endif
263
264 //AV : uncomment next lines to have ASSERTs be defined in all configurations
265
266 //#undef ASSERT
267 //#undef ASSERTMSG
268 //#undef TRACE
269
270 //#define TT(x) L ## x
271
272 //#define RR(x) TT(x)
273
274 //#if !defined(_UNICODE)
275
276 // #if !defined(DDKERNEL_BREAK_POINT_DUMMY_ENABLED)
277 // #define ASSERT(x) do{ \
278 // static bool bIgnoreThis = false; \
279 // if ( !(x) ) \
280 // ArgonAssertFuncA( __FILE__, __LINE__, #x, 0, &bIgnoreThis ); \
281 // } while(0)
282
283 // #define ASSERTMSG(x,c) do{ \
284 // static bool bIgnoreThis = false; \
285 // if(!(x)) \
286 // ArgonAssertFuncA( __FILE__, __LINE__, #x, c, &bIgnoreThis ); \
287 // }while(0)
288 // #else
289 // #define ASSERT(x) do{ \
290 // static bool bIgnoreThis = false; \
291 // BreakPointDummy(); \
292 // if ( !(x) ) \
293 // ArgonAssertFuncA( __FILE__, __LINE__, #x, 0, &bIgnoreThis ); \
294 // } while(0)
295
296 // #define ASSERTMSG(x,c) do{ \
297 // static bool bIgnoreThis = false; \
298 // BreakPointDummy(); \
299 // if(!(x)) \
300 // ArgonAssertFuncA( __FILE__, __LINE__, #x, c, &bIgnoreThis ); \
301 // }while(0)
302 // #endif
303
304 //#else
305
306 // #if !defined(DDKERNEL_BREAK_POINT_DUMMY_ENABLED)
307 // #define ASSERT(x) do{ \
308 // static bool bIgnoreThis = false; \
309 // if ( !(x) ) \
310 // ArgonAssertFuncW( RR(__FILE__), __LINE__, _T(#x), 0, &bIgnoreThis ); \
311 // } while(0)
312
313 // #define ASSERTMSG(x,c) do{ \
314 // static bool bIgnoreThis = false; \
315 // if(!(x)) \
316 // ArgonAssertFuncW( RR(__FILE__), __LINE__, _T(#x), c, &bIgnoreThis ); \
317 // }while(0)
318
319 // #define ASSERT_ONCE(x) do{ \
320 // static bool bIgnoreThis = false; \
321 // static bool bWasHere = false; \
322 // if (!bWasHere && !(x) ) \
323 // { bWasHere = true;\
324 // ArgonAssertFuncW( RR(__FILE__), __LINE__, _T(#x), 0, &bIgnoreThis ); \
325 // }\
326 // } while(0)
327
328 // #define ASSERTMSG(x,c) do{ \
329 // static bool bIgnoreThis = false; \
330 // if(!(x)) \
331 // ArgonAssertFuncW( RR(__FILE__), __LINE__, _T(#x), c, &bIgnoreThis ); \
332 // }while(0)
333 // #else
334 // #define ASSERT(x) do{ \
335 // static bool bIgnoreThis = false; \
336 // BreakPointDummy(); \
337 // if ( !(x) ) \
338 // ArgonAssertFuncW( RR(__FILE__), __LINE__, _T(#x), 0, &bIgnoreThis ); \
339 // } while(0)
340
341 // #define ASSERTMSG(x,c) do{ \
342 // static bool bIgnoreThis = false; \
343 // BreakPointDummy(); \
344 // if(!(x)) \
345 // ArgonAssertFuncW( RR(__FILE__), __LINE__, _T(#x), c, &bIgnoreThis ); \
346 // }while(0)
347
348 // #define ASSERT_ONCE(x) do{ \
349 // static bool bIgnoreThis = false; \
350 // static bool bWasHere = false; \
351 // BreakPointDummy(); \
352 // if (!bWasHere && !(x) ) \
353 // { bWasHere = true;\
354 // ArgonAssertFuncW( RR(__FILE__), __LINE__, _T(#x), 0, &bIgnoreThis ); \
355 // }\
356 // } while(0)
357
358 // #define ASSERTMSG(x,c) do{ \
359 // static bool bIgnoreThis = false; \
360 // BreakPointDummy(); \
361 // if(!(x)) \
362 // ArgonAssertFuncW( RR(__FILE__), __LINE__, _T(#x), c, &bIgnoreThis ); \
363 // }while(0)
364 // #endif
365
366 //#endif
367
368 //#define TRACE CFxTrace( RR(__FILE__), __LINE__ )
369
370#endif //ARGON_FULL_DEBUG
371
372DDKERNEL_API void FxCIPRecordAssertion( const char* cpFile, const int iLine, const char* cpExpr );
373
374#define ASSERT_CIP( expr ) \
375{ \
376 if( !( expr ) ) \
377 FxCIPRecordAssertion( __FILE__, __LINE__, #expr ); \
378 ASSERT( expr ); \
379}
380
381#include "FxPragmaPop.h"
#define DDKERNEL_API
Definition: DDKERNEL.h:32
bool DDKERNEL_API IsAllIgnored()
void FxNoop()
Definition: FxDebug.h:27
void DDKERNEL_API SetIgnoreAll(bool bIgnore)
void DDKERNEL_API ArgonAssertFuncW(const OdChar *cpFile, const int iLine, const OdChar *cpExpr, const OdChar *cpComment, bool *pbIgnoreThis=0)
bool DDKERNEL_API ArgonVerifyFuncA(bool exp, const char *cpFile, const int iLine, const char *cpExpr, const char *cpComment)
DDKERNEL_API void FxCIPRecordAssertion(const char *cpFile, const int iLine, const char *cpExpr)
bool DDKERNEL_API IsCustomAssertUsed()
void DDKERNEL_API UseCustomAssert(bool bUse)
void DDKERNEL_API ArgonAssertFuncA(const char *cpFile, const int iLine, const char *cpExpr, const char *cpComment, bool *pbIgnoreThis=0)
bool DDKERNEL_API ArgonVerifyFuncW(bool exp, const OdChar *cpFile, const int iLine, const OdChar *cpExpr, const OdChar *cpComment)
wchar_t OdChar
void operator()(const char *pszFmt,...) const
void operator()(const OdChar *pszFmt,...) const
CFxTrace(const OdChar *pszFileName, const int iLineNumber)