VirtualBox

source: vbox/trunk/include/iprt/assert.h@ 7340

Last change on this file since 7340 was 7170, checked in by vboxsync, 17 years ago

Doxygen fixes. (DOXYGEN -> DOXYGEN_RUNNING, ++)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 63.5 KB
Line 
1/** @file
2 * innotek Portable Runtime - Assertions.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek 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 (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_assert_h
27#define ___iprt_assert_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31
32/** @defgroup grp_rt_assert Assert - Assertions
33 * @ingroup grp_rt
34 *
35 * Assertions are generally used to check precoditions and other
36 * assumptions. Sometimes it is also used to catch odd errors or errors
37 * that one would like to inspect in the debugger. They should not be
38 * used for errors that happen frequently.
39 *
40 * IPRT provides a host of assertion macros, so many that it can be a bit
41 * overwhelming at first. Don't despair, there is a system (surprise).
42 *
43 * First there are four families of assertions:
44 * - Assert - The normal strict build only assertions.
45 * - AssertLogRel - Calls LogRel() in non-strict builds, otherwise like Assert.
46 * - AssertRelease - Triggers in all builds.
47 * - AssertFatal - Triggers in all builds and cannot be continued.
48 *
49 * Then there are variations wrt to argument list and behavior on failure:
50 * - Msg - Custom RTStrPrintf-like message with the assertion message.
51 * - Return - Return the specific rc on failure.
52 * - ReturnVoid - Return (void) on failure.
53 * - Break - Break (out of switch/loop) on failure.
54 * - Stmt - Execute the specified statment(s) on failure.
55 * - RC - Assert RT_SUCCESS.
56 * - RCSuccess - Assert VINF_SUCCESS.
57 *
58 * In additions there is a very special familiy AssertCompile that can be
59 * used for some limited compile checking. Like structure sizes and member
60 * alignment. This family doesn't have the same variations.
61 *
62 *
63 * @remarks As you might've noticed, the macros doesn't follow the
64 * coding guidelines wrt to macros supposedly being all uppercase
65 * and underscored. For various reasons they don't, and it nobody
66 * has complained yet. Wonder why... :-)
67 *
68 * @remarks Each project has its own specific guidelines on how to use
69 * assertions, so the above is just trying to give you the general idea
70 * from the IPRT point of view.
71 *
72 * @{
73 */
74
75
76/** @def AssertBreakpoint()
77 * Assertion Breakpoint.
78 *
79 * @remark In the gnu world we add a nop instruction after the int3 to
80 * force gdb to remain at the int3 source line.
81 * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
82 */
83#ifdef RT_STRICT
84# ifdef __GNUC__
85# ifndef __L4ENV__
86# define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __asm__ __volatile__ ("int3\n\tnop"); } } while (0)
87# else
88# define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __asm__ __volatile__ ("int3; jmp 1f; 1:"); } } while (0)
89# endif
90# elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
91# define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __debugbreak(); } } while (0)
92# else
93# error "Unknown compiler"
94# endif
95#else
96# define AssertBreakpoint() do { } while (0)
97#endif
98
99/**
100 * RTASSERTTYPE is the type the AssertCompile() macro redefines.
101 * It has no other function and shouldn't be used.
102 * Visual C++ uses this.
103 */
104typedef int RTASSERTTYPE[1];
105
106/**
107 * RTASSERTVAR is the type the AssertCompile() macro redefines.
108 * It has no other function and shouldn't be used.
109 * GCC uses this.
110 */
111#ifdef __GNUC__
112__BEGIN_DECLS
113#endif
114extern int RTASSERTVAR[1];
115#ifdef __GNUC__
116__END_DECLS
117#endif
118
119/** @def AssertCompile
120 * Asserts that a compile-time expression is true. If it's not break the build.
121 * @param expr Expression which should be true.
122 */
123#ifdef __GNUC__
124# define AssertCompile(expr) extern int RTASSERTVAR[1] __attribute__((unused)), RTASSERTVAR[(expr) ? 1 : 0] __attribute__((unused))
125#else
126# define AssertCompile(expr) typedef int RTASSERTTYPE[(expr) ? 1 : 0]
127#endif
128
129/** @def AssertCompileSize
130 * Asserts a size at compile.
131 * @param type The type.
132 * @param size The expected type size.
133 */
134#define AssertCompileSize(type, size) \
135 AssertCompile(sizeof(type) == (size))
136
137/** @def AssertCompileSizeAlignment
138 * Asserts a size alignment at compile.
139 * @param type The type.
140 * @param align The size alignment to assert.
141 */
142#define AssertCompileSizeAlignment(type, align) \
143 AssertCompile(!(sizeof(type) & ((align) - 1)))
144
145/** @def AssertCompileMemberAlignment
146 * Asserts a member offset alignment at compile.
147 * @param type The type.
148 * @param member The member.
149 * @param align The member offset alignment to assert.
150 */
151#if defined(__GNUC__) && defined(__cplusplus)
152# if __GNUC__ >= 4
153# define AssertCompileMemberAlignment(type, member, align) \
154 AssertCompile(!(__builtin_offsetof(type, member) & ((align) - 1)))
155# else
156# define AssertCompileMemberAlignment(type, member, align) \
157 AssertCompile(!(RT_OFFSETOF(type, member) & ((align) - 1)))
158# endif
159#else
160# define AssertCompileMemberAlignment(type, member, align) \
161 AssertCompile(!(RT_OFFSETOF(type, member) & ((align) - 1)))
162#endif
163
164
165/** @def AssertCompileMemberSize
166 * Asserts a member offset alignment at compile.
167 * @param type The type.
168 * @param member The member.
169 * @param size The member size to assert.
170 */
171#define AssertCompileMemberSize(type, member, size) \
172 AssertCompile(RT_SIZEOFMEMB(type, member) == (size))
173
174/** @def AssertCompileMemberSizeAlignment
175 * Asserts a member size alignment at compile.
176 * @param type The type.
177 * @param member The member.
178 * @param align The member size alignment to assert.
179 */
180#define AssertCompileMemberSizeAlignment(type, member, align) \
181 AssertCompile(!(RT_SIZEOFMEMB(type, member) & ((align) - 1)))
182
183
184/** @def Assert
185 * Assert that an expression is true. If it's not hit breakpoint.
186 * @param expr Expression which should be true.
187 */
188#ifdef RT_STRICT
189# define Assert(expr) \
190 do { \
191 if (RT_UNLIKELY(!(expr))) \
192 { \
193 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
194 AssertBreakpoint(); \
195 } \
196 } while (0)
197#else
198# define Assert(expr) do { } while (0)
199#endif
200
201
202/** @def AssertReturn
203 * Assert that an expression is true and returns if it isn't.
204 * In RT_STRICT mode it will hit a breakpoint before returning.
205 *
206 * @param expr Expression which should be true.
207 * @param rc What is to be presented to return.
208 */
209#ifdef RT_STRICT
210# define AssertReturn(expr, rc) \
211 do { \
212 if (RT_UNLIKELY(!(expr))) \
213 { \
214 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
215 AssertBreakpoint(); \
216 return (rc); \
217 } \
218 } while (0)
219#else
220# define AssertReturn(expr, rc) \
221 do { \
222 if (RT_UNLIKELY(!(expr))) \
223 return (rc); \
224 } while (0)
225#endif
226
227/** @def AssertReturnVoid
228 * Assert that an expression is true and returns if it isn't.
229 * In RT_STRICT mode it will hit a breakpoint before returning.
230 *
231 * @param expr Expression which should be true.
232 */
233#ifdef RT_STRICT
234# define AssertReturnVoid(expr) \
235 do { \
236 if (RT_UNLIKELY(!(expr))) \
237 { \
238 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
239 AssertBreakpoint(); \
240 return; \
241 } \
242 } while (0)
243#else
244# define AssertReturnVoid(expr) \
245 do { \
246 if (RT_UNLIKELY(!(expr))) \
247 return; \
248 } while (0)
249#endif
250
251
252/** @def AssertBreak
253 * Assert that an expression is true and breaks if it isn't.
254 * In RT_STRICT mode it will hit a breakpoint before doing break.
255 *
256 * @param expr Expression which should be true.
257 * @param stmt Statement to execute before break in case of a failed assertion.
258 */
259#ifdef RT_STRICT
260# define AssertBreak(expr, stmt) \
261 if (RT_UNLIKELY(!(expr))) { \
262 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
263 AssertBreakpoint(); \
264 stmt; \
265 break; \
266 } else do {} while (0)
267#else
268# define AssertBreak(expr, stmt) \
269 if (RT_UNLIKELY(!(expr))) { \
270 stmt; \
271 break; \
272 } else do {} while (0)
273#endif
274
275/** @def AssertBreakVoid
276 * Assert that an expression is true and breaks if it isn't.
277 * In RT_STRICT mode it will hit a breakpoint before returning.
278 *
279 * @param expr Expression which should be true.
280 * @todo Rename to AssertBreak.
281 * @todo broken, use if.
282 */
283#ifdef RT_STRICT
284# define AssertBreakVoid(expr) \
285 do { \
286 if (RT_UNLIKELY(!(expr))) \
287 { \
288 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
289 AssertBreakpoint(); \
290 break; \
291 } \
292 } while (0)
293#else
294# define AssertBreakVoid(expr) \
295 do { \
296 if (RT_UNLIKELY(!(expr))) \
297 break; \
298 } while (0)
299#endif
300
301
302/** @def AssertMsg
303 * Assert that an expression is true. If it's not print message and hit breakpoint.
304 * @param expr Expression which should be true.
305 * @param a printf argument list (in parenthesis).
306 */
307#ifdef RT_STRICT
308# define AssertMsg(expr, a) \
309 do { \
310 if (RT_UNLIKELY(!(expr))) \
311 { \
312 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
313 AssertMsg2 a; \
314 AssertBreakpoint(); \
315 } \
316 } while (0)
317#else
318# define AssertMsg(expr, a) do { } while (0)
319#endif
320
321/** @def AssertMsgReturn
322 * Assert that an expression is true and returns if it isn't.
323 * In RT_STRICT mode it will hit a breakpoint before returning.
324 *
325 * @param expr Expression which should be true.
326 * @param a printf argument list (in parenthesis).
327 * @param rc What is to be presented to return.
328 */
329#ifdef RT_STRICT
330# define AssertMsgReturn(expr, a, rc) \
331 do { \
332 if (RT_UNLIKELY(!(expr))) \
333 { \
334 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
335 AssertMsg2 a; \
336 AssertBreakpoint(); \
337 return (rc); \
338 } \
339 } while (0)
340#else
341# define AssertMsgReturn(expr, a, rc) \
342 do { \
343 if (RT_UNLIKELY(!(expr))) \
344 return (rc); \
345 } while (0)
346#endif
347
348/** @def AssertMsgReturnVoid
349 * Assert that an expression is true and returns if it isn't.
350 * In RT_STRICT mode it will hit a breakpoint before returning.
351 *
352 * @param expr Expression which should be true.
353 * @param a printf argument list (in parenthesis).
354 */
355#ifdef RT_STRICT
356# define AssertMsgReturnVoid(expr, a) \
357 do { \
358 if (RT_UNLIKELY(!(expr))) \
359 { \
360 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
361 AssertMsg2 a; \
362 AssertBreakpoint(); \
363 return; \
364 } \
365 } while (0)
366#else
367# define AssertMsgReturnVoid(expr, a) \
368 do { \
369 if (RT_UNLIKELY(!(expr))) \
370 return; \
371 } while (0)
372#endif
373
374
375/** @def AssertMsgBreak
376 * Assert that an expression is true and breaks if it isn't.
377 * In RT_STRICT mode it will hit a breakpoint before doing break.
378 *
379 * @param expr Expression which should be true.
380 * @param a printf argument list (in parenthesis).
381 * @param stmt Statement to execute before break in case of a failed assertion.
382 * @todo Rename to AssertMsgBreakStmt.
383 */
384#ifdef RT_STRICT
385# define AssertMsgBreak(expr, a, stmt) \
386 if (RT_UNLIKELY(!(expr))) { \
387 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
388 AssertMsg2 a; \
389 AssertBreakpoint(); \
390 stmt; \
391 break; \
392 } else do {} while (0)
393#else
394# define AssertMsgBreak(expr, a, stmt) \
395 if (RT_UNLIKELY(!(expr))) { \
396 stmt; \
397 break; \
398 } else do {} while (0)
399#endif
400
401/** @def AssertMsgBreakVoid
402 * Assert that an expression is true and breaks if it isn't.
403 * In RT_STRICT mode it will hit a breakpoint before returning.
404 *
405 * @param expr Expression which should be true.
406 * @param a printf argument list (in parenthesis).
407 * @todo Rename to AssertMsgBreak.
408 * @todo broken, use if.
409 */
410#ifdef RT_STRICT
411# define AssertMsgBreakVoid(expr, a) \
412 do { \
413 if (RT_UNLIKELY(!(expr))) \
414 { \
415 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
416 AssertMsg2 a; \
417 AssertBreakpoint(); \
418 break; \
419 } \
420 } while (0)
421#else
422# define AssertMsgBreakVoid(expr, a) \
423 do { \
424 if (RT_UNLIKELY(!(expr))) \
425 break; \
426 } while (0)
427#endif
428
429
430/** @def AssertFailed
431 * An assertion failed hit breakpoint.
432 */
433#ifdef RT_STRICT
434# define AssertFailed() \
435 do { \
436 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
437 AssertBreakpoint(); \
438 } while (0)
439#else
440# define AssertFailed() do { } while (0)
441#endif
442
443/** @def AssertFailedReturn
444 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
445 *
446 * @param rc The rc to return.
447 */
448#ifdef RT_STRICT
449# define AssertFailedReturn(rc) \
450 do { \
451 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
452 AssertBreakpoint(); \
453 return (rc); \
454 } while (0)
455#else
456# define AssertFailedReturn(rc) \
457 do { \
458 return (rc); \
459 } while (0)
460#endif
461
462/** @def AssertFailedReturnVoid
463 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
464 */
465#ifdef RT_STRICT
466# define AssertFailedReturnVoid() \
467 do { \
468 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
469 AssertBreakpoint(); \
470 return; \
471 } while (0)
472#else
473# define AssertFailedReturnVoid() \
474 do { \
475 return; \
476 } while (0)
477#endif
478
479
480/** @def AssertFailedBreak
481 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
482 * the given statement and break.
483 *
484 * @param stmt Statement to execute before break.
485 * @todo Rename to AssertFailedBreakStmt.
486 */
487#ifdef RT_STRICT
488# define AssertFailedBreak(stmt) \
489 if (1) { \
490 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
491 AssertBreakpoint(); \
492 stmt; \
493 break; \
494 } else do {} while (0)
495#else
496# define AssertFailedBreak(stmt) \
497 if (1) { \
498 stmt; \
499 break; \
500 } else do {} while (0)
501#endif
502
503/** @def AssertFailedBreakVoid
504 * An assertion failed, hit breakpoint (RT_STRICT mode only) and break.
505 * @todo Rename to AssertFailedBreak.
506 */
507#ifdef RT_STRICT
508# define AssertFailedBreakVoid() \
509 do { \
510 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
511 AssertBreakpoint(); \
512 break; \
513 } while (0)
514#else
515# define AssertFailedBreakVoid() \
516 do { \
517 break; \
518 } while (0)
519#endif
520
521
522/** @def AssertMsgFailed
523 * An assertion failed print a message and a hit breakpoint.
524 *
525 * @param a printf argument list (in parenthesis).
526 */
527#ifdef RT_STRICT
528# define AssertMsgFailed(a) \
529 do { \
530 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
531 AssertMsg2 a; \
532 AssertBreakpoint(); \
533 } while (0)
534#else
535# define AssertMsgFailed(a) do { } while (0)
536#endif
537
538/** @def AssertMsgFailedReturn
539 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
540 *
541 * @param a printf argument list (in parenthesis).
542 * @param rc What is to be presented to return.
543 */
544#ifdef RT_STRICT
545# define AssertMsgFailedReturn(a, rc) \
546 do { \
547 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
548 AssertMsg2 a; \
549 AssertBreakpoint(); \
550 return (rc); \
551 } while (0)
552#else
553# define AssertMsgFailedReturn(a, rc) \
554 do { \
555 return (rc); \
556 } while (0)
557#endif
558
559/** @def AssertMsgFailedReturnVoid
560 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
561 *
562 * @param a printf argument list (in parenthesis).
563 */
564#ifdef RT_STRICT
565# define AssertMsgFailedReturnVoid(a) \
566 do { \
567 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
568 AssertMsg2 a; \
569 AssertBreakpoint(); \
570 return; \
571 } while (0)
572#else
573# define AssertMsgFailedReturnVoid(a) \
574 do { \
575 return; \
576 } while (0)
577#endif
578
579
580/** @def AssertMsgFailedBreak
581 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
582 * the given statement and break.
583 *
584 * @param a printf argument list (in parenthesis).
585 * @param stmt Statement to execute before break.
586 * @todo Rename to AssertMsgFailedBreakStmt.
587 */
588#ifdef RT_STRICT
589# define AssertMsgFailedBreak(a, stmt) \
590 if (1) { \
591 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
592 AssertMsg2 a; \
593 AssertBreakpoint(); \
594 stmt; \
595 break; \
596 } else do {} while (0)
597#else
598# define AssertMsgFailedBreak(a, stmt) \
599 if (1) { \
600 stmt; \
601 break; \
602 } else do {} while (0)
603#endif
604
605/** @def AssertMsgFailedBreakVoid
606 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and break.
607 *
608 * @param a printf argument list (in parenthesis).
609 * @todo Rename to AssertMsgFailedBreak.
610 * @todo broken
611 */
612#ifdef RT_STRICT
613# define AssertMsgFailedBreakVoid(a) \
614 do { \
615 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
616 AssertMsg2 a; \
617 AssertBreakpoint(); \
618 break; \
619 } while (0)
620#else
621# define AssertMsgFailedBreakVoid(a) \
622 do { \
623 break; \
624 } while (0)
625#endif
626
627
628
629/** @def AssertLogRelBreakpoint()
630 * Assertion LogRel Breakpoint.
631 *
632 * NOP in non-strict (release) builds, hardware breakpoint in strict builds,
633 *
634 * @remark In the gnu world we add a nop instruction after the int3 to
635 * force gdb to remain at the int3 source line.
636 * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
637 */
638#ifdef RT_STRICT
639# ifdef __GNUC__
640# ifndef __L4ENV__
641# define AssertLogRelBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3\n\tnop"); } while (0)
642# else
643# define AssertLogRelBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3; jmp 1f; 1:"); } while (0)
644# endif
645# elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
646# define AssertLogRelBreakpoint() do { RTAssertDoBreakpoint(); __debugbreak(); } while (0)
647# else
648# error "Unknown compiler"
649# endif
650#else /* !RT_STRICT */
651# define AssertLogRelBreakpoint() do { } while (0)
652#endif /* !RT_STRICT */
653
654
655/** @def AssertLogRelMsg1
656 * AssertMsg1 (strict builds) / LogRel wrapper (non-strict).
657 */
658#ifdef RT_STRICT
659# define AssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
660 AssertMsg1(pszExpr, iLine, pszFile, pszFunction)
661#else
662# define AssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
663 LogRel(("AssertLogRel %s(%d): %s\n",\
664 (pszFile), (iLine), (pszFile), (pszFunction), (pszExpr) ))
665#endif
666
667/** @def AssertLogRelMsg2
668 * AssertMsg2 (strict builds) / LogRel wrapper (non-strict).
669 */
670#ifdef RT_STRICT
671# define AssertLogRelMsg2(a) AssertMsg2 a
672#else
673# define AssertLogRelMsg2(a) LogRel(a)
674#endif
675
676/** @def AssertLogRel
677 * Assert that an expression is true.
678 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
679 *
680 * @param expr Expression which should be true.
681 */
682#define AssertLogRel(expr) \
683 do { \
684 if (RT_UNLIKELY(!(expr))) \
685 { \
686 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
687 AssertLogRelBreakpoint(); \
688 } \
689 } while (0)
690
691/** @def AssertLogRelReturn
692 * Assert that an expression is true, return \a rc if it isn't.
693 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
694 *
695 * @param expr Expression which should be true.
696 * @param rc What is to be presented to return.
697 */
698#define AssertLogRelReturn(expr, rc) \
699 do { \
700 if (RT_UNLIKELY(!(expr))) \
701 { \
702 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
703 AssertLogRelBreakpoint(); \
704 return (rc); \
705 } \
706 } while (0)
707
708/** @def AssertLogRelReturnVoid
709 * Assert that an expression is true, return void if it isn't.
710 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
711 *
712 * @param expr Expression which should be true.
713 */
714#define AssertLogRelReturnVoid(expr) \
715 do { \
716 if (RT_UNLIKELY(!(expr))) \
717 { \
718 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
719 AssertLogRelBreakpoint(); \
720 return; \
721 } \
722 } while (0)
723
724/** @def AssertLogRelBreak
725 * Assert that an expression is true, break if it isn't.
726 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
727 *
728 * @param expr Expression which should be true.
729 */
730#define AssertLogRelBreak(expr) \
731 if (RT_UNLIKELY(!(expr))) \
732 { \
733 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
734 AssertLogRelBreakpoint(); \
735 break; \
736 } \
737 else do {} while (0)
738
739/** @def AssertLogRelBreakStmt
740 * Assert that an expression is true, execute \a stmt and break if it isn't.
741 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
742 *
743 * @param expr Expression which should be true.
744 * @param stmt Statement to execute before break in case of a failed assertion.
745 */
746#define AssertLogRelBreakStmt(expr, stmt) \
747 if (RT_UNLIKELY(!(expr))) \
748 { \
749 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
750 AssertLogRelBreakpoint(); \
751 stmt; \
752 break; \
753 } else do {} while (0)
754
755/** @def AssertLogRelMsg
756 * Assert that an expression is true.
757 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
758 *
759 * @param expr Expression which should be true.
760 * @param a printf argument list (in parenthesis).
761 */
762#define AssertLogRelMsg(expr, a) \
763 do { \
764 if (RT_UNLIKELY(!(expr))) \
765 { \
766 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
767 AssertLogRelMsg2(a); \
768 AssertLogRelBreakpoint(); \
769 } \
770 } while (0)
771
772/** @def AssertLogRelMsgReturn
773 * Assert that an expression is true, return \a rc if it isn't.
774 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
775 *
776 * @param expr Expression which should be true.
777 * @param a printf argument list (in parenthesis).
778 * @param rc What is to be presented to return.
779 */
780#define AssertLogRelMsgReturn(expr, a, rc) \
781 do { \
782 if (RT_UNLIKELY(!(expr))) \
783 { \
784 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
785 AssertLogRelMsg2(a); \
786 AssertLogRelBreakpoint(); \
787 return (rc); \
788 } \
789 } while (0)
790
791/** @def AssertLogRelMsgReturnVoid
792 * Assert that an expression is true, return (void) if it isn't.
793 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
794 *
795 * @param expr Expression which should be true.
796 * @param a printf argument list (in parenthesis).
797 */
798#define AssertLogRelMsgReturnVoid(expr, a) \
799 do { \
800 if (RT_UNLIKELY(!(expr))) \
801 { \
802 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
803 AssertLogRelMsg2(a); \
804 AssertLogRelBreakpoint(); \
805 return; \
806 } \
807 } while (0)
808
809/** @def AssertLogRelMsgBreak
810 * Assert that an expression is true, break if it isn't.
811 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
812 *
813 * @param expr Expression which should be true.
814 * @param a printf argument list (in parenthesis).
815 */
816#define AssertLogRelMsgBreak(expr, a) \
817 if (RT_UNLIKELY(!(expr))) \
818 { \
819 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
820 AssertLogRelMsg2(a); \
821 AssertLogRelBreakpoint(); \
822 break; \
823 } \
824 else do {} while (0)
825
826/** @def AssertLogRelMsgBreakStmt
827 * Assert that an expression is true, execute \a stmt and break if it isn't.
828 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
829 *
830 * @param expr Expression which should be true.
831 * @param a printf argument list (in parenthesis).
832 * @param stmt Statement to execute before break in case of a failed assertion.
833 */
834#define AssertLogRelMsgBreakStmt(expr, a, stmt) \
835 if (RT_UNLIKELY(!(expr))) \
836 { \
837 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
838 AssertLogRelMsg2(a); \
839 AssertLogRelBreakpoint(); \
840 stmt; \
841 break; \
842 } else do {} while (0)
843
844/** @def AssertLogRelFailed
845 * An assertion failed.
846 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
847 */
848#define AssertLogRelFailed() \
849 do { \
850 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
851 AssertLogRelBreakpoint(); \
852 } while (0)
853
854/** @def AssertLogRelFailedReturn
855 * An assertion failed.
856 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
857 *
858 * @param rc What is to be presented to return.
859 */
860#define AssertLogRelFailedReturn(rc) \
861 do { \
862 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
863 AssertLogRelBreakpoint(); \
864 return (rc); \
865 } while (0)
866
867/** @def AssertLogRelFailedReturnVoid
868 * An assertion failed, hit a breakpoint and return.
869 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
870 */
871#define AssertLogRelFailedReturnVoid() \
872 do { \
873 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
874 AssertLogRelBreakpoint(); \
875 return; \
876 } while (0)
877
878/** @def AssertLogRelFailedBreak
879 * An assertion failed, break.
880 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
881 */
882#define AssertLogRelFailedBreak() \
883 if (1) \
884 { \
885 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
886 AssertLogRelBreakpoint(); \
887 break; \
888 } else do {} while (0)
889
890/** @def AssertLogRelFailedBreakStmt
891 * An assertion failed, execute \a stmt and break.
892 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
893 *
894 * @param stmt Statement to execute before break.
895 */
896#define AssertLogRelFailedBreakStmt(stmt) \
897 if (1) \
898 { \
899 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
900 AssertLogRelBreakpoint(); \
901 stmt; \
902 break; \
903 } else do {} while (0)
904
905/** @def AssertLogRelMsgFailed
906 * An assertion failed.
907 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
908 *
909 * @param a printf argument list (in parenthesis).
910 */
911#define AssertLogRelMsgFailed(a) \
912 do { \
913 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
914 AssertLogRelMsg2(a); \
915 AssertLogRelBreakpoint(); \
916 } while (0)
917
918/** @def AssertLogRelMsgFailedReturn
919 * An assertion failed, return \a rc.
920 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
921 *
922 * @param a printf argument list (in parenthesis).
923 * @param rc What is to be presented to return.
924 */
925#define AssertLogRelMsgFailedReturn(a, rc) \
926 do { \
927 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
928 AssertLogRelMsg2(a); \
929 AssertLogRelBreakpoint(); \
930 return (rc); \
931 } while (0)
932
933/** @def AssertLogRelMsgFailedReturnVoid
934 * An assertion failed, return void.
935 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
936 *
937 * @param a printf argument list (in parenthesis).
938 */
939#define AssertLogRelMsgFailedReturnVoid(a) \
940 do { \
941 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
942 AssertLogRelMsg2(a); \
943 AssertLogRelBreakpoint(); \
944 return; \
945 } while (0)
946
947/** @def AssertLogRelMsgFailedBreak
948 * An assertion failed, break.
949 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
950 *
951 * @param a printf argument list (in parenthesis).
952 */
953#define AssertLogRelMsgFailedBreak(a) \
954 if (1)\
955 { \
956 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
957 AssertLogRelMsg2(a); \
958 AssertLogRelBreakpoint(); \
959 break; \
960 } else do {} while (0)
961
962/** @def AssertLogRelMsgFailedBreakStmt
963 * An assertion failed, execute \a stmt and break.
964 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
965 *
966 * @param a printf argument list (in parenthesis).
967 * @param stmt Statement to execute before break.
968 * @todo Rename to AssertLogRelMsgFailedBreakStmt.
969 */
970#define AssertLogRelMsgFailedBreakStmt(a, stmt) \
971 if (1) \
972 { \
973 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
974 AssertLogRelMsg2(a); \
975 AssertLogRelBreakpoint(); \
976 stmt; \
977 break; \
978 } else do {} while (0)
979
980
981
982/** @def AssertReleaseBreakpoint()
983 * Assertion Breakpoint.
984 *
985 * @remark In the gnu world we add a nop instruction after the int3 to
986 * force gdb to remain at the int3 source line.
987 * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
988 */
989#ifdef __GNUC__
990# ifndef __L4ENV__
991# define AssertReleaseBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3\n\tnop"); } while (0)
992# else
993# define AssertReleaseBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3; jmp 1f; 1:"); } while (0)
994# endif
995#elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
996# define AssertReleaseBreakpoint() do { RTAssertDoBreakpoint(); __debugbreak(); } while (0)
997#else
998# error "Unknown compiler"
999#endif
1000
1001
1002/** @def AssertRelease
1003 * Assert that an expression is true. If it's not hit a breakpoint.
1004 *
1005 * @param expr Expression which should be true.
1006 */
1007#define AssertRelease(expr) \
1008 do { \
1009 if (RT_UNLIKELY(!(expr))) \
1010 { \
1011 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1012 AssertReleaseBreakpoint(); \
1013 } \
1014 } while (0)
1015
1016/** @def AssertReleaseReturn
1017 * Assert that an expression is true, hit a breakpoing and return if it isn't.
1018 *
1019 * @param expr Expression which should be true.
1020 * @param rc What is to be presented to return.
1021 */
1022#define AssertReleaseReturn(expr, rc) \
1023 do { \
1024 if (RT_UNLIKELY(!(expr))) \
1025 { \
1026 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1027 AssertReleaseBreakpoint(); \
1028 return (rc); \
1029 } \
1030 } while (0)
1031
1032/** @def AssertReleaseReturnVoid
1033 * Assert that an expression is true, hit a breakpoing and return if it isn't.
1034 *
1035 * @param expr Expression which should be true.
1036 */
1037#define AssertReleaseReturnVoid(expr) \
1038 do { \
1039 if (RT_UNLIKELY(!(expr))) \
1040 { \
1041 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1042 AssertReleaseBreakpoint(); \
1043 return; \
1044 } \
1045 } while (0)
1046
1047
1048/** @def AssertReleaseBreak
1049 * Assert that an expression is true, hit a breakpoing and break if it isn't.
1050 *
1051 * @param expr Expression which should be true.
1052 * @param stmt Statement to execute before break in case of a failed assertion.
1053 * @todo Rename to AssertReleaseBreakStmt.
1054 */
1055#define AssertReleaseBreak(expr, stmt) \
1056 do { \
1057 if (RT_UNLIKELY(!(expr))) \
1058 { \
1059 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1060 AssertReleaseBreakpoint(); \
1061 stmt; \
1062 break; \
1063 } \
1064 } while (0)
1065
1066/** @def AssertReleaseBreakVoid
1067 * Assert that an expression is true, hit a breakpoing and break if it isn't.
1068 *
1069 * @param expr Expression which should be true.
1070 * @todo Rename to AssertReleaseBreak.
1071 * @todo broken
1072 */
1073#define AssertReleaseBreakVoid(expr) \
1074 do { \
1075 if (RT_UNLIKELY(!(expr))) \
1076 { \
1077 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1078 AssertReleaseBreakpoint(); \
1079 break; \
1080 } \
1081 } while (0)
1082
1083
1084/** @def AssertReleaseMsg
1085 * Assert that an expression is true, print the message and hit a breakpoint if it isn't.
1086 *
1087 * @param expr Expression which should be true.
1088 * @param a printf argument list (in parenthesis).
1089 */
1090#define AssertReleaseMsg(expr, a) \
1091 do { \
1092 if (RT_UNLIKELY(!(expr))) \
1093 { \
1094 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1095 AssertMsg2 a; \
1096 AssertReleaseBreakpoint(); \
1097 } \
1098 } while (0)
1099
1100/** @def AssertReleaseMsgReturn
1101 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1102 *
1103 * @param expr Expression which should be true.
1104 * @param a printf argument list (in parenthesis).
1105 * @param rc What is to be presented to return.
1106 */
1107#define AssertReleaseMsgReturn(expr, a, rc) \
1108 do { \
1109 if (RT_UNLIKELY(!(expr))) \
1110 { \
1111 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1112 AssertMsg2 a; \
1113 AssertReleaseBreakpoint(); \
1114 return (rc); \
1115 } \
1116 } while (0)
1117
1118/** @def AssertReleaseMsgReturnVoid
1119 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1120 *
1121 * @param expr Expression which should be true.
1122 * @param a printf argument list (in parenthesis).
1123 */
1124#define AssertReleaseMsgReturnVoid(expr, a) \
1125 do { \
1126 if (RT_UNLIKELY(!(expr))) \
1127 { \
1128 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1129 AssertMsg2 a; \
1130 AssertReleaseBreakpoint(); \
1131 return; \
1132 } \
1133 } while (0)
1134
1135
1136/** @def AssertReleaseMsgBreak
1137 * Assert that an expression is true, print the message and hit a breakpoing and break if it isn't.
1138 *
1139 * @param expr Expression which should be true.
1140 * @param a printf argument list (in parenthesis).
1141 * @param stmt Statement to execute before break in case of a failed assertion.
1142 * @todo Rename to AssertReleaseMsgBreakStmt.
1143 */
1144#define AssertReleaseMsgBreak(expr, a, stmt) \
1145 if (RT_UNLIKELY(!(expr))) { \
1146 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1147 AssertMsg2 a; \
1148 AssertReleaseBreakpoint(); \
1149 stmt; \
1150 break; \
1151 } else do {} while (0)
1152
1153/** @def AssertReleaseMsgBreakVoid
1154 * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
1155 *
1156 * @param expr Expression which should be true.
1157 * @param a printf argument list (in parenthesis).
1158 * @todo Rename to AssertReleaseMsgBreak.
1159 * @todo broken
1160 */
1161#define AssertReleaseMsgBreakVoid(expr, a) \
1162 do { \
1163 if (RT_UNLIKELY(!(expr))) \
1164 { \
1165 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1166 AssertMsg2 a; \
1167 AssertReleaseBreakpoint(); \
1168 break; \
1169 } \
1170 } while (0)
1171
1172
1173/** @def AssertReleaseFailed
1174 * An assertion failed, hit a breakpoint.
1175 */
1176#define AssertReleaseFailed() \
1177 do { \
1178 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1179 AssertReleaseBreakpoint(); \
1180 } while (0)
1181
1182/** @def AssertReleaseFailedReturn
1183 * An assertion failed, hit a breakpoint and return.
1184 *
1185 * @param rc What is to be presented to return.
1186 */
1187#define AssertReleaseFailedReturn(rc) \
1188 do { \
1189 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1190 AssertReleaseBreakpoint(); \
1191 return (rc); \
1192 } while (0)
1193
1194/** @def AssertReleaseFailedReturnVoid
1195 * An assertion failed, hit a breakpoint and return.
1196 */
1197#define AssertReleaseFailedReturnVoid() \
1198 do { \
1199 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1200 AssertReleaseBreakpoint(); \
1201 return; \
1202 } while (0)
1203
1204
1205/** @def AssertReleaseFailedBreak
1206 * An assertion failed, hit a breakpoint and break.
1207 *
1208 * @param stmt Statement to execute before break.
1209 * @todo Rename to AssertReleaseMsgFailedStmt.
1210 */
1211#define AssertReleaseFailedBreak(stmt) \
1212 if (1) { \
1213 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1214 AssertReleaseBreakpoint(); \
1215 stmt; \
1216 break; \
1217 } else do {} while (0)
1218
1219/** @def AssertReleaseFailedBreakVoid
1220 * An assertion failed, hit a breakpoint and break.
1221 * @todo Rename to AssertReleaseFailedBreak.
1222 * @todo broken, should use 'if' instead of 'do'.
1223 */
1224#define AssertReleaseFailedBreakVoid() \
1225 do { \
1226 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1227 AssertReleaseBreakpoint(); \
1228 break; \
1229 } while (0)
1230
1231
1232/** @def AssertReleaseMsgFailed
1233 * An assertion failed, print a message and hit a breakpoint.
1234 *
1235 * @param a printf argument list (in parenthesis).
1236 */
1237#define AssertReleaseMsgFailed(a) \
1238 do { \
1239 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1240 AssertMsg2 a; \
1241 AssertReleaseBreakpoint(); \
1242 } while (0)
1243
1244/** @def AssertReleaseMsgFailedReturn
1245 * An assertion failed, print a message, hit a breakpoint and return.
1246 *
1247 * @param a printf argument list (in parenthesis).
1248 * @param rc What is to be presented to return.
1249 */
1250#define AssertReleaseMsgFailedReturn(a, rc) \
1251 do { \
1252 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1253 AssertMsg2 a; \
1254 AssertReleaseBreakpoint(); \
1255 return (rc); \
1256 } while (0)
1257
1258/** @def AssertReleaseMsgFailedReturnVoid
1259 * An assertion failed, print a message, hit a breakpoint and return.
1260 *
1261 * @param a printf argument list (in parenthesis).
1262 */
1263#define AssertReleaseMsgFailedReturnVoid(a) \
1264 do { \
1265 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1266 AssertMsg2 a; \
1267 AssertReleaseBreakpoint(); \
1268 return; \
1269 } while (0)
1270
1271
1272/** @def AssertReleaseMsgFailedBreak
1273 * An assertion failed, print a message, hit a breakpoint and break.
1274 *
1275 * @param a printf argument list (in parenthesis).
1276 * @param stmt Statement to execute before break.
1277 * @todo Rename to AssertReleaseMsgFailedBreakStmt.
1278 */
1279#define AssertReleaseMsgFailedBreak(a, stmt) \
1280 if (1) { \
1281 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1282 AssertMsg2 a; \
1283 AssertReleaseBreakpoint(); \
1284 stmt; \
1285 break; \
1286 } else do {} while (0)
1287
1288/** @def AssertReleaseMsgFailedBreakVoid
1289 * An assertion failed, print a message, hit a breakpoint and break.
1290 *
1291 * @param a printf argument list (in parenthesis).
1292 * @todo Rename to AssertReleaseMsgFailedBreak.
1293 * @todo broken
1294 */
1295#define AssertReleaseMsgFailedBreakVoid(a) \
1296 do { \
1297 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1298 AssertMsg2 a; \
1299 AssertReleaseBreakpoint(); \
1300 break; \
1301 } while (0)
1302
1303
1304/** @def AssertFatal
1305 * Assert that an expression is true. If it's not hit a breakpoint (for ever).
1306 *
1307 * @param expr Expression which should be true.
1308 */
1309#define AssertFatal(expr) \
1310 do { \
1311 if (RT_UNLIKELY(!(expr))) \
1312 for (;;) \
1313 { \
1314 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1315 AssertReleaseBreakpoint(); \
1316 } \
1317 } while (0)
1318
1319/** @def AssertFatalMsg
1320 * Assert that an expression is true, print the message and hit a breakpoint (for ever) if it isn't.
1321 *
1322 * @param expr Expression which should be true.
1323 * @param a printf argument list (in parenthesis).
1324 */
1325#define AssertFatalMsg(expr, a) \
1326 do { \
1327 if (RT_UNLIKELY(!(expr))) \
1328 for (;;) \
1329 { \
1330 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1331 AssertMsg2 a; \
1332 AssertReleaseBreakpoint(); \
1333 } \
1334 } while (0)
1335
1336/** @def AssertFatalFailed
1337 * An assertion failed, hit a breakpoint (for ever).
1338 */
1339#define AssertFatalFailed() \
1340 do { \
1341 for (;;) \
1342 { \
1343 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1344 AssertReleaseBreakpoint(); \
1345 } \
1346 } while (0)
1347
1348/** @def AssertFatalMsgFailed
1349 * An assertion failed, print a message and hit a breakpoint (for ever).
1350 *
1351 * @param a printf argument list (in parenthesis).
1352 */
1353#define AssertFatalMsgFailed(a) \
1354 do { \
1355 for (;;) \
1356 { \
1357 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1358 AssertMsg2 a; \
1359 AssertReleaseBreakpoint(); \
1360 } \
1361 } while (0)
1362
1363
1364/** @def AssertRC
1365 * Asserts a iprt status code successful.
1366 *
1367 * On failure it will print info about the rc and hit a breakpoint.
1368 *
1369 * @param rc iprt status code.
1370 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1371 */
1372#define AssertRC(rc) AssertMsgRC(rc, ("%Vra\n", (rc)))
1373
1374/** @def AssertRCReturn
1375 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
1376 *
1377 * @param rc iprt status code.
1378 * @param rcRet What is to be presented to return.
1379 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1380 */
1381#define AssertRCReturn(rc, rcRet) AssertMsgRCReturn(rc, ("%Vra\n", (rc)), rcRet)
1382
1383/** @def AssertRCReturnVoid
1384 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
1385 *
1386 * @param rc iprt status code.
1387 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1388 */
1389#define AssertRCReturnVoid(rc) AssertMsgRCReturnVoid(rc, ("%Vra\n", (rc)))
1390
1391/** @def AssertRCBreak
1392 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
1393 *
1394 * @param rc iprt status code.
1395 * @param stmt Statement to execute before break in case of a failed assertion.
1396 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1397 * @todo Rename to AssertRCBreakStmt.
1398 */
1399#define AssertRCBreak(rc, stmt) AssertMsgRCBreak(rc, ("%Vra\n", (rc)), stmt)
1400
1401/** @def AssertRCBreakVoid
1402 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
1403 *
1404 * @param rc iprt status code.
1405 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1406 * @todo Rename to AssertRCBreak.
1407 */
1408#define AssertRCBreakVoid(rc) AssertMsgRCBreakVoid(rc, ("%Vra\n", (rc)))
1409
1410/** @def AssertMsgRC
1411 * Asserts a iprt status code successful.
1412 *
1413 * It prints a custom message and hits a breakpoint on FAILURE.
1414 *
1415 * @param rc iprt status code.
1416 * @param msg printf argument list (in parenthesis).
1417 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1418 */
1419#define AssertMsgRC(rc, msg) \
1420 do { AssertMsg(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
1421
1422/** @def AssertMsgRCReturn
1423 * Asserts a iprt status code successful and if it's not return the specified status code.
1424 *
1425 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
1426 *
1427 * @param rc iprt status code.
1428 * @param msg printf argument list (in parenthesis).
1429 * @param rcRet What is to be presented to return.
1430 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1431 */
1432#define AssertMsgRCReturn(rc, msg, rcRet) \
1433 do { AssertMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet); NOREF(rc); } while (0)
1434
1435/** @def AssertMsgRCReturnVoid
1436 * Asserts a iprt status code successful and if it's not return.
1437 *
1438 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
1439 *
1440 * @param rc iprt status code.
1441 * @param msg printf argument list (in parenthesis).
1442 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1443 */
1444#define AssertMsgRCReturnVoid(rc, msg) \
1445 do { AssertMsgReturnVoid(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
1446
1447/** @def AssertMsgRCBreak
1448 * Asserts a iprt status code successful and break if it's not.
1449 *
1450 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
1451 *
1452 * @param rc iprt status code.
1453 * @param msg printf argument list (in parenthesis).
1454 * @param stmt Statement to execute before break in case of a failed assertion.
1455 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1456 * @todo Rename to AssertMsgRCBreakStmt.
1457 */
1458#define AssertMsgRCBreak(rc, msg, stmt) \
1459 do { AssertMsgBreak(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
1460
1461/** @def AssertMsgRCBreakVoid
1462 * Asserts a iprt status code successful and if it's not break.
1463 *
1464 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it breaks
1465 *
1466 * @param rc iprt status code.
1467 * @param msg printf argument list (in parenthesis).
1468 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1469 * @todo Rename to AssertMsgRCBreak.
1470 */
1471#define AssertMsgRCBreakVoid(rc, msg) \
1472 do { AssertMsgBreakVoid(RT_SUCCESS(rc), msg); NOREF(rc); } while (0)
1473
1474/** @def AssertRCSuccess
1475 * Asserts an iprt status code equals VINF_SUCCESS.
1476 *
1477 * On failure it will print info about the rc and hit a breakpoint.
1478 *
1479 * @param rc iprt status code.
1480 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1481 */
1482#define AssertRCSuccess(rc) AssertMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1483
1484/** @def AssertRCSuccessReturn
1485 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
1486 *
1487 * @param rc iprt status code.
1488 * @param rcRet What is to be presented to return.
1489 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1490 */
1491#define AssertRCSuccessReturn(rc, rcRet) AssertMsgReturn((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), rcRet)
1492
1493/** @def AssertRCSuccessReturnVoid
1494 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
1495 *
1496 * @param rc iprt status code.
1497 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1498 */
1499#define AssertRCSuccessReturnVoid(rc) AssertMsgReturnVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1500
1501/** @def AssertRCSuccessBreak
1502 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
1503 *
1504 * @param rc iprt status code.
1505 * @param stmt Statement to execute before break in case of a failed assertion.
1506 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1507 * @todo Rename to AssertRCSuccessBreakStmt.
1508 */
1509#define AssertRCSuccessBreak(rc, stmt) AssertMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
1510
1511/** @def AssertRCSuccessBreakVoid
1512 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
1513 *
1514 * @param rc iprt status code.
1515 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1516 * @todo Rename to AssertRCSuccessBreak.
1517 */
1518#define AssertRCSuccessBreakVoid(rc) AssertMsgBreakVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1519
1520
1521/** @def AssertLogRelRC
1522 * Asserts a iprt status code successful.
1523 *
1524 * @param rc iprt status code.
1525 * @remark rc is references multiple times.
1526 */
1527#define AssertLogRelRC(rc) AssertLogRelMsgRC(rc, ("%Rra\n", (rc)))
1528
1529/** @def AssertLogRelRCReturn
1530 * Asserts a iprt status code successful, returning \a rc if it isn't.
1531 *
1532 * @param rc iprt status code.
1533 * @param rcRet What is to be presented to return.
1534 * @remark rc is references multiple times.
1535 */
1536#define AssertLogRelRCReturn(rc, rcRet) AssertLogRelMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
1537
1538/** @def AssertLogRelRCReturnVoid
1539 * Asserts a iprt status code successful, returning (void) if it isn't.
1540 *
1541 * @param rc iprt status code.
1542 * @remark rc is references multiple times.
1543 */
1544#define AssertLogRelRCReturnVoid(rc) AssertLogRelMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
1545
1546/** @def AssertLogRelRCBreak
1547 * Asserts a iprt status code successful, breaking if it isn't.
1548 *
1549 * @param rc iprt status code.
1550 * @remark rc is references multiple times.
1551 */
1552#define AssertLogRelRCBreak(rc) AssertLogRelMsgRCBreak(rc, ("%Rra\n", (rc)))
1553
1554/** @def AssertLogRelRCBreakStmt
1555 * Asserts a iprt status code successful, execute \a statement and break if it isn't.
1556 *
1557 * @param rc iprt status code.
1558 * @param stmt Statement to execute before break in case of a failed assertion.
1559 * @remark rc is references multiple times.
1560 */
1561#define AssertLogRelRCBreakStmt(rc, stmt) AssertLogRelMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
1562
1563/** @def AssertLogRelMsgRC
1564 * Asserts a iprt status code successful.
1565 *
1566 * @param rc iprt status code.
1567 * @param msg printf argument list (in parenthesis).
1568 * @remark rc is references multiple times.
1569 */
1570#define AssertLogRelMsgRC(rc, msg) AssertLogRelMsg(RT_SUCCESS_NP(rc), msg)
1571
1572/** @def AssertLogRelMsgRCReturn
1573 * Asserts a iprt status code successful.
1574 *
1575 * @param rc iprt status code.
1576 * @param msg printf argument list (in parenthesis).
1577 * @param rcRet What is to be presented to return.
1578 * @remark rc is references multiple times.
1579 */
1580#define AssertLogRelMsgRCReturn(rc, msg, rcRet) AssertLogRelMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
1581
1582/** @def AssertLogRelMsgRCReturnVoid
1583 * Asserts a iprt status code successful.
1584 *
1585 * @param rc iprt status code.
1586 * @param msg printf argument list (in parenthesis).
1587 * @remark rc is references multiple times.
1588 */
1589#define AssertLogRelMsgRCReturnVoid(rc, msg) AssertLogRelMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
1590
1591/** @def AssertLogRelMsgRCBreak
1592 * Asserts a iprt status code successful.
1593 *
1594 * @param rc iprt status code.
1595 * @param msg printf argument list (in parenthesis).
1596 * @remark rc is references multiple times.
1597 */
1598#define AssertLogRelMsgRCBreak(rc, msg) AssertLogRelMsgBreak(RT_SUCCESS(rc), msg)
1599
1600/** @def AssertLogRelMsgRCBreakStmt
1601 * Asserts a iprt status code successful, execute \a stmt and break if it isn't.
1602 *
1603 * @param rc iprt status code.
1604 * @param msg printf argument list (in parenthesis).
1605 * @param stmt Statement to execute before break in case of a failed assertion.
1606 * @remark rc is references multiple times.
1607 */
1608#define AssertLogRelMsgRCBreakStmt(rc, msg, stmt) AssertLogRelMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
1609
1610/** @def AssertLogRelRCSuccess
1611 * Asserts that an iprt status code equals VINF_SUCCESS.
1612 *
1613 * @param rc iprt status code.
1614 * @remark rc is references multiple times.
1615 */
1616#define AssertLogRelRCSuccess(rc) AssertLogRelMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1617
1618/** @def AssertLogRelRCSuccessReturn
1619 * Asserts that an iprt status code equals VINF_SUCCESS.
1620 *
1621 * @param rc iprt status code.
1622 * @param rcRet What is to be presented to return.
1623 * @remark rc is references multiple times.
1624 */
1625#define AssertLogRelRCSuccessReturn(rc, rcRet) AssertLogRelMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
1626
1627/** @def AssertLogRelRCSuccessReturnVoid
1628 * Asserts that an iprt status code equals VINF_SUCCESS.
1629 *
1630 * @param rc iprt status code.
1631 * @remark rc is references multiple times.
1632 */
1633#define AssertLogRelRCSuccessReturnVoid(rc) AssertLogRelMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1634
1635/** @def AssertLogRelRCSuccessBreak
1636 * Asserts that an iprt status code equals VINF_SUCCESS.
1637 *
1638 * @param rc iprt status code.
1639 * @remark rc is references multiple times.
1640 */
1641#define AssertLogRelRCSuccessBreak(rc) AssertLogRelMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1642
1643/** @def AssertLogRelRCSuccessBreakStmt
1644 * Asserts that an iprt status code equals VINF_SUCCESS.
1645 *
1646 * @param rc iprt status code.
1647 * @param stmt Statement to execute before break in case of a failed assertion.
1648 * @remark rc is references multiple times.
1649 */
1650#define AssertLogRelRCSuccessBreakStmt(rc, stmt) AssertLogRelMsgBreakStmt((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
1651
1652
1653/** @def AssertReleaseRC
1654 * Asserts a iprt status code successful.
1655 *
1656 * On failure information about the error will be printed and a breakpoint hit.
1657 *
1658 * @param rc iprt status code.
1659 * @remark rc is references multiple times.
1660 */
1661#define AssertReleaseRC(rc) AssertReleaseMsgRC(rc, ("%Vra\n", (rc)))
1662
1663/** @def AssertReleaseRCReturn
1664 * Asserts a iprt status code successful, returning if it isn't.
1665 *
1666 * On failure information about the error will be printed, a breakpoint hit
1667 * and finally returning from the function if the breakpoint is somehow ignored.
1668 *
1669 * @param rc iprt status code.
1670 * @param rcRet What is to be presented to return.
1671 * @remark rc is references multiple times.
1672 */
1673#define AssertReleaseRCReturn(rc, rcRet) AssertReleaseMsgRCReturn(rc, ("%Vra\n", (rc)), rcRet)
1674
1675/** @def AssertReleaseRCReturnVoid
1676 * Asserts a iprt status code successful, returning if it isn't.
1677 *
1678 * On failure information about the error will be printed, a breakpoint hit
1679 * and finally returning from the function if the breakpoint is somehow ignored.
1680 *
1681 * @param rc iprt status code.
1682 * @remark rc is references multiple times.
1683 */
1684#define AssertReleaseRCReturnVoid(rc) AssertReleaseMsgRCReturnVoid(rc, ("%Vra\n", (rc)))
1685
1686/** @def AssertReleaseRCBreak
1687 * Asserts a iprt status code successful, break if it isn't.
1688 *
1689 * On failure information about the error will be printed, a breakpoint hit
1690 * and finally the break statement will be issued if the breakpoint is somehow ignored.
1691 *
1692 * @param rc iprt status code.
1693 * @param stmt Statement to execute before break in case of a failed assertion.
1694 * @remark rc is references multiple times.
1695 * @todo Rename to AssertReleaseRCBreakStmt.
1696 */
1697#define AssertReleaseRCBreak(rc, stmt) AssertReleaseMsgRCBreak(rc, ("%Vra\n", (rc)), stmt)
1698
1699/** @def AssertReleaseRCBreakVoid
1700 * Asserts a iprt status code successful, breaking if it isn't.
1701 *
1702 * On failure information about the error will be printed, a breakpoint hit
1703 * and finally breaking the current statement if the breakpoint is somehow ignored.
1704 *
1705 * @param rc iprt status code.
1706 * @remark rc is references multiple times.
1707 * @todo Rename to AssertReleaseRCBreak.
1708 */
1709#define AssertReleaseRCBreakVoid(rc) AssertReleaseMsgRCBreakVoid(rc, ("%Vra\n", (rc)))
1710
1711/** @def AssertReleaseMsgRC
1712 * Asserts a iprt status code successful.
1713 *
1714 * On failure a custom message is printed and a breakpoint is hit.
1715 *
1716 * @param rc iprt status code.
1717 * @param msg printf argument list (in parenthesis).
1718 * @remark rc is references multiple times.
1719 */
1720#define AssertReleaseMsgRC(rc, msg) AssertReleaseMsg(RT_SUCCESS_NP(rc), msg)
1721
1722/** @def AssertReleaseMsgRCReturn
1723 * Asserts a iprt status code successful.
1724 *
1725 * On failure a custom message is printed, a breakpoint is hit, and finally
1726 * returning from the function if the breakpoint is showhow ignored.
1727 *
1728 * @param rc iprt status code.
1729 * @param msg printf argument list (in parenthesis).
1730 * @param rcRet What is to be presented to return.
1731 * @remark rc is references multiple times.
1732 */
1733#define AssertReleaseMsgRCReturn(rc, msg, rcRet) AssertReleaseMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
1734
1735/** @def AssertReleaseMsgRCReturnVoid
1736 * Asserts a iprt status code successful.
1737 *
1738 * On failure a custom message is printed, a breakpoint is hit, and finally
1739 * returning from the function if the breakpoint is showhow ignored.
1740 *
1741 * @param rc iprt status code.
1742 * @param msg printf argument list (in parenthesis).
1743 * @remark rc is references multiple times.
1744 */
1745#define AssertReleaseMsgRCReturnVoid(rc, msg) AssertReleaseMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
1746
1747/** @def AssertReleaseMsgRCBreak
1748 * Asserts a iprt status code successful.
1749 *
1750 * On failure a custom message is printed, a breakpoint is hit, and finally
1751 * the brean statement is issued if the breakpoint is showhow ignored.
1752 *
1753 * @param rc iprt status code.
1754 * @param msg printf argument list (in parenthesis).
1755 * @param stmt Statement to execute before break in case of a failed assertion.
1756 * @remark rc is references multiple times.
1757 * @todo Rename to AssertReleaseMsgRCBreakStmt.
1758 */
1759#define AssertReleaseMsgRCBreak(rc, msg, stmt) AssertReleaseMsgBreak(RT_SUCCESS_NP(rc), msg, stmt)
1760
1761/** @def AssertReleaseMsgRCBreakVoid
1762 * Asserts a iprt status code successful.
1763 *
1764 * On failure a custom message is printed, a breakpoint is hit, and finally
1765 * breaking the current status if the breakpoint is showhow ignored.
1766 *
1767 * @param rc iprt status code.
1768 * @param msg printf argument list (in parenthesis).
1769 * @remark rc is references multiple times.
1770 * @todo Rename to AssertReleaseMsgRCBreak.
1771 */
1772#define AssertReleaseMsgRCBreakVoid(rc, msg) AssertReleaseMsgBreakVoid(RT_SUCCESS(rc), msg)
1773
1774/** @def AssertReleaseRCSuccess
1775 * Asserts that an iprt status code equals VINF_SUCCESS.
1776 *
1777 * On failure information about the error will be printed and a breakpoint hit.
1778 *
1779 * @param rc iprt status code.
1780 * @remark rc is references multiple times.
1781 */
1782#define AssertReleaseRCSuccess(rc) AssertReleaseMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1783
1784/** @def AssertReleaseRCSuccessReturn
1785 * Asserts that an iprt status code equals VINF_SUCCESS.
1786 *
1787 * On failure information about the error will be printed, a breakpoint hit
1788 * and finally returning from the function if the breakpoint is somehow ignored.
1789 *
1790 * @param rc iprt status code.
1791 * @param rcRet What is to be presented to return.
1792 * @remark rc is references multiple times.
1793 */
1794#define AssertReleaseRCSuccessReturn(rc, rcRet) AssertReleaseMsgReturn((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), rcRet)
1795
1796/** @def AssertReleaseRCSuccessReturnVoid
1797 * Asserts that an iprt status code equals VINF_SUCCESS.
1798 *
1799 * On failure information about the error will be printed, a breakpoint hit
1800 * and finally returning from the function if the breakpoint is somehow ignored.
1801 *
1802 * @param rc iprt status code.
1803 * @remark rc is references multiple times.
1804 */
1805#define AssertReleaseRCSuccessReturnVoid(rc) AssertReleaseMsgReturnVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1806
1807/** @def AssertReleaseRCSuccessBreak
1808 * Asserts that an iprt status code equals VINF_SUCCESS.
1809 *
1810 * On failure information about the error will be printed, a breakpoint hit
1811 * and finally the break statement will be issued if the breakpoint is somehow ignored.
1812 *
1813 * @param rc iprt status code.
1814 * @param stmt Statement to execute before break in case of a failed assertion.
1815 * @remark rc is references multiple times.
1816 * @todo Rename to AssertReleaseRCSuccessBreakStmt.
1817 */
1818#define AssertReleaseRCSuccessBreak(rc, stmt) AssertReleaseMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
1819
1820/** @def AssertReleaseRCSuccessBreakVoid
1821 * Asserts that an iprt status code equals VINF_SUCCESS.
1822 *
1823 * On failure information about the error will be printed, a breakpoint hit
1824 * and finally breaking the current statement if the breakpoint is somehow ignored.
1825 *
1826 * @param rc iprt status code.
1827 * @remark rc is references multiple times.
1828 * @todo Rename to AssertReleaseRCSuccessBreak.
1829 */
1830#define AssertReleaseRCSuccessBreakVoid(rc) AssertReleaseMsgBreakVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1831
1832
1833/** @def AssertFatalRC
1834 * Asserts a iprt status code successful.
1835 *
1836 * On failure information about the error will be printed and a breakpoint hit.
1837 *
1838 * @param rc iprt status code.
1839 * @remark rc is references multiple times.
1840 */
1841#define AssertFatalRC(rc) AssertFatalMsgRC(rc, ("%Vra\n", (rc)))
1842
1843/** @def AssertReleaseMsgRC
1844 * Asserts a iprt status code successful.
1845 *
1846 * On failure a custom message is printed and a breakpoint is hit.
1847 *
1848 * @param rc iprt status code.
1849 * @param msg printf argument list (in parenthesis).
1850 * @remark rc is references multiple times.
1851 */
1852#define AssertFatalMsgRC(rc, msg) AssertFatalMsg(RT_SUCCESS_NP(rc), msg)
1853
1854/** @def AssertFatalRCSuccess
1855 * Asserts that an iprt status code equals VINF_SUCCESS.
1856 *
1857 * On failure information about the error will be printed and a breakpoint hit.
1858 *
1859 * @param rc iprt status code.
1860 * @remark rc is references multiple times.
1861 */
1862#define AssertFatalRCSuccess(rc) AssertFatalMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1863
1864
1865/** @def AssertPtr
1866 * Asserts that a pointer is valid.
1867 *
1868 * @param pv The pointer.
1869 */
1870#define AssertPtr(pv) AssertMsg(VALID_PTR(pv), ("%p\n", (pv)))
1871
1872/** @def AssertPtrReturn
1873 * Asserts that a pointer is valid.
1874 *
1875 * @param pv The pointer.
1876 * @param rcRet What is to be presented to return.
1877 */
1878#define AssertPtrReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv), ("%p\n", (pv)), rcRet)
1879
1880/** @def AssertPtrReturnVoid
1881 * Asserts that a pointer is valid.
1882 *
1883 * @param pv The pointer.
1884 */
1885#define AssertPtrReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv), ("%p\n", (pv)))
1886
1887/** @def AssertPtrBreak
1888 * Asserts that a pointer is valid.
1889 *
1890 * @param pv The pointer.
1891 * @param stmt Statement to execute before break in case of a failed assertion.
1892 * @todo Rename to AssertPtrBreakStmt.
1893 */
1894#define AssertPtrBreak(pv, stmt) AssertMsgBreak(VALID_PTR(pv), ("%p\n", (pv)), stmt)
1895
1896/** @def AssertPtrBreakVoid
1897 * Asserts that a pointer is valid.
1898 *
1899 * @param pv The pointer.
1900 * @todo Rename to AssertPtrBreak.
1901 */
1902#define AssertPtrBreakVoid(pv) AssertMsgBreakVoid(VALID_PTR(pv), ("%p\n", (pv)))
1903
1904/** @def AssertPtrNull
1905 * Asserts that a pointer is valid or NULL.
1906 *
1907 * @param pv The pointer.
1908 */
1909#define AssertPtrNull(pv) AssertMsg(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
1910
1911/** @def AssertPtrNullReturn
1912 * Asserts that a pointer is valid or NULL.
1913 *
1914 * @param pv The pointer.
1915 * @param rcRet What is to be presented to return.
1916 */
1917#define AssertPtrNullReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), rcRet)
1918
1919/** @def AssertPtrNullReturnVoid
1920 * Asserts that a pointer is valid or NULL.
1921 *
1922 * @param pv The pointer.
1923 */
1924#define AssertPtrNullReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
1925
1926/** @def AssertPtrNullBreak
1927 * Asserts that a pointer is valid or NULL.
1928 *
1929 * @param pv The pointer.
1930 * @param stmt Statement to execute before break in case of a failed assertion.
1931 * @todo Rename to AssertPtrNullBreakStmt.
1932 */
1933#define AssertPtrNullBreak(pv, stmt) AssertMsgBreak(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt)
1934
1935/** @def AssertPtrNullBreakVoid
1936 * Asserts that a pointer is valid or NULL.
1937 *
1938 * @param pv The pointer.
1939 * @todo Rename to AssertPtrNullBreak.
1940 */
1941#define AssertPtrNullBreakVoid(pv) AssertMsgBreakVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
1942
1943
1944__BEGIN_DECLS
1945
1946/**
1947 * The 1st part of an assert message.
1948 *
1949 * @param pszExpr Expression. Can be NULL.
1950 * @param uLine Location line number.
1951 * @param pszFile Location file name.
1952 * @param pszFunction Location function name.
1953 * @remark This API exists in HC Ring-3 and GC.
1954 */
1955RTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction);
1956
1957/**
1958 * The 2nd (optional) part of an assert message.
1959 * @param pszFormat Printf like format string.
1960 * @param ... Arguments to that string.
1961 * @remark This API exists in HC Ring-3 and GC.
1962 */
1963RTDECL(void) AssertMsg2(const char *pszFormat, ...);
1964
1965/**
1966 * Overridable function that decides whether assertions executes the breakpoint or not.
1967 *
1968 * The generic implementation will return true.
1969 *
1970 * @returns true if the breakpoint should be hit, false if it should be ignored.
1971 * @remark The RTDECL() makes this a bit difficult to override on windows. Sorry.
1972 */
1973RTDECL(bool) RTAssertDoBreakpoint(void);
1974
1975/** The last assert message, 1st part. */
1976extern RTDATADECL(char) g_szRTAssertMsg1[1024];
1977/** The last assert message, 2nd part. */
1978extern RTDATADECL(char) g_szRTAssertMsg2[2048];
1979
1980__END_DECLS
1981
1982/** @} */
1983
1984#endif
1985
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette