CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
FxDebug.h
Go to the documentation of this file.
1//
2// (C) Copyright 2005-2025 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
80 const char* msg,
81 const char* file,
82 const int line
83);
84
86 const wchar_t* msg,
87 const wchar_t* file,
88 const int line
89);
90
97{
98public:
99#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(_WIN32_WCE)
100 CFxTrace( const __wchar_t* pszFileName, const int iLineNumber );
101#endif
102 CFxTrace( const OdChar* pszFileName, const int iLineNumber );
103
104#ifdef _UNICODE
105 void operator()(const char *pszFmt, ...) const;
106#endif
107#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(_WIN32_WCE)
108 void operator()(const __wchar_t *pszFmt, ...) const;
109#endif
110 void operator()(const OdChar *pszFmt, ...) const;
111
112private:
113 const OdChar* m_pszFileName;
114 const int m_iLineNumber;
115};
116
117void DDKERNEL_API SetIgnoreAll( bool bIgnore );
119
122
123#if (defined(_DEBUG) || defined(QT_DEBUG)) && !defined(ARGON_FULL_DEBUG)
124 #define ARGON_FULL_DEBUG
125#endif
126
127// Uncomment the following line to have ASSERTs defined in all configurations.
128//#define ARGON_ENFORCE_ASSERTS
129
130#if defined(ARGON_FULL_DEBUG) || defined(ARGON_ENFORCE_ASSERTS)
131
132 #undef ASSERT
133 #undef ASSERTMSG
134 #undef ASSERT_UNREACHABLE
135 #undef ASSERT_UNREACHABLE_MSG
136 #undef TRACE
137 #undef FXVERIFY //Like ASSERT, but inlined and always returns result of expression.
138
139 #define TT(x) L ## x
140
141 #define RR(x) TT(x)
142
143 #if !defined(_UNICODE)
144 #if !defined(DDKERNEL_BREAK_POINT_DUMMY_ENABLED)
145 #define ASSERT(x) \
146 do { \
147 static bool bIgnoreThis = false; \
148 if ( !(x) ) \
149 ArgonAssertFuncA( __FILE__, __LINE__, #x, 0, &bIgnoreThis ); \
150 } while(0)
151
152 #define ASSERTMSG(x,c) \
153 do { \
154 static bool bIgnoreThis = false; \
155 if( !(x) ) \
156 ArgonAssertFuncA( __FILE__, __LINE__, #x, c, &bIgnoreThis ); \
157 } while(0)
158
159 #define ASSERT_ONCE(x) \
160 do { \
161 static bool bIgnoreThis = false; \
162 static bool bWasHere = false; \
163 if ( !bWasHere && !(x) ) \
164 { \
165 bWasHere = true; \
166 ArgonAssertFuncA( __FILE__, __LINE__, #x, 0, &bIgnoreThis ); \
167 } \
168 } while(0)
169
170 #define ASSERT_UNREACHABLE() \
171 do { \
172 static bool bIgnoreThis = false; \
173 ArgonAssertFuncA( __FILE__, __LINE__, "unreachable", 0, &bIgnoreThis ); \
174 } while(0)
175
176 #define ASSERT_UNREACHABLE_MSG(c) \
177 do { \
178 static bool bIgnoreThis = false; \
179 ArgonAssertFuncA( __FILE__, __LINE__, "unreachable", c, &bIgnoreThis ); \
180 } while(0)
181
182 #define FXVERIFY(x) ArgonVerifyFuncA( !!(x), __FILE__, __LINE__, #x, 0 )
183
184 #define ASSERT_LOG_MESSAGE(msg) ArgonLogToAssertLog(msg, __FILE__, __LINE__)
185 #else
186 #define ASSERT(x) \
187 do { \
188 static bool bIgnoreThis = false; \
189 BreakPointDummy(); \
190 if ( !(x) ) \
191 ArgonAssertFuncA( __FILE__, __LINE__, #x, 0, &bIgnoreThis ); \
192 } while(0)
193
194 #define ASSERTMSG(x,c) \
195 do { \
196 static bool bIgnoreThis = false; \
197 BreakPointDummy(); \
198 if( !(x) ) \
199 ArgonAssertFuncA( __FILE__, __LINE__, #x, c, &bIgnoreThis ); \
200 } while(0)
201
202 #define ASSERT_ONCE(x) \
203 do { \
204 static bool bIgnoreThis = false; \
205 static bool bWasHere = false; \
206 if ( !bWasHere && !(x) ) \
207 { \
208 bWasHere = true; \
209 ArgonAssertFuncA( __FILE__, __LINE__, #x, 0, &bIgnoreThis ); \
210 } \
211 } while(0)
212
213 #define ASSERT_UNREACHABLE() \
214 do { \
215 static bool bIgnoreThis = false; \
216 BreakPointDummy(); \
217 ArgonAssertFuncA( __FILE__, __LINE__, "unreachable", 0, &bIgnoreThis ); \
218 } while(0)
219
220 #define ASSERT_UNREACHABLE_MSG(c) \
221 do { \
222 static bool bIgnoreThis = false; \
223 BreakPointDummy(); \
224 ArgonAssertFuncA( __FILE__, __LINE__, "unreachable", c, &bIgnoreThis ); \
225 } while(0)
226
227 #define FXVERIFY(x) ArgonVerifyFuncA( !!(x), __FILE__, __LINE__, #x, 0 )
228
229 #define ASSERT_LOG_MESSAGE(msg) ArgonLogToAssertLog(msg, __FILE__, __LINE__)
230 #endif
231 #else
232 #if !defined(DDKERNEL_BREAK_POINT_DUMMY_ENABLED)
233 #define ASSERT(x) \
234 do { \
235 static bool bIgnoreThis = false; \
236 if ( !(x) ) \
237 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, 0, &bIgnoreThis ); \
238 } while(0)
239
240 #define ASSERTMSG(x,c) \
241 do { \
242 static bool bIgnoreThis = false; \
243 if( !(x) ) \
244 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, c, &bIgnoreThis ); \
245 } while(0)
246
247 #define ASSERT_ONCE(x) \
248 do { \
249 static bool bIgnoreThis = false; \
250 static bool bWasHere = false; \
251 if ( !bWasHere && !(x) ) \
252 { \
253 bWasHere = true; \
254 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, 0, &bIgnoreThis ); \
255 } \
256 } while(0)
257
258 #define ASSERT_UNREACHABLE() \
259 do { \
260 static bool bIgnoreThis = false; \
261 ArgonAssertFuncW( RR(__FILE__), __LINE__, L"unreachable", 0, &bIgnoreThis ); \
262 } while(0)
263
264 #define ASSERT_UNREACHABLE_MSG(c) \
265 do { \
266 static bool bIgnoreThis = false; \
267 ArgonAssertFuncW( RR(__FILE__), __LINE__, L"unreachable", c, &bIgnoreThis ); \
268 } while(0)
269
270 #define FXVERIFY(x) ArgonVerifyFuncW( !!(x), RR(__FILE__), __LINE__, L ## #x, 0 )
271
272 #define ASSERT_LOG_MESSAGE(msg) ArgonLogToAssertLog(msg, RR(__FILE__), __LINE__)
273 #else
274 #define ASSERT(x) \
275 do { \
276 static bool bIgnoreThis = false; \
277 BreakPointDummy(); \
278 if ( !(x) ) \
279 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, 0, &bIgnoreThis ); \
280 } while(0)
281
282 #define ASSERTMSG(x,c) \
283 do { \
284 static bool bIgnoreThis = false; \
285 BreakPointDummy(); \
286 if(!(x)) \
287 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, c, &bIgnoreThis ); \
288 } while(0)
289
290 #define ASSERT_ONCE(x) \
291 do{ \
292 static bool bIgnoreThis = false; \
293 static bool bWasHere = false; \
294 BreakPointDummy(); \
295 if ( !bWasHere && !(x) ) \
296 { \
297 bWasHere = true; \
298 ArgonAssertFuncW( RR(__FILE__), __LINE__, L ## #x, 0, &bIgnoreThis ); \
299 } \
300 } while(0)
301
302 #define ASSERT_UNREACHABLE() \
303 do { \
304 static bool bIgnoreThis = false; \
305 BreakPointDummy(); \
306 ArgonAssertFuncW( RR(__FILE__), __LINE__, L"unreachable", 0, &bIgnoreThis ); \
307 } while(0)
308
309 #define ASSERT_UNREACHABLE_MSG(c) \
310 do { \
311 static bool bIgnoreThis = false; \
312 BreakPointDummy(); \
313 ArgonAssertFuncW( RR(__FILE__), __LINE__, L"unreachable", c, &bIgnoreThis ); \
314 } while(0)
315
316 #define FXVERIFY(x) ArgonVerifyFuncW( !!(x), RR(__FILE__), __LINE__, L ## #x, 0 )
317
318 #define ASSERT_LOG_MESSAGE(msg) ArgonLogToAssertLog(msg, RR(__FILE__), __LINE__)
319 #endif
320 #endif
321
322 #define TRACE CFxTrace( RR(__FILE__), __LINE__ )
323
324#else // ARGON_FULL_DEBUG || ARGON_ENFORCE_ASSERTS
325
326 #ifdef _MSC_VER
327 #ifndef ASSERT
328 #define ASSERT(x) __noop
329 #endif
330 #define ASSERT_ONCE(x) __noop
331 #define ASSERTMSG(x,c) __noop
332 #define ASSERT_UNREACHABLE() __noop
333 #define ASSERT_UNREACHABLE_MSG(c) __noop
334 #define TRACE __noop
335 #define FXVERIFY(x) (x)
336 #define ASSERT_LOG_MESSAGE(msg) __noop
337 #else
338 #define ASSERT(x) FxNoop()
339 #define ASSERT_ONCE(x) FxNoop()
340 #define ASSERTMSG(x,c) FxNoop()
341 #define ASSERT_UNREACHABLE() FxNoop()
342 #define ASSERT_UNREACHABLE_MSG(c) FxNoop()
343 #define TRACE(...) FxNoop()
344 #define FXVERIFY(x) (x)
345 #define ASSERT_LOG_MESSAGE(msg) FxNoop()
346 #endif
347
348#endif // ARGON_FULL_DEBUG || ARGON_ENFORCE_ASSERTS
349
350DDKERNEL_API void FxCIPRecordAssertion( const char* cpFile, const int iLine, const char* cpExpr );
351
352#define ASSERT_CIP( expr ) \
353{ \
354 if( !( expr ) ) \
355 FxCIPRecordAssertion( __FILE__, __LINE__, #expr ); \
356 ASSERT( expr ); \
357}
358
359#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)
void DDKERNEL_API ArgonLogToAssertLog(const char *msg, const char *file, const int line)
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)