1 | /** @file
|
---|
2 | * InnoTek Portable Runtime - Assertions.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License as published by the Free Software Foundation,
|
---|
12 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
13 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
14 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * If you received this file as part of a commercial VirtualBox
|
---|
17 | * distribution, then only the terms of your commercial VirtualBox
|
---|
18 | * license agreement apply instead of the previous paragraph.
|
---|
19 | */
|
---|
20 |
|
---|
21 | #ifndef __iprt_assert_h__
|
---|
22 | #define __iprt_assert_h__
|
---|
23 |
|
---|
24 | #include <iprt/cdefs.h>
|
---|
25 | #include <iprt/types.h>
|
---|
26 |
|
---|
27 | /** @defgroup grp_rt_assert Assert - Assertions
|
---|
28 | * @ingroup grp_rt
|
---|
29 | * @{
|
---|
30 | */
|
---|
31 |
|
---|
32 |
|
---|
33 | /** @def AssertBreakpoint()
|
---|
34 | * Assertion Breakpoint.
|
---|
35 | *
|
---|
36 | * @remark In the gnu world we add a nop instruction after the int3 to
|
---|
37 | * force gdb to remain at the int3 source line.
|
---|
38 | * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
|
---|
39 | */
|
---|
40 | #ifdef RT_STRICT
|
---|
41 | # ifdef __GNUC__
|
---|
42 | # ifndef __L4ENV__
|
---|
43 | # define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __asm__ __volatile__ ("int3\n\tnop"); } } while (0)
|
---|
44 | # else
|
---|
45 | # define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __asm__ __volatile__ ("int3; jmp 1f; 1:"); } } while (0)
|
---|
46 | # endif
|
---|
47 | # elif defined(_MSC_VER)
|
---|
48 | # define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __debugbreak(); } } while (0)
|
---|
49 | # else
|
---|
50 | # error "Unknown compiler"
|
---|
51 | # endif
|
---|
52 | #else
|
---|
53 | # define AssertBreakpoint() do { } while (0)
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * RTASSERTTYPE is the type the AssertCompile() macro redefines.
|
---|
58 | * It has no other function and shouldn't be used.
|
---|
59 | * Visual C++ uses this.
|
---|
60 | */
|
---|
61 | typedef int RTASSERTTYPE[1];
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * RTASSERTVAR is the type the AssertCompile() macro redefines.
|
---|
65 | * It has no other function and shouldn't be used.
|
---|
66 | * GCC uses this.
|
---|
67 | */
|
---|
68 | #ifdef __GNUC__
|
---|
69 | __BEGIN_DECLS
|
---|
70 | #endif
|
---|
71 | extern int RTASSERTVAR[1];
|
---|
72 | #ifdef __GNUC__
|
---|
73 | __END_DECLS
|
---|
74 | #endif
|
---|
75 |
|
---|
76 | /** @def AssertCompile
|
---|
77 | * Asserts that a compile-time expression is true. If it's not break the build.
|
---|
78 | * @param expr Expression which should be true.
|
---|
79 | */
|
---|
80 | #ifdef __GNUC__
|
---|
81 | # define AssertCompile(expr) extern int RTASSERTVAR[1] __attribute__((unused)), RTASSERTVAR[(expr) ? 1 : 0] __attribute__((unused))
|
---|
82 | #else
|
---|
83 | # define AssertCompile(expr) typedef int RTASSERTTYPE[(expr) ? 1 : 0]
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | /** @def AssertCompileSize
|
---|
87 | * Asserts a size at compile.
|
---|
88 | * @param type The type.
|
---|
89 | * @param size The expected type size.
|
---|
90 | */
|
---|
91 | #define AssertCompileSize(type, size) \
|
---|
92 | AssertCompile(sizeof(type) == (size))
|
---|
93 |
|
---|
94 | /** @def AssertCompileSizeAlignment
|
---|
95 | * Asserts a size alignment at compile.
|
---|
96 | * @param type The type.
|
---|
97 | * @param align The size alignment to assert.
|
---|
98 | */
|
---|
99 | #define AssertCompileSizeAlignment(type, align) \
|
---|
100 | AssertCompile(!(sizeof(type) & ((align) - 1)))
|
---|
101 |
|
---|
102 | /** @def AssertCompileMemberAlignment
|
---|
103 | * Asserts a member offset alignment at compile.
|
---|
104 | * @param type The type.
|
---|
105 | * @param member The member.
|
---|
106 | * @param align The member offset alignment to assert.
|
---|
107 | */
|
---|
108 | #if defined(__GNUC__) && defined(__cplusplus)
|
---|
109 | # if __GNUC__ >= 4
|
---|
110 | # define AssertCompileMemberAlignment(type, member, align) \
|
---|
111 | AssertCompile(!(__builtin_offsetof(type, member) & ((align) - 1)))
|
---|
112 | # else
|
---|
113 | # define AssertCompileMemberAlignment(type, member, align) \
|
---|
114 | AssertCompile(!(RT_OFFSETOF(type, member) & ((align) - 1)))
|
---|
115 | # endif
|
---|
116 | #else
|
---|
117 | # define AssertCompileMemberAlignment(type, member, align) \
|
---|
118 | AssertCompile(!(RT_OFFSETOF(type, member) & ((align) - 1)))
|
---|
119 | #endif
|
---|
120 |
|
---|
121 |
|
---|
122 | /** @def AssertCompileMemberSize
|
---|
123 | * Asserts a member offset alignment at compile.
|
---|
124 | * @param type The type.
|
---|
125 | * @param member The member.
|
---|
126 | * @param size The member size to assert.
|
---|
127 | */
|
---|
128 | #define AssertCompileMemberSize(type, member, size) \
|
---|
129 | AssertCompile(RT_SIZEOFMEMB(type, member) == (size))
|
---|
130 |
|
---|
131 | /** @def AssertCompileMemberSizeAlignment
|
---|
132 | * Asserts a member size alignment at compile.
|
---|
133 | * @param type The type.
|
---|
134 | * @param member The member.
|
---|
135 | * @param align The member size alignment to assert.
|
---|
136 | */
|
---|
137 | #define AssertCompileMemberSizeAlignment(type, member, align) \
|
---|
138 | AssertCompile(!(RT_SIZEOFMEMB(type, member) & ((align) - 1)))
|
---|
139 |
|
---|
140 |
|
---|
141 | /** @def Assert
|
---|
142 | * Assert that an expression is true. If it's not hit breakpoint.
|
---|
143 | * @param expr Expression which should be true.
|
---|
144 | */
|
---|
145 | #ifdef RT_STRICT
|
---|
146 | # define Assert(expr) \
|
---|
147 | do { \
|
---|
148 | if (RT_UNLIKELY(!(expr))) \
|
---|
149 | { \
|
---|
150 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
151 | AssertBreakpoint(); \
|
---|
152 | } \
|
---|
153 | } while (0)
|
---|
154 | #else
|
---|
155 | # define Assert(expr) do { } while (0)
|
---|
156 | #endif
|
---|
157 |
|
---|
158 |
|
---|
159 | /** @def AssertReturn
|
---|
160 | * Assert that an expression is true and returns if it isn't.
|
---|
161 | * In RT_STRICT mode it will hit a breakpoint before returning.
|
---|
162 | *
|
---|
163 | * @param expr Expression which should be true.
|
---|
164 | * @param rc What is to be presented to return.
|
---|
165 | */
|
---|
166 | #ifdef RT_STRICT
|
---|
167 | # define AssertReturn(expr, rc) \
|
---|
168 | do { \
|
---|
169 | if (RT_UNLIKELY(!(expr))) \
|
---|
170 | { \
|
---|
171 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
172 | AssertBreakpoint(); \
|
---|
173 | return (rc); \
|
---|
174 | } \
|
---|
175 | } while (0)
|
---|
176 | #else
|
---|
177 | # define AssertReturn(expr, rc) \
|
---|
178 | do { \
|
---|
179 | if (RT_UNLIKELY(!(expr))) \
|
---|
180 | return (rc); \
|
---|
181 | } while (0)
|
---|
182 | #endif
|
---|
183 |
|
---|
184 | /** @def AssertReturnVoid
|
---|
185 | * Assert that an expression is true and returns if it isn't.
|
---|
186 | * In RT_STRICT mode it will hit a breakpoint before returning.
|
---|
187 | *
|
---|
188 | * @param expr Expression which should be true.
|
---|
189 | */
|
---|
190 | #ifdef RT_STRICT
|
---|
191 | # define AssertReturnVoid(expr) \
|
---|
192 | do { \
|
---|
193 | if (RT_UNLIKELY(!(expr))) \
|
---|
194 | { \
|
---|
195 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
196 | AssertBreakpoint(); \
|
---|
197 | return; \
|
---|
198 | } \
|
---|
199 | } while (0)
|
---|
200 | #else
|
---|
201 | # define AssertReturnVoid(expr) \
|
---|
202 | do { \
|
---|
203 | if (RT_UNLIKELY(!(expr))) \
|
---|
204 | return; \
|
---|
205 | } while (0)
|
---|
206 | #endif
|
---|
207 |
|
---|
208 |
|
---|
209 | /** @def AssertBreak
|
---|
210 | * Assert that an expression is true and breaks if it isn't.
|
---|
211 | * In RT_STRICT mode it will hit a breakpoint before doing break.
|
---|
212 | *
|
---|
213 | * @param expr Expression which should be true.
|
---|
214 | * @param stmt Statement to execute before break in case of a failed assertion.
|
---|
215 | */
|
---|
216 | #ifdef RT_STRICT
|
---|
217 | # define AssertBreak(expr, stmt) \
|
---|
218 | if (RT_UNLIKELY(!(expr))) { \
|
---|
219 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
220 | AssertBreakpoint(); \
|
---|
221 | stmt; \
|
---|
222 | break; \
|
---|
223 | } else do {} while (0)
|
---|
224 | #else
|
---|
225 | # define AssertBreak(expr, stmt) \
|
---|
226 | if (RT_UNLIKELY(!(expr))) { \
|
---|
227 | stmt; \
|
---|
228 | break; \
|
---|
229 | } else do {} while (0)
|
---|
230 | #endif
|
---|
231 |
|
---|
232 |
|
---|
233 | /** @def AssertMsg
|
---|
234 | * Assert that an expression is true. If it's not print message and hit breakpoint.
|
---|
235 | * @param expr Expression which should be true.
|
---|
236 | * @param a printf argument list (in parenthesis).
|
---|
237 | */
|
---|
238 | #ifdef RT_STRICT
|
---|
239 | # define AssertMsg(expr, a) \
|
---|
240 | do { \
|
---|
241 | if (RT_UNLIKELY(!(expr))) \
|
---|
242 | { \
|
---|
243 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
244 | AssertMsg2 a; \
|
---|
245 | AssertBreakpoint(); \
|
---|
246 | } \
|
---|
247 | } while (0)
|
---|
248 | #else
|
---|
249 | # define AssertMsg(expr, a) do { } while (0)
|
---|
250 | #endif
|
---|
251 |
|
---|
252 | /** @def AssertMsgReturn
|
---|
253 | * Assert that an expression is true and returns if it isn't.
|
---|
254 | * In RT_STRICT mode it will hit a breakpoint before returning.
|
---|
255 | *
|
---|
256 | * @param expr Expression which should be true.
|
---|
257 | * @param a printf argument list (in parenthesis).
|
---|
258 | * @param rc What is to be presented to return.
|
---|
259 | */
|
---|
260 | #ifdef RT_STRICT
|
---|
261 | # define AssertMsgReturn(expr, a, rc) \
|
---|
262 | do { \
|
---|
263 | if (RT_UNLIKELY(!(expr))) \
|
---|
264 | { \
|
---|
265 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
266 | AssertMsg2 a; \
|
---|
267 | AssertBreakpoint(); \
|
---|
268 | return (rc); \
|
---|
269 | } \
|
---|
270 | } while (0)
|
---|
271 | #else
|
---|
272 | # define AssertMsgReturn(expr, a, rc) \
|
---|
273 | do { \
|
---|
274 | if (RT_UNLIKELY(!(expr))) \
|
---|
275 | return (rc); \
|
---|
276 | } while (0)
|
---|
277 | #endif
|
---|
278 |
|
---|
279 | /** @def AssertMsgReturnVoid
|
---|
280 | * Assert that an expression is true and returns if it isn't.
|
---|
281 | * In RT_STRICT mode it will hit a breakpoint before returning.
|
---|
282 | *
|
---|
283 | * @param expr Expression which should be true.
|
---|
284 | * @param a printf argument list (in parenthesis).
|
---|
285 | */
|
---|
286 | #ifdef RT_STRICT
|
---|
287 | # define AssertMsgReturnVoid(expr, a) \
|
---|
288 | do { \
|
---|
289 | if (RT_UNLIKELY(!(expr))) \
|
---|
290 | { \
|
---|
291 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
292 | AssertMsg2 a; \
|
---|
293 | AssertBreakpoint(); \
|
---|
294 | return; \
|
---|
295 | } \
|
---|
296 | } while (0)
|
---|
297 | #else
|
---|
298 | # define AssertMsgReturnVoid(expr, a) \
|
---|
299 | do { \
|
---|
300 | if (RT_UNLIKELY(!(expr))) \
|
---|
301 | return; \
|
---|
302 | } while (0)
|
---|
303 | #endif
|
---|
304 |
|
---|
305 |
|
---|
306 | /** @def AssertMsgBreak
|
---|
307 | * Assert that an expression is true and breaks if it isn't.
|
---|
308 | * In RT_STRICT mode it will hit a breakpoint before doing break.
|
---|
309 | *
|
---|
310 | * @param expr Expression which should be true.
|
---|
311 | * @param a printf argument list (in parenthesis).
|
---|
312 | * @param stmt Statement to execute before break in case of a failed assertion.
|
---|
313 | */
|
---|
314 | #ifdef RT_STRICT
|
---|
315 | # define AssertMsgBreak(expr, a, stmt) \
|
---|
316 | if (RT_UNLIKELY(!(expr))) { \
|
---|
317 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
318 | AssertMsg2 a; \
|
---|
319 | AssertBreakpoint(); \
|
---|
320 | stmt; \
|
---|
321 | break; \
|
---|
322 | } else do {} while (0)
|
---|
323 | #else
|
---|
324 | # define AssertMsgBreak(expr, a, stmt) \
|
---|
325 | if (RT_UNLIKELY(!(expr))) { \
|
---|
326 | stmt; \
|
---|
327 | break; \
|
---|
328 | } else do {} while (0)
|
---|
329 | #endif
|
---|
330 |
|
---|
331 |
|
---|
332 | /** @def AssertFailed
|
---|
333 | * An assertion failed hit breakpoint.
|
---|
334 | */
|
---|
335 | #ifdef RT_STRICT
|
---|
336 | # define AssertFailed() \
|
---|
337 | do { \
|
---|
338 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
339 | AssertBreakpoint(); \
|
---|
340 | } while (0)
|
---|
341 | #else
|
---|
342 | # define AssertFailed() do { } while (0)
|
---|
343 | #endif
|
---|
344 |
|
---|
345 | /** @def AssertFailedReturn
|
---|
346 | * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
|
---|
347 | *
|
---|
348 | * @param rc The rc to return.
|
---|
349 | */
|
---|
350 | #ifdef RT_STRICT
|
---|
351 | # define AssertFailedReturn(rc) \
|
---|
352 | do { \
|
---|
353 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
354 | AssertBreakpoint(); \
|
---|
355 | return (rc); \
|
---|
356 | } while (0)
|
---|
357 | #else
|
---|
358 | # define AssertFailedReturn(rc) \
|
---|
359 | do { \
|
---|
360 | return (rc); \
|
---|
361 | } while (0)
|
---|
362 | #endif
|
---|
363 |
|
---|
364 | /** @def AssertFailedReturnVoid
|
---|
365 | * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
|
---|
366 | */
|
---|
367 | #ifdef RT_STRICT
|
---|
368 | # define AssertFailedReturnVoid() \
|
---|
369 | do { \
|
---|
370 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
371 | AssertBreakpoint(); \
|
---|
372 | return; \
|
---|
373 | } while (0)
|
---|
374 | #else
|
---|
375 | # define AssertFailedReturnVoid() \
|
---|
376 | do { \
|
---|
377 | return; \
|
---|
378 | } while (0)
|
---|
379 | #endif
|
---|
380 |
|
---|
381 |
|
---|
382 | /** @def AssertFailedBreak
|
---|
383 | * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
|
---|
384 | * the given statement and break.
|
---|
385 | *
|
---|
386 | * @param stmt Statement to execute before break.
|
---|
387 | */
|
---|
388 | #ifdef RT_STRICT
|
---|
389 | # define AssertFailedBreak(stmt) \
|
---|
390 | if (1) { \
|
---|
391 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
392 | AssertBreakpoint(); \
|
---|
393 | stmt; \
|
---|
394 | break; \
|
---|
395 | } else do {} while (0)
|
---|
396 | #else
|
---|
397 | # define AssertFailedBreak(stmt) \
|
---|
398 | if (1) { \
|
---|
399 | stmt; \
|
---|
400 | break; \
|
---|
401 | } else do {} while (0)
|
---|
402 | #endif
|
---|
403 |
|
---|
404 |
|
---|
405 | /** @def AssertMsgFailed
|
---|
406 | * An assertion failed print a message and a hit breakpoint.
|
---|
407 | *
|
---|
408 | * @param a printf argument list (in parenthesis).
|
---|
409 | */
|
---|
410 | #ifdef RT_STRICT
|
---|
411 | # define AssertMsgFailed(a) \
|
---|
412 | do { \
|
---|
413 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
414 | AssertMsg2 a; \
|
---|
415 | AssertBreakpoint(); \
|
---|
416 | } while (0)
|
---|
417 | #else
|
---|
418 | # define AssertMsgFailed(a) do { } while (0)
|
---|
419 | #endif
|
---|
420 |
|
---|
421 | /** @def AssertMsgFailedReturn
|
---|
422 | * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
|
---|
423 | *
|
---|
424 | * @param a printf argument list (in parenthesis).
|
---|
425 | * @param rc What is to be presented to return.
|
---|
426 | */
|
---|
427 | #ifdef RT_STRICT
|
---|
428 | # define AssertMsgFailedReturn(a, rc) \
|
---|
429 | do { \
|
---|
430 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
431 | AssertMsg2 a; \
|
---|
432 | AssertBreakpoint(); \
|
---|
433 | return (rc); \
|
---|
434 | } while (0)
|
---|
435 | #else
|
---|
436 | # define AssertMsgFailedReturn(a, rc) \
|
---|
437 | do { \
|
---|
438 | return (rc); \
|
---|
439 | } while (0)
|
---|
440 | #endif
|
---|
441 |
|
---|
442 | /** @def AssertMsgFailedReturnVoid
|
---|
443 | * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
|
---|
444 | *
|
---|
445 | * @param a printf argument list (in parenthesis).
|
---|
446 | */
|
---|
447 | #ifdef RT_STRICT
|
---|
448 | # define AssertMsgFailedReturnVoid(a) \
|
---|
449 | do { \
|
---|
450 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
451 | AssertMsg2 a; \
|
---|
452 | AssertBreakpoint(); \
|
---|
453 | return; \
|
---|
454 | } while (0)
|
---|
455 | #else
|
---|
456 | # define AssertMsgFailedReturnVoid(a) \
|
---|
457 | do { \
|
---|
458 | return; \
|
---|
459 | } while (0)
|
---|
460 | #endif
|
---|
461 |
|
---|
462 |
|
---|
463 | /** @def AssertMsgFailedBreak
|
---|
464 | * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
|
---|
465 | * the given statement and break.
|
---|
466 | *
|
---|
467 | * @param a printf argument list (in parenthesis).
|
---|
468 | * @param stmt Statement to execute before break.
|
---|
469 | */
|
---|
470 | #ifdef RT_STRICT
|
---|
471 | # define AssertMsgFailedBreak(a, stmt) \
|
---|
472 | if (1) { \
|
---|
473 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
474 | AssertMsg2 a; \
|
---|
475 | AssertBreakpoint(); \
|
---|
476 | stmt; \
|
---|
477 | break; \
|
---|
478 | } else do {} while (0)
|
---|
479 | #else
|
---|
480 | # define AssertMsgFailedBreak(a, stmt) \
|
---|
481 | if (1) { \
|
---|
482 | stmt; \
|
---|
483 | break; \
|
---|
484 | } else do {} while (0)
|
---|
485 | #endif
|
---|
486 |
|
---|
487 |
|
---|
488 | /** @def AssertReleaseBreakpoint()
|
---|
489 | * Assertion Breakpoint.
|
---|
490 | *
|
---|
491 | * @remark In the gnu world we add a nop instruction after the int3 to
|
---|
492 | * force gdb to remain at the int3 source line.
|
---|
493 | * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
|
---|
494 | */
|
---|
495 | #ifdef __GNUC__
|
---|
496 | # ifndef __L4ENV__
|
---|
497 | # define AssertReleaseBreakpoint() do { __asm__ __volatile__ ("int3\n\tnop"); } while (0)
|
---|
498 | # else
|
---|
499 | # define AssertReleaseBreakpoint() do { __asm__ __volatile__ ("int3; jmp 1f; 1:"); } while (0)
|
---|
500 | # endif
|
---|
501 | #elif defined(_MSC_VER)
|
---|
502 | # define AssertReleaseBreakpoint() __debugbreak()
|
---|
503 | #else
|
---|
504 | # error "Unknown compiler"
|
---|
505 | #endif
|
---|
506 |
|
---|
507 |
|
---|
508 | /** @def AssertRelease
|
---|
509 | * Assert that an expression is true. If it's not hit a breakpoint.
|
---|
510 | *
|
---|
511 | * @param expr Expression which should be true.
|
---|
512 | */
|
---|
513 | #define AssertRelease(expr) \
|
---|
514 | do { \
|
---|
515 | if (RT_UNLIKELY(!(expr))) \
|
---|
516 | { \
|
---|
517 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
518 | AssertReleaseBreakpoint(); \
|
---|
519 | } \
|
---|
520 | } while (0)
|
---|
521 |
|
---|
522 | /** @def AssertReleaseReturn
|
---|
523 | * Assert that an expression is true, hit a breakpoing and return if it isn't.
|
---|
524 | *
|
---|
525 | * @param expr Expression which should be true.
|
---|
526 | * @param rc What is to be presented to return.
|
---|
527 | */
|
---|
528 | #define AssertReleaseReturn(expr, rc) \
|
---|
529 | do { \
|
---|
530 | if (RT_UNLIKELY(!(expr))) \
|
---|
531 | { \
|
---|
532 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
533 | AssertReleaseBreakpoint(); \
|
---|
534 | return (rc); \
|
---|
535 | } \
|
---|
536 | } while (0)
|
---|
537 |
|
---|
538 | /** @def AssertReleaseReturnVoid
|
---|
539 | * Assert that an expression is true, hit a breakpoing and return if it isn't.
|
---|
540 | *
|
---|
541 | * @param expr Expression which should be true.
|
---|
542 | */
|
---|
543 | #define AssertReleaseReturnVoid(expr) \
|
---|
544 | do { \
|
---|
545 | if (RT_UNLIKELY(!(expr))) \
|
---|
546 | { \
|
---|
547 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
548 | AssertReleaseBreakpoint(); \
|
---|
549 | return; \
|
---|
550 | } \
|
---|
551 | } while (0)
|
---|
552 |
|
---|
553 |
|
---|
554 | /** @def AssertReleaseBreak
|
---|
555 | * Assert that an expression is true, hit a breakpoing and break if it isn't.
|
---|
556 | *
|
---|
557 | * @param expr Expression which should be true.
|
---|
558 | * @param stmt Statement to execute before break in case of a failed assertion.
|
---|
559 | */
|
---|
560 | #define AssertReleaseBreak(expr, stmt) \
|
---|
561 | if (RT_UNLIKELY(!(expr))) { \
|
---|
562 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
563 | AssertReleaseBreakpoint(); \
|
---|
564 | stmt; \
|
---|
565 | break; \
|
---|
566 | } else do {} while (0)
|
---|
567 |
|
---|
568 |
|
---|
569 |
|
---|
570 | /** @def AssertReleaseMsg
|
---|
571 | * Assert that an expression is true, print the message and hit a breakpoint if it isn't.
|
---|
572 | *
|
---|
573 | * @param expr Expression which should be true.
|
---|
574 | * @param a printf argument list (in parenthesis).
|
---|
575 | */
|
---|
576 | #define AssertReleaseMsg(expr, a) \
|
---|
577 | do { \
|
---|
578 | if (RT_UNLIKELY(!(expr))) \
|
---|
579 | { \
|
---|
580 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
581 | AssertMsg2 a; \
|
---|
582 | AssertReleaseBreakpoint(); \
|
---|
583 | } \
|
---|
584 | } while (0)
|
---|
585 |
|
---|
586 | /** @def AssertReleaseMsgReturn
|
---|
587 | * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
|
---|
588 | *
|
---|
589 | * @param expr Expression which should be true.
|
---|
590 | * @param a printf argument list (in parenthesis).
|
---|
591 | * @param rc What is to be presented to return.
|
---|
592 | */
|
---|
593 | #define AssertReleaseMsgReturn(expr, a, rc) \
|
---|
594 | do { \
|
---|
595 | if (RT_UNLIKELY(!(expr))) \
|
---|
596 | { \
|
---|
597 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
598 | AssertMsg2 a; \
|
---|
599 | AssertReleaseBreakpoint(); \
|
---|
600 | return (rc); \
|
---|
601 | } \
|
---|
602 | } while (0)
|
---|
603 |
|
---|
604 | /** @def AssertReleaseMsgReturn
|
---|
605 | * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
|
---|
606 | *
|
---|
607 | * @param expr Expression which should be true.
|
---|
608 | * @param a printf argument list (in parenthesis).
|
---|
609 | */
|
---|
610 | #define AssertReleaseMsgReturnVoid(expr, a) \
|
---|
611 | do { \
|
---|
612 | if (RT_UNLIKELY(!(expr))) \
|
---|
613 | { \
|
---|
614 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
615 | AssertMsg2 a; \
|
---|
616 | AssertReleaseBreakpoint(); \
|
---|
617 | return; \
|
---|
618 | } \
|
---|
619 | } while (0)
|
---|
620 |
|
---|
621 |
|
---|
622 | /** @def AssertReleaseMsgBreak
|
---|
623 | * Assert that an expression is true, print the message and hit a breakpoing and break if it isn't.
|
---|
624 | *
|
---|
625 | * @param expr Expression which should be true.
|
---|
626 | * @param a printf argument list (in parenthesis).
|
---|
627 | * @param stmt Statement to execute before break in case of a failed assertion.
|
---|
628 | */
|
---|
629 | #define AssertReleaseMsgBreak(expr, a, stmt) \
|
---|
630 | if (RT_UNLIKELY(!(expr))) { \
|
---|
631 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
632 | AssertMsg2 a; \
|
---|
633 | AssertReleaseBreakpoint(); \
|
---|
634 | stmt; \
|
---|
635 | break; \
|
---|
636 | } else do {} while (0)
|
---|
637 |
|
---|
638 |
|
---|
639 | /** @def AssertReleaseFailed
|
---|
640 | * An assertion failed, hit a breakpoint.
|
---|
641 | */
|
---|
642 | #define AssertReleaseFailed() \
|
---|
643 | do { \
|
---|
644 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
645 | AssertReleaseBreakpoint(); \
|
---|
646 | } while (0)
|
---|
647 |
|
---|
648 | /** @def AssertReleaseFailedReturn
|
---|
649 | * An assertion failed, hit a breakpoint and return.
|
---|
650 | *
|
---|
651 | * @param rc What is to be presented to return.
|
---|
652 | */
|
---|
653 | #define AssertReleaseFailedReturn(rc) \
|
---|
654 | do { \
|
---|
655 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
656 | AssertReleaseBreakpoint(); \
|
---|
657 | return (rc); \
|
---|
658 | } while (0)
|
---|
659 |
|
---|
660 | /** @def AssertReleaseFailedReturn
|
---|
661 | * An assertion failed, hit a breakpoint and return.
|
---|
662 | */
|
---|
663 | #define AssertReleaseFailedReturnVoid() \
|
---|
664 | do { \
|
---|
665 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
666 | AssertReleaseBreakpoint(); \
|
---|
667 | return; \
|
---|
668 | } while (0)
|
---|
669 |
|
---|
670 |
|
---|
671 | /** @def AssertReleaseFailedBreak
|
---|
672 | * An assertion failed, hit a breakpoint and break.
|
---|
673 | *
|
---|
674 | * @param stmt Statement to execute before break.
|
---|
675 | */
|
---|
676 | #define AssertReleaseFailedBreak(stmt) \
|
---|
677 | if (1) { \
|
---|
678 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
679 | AssertReleaseBreakpoint(); \
|
---|
680 | stmt; \
|
---|
681 | break; \
|
---|
682 | } else do {} while (0)
|
---|
683 |
|
---|
684 |
|
---|
685 | /** @def AssertReleaseMsgFailed
|
---|
686 | * An assertion failed, print a message and hit a breakpoint.
|
---|
687 | *
|
---|
688 | * @param a printf argument list (in parenthesis).
|
---|
689 | */
|
---|
690 | #define AssertReleaseMsgFailed(a) \
|
---|
691 | do { \
|
---|
692 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
693 | AssertMsg2 a; \
|
---|
694 | AssertReleaseBreakpoint(); \
|
---|
695 | } while (0)
|
---|
696 |
|
---|
697 | /** @def AssertReleaseMsgFailedReturn
|
---|
698 | * An assertion failed, print a message, hit a breakpoint and return.
|
---|
699 | *
|
---|
700 | * @param a printf argument list (in parenthesis).
|
---|
701 | * @param rc What is to be presented to return.
|
---|
702 | */
|
---|
703 | #define AssertReleaseMsgFailedReturn(a, rc) \
|
---|
704 | do { \
|
---|
705 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
706 | AssertMsg2 a; \
|
---|
707 | AssertReleaseBreakpoint(); \
|
---|
708 | return (rc); \
|
---|
709 | } while (0)
|
---|
710 |
|
---|
711 | /** @def AssertReleaseMsgFailedReturnVoid
|
---|
712 | * An assertion failed, print a message, hit a breakpoint and return.
|
---|
713 | *
|
---|
714 | * @param a printf argument list (in parenthesis).
|
---|
715 | */
|
---|
716 | #define AssertReleaseMsgFailedReturnVoid(a) \
|
---|
717 | do { \
|
---|
718 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
719 | AssertMsg2 a; \
|
---|
720 | AssertReleaseBreakpoint(); \
|
---|
721 | return; \
|
---|
722 | } while (0)
|
---|
723 |
|
---|
724 |
|
---|
725 | /** @def AssertReleaseMsgFailedBreak
|
---|
726 | * An assertion failed, print a message, hit a breakpoint and break.
|
---|
727 | *
|
---|
728 | * @param a printf argument list (in parenthesis).
|
---|
729 | * @param stmt Statement to execute before break.
|
---|
730 | */
|
---|
731 | #define AssertReleaseMsgFailedBreak(a, stmt) \
|
---|
732 | if (1) { \
|
---|
733 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
734 | AssertMsg2 a; \
|
---|
735 | AssertReleaseBreakpoint(); \
|
---|
736 | stmt; \
|
---|
737 | break; \
|
---|
738 | } else do {} while (0)
|
---|
739 |
|
---|
740 |
|
---|
741 |
|
---|
742 | /** @def AssertFatal
|
---|
743 | * Assert that an expression is true. If it's not hit a breakpoint (for ever).
|
---|
744 | *
|
---|
745 | * @param expr Expression which should be true.
|
---|
746 | */
|
---|
747 | #define AssertFatal(expr) \
|
---|
748 | do { \
|
---|
749 | if (RT_UNLIKELY(!(expr))) \
|
---|
750 | for (;;) \
|
---|
751 | { \
|
---|
752 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
753 | AssertReleaseBreakpoint(); \
|
---|
754 | } \
|
---|
755 | } while (0)
|
---|
756 |
|
---|
757 | /** @def AssertFatalMsg
|
---|
758 | * Assert that an expression is true, print the message and hit a breakpoint (for ever) if it isn't.
|
---|
759 | *
|
---|
760 | * @param expr Expression which should be true.
|
---|
761 | * @param a printf argument list (in parenthesis).
|
---|
762 | */
|
---|
763 | #define AssertFatalMsg(expr, a) \
|
---|
764 | do { \
|
---|
765 | if (RT_UNLIKELY(!(expr))) \
|
---|
766 | for (;;) \
|
---|
767 | { \
|
---|
768 | AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
769 | AssertMsg2 a; \
|
---|
770 | AssertReleaseBreakpoint(); \
|
---|
771 | } \
|
---|
772 | } while (0)
|
---|
773 |
|
---|
774 | /** @def AssertFatalFailed
|
---|
775 | * An assertion failed, hit a breakpoint (for ever).
|
---|
776 | */
|
---|
777 | #define AssertFatalFailed() \
|
---|
778 | do { \
|
---|
779 | for (;;) \
|
---|
780 | { \
|
---|
781 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
782 | AssertReleaseBreakpoint(); \
|
---|
783 | } \
|
---|
784 | } while (0)
|
---|
785 |
|
---|
786 | /** @def AssertFatalMsgFailed
|
---|
787 | * An assertion failed, print a message and hit a breakpoint (for ever).
|
---|
788 | *
|
---|
789 | * @param a printf argument list (in parenthesis).
|
---|
790 | */
|
---|
791 | #define AssertFatalMsgFailed(a) \
|
---|
792 | do { \
|
---|
793 | for (;;) \
|
---|
794 | { \
|
---|
795 | AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
|
---|
796 | AssertMsg2 a; \
|
---|
797 | AssertReleaseBreakpoint(); \
|
---|
798 | } \
|
---|
799 | } while (0)
|
---|
800 |
|
---|
801 |
|
---|
802 | /** @def AssertRC
|
---|
803 | * Asserts a iprt status code successful.
|
---|
804 | *
|
---|
805 | * On failure it will print info about the rc and hit a breakpoint.
|
---|
806 | *
|
---|
807 | * @param rc iprt status code.
|
---|
808 | * @remark rc is references multiple times. In release mode is NOREF()'ed.
|
---|
809 | */
|
---|
810 | #define AssertRC(rc) AssertMsgRC(rc, ("%Vra\n", (rc)))
|
---|
811 |
|
---|
812 | /** @def AssertRCReturn
|
---|
813 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
|
---|
814 | *
|
---|
815 | * @param rc iprt status code.
|
---|
816 | * @param rcRet What is to be presented to return.
|
---|
817 | * @remark rc is references multiple times. In release mode is NOREF()'ed.
|
---|
818 | */
|
---|
819 | #define AssertRCReturn(rc, rcRet) AssertMsgRCReturn(rc, ("%Vra\n", (rc)), rcRet)
|
---|
820 |
|
---|
821 | /** @def AssertRCBreak
|
---|
822 | * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
|
---|
823 | *
|
---|
824 | * @param rc iprt status code.
|
---|
825 | * @param stmt Statement to execute before break in case of a failed assertion.
|
---|
826 | * @remark rc is references multiple times. In release mode is NOREF()'ed.
|
---|
827 | */
|
---|
828 | #define AssertRCBreak(rc, stmt) AssertMsgRCBreak(rc, ("%Vra\n", (rc)), stmt)
|
---|
829 |
|
---|
830 | /** @def AssertMsgRC
|
---|
831 | * Asserts a iprt status code successful.
|
---|
832 | *
|
---|
833 | * It prints a custom message and hits a breakpoint on FAILURE.
|
---|
834 | *
|
---|
835 | * @param rc iprt status code.
|
---|
836 | * @param msg printf argument list (in parenthesis).
|
---|
837 | * @remark rc is references multiple times. In release mode is NOREF()'ed.
|
---|
838 | */
|
---|
839 | #define AssertMsgRC(rc, msg) \
|
---|
840 | do { AssertMsg(RT_SUCCESS(rc), msg); NOREF(rc); } while (0)
|
---|
841 |
|
---|
842 | /** @def AssertMsgRCReturn
|
---|
843 | * Asserts a iprt status code successful and if it's not return the specified status code.
|
---|
844 | *
|
---|
845 | * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
|
---|
846 | *
|
---|
847 | * @param rc iprt status code.
|
---|
848 | * @param msg printf argument list (in parenthesis).
|
---|
849 | * @param rcRet What is to be presented to return.
|
---|
850 | * @remark rc is references multiple times. In release mode is NOREF()'ed.
|
---|
851 | */
|
---|
852 | #define AssertMsgRCReturn(rc, msg, rcRet) \
|
---|
853 | do { AssertMsgReturn(RT_SUCCESS(rc), msg, rcRet); NOREF(rc); } while (0)
|
---|
854 |
|
---|
855 | /** @def AssertMsgRCBreak
|
---|
856 | * Asserts a iprt status code successful and break if it's not.
|
---|
857 | *
|
---|
858 | * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
|
---|
859 | *
|
---|
860 | * @param rc iprt status code.
|
---|
861 | * @param msg printf argument list (in parenthesis).
|
---|
862 | * @param stmt Statement to execute before break in case of a failed assertion.
|
---|
863 | * @remark rc is references multiple times. In release mode is NOREF()'ed.
|
---|
864 | */
|
---|
865 | #define AssertMsgRCBreak(rc, msg, stmt) \
|
---|
866 | do { AssertMsgBreak(RT_SUCCESS(rc), msg, stmt); NOREF(rc); } while (0)
|
---|
867 |
|
---|
868 | /** @def AssertRCSuccess
|
---|
869 | * Asserts an iprt status code equals VINF_SUCCESS.
|
---|
870 | *
|
---|
871 | * On failure it will print info about the rc and hit a breakpoint.
|
---|
872 | *
|
---|
873 | * @param rc iprt status code.
|
---|
874 | * @remark rc is references multiple times. In release mode is NOREF()'ed.
|
---|
875 | */
|
---|
876 | #define AssertRCSuccess(rc) AssertMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
|
---|
877 |
|
---|
878 | /** @def AssertRCSuccessReturn
|
---|
879 | * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
|
---|
880 | *
|
---|
881 | * @param rc iprt status code.
|
---|
882 | * @param rcRet What is to be presented to return.
|
---|
883 | * @remark rc is references multiple times. In release mode is NOREF()'ed.
|
---|
884 | */
|
---|
885 | #define AssertRCSuccessReturn(rc, rcRet) AssertMsgReturn((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), rcRet)
|
---|
886 |
|
---|
887 | /** @def AssertRCSuccessBreak
|
---|
888 | * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
|
---|
889 | *
|
---|
890 | * @param rc iprt status code.
|
---|
891 | * @param stmt Statement to execute before break in case of a failed assertion.
|
---|
892 | * @remark rc is references multiple times. In release mode is NOREF()'ed.
|
---|
893 | */
|
---|
894 | #define AssertRCSuccessBreak(rc, stmt) AssertMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
|
---|
895 |
|
---|
896 |
|
---|
897 | /** @def AssertReleaseRC
|
---|
898 | * Asserts a iprt status code successful.
|
---|
899 | *
|
---|
900 | * On failure information about the error will be printed and a breakpoint hit.
|
---|
901 | *
|
---|
902 | * @param rc iprt status code.
|
---|
903 | * @remark rc is references multiple times.
|
---|
904 | */
|
---|
905 | #define AssertReleaseRC(rc) AssertReleaseMsgRC(rc, ("%Vra\n", (rc)))
|
---|
906 |
|
---|
907 | /** @def AssertReleaseRCReturn
|
---|
908 | * Asserts a iprt status code successful, returning if it isn't.
|
---|
909 | *
|
---|
910 | * On failure information about the error will be printed, a breakpoint hit
|
---|
911 | * and finally returning from the function if the breakpoint is somehow ignored.
|
---|
912 | *
|
---|
913 | * @param rc iprt status code.
|
---|
914 | * @param rcRet What is to be presented to return.
|
---|
915 | * @remark rc is references multiple times.
|
---|
916 | */
|
---|
917 | #define AssertReleaseRCReturn(rc, rcRet) AssertReleaseMsgRCReturn(rc, ("%Vra\n", (rc)), rcRet)
|
---|
918 |
|
---|
919 | /** @def AssertReleaseRCBreak
|
---|
920 | * Asserts a iprt status code successful, break if it isn't.
|
---|
921 | *
|
---|
922 | * On failure information about the error will be printed, a breakpoint hit
|
---|
923 | * and finally the break statement will be issued if the breakpoint is somehow ignored.
|
---|
924 | *
|
---|
925 | * @param rc iprt status code.
|
---|
926 | * @param stmt Statement to execute before break in case of a failed assertion.
|
---|
927 | * @remark rc is references multiple times.
|
---|
928 | */
|
---|
929 | #define AssertReleaseRCBreak(rc, stmt) AssertReleaseMsgRCBreak(rc, ("%Vra\n", (rc)), stmt)
|
---|
930 |
|
---|
931 | /** @def AssertReleaseMsgRC
|
---|
932 | * Asserts a iprt status code successful.
|
---|
933 | *
|
---|
934 | * On failure a custom message is printed and a breakpoint is hit.
|
---|
935 | *
|
---|
936 | * @param rc iprt status code.
|
---|
937 | * @param msg printf argument list (in parenthesis).
|
---|
938 | * @remark rc is references multiple times.
|
---|
939 | */
|
---|
940 | #define AssertReleaseMsgRC(rc, msg) AssertReleaseMsg(RT_SUCCESS(rc), msg)
|
---|
941 |
|
---|
942 | /** @def AssertReleaseMsgRCReturn
|
---|
943 | * Asserts a iprt status code successful.
|
---|
944 | *
|
---|
945 | * On failure a custom message is printed, a breakpoint is hit, and finally
|
---|
946 | * returning from the function if the breakpoint is showhow ignored.
|
---|
947 | *
|
---|
948 | * @param rc iprt status code.
|
---|
949 | * @param msg printf argument list (in parenthesis).
|
---|
950 | * @param rcRet What is to be presented to return.
|
---|
951 | * @remark rc is references multiple times.
|
---|
952 | */
|
---|
953 | #define AssertReleaseMsgRCReturn(rc, msg, rcRet) AssertReleaseMsgReturn(RT_SUCCESS(rc), msg, rcRet)
|
---|
954 |
|
---|
955 | /** @def AssertReleaseMsgRCBreak
|
---|
956 | * Asserts a iprt status code successful.
|
---|
957 | *
|
---|
958 | * On failure a custom message is printed, a breakpoint is hit, and finally
|
---|
959 | * the brean statement is issued if the breakpoint is showhow ignored.
|
---|
960 | *
|
---|
961 | * @param rc iprt status code.
|
---|
962 | * @param msg printf argument list (in parenthesis).
|
---|
963 | * @param stmt Statement to execute before break in case of a failed assertion.
|
---|
964 | * @remark rc is references multiple times.
|
---|
965 | */
|
---|
966 | #define AssertReleaseMsgRCBreak(rc, msg, stmt) AssertReleaseMsgBreak(RT_SUCCESS(rc), msg, stmt)
|
---|
967 |
|
---|
968 | /** @def AssertReleaseRCSuccess
|
---|
969 | * Asserts that an iprt status code equals VINF_SUCCESS.
|
---|
970 | *
|
---|
971 | * On failure information about the error will be printed and a breakpoint hit.
|
---|
972 | *
|
---|
973 | * @param rc iprt status code.
|
---|
974 | * @remark rc is references multiple times.
|
---|
975 | */
|
---|
976 | #define AssertReleaseRCSuccess(rc) AssertReleaseMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
|
---|
977 |
|
---|
978 | /** @def AssertReleaseRCSuccessReturn
|
---|
979 | * Asserts that an iprt status code equals VINF_SUCCESS.
|
---|
980 | *
|
---|
981 | * On failure information about the error will be printed, a breakpoint hit
|
---|
982 | * and finally returning from the function if the breakpoint is somehow ignored.
|
---|
983 | *
|
---|
984 | * @param rc iprt status code.
|
---|
985 | * @param rcRet What is to be presented to return.
|
---|
986 | * @remark rc is references multiple times.
|
---|
987 | */
|
---|
988 | #define AssertReleaseRCSuccessReturn(rc, rcRet) AssertReleaseMsgReturn((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), rcRet)
|
---|
989 |
|
---|
990 | /** @def AssertReleaseRCSuccessBreak
|
---|
991 | * Asserts that an iprt status code equals VINF_SUCCESS.
|
---|
992 | *
|
---|
993 | * On failure information about the error will be printed, a breakpoint hit
|
---|
994 | * and finally the break statement will be issued if the breakpoint is somehow ignored.
|
---|
995 | *
|
---|
996 | * @param rc iprt status code.
|
---|
997 | * @param stmt Statement to execute before break in case of a failed assertion.
|
---|
998 | * @remark rc is references multiple times.
|
---|
999 | */
|
---|
1000 | #define AssertReleaseRCSuccessBreak(rc, stmt) AssertReleaseMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
|
---|
1001 |
|
---|
1002 |
|
---|
1003 | /** @def AssertFatalRC
|
---|
1004 | * Asserts a iprt status code successful.
|
---|
1005 | *
|
---|
1006 | * On failure information about the error will be printed and a breakpoint hit.
|
---|
1007 | *
|
---|
1008 | * @param rc iprt status code.
|
---|
1009 | * @remark rc is references multiple times.
|
---|
1010 | */
|
---|
1011 | #define AssertFatalRC(rc) AssertFatalMsgRC(rc, ("%Vra\n", (rc)))
|
---|
1012 |
|
---|
1013 | /** @def AssertReleaseMsgRC
|
---|
1014 | * Asserts a iprt status code successful.
|
---|
1015 | *
|
---|
1016 | * On failure a custom message is printed and a breakpoint is hit.
|
---|
1017 | *
|
---|
1018 | * @param rc iprt status code.
|
---|
1019 | * @param msg printf argument list (in parenthesis).
|
---|
1020 | * @remark rc is references multiple times.
|
---|
1021 | */
|
---|
1022 | #define AssertFatalMsgRC(rc, msg) AssertFatalMsg(RT_SUCCESS(rc), msg)
|
---|
1023 |
|
---|
1024 | /** @def AssertFatalRCSuccess
|
---|
1025 | * Asserts that an iprt status code equals VINF_SUCCESS.
|
---|
1026 | *
|
---|
1027 | * On failure information about the error will be printed and a breakpoint hit.
|
---|
1028 | *
|
---|
1029 | * @param rc iprt status code.
|
---|
1030 | * @remark rc is references multiple times.
|
---|
1031 | */
|
---|
1032 | #define AssertFatalRCSuccess(rc) AssertFatalMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
|
---|
1033 |
|
---|
1034 |
|
---|
1035 | /** @def AssertPtr
|
---|
1036 | * Asserts that a pointer is valid.
|
---|
1037 | *
|
---|
1038 | * @param pv The pointer.
|
---|
1039 | */
|
---|
1040 | #define AssertPtr(pv) AssertMsg(VALID_PTR(pv), ("%p\n", (pv)))
|
---|
1041 |
|
---|
1042 | /** @def AssertPtrReturn
|
---|
1043 | * Asserts that a pointer is valid.
|
---|
1044 | *
|
---|
1045 | * @param pv The pointer.
|
---|
1046 | * @param rcRet What is to be presented to return.
|
---|
1047 | */
|
---|
1048 | #define AssertPtrReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv), ("%p\n", (pv)), rcRet)
|
---|
1049 |
|
---|
1050 | /** @def AssertPtrBreak
|
---|
1051 | * Asserts that a pointer is valid.
|
---|
1052 | *
|
---|
1053 | * @param pv The pointer.
|
---|
1054 | * @param stmt Statement to execute before break in case of a failed assertion.
|
---|
1055 | */
|
---|
1056 | #define AssertPtrBreak(pv, stmt) AssertMsgBreak(VALID_PTR(pv), ("%p\n", (pv)), stmt)
|
---|
1057 |
|
---|
1058 | /** @def AssertPtrNull
|
---|
1059 | * Asserts that a pointer is valid or NULL.
|
---|
1060 | *
|
---|
1061 | * @param pv The pointer.
|
---|
1062 | */
|
---|
1063 | #define AssertPtrNull(pv) AssertMsg(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
|
---|
1064 |
|
---|
1065 | /** @def AssertPtrNullReturn
|
---|
1066 | * Asserts that a pointer is valid or NULL.
|
---|
1067 | *
|
---|
1068 | * @param pv The pointer.
|
---|
1069 | * @param rcRet What is to be presented to return.
|
---|
1070 | */
|
---|
1071 | #define AssertPtrNullReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), rcRet)
|
---|
1072 |
|
---|
1073 | /** @def AssertPtrNullBreak
|
---|
1074 | * Asserts that a pointer is valid or NULL.
|
---|
1075 | *
|
---|
1076 | * @param pv The pointer.
|
---|
1077 | * @param stmt Statement to execute before break in case of a failed assertion.
|
---|
1078 | */
|
---|
1079 | #define AssertPtrNullBreak(pv, stmt) AssertMsgBreak(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt)
|
---|
1080 |
|
---|
1081 |
|
---|
1082 | __BEGIN_DECLS
|
---|
1083 |
|
---|
1084 | /**
|
---|
1085 | * The 1st part of an assert message.
|
---|
1086 | *
|
---|
1087 | * @param pszExpr Expression. Can be NULL.
|
---|
1088 | * @param uLine Location line number.
|
---|
1089 | * @param pszFile Location file name.
|
---|
1090 | * @param pszFunction Location function name.
|
---|
1091 | * @remark This API exists in HC Ring-3 and GC.
|
---|
1092 | */
|
---|
1093 | RTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction);
|
---|
1094 |
|
---|
1095 | /**
|
---|
1096 | * The 2nd (optional) part of an assert message.
|
---|
1097 | * @param pszFormat Printf like format string.
|
---|
1098 | * @param ... Arguments to that string.
|
---|
1099 | * @remark This API exists in HC Ring-3 and GC.
|
---|
1100 | */
|
---|
1101 | RTDECL(void) AssertMsg2(const char *pszFormat, ...);
|
---|
1102 |
|
---|
1103 | /**
|
---|
1104 | * Overridable function that decides whether assertions executes the breakpoint or not.
|
---|
1105 | *
|
---|
1106 | * The generic implementation will return true.
|
---|
1107 | *
|
---|
1108 | * @returns true if the breakpoint should be hit, false if it should be ignored.
|
---|
1109 | * @remark The RTDECL() makes this a bit difficult to override on windows. Sorry.
|
---|
1110 | */
|
---|
1111 | RTDECL(bool) RTAssertDoBreakpoint(void);
|
---|
1112 |
|
---|
1113 |
|
---|
1114 | /** The last assert message, 1st part. */
|
---|
1115 | extern RTDATADECL(char) g_szRTAssertMsg1[1024];
|
---|
1116 | /** The last assert message, 2nd part. */
|
---|
1117 | extern RTDATADECL(char) g_szRTAssertMsg2[2048];
|
---|
1118 |
|
---|
1119 | __END_DECLS
|
---|
1120 |
|
---|
1121 | /** @} */
|
---|
1122 |
|
---|
1123 | #endif
|
---|
1124 |
|
---|