]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - ubuntu/vbox/vboxsf/include/iprt/assert.h
6 * Copyright (C) 2006-2017 Oracle Corporation
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.
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.
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.
26 #ifndef ___iprt_assert_h
27 #define ___iprt_assert_h
29 #include <iprt/cdefs.h>
30 #include <iprt/types.h>
31 #include <iprt/stdarg.h>
32 #include <iprt/assertcompile.h>
34 /** @defgroup grp_rt_assert Assert - Assertions
37 * Assertions are generally used to check preconditions and other
38 * assumptions. Sometimes it is also used to catch odd errors or errors
39 * that one would like to inspect in the debugger. They should not be
40 * used for errors that happen frequently.
42 * IPRT provides a host of assertion macros, so many that it can be a bit
43 * overwhelming at first. Don't despair, there is a system (surprise).
45 * First there are four families of assertions:
46 * - Assert - The normal strict build only assertions.
47 * - AssertLogRel - Calls LogRel() in non-strict builds, otherwise like Assert.
48 * - AssertRelease - Triggers in all builds.
49 * - AssertFatal - Triggers in all builds and cannot be continued.
51 * Then there are variations wrt to argument list and behavior on failure:
52 * - Msg - Custom RTStrPrintf-like message with the assertion message.
53 * - Return - Return the specific rc on failure.
54 * - ReturnVoid - Return (void) on failure.
55 * - Break - Break (out of switch/loop) on failure.
56 * - Stmt - Execute the specified statement(s) on failure.
57 * - RC - Assert RT_SUCCESS.
58 * - RCSuccess - Assert VINF_SUCCESS.
60 * @remarks As you might have noticed, the macros don't follow the
61 * coding guidelines wrt to macros supposedly being all uppercase
62 * and underscored. For various reasons they don't, and nobody
63 * has complained yet. Wonder why... :-)
65 * @remarks Each project has its own specific guidelines on how to use
66 * assertions, so the above is just trying to give you the general idea
67 * from the IPRT point of view.
75 * The 1st part of an assert message.
77 * @param pszExpr Expression. Can be NULL.
78 * @param uLine Location line number.
79 * @param pszFile Location file name.
80 * @param pszFunction Location function name.
82 RTDECL(void) RTAssertMsg1(const char *pszExpr
, unsigned uLine
, const char *pszFile
, const char *pszFunction
);
84 * Weak version of RTAssertMsg1 that can be overridden locally in a module to
85 * modify, redirect or otherwise mess with the assertion output.
87 * @copydoc RTAssertMsg1
89 RTDECL(void) RTAssertMsg1Weak(const char *pszExpr
, unsigned uLine
, const char *pszFile
, const char *pszFunction
);
92 * The 2nd (optional) part of an assert message.
94 * @param pszFormat Printf like format string.
95 * @param ... Arguments to that string.
97 RTDECL(void) RTAssertMsg2(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
99 * Weak version of RTAssertMsg2 that forwards to RTAssertMsg2WeakV.
101 * There is not need to override this, check out RTAssertMsg2WeakV instead!
103 * @copydoc RTAssertMsg2
105 RTDECL(void) RTAssertMsg2Weak(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
108 * The 2nd (optional) part of an assert message.
110 * @param pszFormat Printf like format string.
111 * @param va Arguments to that string.
113 RTDECL(void) RTAssertMsg2V(const char *pszFormat
, va_list va
) RT_IPRT_FORMAT_ATTR(1, 0);
115 * Weak version of RTAssertMsg2V that can be overridden locally in a module to
116 * modify, redirect or otherwise mess with the assertion output.
118 * @copydoc RTAssertMsg2V
120 RTDECL(void) RTAssertMsg2WeakV(const char *pszFormat
, va_list va
) RT_IPRT_FORMAT_ATTR(1, 0);
123 * Additional information which should be appended to the 2nd part of an
126 * @param pszFormat Printf like format string.
127 * @param ... Arguments to that string.
129 RTDECL(void) RTAssertMsg2Add(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
131 * Weak version of RTAssertMsg2Add that forwards to RTAssertMsg2AddWeakV.
133 * There is not need to override this, check out RTAssertMsg2AddWeakV instead!
135 * @copydoc RTAssertMsg2Add
137 RTDECL(void) RTAssertMsg2AddWeak(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
140 * Additional information which should be appended to the 2nd part of an
143 * @param pszFormat Printf like format string.
144 * @param va Arguments to that string.
146 RTDECL(void) RTAssertMsg2AddV(const char *pszFormat
, va_list va
) RT_IPRT_FORMAT_ATTR(1, 0);
148 * Weak version of RTAssertMsg2AddV that can be overridden locally in a module
149 * to modify, redirect or otherwise mess with the assertion output.
151 * @copydoc RTAssertMsg2AddV
153 RTDECL(void) RTAssertMsg2AddWeakV(const char *pszFormat
, va_list va
) RT_IPRT_FORMAT_ATTR(1, 0);
157 * Panics the system as the result of a fail assertion.
159 RTR0DECL(void) RTR0AssertPanicSystem(void);
160 #endif /* IN_RING0 */
163 * Overridable function that decides whether assertions executes the panic
164 * (breakpoint) or not.
166 * The generic implementation will return true.
168 * @returns true if the breakpoint should be hit, false if it should be ignored.
170 * @remark The RTDECL() makes this a bit difficult to override on Windows. So,
171 * you'll have to use RTASSERT_HAVE_SHOULD_PANIC or
172 * RTASSERT_HAVE_SHOULD_PANIC_PRIVATE there to control the kind of
175 #if !defined(RTASSERT_HAVE_SHOULD_PANIC) && !defined(RTASSERT_HAVE_SHOULD_PANIC_PRIVATE)
176 RTDECL(bool) RTAssertShouldPanic(void);
177 #elif defined(RTASSERT_HAVE_SHOULD_PANIC_PRIVATE)
178 bool RTAssertShouldPanic(void);
180 DECLEXPORT(bool) RTCALL
RTAssertShouldPanic(void);
184 * Controls whether the assertions should be quiet or noisy (default).
186 * @returns The old setting.
187 * @param fQuiet The new setting.
189 RTDECL(bool) RTAssertSetQuiet(bool fQuiet
);
192 * Are assertions quiet or noisy?
194 * @returns True if they are quiet, false if noisy.
196 RTDECL(bool) RTAssertAreQuiet(void);
199 * Makes the assertions panic (default) or not.
201 * @returns The old setting.
202 * @param fPanic The new setting.
204 RTDECL(bool) RTAssertSetMayPanic(bool fPanic
);
207 * Can assertion panic.
209 * @returns True if they can, false if not.
211 RTDECL(bool) RTAssertMayPanic(void);
214 /** @name Globals for crash analysis
215 * @remarks This is the full potential set, it
218 /** The last assert message, 1st part. */
219 extern RTDATADECL(char) g_szRTAssertMsg1
[1024];
220 /** The last assert message, 2nd part. */
221 extern RTDATADECL(char) g_szRTAssertMsg2
[4096];
222 /** The last assert message, expression. */
223 extern RTDATADECL(const char * volatile) g_pszRTAssertExpr
;
224 /** The last assert message, file name. */
225 extern RTDATADECL(const char * volatile) g_pszRTAssertFile
;
226 /** The last assert message, line number. */
227 extern RTDATADECL(uint32_t volatile) g_u32RTAssertLine
;
228 /** The last assert message, function name. */
229 extern RTDATADECL(const char * volatile) g_pszRTAssertFunction
;
234 /** @def RTAssertDebugBreak()
235 * Debugger breakpoint instruction.
237 * @remarks This macro does not depend on RT_STRICT.
239 #define RTAssertDebugBreak() do { RT_BREAKPOINT(); } while (0)
245 * These assertions will only trigger when RT_STRICT is defined. When it is
246 * undefined they will all be no-ops and generate no code.
252 /** @def RTASSERT_QUIET
253 * This can be defined to shut up the messages for a file where this would be
254 * problematic because the message printing code path passes thru it.
256 #ifdef DOXYGEN_RUNNING
257 # define RTASSERT_QUIET
259 #if defined(RTASSERT_QUIET) && !defined(DOXYGEN_RUNNING)
260 # define RTAssertMsg1Weak(pszExpr, uLine, pszfile, pszFunction) \
262 # define RTAssertMsg2Weak if (1) {} else RTAssertMsg2Weak
265 /** @def RTAssertDoPanic
266 * Raises an assertion panic appropriate to the current context.
267 * @remarks This macro does not depend on RT_STRICT.
269 #if defined(IN_RING0) \
270 && (defined(RT_OS_DARWIN) || defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS))
271 # define RTAssertDoPanic() RTR0AssertPanicSystem()
273 # define RTAssertDoPanic() RTAssertDebugBreak()
276 /** @def AssertBreakpoint()
277 * Assertion Breakpoint.
278 * @deprecated Use RTAssertPanic or RTAssertDebugBreak instead.
281 # define AssertBreakpoint() RTAssertDebugBreak()
283 # define AssertBreakpoint() do { } while (0)
286 /** @def RTAssertPanic()
287 * If RT_STRICT is defined this macro will invoke RTAssertDoPanic if
288 * RTAssertShouldPanic returns true. If RT_STRICT isn't defined it won't do any
291 #if defined(RT_STRICT) && !defined(RTASSERT_DONT_PANIC)
292 # define RTAssertPanic() do { if (RTAssertShouldPanic()) RTAssertDoPanic(); } while (0)
294 # define RTAssertPanic() do { } while (0)
298 * Assert that an expression is true. If false, hit breakpoint.
299 * @param expr Expression which should be true.
302 # define Assert(expr) \
304 if (RT_LIKELY(!!(expr))) \
308 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
313 # define Assert(expr) do { } while (0)
318 * Assert that an expression is true. If false, hit breakpoint and execute the
320 * @param expr Expression which should be true.
321 * @param stmt Statement to execute on failure.
324 # define AssertStmt(expr, stmt) \
326 if (RT_LIKELY(!!(expr))) \
330 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
336 # define AssertStmt(expr, stmt) \
338 if (RT_LIKELY(!!(expr))) \
348 /** @def AssertReturn
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.
352 * @param expr Expression which should be true.
353 * @param rc What is to be presented to return.
356 # define AssertReturn(expr, rc) \
358 if (RT_LIKELY(!!(expr))) \
362 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
368 # define AssertReturn(expr, rc) \
370 if (RT_LIKELY(!!(expr))) \
377 /** @def AssertReturnStmt
378 * Assert that an expression is true, if it isn't execute the given statement
381 * In RT_STRICT mode it will hit a breakpoint before executing the statement and
384 * @param expr Expression which should be true.
385 * @param stmt Statement to execute before returning on failure.
386 * @param rc What is to be presented to return.
389 # define AssertReturnStmt(expr, stmt, rc) \
391 if (RT_LIKELY(!!(expr))) \
395 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
402 # define AssertReturnStmt(expr, stmt, rc) \
404 if (RT_LIKELY(!!(expr))) \
414 /** @def AssertReturnVoid
415 * Assert that an expression is true and returns if it isn't.
416 * In RT_STRICT mode it will hit a breakpoint before returning.
418 * @param expr Expression which should be true.
421 # define AssertReturnVoid(expr) \
423 if (RT_LIKELY(!!(expr))) \
427 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
433 # define AssertReturnVoid(expr) \
435 if (RT_LIKELY(!!(expr))) \
442 /** @def AssertReturnVoidStmt
443 * Assert that an expression is true, if it isn't execute the given statement
446 * In RT_STRICT mode it will hit a breakpoint before returning.
448 * @param expr Expression which should be true.
449 * @param stmt Statement to execute before returning on failure.
452 # define AssertReturnVoidStmt(expr, stmt) \
454 if (RT_LIKELY(!!(expr))) \
458 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
465 # define AssertReturnVoidStmt(expr, stmt) \
467 if (RT_LIKELY(!!(expr))) \
479 * Assert that an expression is true and breaks if it isn't.
480 * In RT_STRICT mode it will hit a breakpoint before breaking.
482 * @param expr Expression which should be true.
485 # define AssertBreak(expr) \
486 if (RT_LIKELY(!!(expr))) \
490 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
496 # define AssertBreak(expr) \
497 if (RT_LIKELY(!!(expr))) \
503 /** @def AssertContinue
504 * Assert that an expression is true and continue if it isn't.
505 * In RT_STRICT mode it will hit a breakpoint before continuing.
507 * @param expr Expression which should be true.
510 # define AssertContinue(expr) \
511 if (RT_LIKELY(!!(expr))) \
515 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
518 } else do {} while (0)
520 # define AssertContinue(expr) \
521 if (RT_LIKELY(!!(expr))) \
527 /** @def AssertBreakStmt
528 * Assert that an expression is true and breaks if it isn't.
529 * In RT_STRICT mode it will hit a breakpoint before doing break.
531 * @param expr Expression which should be true.
532 * @param stmt Statement to execute before break in case of a failed assertion.
535 # define AssertBreakStmt(expr, stmt) \
536 if (RT_LIKELY(!!(expr))) \
540 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
544 } else do {} while (0)
546 # define AssertBreakStmt(expr, stmt) \
547 if (RT_LIKELY(!!(expr))) \
553 } else do {} while (0)
558 * Assert that an expression is true. If it's not print message and hit breakpoint.
559 * @param expr Expression which should be true.
560 * @param a printf argument list (in parenthesis).
563 # define AssertMsg(expr, a) \
565 if (RT_LIKELY(!!(expr))) \
569 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
570 RTAssertMsg2Weak a; \
575 # define AssertMsg(expr, a) do { } while (0)
578 /** @def AssertMsgStmt
579 * Assert that an expression is true. If it's not print message and hit
580 * breakpoint and execute the statement.
582 * @param expr Expression which should be true.
583 * @param a printf argument list (in parenthesis).
584 * @param stmt Statement to execute in case of a failed assertion.
586 * @remarks The expression and statement will be evaluated in all build types.
589 # define AssertMsgStmt(expr, a, stmt) \
591 if (RT_LIKELY(!!(expr))) \
595 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
596 RTAssertMsg2Weak a; \
602 # define AssertMsgStmt(expr, a, stmt) \
604 if (RT_LIKELY(!!(expr))) \
613 /** @def AssertMsgReturn
614 * Assert that an expression is true and returns if it isn't.
615 * In RT_STRICT mode it will hit a breakpoint before returning.
617 * @param expr Expression which should be true.
618 * @param a printf argument list (in parenthesis).
619 * @param rc What is to be presented to return.
622 # define AssertMsgReturn(expr, a, rc) \
624 if (RT_LIKELY(!!(expr))) \
628 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
629 RTAssertMsg2Weak a; \
635 # define AssertMsgReturn(expr, a, rc) \
637 if (RT_LIKELY(!!(expr))) \
644 /** @def AssertMsgReturnStmt
645 * Assert that an expression is true, if it isn't execute the statement and
648 * In RT_STRICT mode it will hit a breakpoint before returning.
650 * @param expr Expression which should be true.
651 * @param a printf argument list (in parenthesis).
652 * @param stmt Statement to execute before returning in case of a failed
654 * @param rc What is to be presented to return.
657 # define AssertMsgReturnStmt(expr, a, stmt, rc) \
659 if (RT_LIKELY(!!(expr))) \
663 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
664 RTAssertMsg2Weak a; \
671 # define AssertMsgReturnStmt(expr, a, stmt, rc) \
673 if (RT_LIKELY(!!(expr))) \
683 /** @def AssertMsgReturnVoid
684 * Assert that an expression is true and returns if it isn't.
685 * In RT_STRICT mode it will hit a breakpoint before returning.
687 * @param expr Expression which should be true.
688 * @param a printf argument list (in parenthesis).
691 # define AssertMsgReturnVoid(expr, a) \
693 if (RT_LIKELY(!!(expr))) \
697 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
698 RTAssertMsg2Weak a; \
704 # define AssertMsgReturnVoid(expr, a) \
706 if (RT_LIKELY(!!(expr))) \
713 /** @def AssertMsgReturnVoidStmt
714 * Assert that an expression is true, if it isn't execute the statement and
717 * In RT_STRICT mode it will hit a breakpoint before returning.
719 * @param expr Expression which should be true.
720 * @param a printf argument list (in parenthesis).
721 * @param stmt Statement to execute before return in case of a failed assertion.
724 # define AssertMsgReturnVoidStmt(expr, a, stmt) \
726 if (RT_LIKELY(!!(expr))) \
730 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
731 RTAssertMsg2Weak a; \
738 # define AssertMsgReturnVoidStmt(expr, a, stmt) \
740 if (RT_LIKELY(!!(expr))) \
751 /** @def AssertMsgBreak
752 * Assert that an expression is true and breaks if it isn't.
753 * In RT_STRICT mode it will hit a breakpoint before returning.
755 * @param expr Expression which should be true.
756 * @param a printf argument list (in parenthesis).
759 # define AssertMsgBreak(expr, a) \
760 if (RT_LIKELY(!!(expr))) \
764 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
765 RTAssertMsg2Weak a; \
771 # define AssertMsgBreak(expr, a) \
772 if (RT_LIKELY(!!(expr))) \
778 /** @def AssertMsgBreakStmt
779 * Assert that an expression is true and breaks if it isn't.
780 * In RT_STRICT mode it will hit a breakpoint before doing break.
782 * @param expr Expression which should be true.
783 * @param a printf argument list (in parenthesis).
784 * @param stmt Statement to execute before break in case of a failed assertion.
787 # define AssertMsgBreakStmt(expr, a, stmt) \
788 if (RT_LIKELY(!!(expr))) \
792 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
793 RTAssertMsg2Weak a; \
800 # define AssertMsgBreakStmt(expr, a, stmt) \
801 if (RT_LIKELY(!!(expr))) \
811 /** @def AssertFailed
812 * An assertion failed, hit breakpoint.
815 # define AssertFailed() \
817 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
821 # define AssertFailed() do { } while (0)
824 /** @def AssertFailedStmt
825 * An assertion failed, hit breakpoint and execute statement.
828 # define AssertFailedStmt(stmt) \
830 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
835 # define AssertFailedStmt(stmt) do { stmt; } while (0)
838 /** @def AssertFailedReturn
839 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
841 * @param rc The rc to return.
844 # define AssertFailedReturn(rc) \
846 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
851 # define AssertFailedReturn(rc) \
857 /** @def AssertFailedReturnStmt
858 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a
859 * statement and return a value.
861 * @param stmt The statement to execute before returning.
862 * @param rc The value to return.
865 # define AssertFailedReturnStmt(stmt, rc) \
867 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
873 # define AssertFailedReturnStmt(stmt, rc) \
880 /** @def AssertFailedReturnVoid
881 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
884 # define AssertFailedReturnVoid() \
886 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
891 # define AssertFailedReturnVoid() \
897 /** @def AssertFailedReturnVoidStmt
898 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a
899 * statement and return.
901 * @param stmt The statement to execute before returning.
904 # define AssertFailedReturnVoidStmt(stmt) \
906 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
912 # define AssertFailedReturnVoidStmt(stmt) \
920 /** @def AssertFailedBreak
921 * An assertion failed, hit breakpoint (RT_STRICT mode only) and break.
924 # define AssertFailedBreak() \
926 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
932 # define AssertFailedBreak() \
939 /** @def AssertFailedBreakStmt
940 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
941 * the given statement and break.
943 * @param stmt Statement to execute before break.
946 # define AssertFailedBreakStmt(stmt) \
948 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
955 # define AssertFailedBreakStmt(stmt) \
964 /** @def AssertMsgFailed
965 * An assertion failed print a message and a hit breakpoint.
967 * @param a printf argument list (in parenthesis).
970 # define AssertMsgFailed(a) \
972 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
973 RTAssertMsg2Weak a; \
977 # define AssertMsgFailed(a) do { } while (0)
980 /** @def AssertMsgFailedReturn
981 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
983 * @param a printf argument list (in parenthesis).
984 * @param rc What is to be presented to return.
987 # define AssertMsgFailedReturn(a, rc) \
989 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
990 RTAssertMsg2Weak a; \
995 # define AssertMsgFailedReturn(a, rc) \
1001 /** @def AssertMsgFailedReturnVoid
1002 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
1004 * @param a printf argument list (in parenthesis).
1007 # define AssertMsgFailedReturnVoid(a) \
1009 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1010 RTAssertMsg2Weak a; \
1015 # define AssertMsgFailedReturnVoid(a) \
1022 /** @def AssertMsgFailedBreak
1023 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and break.
1025 * @param a printf argument list (in parenthesis).
1028 # define AssertMsgFailedBreak(a) \
1030 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1031 RTAssertMsg2Weak a; \
1037 # define AssertMsgFailedBreak(a) \
1044 /** @def AssertMsgFailedBreakStmt
1045 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
1046 * the given statement and break.
1048 * @param a printf argument list (in parenthesis).
1049 * @param stmt Statement to execute before break.
1052 # define AssertMsgFailedBreakStmt(a, stmt) \
1054 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1055 RTAssertMsg2Weak a; \
1062 # define AssertMsgFailedBreakStmt(a, stmt) \
1074 /** @name Release Log Assertions
1076 * These assertions will work like normal strict assertion when RT_STRICT is
1077 * defined and LogRel statements when RT_STRICT is undefined. Typically used for
1078 * things which shouldn't go wrong, but when it does you'd like to know one way
1084 /** @def RTAssertLogRelMsg1
1085 * RTAssertMsg1Weak (strict builds) / LogRel wrapper (non-strict).
1088 # define RTAssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
1089 RTAssertMsg1Weak(pszExpr, iLine, pszFile, pszFunction)
1091 # define RTAssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
1092 LogRel(("AssertLogRel %s(%d) %s: %s\n",\
1093 (pszFile), (iLine), (pszFunction), (pszExpr) ))
1096 /** @def RTAssertLogRelMsg2
1097 * RTAssertMsg2Weak (strict builds) / LogRel wrapper (non-strict).
1100 # define RTAssertLogRelMsg2(a) RTAssertMsg2Weak a
1102 # define RTAssertLogRelMsg2(a) LogRel(a)
1105 /** @def AssertLogRel
1106 * Assert that an expression is true.
1107 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1109 * @param expr Expression which should be true.
1111 #define AssertLogRel(expr) \
1113 if (RT_LIKELY(!!(expr))) \
1117 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1122 /** @def AssertLogRelReturn
1123 * Assert that an expression is true, return \a rc if it isn't.
1124 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1126 * @param expr Expression which should be true.
1127 * @param rc What is to be presented to return.
1129 #define AssertLogRelReturn(expr, rc) \
1131 if (RT_LIKELY(!!(expr))) \
1135 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1141 /** @def AssertLogRelReturnVoid
1142 * Assert that an expression is true, return void if it isn't.
1143 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1145 * @param expr Expression which should be true.
1147 #define AssertLogRelReturnVoid(expr) \
1149 if (RT_LIKELY(!!(expr))) \
1153 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1159 /** @def AssertLogRelBreak
1160 * Assert that an expression is true, break if it isn't.
1161 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1163 * @param expr Expression which should be true.
1165 #define AssertLogRelBreak(expr) \
1166 if (RT_LIKELY(!!(expr))) \
1170 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1177 /** @def AssertLogRelBreakStmt
1178 * Assert that an expression is true, execute \a stmt and break if it isn't.
1179 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1181 * @param expr Expression which should be true.
1182 * @param stmt Statement to execute before break in case of a failed assertion.
1184 #define AssertLogRelBreakStmt(expr, stmt) \
1185 if (RT_LIKELY(!!(expr))) \
1189 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1196 /** @def AssertLogRelMsg
1197 * Assert that an expression is true.
1198 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1200 * @param expr Expression which should be true.
1201 * @param a printf argument list (in parenthesis).
1203 #define AssertLogRelMsg(expr, a) \
1205 if (RT_LIKELY(!!(expr))) \
1209 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1210 RTAssertLogRelMsg2(a); \
1215 /** @def AssertLogRelMsgStmt
1216 * Assert that an expression is true, execute \a stmt and break if it isn't
1217 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1219 * @param expr Expression which should be true.
1220 * @param a printf argument list (in parenthesis).
1221 * @param stmt Statement to execute in case of a failed assertion.
1223 #define AssertLogRelMsgStmt(expr, a, stmt) \
1225 if (RT_LIKELY(!!(expr))) \
1229 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1230 RTAssertLogRelMsg2(a); \
1236 /** @def AssertLogRelMsgReturn
1237 * Assert that an expression is true, return \a rc if it isn't.
1238 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1240 * @param expr Expression which should be true.
1241 * @param a printf argument list (in parenthesis).
1242 * @param rc What is to be presented to return.
1244 #define AssertLogRelMsgReturn(expr, a, rc) \
1246 if (RT_LIKELY(!!(expr))) \
1250 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1251 RTAssertLogRelMsg2(a); \
1257 /** @def AssertLogRelMsgReturnStmt
1258 * Assert that an expression is true, execute @a stmt and return @a rcRet if it
1260 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1262 * @param expr Expression which should be true.
1263 * @param a printf argument list (in parenthesis).
1264 * @param stmt Statement to execute before returning in case of a failed
1266 * @param rcRet What is to be presented to return.
1268 #define AssertLogRelMsgReturnStmt(expr, a, stmt, rcRet) \
1270 if (RT_LIKELY(!!(expr))) \
1274 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1275 RTAssertLogRelMsg2(a); \
1282 /** @def AssertLogRelMsgReturnVoid
1283 * Assert that an expression is true, return (void) if it isn't.
1284 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1286 * @param expr Expression which should be true.
1287 * @param a printf argument list (in parenthesis).
1289 #define AssertLogRelMsgReturnVoid(expr, a) \
1291 if (RT_LIKELY(!!(expr))) \
1295 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1296 RTAssertLogRelMsg2(a); \
1302 /** @def AssertLogRelMsgBreak
1303 * Assert that an expression is true, break if it isn't.
1304 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1306 * @param expr Expression which should be true.
1307 * @param a printf argument list (in parenthesis).
1309 #define AssertLogRelMsgBreak(expr, a) \
1310 if (RT_LIKELY(!!(expr))) \
1314 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1315 RTAssertLogRelMsg2(a); \
1322 /** @def AssertLogRelMsgBreakStmt
1323 * Assert that an expression is true, execute \a stmt and break if it isn't.
1324 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1326 * @param expr Expression which should be true.
1327 * @param a printf argument list (in parenthesis).
1328 * @param stmt Statement to execute before break in case of a failed assertion.
1330 #define AssertLogRelMsgBreakStmt(expr, a, stmt) \
1331 if (RT_LIKELY(!!(expr))) \
1335 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1336 RTAssertLogRelMsg2(a); \
1343 /** @def AssertLogRelFailed
1344 * An assertion failed.
1345 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1347 #define AssertLogRelFailed() \
1349 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1353 /** @def AssertLogRelFailedReturn
1354 * An assertion failed.
1355 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1357 * @param rc What is to be presented to return.
1359 #define AssertLogRelFailedReturn(rc) \
1361 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1366 /** @def AssertLogRelFailedReturnVoid
1367 * An assertion failed, hit a breakpoint and return.
1368 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1370 #define AssertLogRelFailedReturnVoid() \
1372 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1377 /** @def AssertLogRelFailedBreak
1378 * An assertion failed, break.
1379 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1381 #define AssertLogRelFailedBreak() \
1384 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1390 /** @def AssertLogRelFailedBreakStmt
1391 * An assertion failed, execute \a stmt and break.
1392 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1394 * @param stmt Statement to execute before break.
1396 #define AssertLogRelFailedBreakStmt(stmt) \
1399 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1406 /** @def AssertLogRelMsgFailed
1407 * An assertion failed.
1408 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1410 * @param a printf argument list (in parenthesis).
1412 #define AssertLogRelMsgFailed(a) \
1414 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1415 RTAssertLogRelMsg2(a); \
1419 /** @def AssertLogRelMsgFailedStmt
1420 * An assertion failed, execute @a stmt.
1422 * Strict builds will hit a breakpoint, non-strict will only do LogRel. The
1423 * statement will be executed in regardless of build type.
1425 * @param a printf argument list (in parenthesis).
1426 * @param stmt Statement to execute after raising/logging the assertion.
1428 #define AssertLogRelMsgFailedStmt(a, stmt) \
1430 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1431 RTAssertLogRelMsg2(a); \
1436 /** @def AssertLogRelMsgFailedReturn
1437 * An assertion failed, return \a rc.
1438 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1440 * @param a printf argument list (in parenthesis).
1441 * @param rc What is to be presented to return.
1443 #define AssertLogRelMsgFailedReturn(a, rc) \
1445 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1446 RTAssertLogRelMsg2(a); \
1451 /** @def AssertLogRelMsgFailedReturnStmt
1452 * An assertion failed, execute @a stmt and return @a rc.
1453 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1455 * @param a printf argument list (in parenthesis).
1456 * @param stmt Statement to execute before returning in case of a failed
1458 * @param rc What is to be presented to return.
1460 #define AssertLogRelMsgFailedReturnStmt(a, stmt, rc) \
1462 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1463 RTAssertLogRelMsg2(a); \
1469 /** @def AssertLogRelMsgFailedReturnVoid
1470 * An assertion failed, return void.
1471 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1473 * @param a printf argument list (in parenthesis).
1475 #define AssertLogRelMsgFailedReturnVoid(a) \
1477 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1478 RTAssertLogRelMsg2(a); \
1483 /** @def AssertLogRelMsgFailedReturnVoidStmt
1484 * An assertion failed, execute @a stmt and return void.
1485 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1487 * @param a printf argument list (in parenthesis).
1488 * @param stmt Statement to execute before returning in case of a failed
1491 #define AssertLogRelMsgFailedReturnVoidStmt(a, stmt) \
1493 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1494 RTAssertLogRelMsg2(a); \
1500 /** @def AssertLogRelMsgFailedBreak
1501 * An assertion failed, break.
1502 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1504 * @param a printf argument list (in parenthesis).
1506 #define AssertLogRelMsgFailedBreak(a) \
1509 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1510 RTAssertLogRelMsg2(a); \
1516 /** @def AssertLogRelMsgFailedBreakStmt
1517 * An assertion failed, execute \a stmt and break.
1518 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1520 * @param a printf argument list (in parenthesis).
1521 * @param stmt Statement to execute before break.
1523 #define AssertLogRelMsgFailedBreakStmt(a, stmt) \
1526 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1527 RTAssertLogRelMsg2(a); \
1538 /** @name Release Assertions
1540 * These assertions are always enabled.
1544 /** @def RTAssertReleasePanic()
1545 * Invokes RTAssertShouldPanic and RTAssertDoPanic.
1547 * It might seem odd that RTAssertShouldPanic is necessary when its result isn't
1548 * checked, but it's done since RTAssertShouldPanic is overrideable and might be
1549 * used to bail out before taking down the system (the VMMR0 case).
1551 #define RTAssertReleasePanic() do { RTAssertShouldPanic(); RTAssertDoPanic(); } while (0)
1554 /** @def AssertRelease
1555 * Assert that an expression is true. If it's not hit a breakpoint.
1557 * @param expr Expression which should be true.
1559 #define AssertRelease(expr) \
1561 if (RT_LIKELY(!!(expr))) \
1565 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1566 RTAssertReleasePanic(); \
1570 /** @def AssertReleaseReturn
1571 * Assert that an expression is true, hit a breakpoint and return if it isn't.
1573 * @param expr Expression which should be true.
1574 * @param rc What is to be presented to return.
1576 #define AssertReleaseReturn(expr, rc) \
1578 if (RT_LIKELY(!!(expr))) \
1582 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1583 RTAssertReleasePanic(); \
1588 /** @def AssertReleaseReturnVoid
1589 * Assert that an expression is true, hit a breakpoint and return if it isn't.
1591 * @param expr Expression which should be true.
1593 #define AssertReleaseReturnVoid(expr) \
1595 if (RT_LIKELY(!!(expr))) \
1599 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1600 RTAssertReleasePanic(); \
1606 /** @def AssertReleaseBreak
1607 * Assert that an expression is true, hit a breakpoint and break if it isn't.
1609 * @param expr Expression which should be true.
1611 #define AssertReleaseBreak(expr) \
1612 if (RT_LIKELY(!!(expr))) \
1616 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1617 RTAssertReleasePanic(); \
1622 /** @def AssertReleaseBreakStmt
1623 * Assert that an expression is true, hit a breakpoint and break if it isn't.
1625 * @param expr Expression which should be true.
1626 * @param stmt Statement to execute before break in case of a failed assertion.
1628 #define AssertReleaseBreakStmt(expr, stmt) \
1629 if (RT_LIKELY(!!(expr))) \
1633 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1634 RTAssertReleasePanic(); \
1641 /** @def AssertReleaseMsg
1642 * Assert that an expression is true, print the message and hit a breakpoint if it isn't.
1644 * @param expr Expression which should be true.
1645 * @param a printf argument list (in parenthesis).
1647 #define AssertReleaseMsg(expr, a) \
1649 if (RT_LIKELY(!!(expr))) \
1653 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1654 RTAssertMsg2Weak a; \
1655 RTAssertReleasePanic(); \
1659 /** @def AssertReleaseMsgReturn
1660 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1662 * @param expr Expression which should be true.
1663 * @param a printf argument list (in parenthesis).
1664 * @param rc What is to be presented to return.
1666 #define AssertReleaseMsgReturn(expr, a, rc) \
1668 if (RT_LIKELY(!!(expr))) \
1672 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1673 RTAssertMsg2Weak a; \
1674 RTAssertReleasePanic(); \
1679 /** @def AssertReleaseMsgReturnVoid
1680 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1682 * @param expr Expression which should be true.
1683 * @param a printf argument list (in parenthesis).
1685 #define AssertReleaseMsgReturnVoid(expr, a) \
1687 if (RT_LIKELY(!!(expr))) \
1691 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1692 RTAssertMsg2Weak a; \
1693 RTAssertReleasePanic(); \
1699 /** @def AssertReleaseMsgBreak
1700 * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
1702 * @param expr Expression which should be true.
1703 * @param a printf argument list (in parenthesis).
1705 #define AssertReleaseMsgBreak(expr, a) \
1706 if (RT_LIKELY(!!(expr))) \
1710 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1711 RTAssertMsg2Weak a; \
1712 RTAssertReleasePanic(); \
1717 /** @def AssertReleaseMsgBreakStmt
1718 * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
1720 * @param expr Expression which should be true.
1721 * @param a printf argument list (in parenthesis).
1722 * @param stmt Statement to execute before break in case of a failed assertion.
1724 #define AssertReleaseMsgBreakStmt(expr, a, stmt) \
1725 if (RT_LIKELY(!!(expr))) \
1729 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1730 RTAssertMsg2Weak a; \
1731 RTAssertReleasePanic(); \
1738 /** @def AssertReleaseFailed
1739 * An assertion failed, hit a breakpoint.
1741 #define AssertReleaseFailed() \
1743 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1744 RTAssertReleasePanic(); \
1747 /** @def AssertReleaseFailedReturn
1748 * An assertion failed, hit a breakpoint and return.
1750 * @param rc What is to be presented to return.
1752 #define AssertReleaseFailedReturn(rc) \
1754 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1755 RTAssertReleasePanic(); \
1759 /** @def AssertReleaseFailedReturnVoid
1760 * An assertion failed, hit a breakpoint and return.
1762 #define AssertReleaseFailedReturnVoid() \
1764 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1765 RTAssertReleasePanic(); \
1770 /** @def AssertReleaseFailedBreak
1771 * An assertion failed, hit a breakpoint and break.
1773 #define AssertReleaseFailedBreak() \
1775 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1776 RTAssertReleasePanic(); \
1781 /** @def AssertReleaseFailedBreakStmt
1782 * An assertion failed, hit a breakpoint and break.
1784 * @param stmt Statement to execute before break.
1786 #define AssertReleaseFailedBreakStmt(stmt) \
1788 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1789 RTAssertReleasePanic(); \
1796 /** @def AssertReleaseMsgFailed
1797 * An assertion failed, print a message and hit a breakpoint.
1799 * @param a printf argument list (in parenthesis).
1801 #define AssertReleaseMsgFailed(a) \
1803 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1804 RTAssertMsg2Weak a; \
1805 RTAssertReleasePanic(); \
1808 /** @def AssertReleaseMsgFailedReturn
1809 * An assertion failed, print a message, hit a breakpoint and return.
1811 * @param a printf argument list (in parenthesis).
1812 * @param rc What is to be presented to return.
1814 #define AssertReleaseMsgFailedReturn(a, rc) \
1816 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1817 RTAssertMsg2Weak a; \
1818 RTAssertReleasePanic(); \
1822 /** @def AssertReleaseMsgFailedReturnVoid
1823 * An assertion failed, print a message, hit a breakpoint and return.
1825 * @param a printf argument list (in parenthesis).
1827 #define AssertReleaseMsgFailedReturnVoid(a) \
1829 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1830 RTAssertMsg2Weak a; \
1831 RTAssertReleasePanic(); \
1836 /** @def AssertReleaseMsgFailedBreak
1837 * An assertion failed, print a message, hit a breakpoint and break.
1839 * @param a printf argument list (in parenthesis).
1841 #define AssertReleaseMsgFailedBreak(a) \
1843 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1844 RTAssertMsg2Weak a; \
1845 RTAssertReleasePanic(); \
1850 /** @def AssertReleaseMsgFailedBreakStmt
1851 * An assertion failed, print a message, hit a breakpoint and break.
1853 * @param a printf argument list (in parenthesis).
1854 * @param stmt Statement to execute before break.
1856 #define AssertReleaseMsgFailedBreakStmt(a, stmt) \
1858 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1859 RTAssertMsg2Weak a; \
1860 RTAssertReleasePanic(); \
1870 /** @name Fatal Assertions
1871 * These are similar to release assertions except that you cannot ignore them in
1872 * any way, they will loop for ever if RTAssertDoPanic returns.
1877 /** @def AssertFatal
1878 * Assert that an expression is true. If it's not hit a breakpoint (for ever).
1880 * @param expr Expression which should be true.
1882 #define AssertFatal(expr) \
1884 if (RT_LIKELY(!!(expr))) \
1889 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1890 RTAssertReleasePanic(); \
1894 /** @def AssertFatalMsg
1895 * Assert that an expression is true, print the message and hit a breakpoint (for ever) if it isn't.
1897 * @param expr Expression which should be true.
1898 * @param a printf argument list (in parenthesis).
1900 #define AssertFatalMsg(expr, a) \
1902 if (RT_LIKELY(!!(expr))) \
1907 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1908 RTAssertMsg2Weak a; \
1909 RTAssertReleasePanic(); \
1913 /** @def AssertFatalFailed
1914 * An assertion failed, hit a breakpoint (for ever).
1916 #define AssertFatalFailed() \
1920 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1921 RTAssertReleasePanic(); \
1925 /** @def AssertFatalMsgFailed
1926 * An assertion failed, print a message and hit a breakpoint (for ever).
1928 * @param a printf argument list (in parenthesis).
1930 #define AssertFatalMsgFailed(a) \
1934 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1935 RTAssertMsg2Weak a; \
1936 RTAssertReleasePanic(); \
1944 /** @name Convenience Assertions Macros
1949 * Asserts a iprt status code successful.
1951 * On failure it will print info about the rc and hit a breakpoint.
1953 * @param rc iprt status code.
1954 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1956 #define AssertRC(rc) AssertMsgRC(rc, ("%Rra\n", (rc)))
1958 /** @def AssertRCStmt
1959 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and execute
1960 * @a stmt if it isn't.
1962 * @param rc iprt status code.
1963 * @param stmt Statement to execute before returning in case of a failed
1965 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1967 #define AssertRCStmt(rc, stmt) AssertMsgRCStmt(rc, ("%Rra\n", (rc)), stmt)
1969 /** @def AssertRCReturn
1970 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
1972 * @param rc iprt status code.
1973 * @param rcRet What is to be presented to return.
1974 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1976 #define AssertRCReturn(rc, rcRet) AssertMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
1978 /** @def AssertRCReturnStmt
1979 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
1980 * @a stmt and returns @a rcRet if it isn't.
1982 * @param rc iprt status code.
1983 * @param stmt Statement to execute before returning in case of a failed
1985 * @param rcRet What is to be presented to return.
1986 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1988 #define AssertRCReturnStmt(rc, stmt, rcRet) AssertMsgRCReturnStmt(rc, ("%Rra\n", (rc)), stmt, rcRet)
1990 /** @def AssertRCReturnVoid
1991 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
1993 * @param rc iprt status code.
1994 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1996 #define AssertRCReturnVoid(rc) AssertMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
1998 /** @def AssertRCReturnVoidStmt
1999 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), and
2000 * execute the given statement/return if it isn't.
2002 * @param rc iprt status code.
2003 * @param stmt Statement to execute before returning on failure.
2004 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2006 #define AssertRCReturnVoidStmt(rc, stmt) AssertMsgRCReturnVoidStmt(rc, ("%Rra\n", (rc)), stmt)
2008 /** @def AssertRCBreak
2009 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
2011 * @param rc iprt status code.
2012 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2014 #define AssertRCBreak(rc) AssertMsgRCBreak(rc, ("%Rra\n", (rc)))
2016 /** @def AssertRCBreakStmt
2017 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
2019 * @param rc iprt status code.
2020 * @param stmt Statement to execute before break in case of a failed assertion.
2021 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2023 #define AssertRCBreakStmt(rc, stmt) AssertMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
2025 /** @def AssertMsgRC
2026 * Asserts a iprt status code successful.
2028 * It prints a custom message and hits a breakpoint on FAILURE.
2030 * @param rc iprt status code.
2031 * @param msg printf argument list (in parenthesis).
2032 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2034 #define AssertMsgRC(rc, msg) \
2035 do { AssertMsg(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
2037 /** @def AssertMsgRCStmt
2038 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and
2039 * execute @a stmt if it isn't.
2041 * @param rc iprt status code.
2042 * @param msg printf argument list (in parenthesis).
2043 * @param stmt Statement to execute before returning in case of a failed
2045 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2047 #define AssertMsgRCStmt(rc, msg, stmt) \
2048 do { AssertMsgStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
2050 /** @def AssertMsgRCReturn
2051 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return
2052 * @a rcRet if it isn't.
2054 * @param rc iprt status code.
2055 * @param msg printf argument list (in parenthesis).
2056 * @param rcRet What is to be presented to return.
2057 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2059 #define AssertMsgRCReturn(rc, msg, rcRet) \
2060 do { AssertMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet); NOREF(rc); } while (0)
2062 /** @def AssertMsgRCReturnStmt
2063 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
2064 * @a stmt and return @a rcRet if it isn't.
2066 * @param rc iprt status code.
2067 * @param msg printf argument list (in parenthesis).
2068 * @param stmt Statement to execute before returning in case of a failed
2070 * @param rcRet What is to be presented to return.
2071 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2073 #define AssertMsgRCReturnStmt(rc, msg, stmt, rcRet) \
2074 do { AssertMsgReturnStmt(RT_SUCCESS_NP(rc), msg, stmt, rcRet); NOREF(rc); } while (0)
2076 /** @def AssertMsgRCReturnVoid
2077 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return
2080 * @param rc iprt status code.
2081 * @param msg printf argument list (in parenthesis).
2082 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2084 #define AssertMsgRCReturnVoid(rc, msg) \
2085 do { AssertMsgReturnVoid(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
2087 /** @def AssertMsgRCReturnVoidStmt
2088 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
2089 * @a stmt and return void if it isn't.
2091 * @param rc iprt status code.
2092 * @param msg printf argument list (in parenthesis).
2093 * @param stmt Statement to execute before break in case of a failed assertion.
2094 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2096 #define AssertMsgRCReturnVoidStmt(rc, msg, stmt) \
2097 do { AssertMsgReturnVoidStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
2099 /** @def AssertMsgRCBreak
2100 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break
2103 * @param rc iprt status code.
2104 * @param msg printf argument list (in parenthesis).
2105 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2107 #define AssertMsgRCBreak(rc, msg) \
2108 if (1) { AssertMsgBreak(RT_SUCCESS(rc), msg); NOREF(rc); } else do {} while (0)
2110 /** @def AssertMsgRCBreakStmt
2111 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
2112 * @a stmt and break if it isn't.
2114 * @param rc iprt status code.
2115 * @param msg printf argument list (in parenthesis).
2116 * @param stmt Statement to execute before break in case of a failed assertion.
2117 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2119 #define AssertMsgRCBreakStmt(rc, msg, stmt) \
2120 if (1) { AssertMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } else do {} while (0)
2122 /** @def AssertRCSuccess
2123 * Asserts an iprt status code equals VINF_SUCCESS.
2125 * On failure it will print info about the rc and hit a breakpoint.
2127 * @param rc iprt status code.
2128 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2130 #define AssertRCSuccess(rc) do { AssertMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc))); NOREF(rc); } while (0)
2132 /** @def AssertRCSuccessReturn
2133 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
2135 * @param rc iprt status code.
2136 * @param rcRet What is to be presented to return.
2137 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2139 #define AssertRCSuccessReturn(rc, rcRet) AssertMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
2141 /** @def AssertRCSuccessReturnVoid
2142 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
2144 * @param rc iprt status code.
2145 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2147 #define AssertRCSuccessReturnVoid(rc) AssertMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2149 /** @def AssertRCSuccessBreak
2150 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
2152 * @param rc iprt status code.
2153 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2155 #define AssertRCSuccessBreak(rc) AssertMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2157 /** @def AssertRCSuccessBreakStmt
2158 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
2160 * @param rc iprt status code.
2161 * @param stmt Statement to execute before break in case of a failed assertion.
2162 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2164 #define AssertRCSuccessBreakStmt(rc, stmt) AssertMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
2167 /** @def AssertLogRelRC
2168 * Asserts a iprt status code successful.
2170 * @param rc iprt status code.
2171 * @remark rc is referenced multiple times.
2173 #define AssertLogRelRC(rc) AssertLogRelMsgRC(rc, ("%Rra\n", (rc)))
2175 /** @def AssertLogRelRCReturn
2176 * Asserts a iprt status code successful, returning \a rc if it isn't.
2178 * @param rc iprt status code.
2179 * @param rcRet What is to be presented to return.
2180 * @remark rc is referenced multiple times.
2182 #define AssertLogRelRCReturn(rc, rcRet) AssertLogRelMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
2184 /** @def AssertLogRelRCReturnStmt
2185 * Asserts a iprt status code successful, executing \a stmt and returning \a rc
2188 * @param rc iprt status code.
2189 * @param stmt Statement to execute before returning in case of a failed
2191 * @param rcRet What is to be presented to return.
2192 * @remark rc is referenced multiple times.
2194 #define AssertLogRelRCReturnStmt(rc, stmt, rcRet) AssertLogRelMsgRCReturnStmt(rc, ("%Rra\n", (rc)), stmt, rcRet)
2196 /** @def AssertLogRelRCReturnVoid
2197 * Asserts a iprt status code successful, returning (void) if it isn't.
2199 * @param rc iprt status code.
2200 * @remark rc is referenced multiple times.
2202 #define AssertLogRelRCReturnVoid(rc) AssertLogRelMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
2204 /** @def AssertLogRelRCBreak
2205 * Asserts a iprt status code successful, breaking if it isn't.
2207 * @param rc iprt status code.
2208 * @remark rc is referenced multiple times.
2210 #define AssertLogRelRCBreak(rc) AssertLogRelMsgRCBreak(rc, ("%Rra\n", (rc)))
2212 /** @def AssertLogRelRCBreakStmt
2213 * Asserts a iprt status code successful, execute \a statement and break if it isn't.
2215 * @param rc iprt status code.
2216 * @param stmt Statement to execute before break in case of a failed assertion.
2217 * @remark rc is referenced multiple times.
2219 #define AssertLogRelRCBreakStmt(rc, stmt) AssertLogRelMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
2221 /** @def AssertLogRelMsgRC
2222 * Asserts a iprt status code successful.
2224 * @param rc iprt status code.
2225 * @param msg printf argument list (in parenthesis).
2226 * @remark rc is referenced multiple times.
2228 #define AssertLogRelMsgRC(rc, msg) AssertLogRelMsg(RT_SUCCESS_NP(rc), msg)
2230 /** @def AssertLogRelMsgRCReturn
2231 * Asserts a iprt status code successful.
2233 * @param rc iprt status code.
2234 * @param msg printf argument list (in parenthesis).
2235 * @param rcRet What is to be presented to return.
2236 * @remark rc is referenced multiple times.
2238 #define AssertLogRelMsgRCReturn(rc, msg, rcRet) AssertLogRelMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
2240 /** @def AssertLogRelMsgRCReturnStmt
2241 * Asserts a iprt status code successful, execute \a stmt and return on
2244 * @param rc iprt status code.
2245 * @param msg printf argument list (in parenthesis).
2246 * @param stmt Statement to execute before returning in case of a failed
2248 * @param rcRet What is to be presented to return.
2249 * @remark rc is referenced multiple times.
2251 #define AssertLogRelMsgRCReturnStmt(rc, msg, stmt, rcRet) AssertLogRelMsgReturnStmt(RT_SUCCESS_NP(rc), msg, stmt, rcRet)
2253 /** @def AssertLogRelMsgRCReturnVoid
2254 * Asserts a iprt status code successful.
2256 * @param rc iprt status code.
2257 * @param msg printf argument list (in parenthesis).
2258 * @remark rc is referenced multiple times.
2260 #define AssertLogRelMsgRCReturnVoid(rc, msg) AssertLogRelMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
2262 /** @def AssertLogRelMsgRCBreak
2263 * Asserts a iprt status code successful.
2265 * @param rc iprt status code.
2266 * @param msg printf argument list (in parenthesis).
2267 * @remark rc is referenced multiple times.
2269 #define AssertLogRelMsgRCBreak(rc, msg) AssertLogRelMsgBreak(RT_SUCCESS(rc), msg)
2271 /** @def AssertLogRelMsgRCBreakStmt
2272 * Asserts a iprt status code successful, execute \a stmt and break if it isn't.
2274 * @param rc iprt status code.
2275 * @param msg printf argument list (in parenthesis).
2276 * @param stmt Statement to execute before break in case of a failed assertion.
2277 * @remark rc is referenced multiple times.
2279 #define AssertLogRelMsgRCBreakStmt(rc, msg, stmt) AssertLogRelMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
2281 /** @def AssertLogRelRCSuccess
2282 * Asserts that an iprt status code equals VINF_SUCCESS.
2284 * @param rc iprt status code.
2285 * @remark rc is referenced multiple times.
2287 #define AssertLogRelRCSuccess(rc) AssertLogRelMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2289 /** @def AssertLogRelRCSuccessReturn
2290 * Asserts that an iprt status code equals VINF_SUCCESS.
2292 * @param rc iprt status code.
2293 * @param rcRet What is to be presented to return.
2294 * @remark rc is referenced multiple times.
2296 #define AssertLogRelRCSuccessReturn(rc, rcRet) AssertLogRelMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
2298 /** @def AssertLogRelRCSuccessReturnVoid
2299 * Asserts that an iprt status code equals VINF_SUCCESS.
2301 * @param rc iprt status code.
2302 * @remark rc is referenced multiple times.
2304 #define AssertLogRelRCSuccessReturnVoid(rc) AssertLogRelMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2306 /** @def AssertLogRelRCSuccessBreak
2307 * Asserts that an iprt status code equals VINF_SUCCESS.
2309 * @param rc iprt status code.
2310 * @remark rc is referenced multiple times.
2312 #define AssertLogRelRCSuccessBreak(rc) AssertLogRelMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2314 /** @def AssertLogRelRCSuccessBreakStmt
2315 * Asserts that an iprt status code equals VINF_SUCCESS.
2317 * @param rc iprt status code.
2318 * @param stmt Statement to execute before break in case of a failed assertion.
2319 * @remark rc is referenced multiple times.
2321 #define AssertLogRelRCSuccessBreakStmt(rc, stmt) AssertLogRelMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
2324 /** @def AssertReleaseRC
2325 * Asserts a iprt status code successful.
2327 * On failure information about the error will be printed and a breakpoint hit.
2329 * @param rc iprt status code.
2330 * @remark rc is referenced multiple times.
2332 #define AssertReleaseRC(rc) AssertReleaseMsgRC(rc, ("%Rra\n", (rc)))
2334 /** @def AssertReleaseRCReturn
2335 * Asserts a iprt status code successful, returning if it isn't.
2337 * On failure information about the error will be printed, a breakpoint hit
2338 * and finally returning from the function if the breakpoint is somehow ignored.
2340 * @param rc iprt status code.
2341 * @param rcRet What is to be presented to return.
2342 * @remark rc is referenced multiple times.
2344 #define AssertReleaseRCReturn(rc, rcRet) AssertReleaseMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
2346 /** @def AssertReleaseRCReturnVoid
2347 * Asserts a iprt status code successful, returning if it isn't.
2349 * On failure information about the error will be printed, a breakpoint hit
2350 * and finally returning from the function if the breakpoint is somehow ignored.
2352 * @param rc iprt status code.
2353 * @remark rc is referenced multiple times.
2355 #define AssertReleaseRCReturnVoid(rc) AssertReleaseMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
2357 /** @def AssertReleaseRCBreak
2358 * Asserts a iprt status code successful, breaking if it isn't.
2360 * On failure information about the error will be printed, a breakpoint hit
2361 * and finally breaking the current statement if the breakpoint is somehow ignored.
2363 * @param rc iprt status code.
2364 * @remark rc is referenced multiple times.
2366 #define AssertReleaseRCBreak(rc) AssertReleaseMsgRCBreak(rc, ("%Rra\n", (rc)))
2368 /** @def AssertReleaseRCBreakStmt
2369 * Asserts a iprt status code successful, break if it isn't.
2371 * On failure information about the error will be printed, a breakpoint hit
2372 * and finally the break statement will be issued if the breakpoint is somehow ignored.
2374 * @param rc iprt status code.
2375 * @param stmt Statement to execute before break in case of a failed assertion.
2376 * @remark rc is referenced multiple times.
2378 #define AssertReleaseRCBreakStmt(rc, stmt) AssertReleaseMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
2380 /** @def AssertReleaseMsgRC
2381 * Asserts a iprt status code successful.
2383 * On failure a custom message is printed and a breakpoint is hit.
2385 * @param rc iprt status code.
2386 * @param msg printf argument list (in parenthesis).
2387 * @remark rc is referenced multiple times.
2389 #define AssertReleaseMsgRC(rc, msg) AssertReleaseMsg(RT_SUCCESS_NP(rc), msg)
2391 /** @def AssertReleaseMsgRCReturn
2392 * Asserts a iprt status code successful.
2394 * On failure a custom message is printed, a breakpoint is hit, and finally
2395 * returning from the function if the breakpoint is somehow ignored.
2397 * @param rc iprt status code.
2398 * @param msg printf argument list (in parenthesis).
2399 * @param rcRet What is to be presented to return.
2400 * @remark rc is referenced multiple times.
2402 #define AssertReleaseMsgRCReturn(rc, msg, rcRet) AssertReleaseMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
2404 /** @def AssertReleaseMsgRCReturnVoid
2405 * Asserts a iprt status code successful.
2407 * On failure a custom message is printed, a breakpoint is hit, and finally
2408 * returning from the function if the breakpoint is somehow ignored.
2410 * @param rc iprt status code.
2411 * @param msg printf argument list (in parenthesis).
2412 * @remark rc is referenced multiple times.
2414 #define AssertReleaseMsgRCReturnVoid(rc, msg) AssertReleaseMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
2416 /** @def AssertReleaseMsgRCBreak
2417 * Asserts a iprt status code successful.
2419 * On failure a custom message is printed, a breakpoint is hit, and finally
2420 * breaking the current status if the breakpoint is somehow ignored.
2422 * @param rc iprt status code.
2423 * @param msg printf argument list (in parenthesis).
2424 * @remark rc is referenced multiple times.
2426 #define AssertReleaseMsgRCBreak(rc, msg) AssertReleaseMsgBreak(RT_SUCCESS(rc), msg)
2428 /** @def AssertReleaseMsgRCBreakStmt
2429 * Asserts a iprt status code successful.
2431 * On failure a custom message is printed, a breakpoint is hit, and finally
2432 * the break statement is issued if the breakpoint is somehow ignored.
2434 * @param rc iprt status code.
2435 * @param msg printf argument list (in parenthesis).
2436 * @param stmt Statement to execute before break in case of a failed assertion.
2437 * @remark rc is referenced multiple times.
2439 #define AssertReleaseMsgRCBreakStmt(rc, msg, stmt) AssertReleaseMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
2441 /** @def AssertReleaseRCSuccess
2442 * Asserts that an iprt status code equals VINF_SUCCESS.
2444 * On failure information about the error will be printed and a breakpoint hit.
2446 * @param rc iprt status code.
2447 * @remark rc is referenced multiple times.
2449 #define AssertReleaseRCSuccess(rc) AssertReleaseMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2451 /** @def AssertReleaseRCSuccessReturn
2452 * Asserts that an iprt status code equals VINF_SUCCESS.
2454 * On failure information about the error will be printed, a breakpoint hit
2455 * and finally returning from the function if the breakpoint is somehow ignored.
2457 * @param rc iprt status code.
2458 * @param rcRet What is to be presented to return.
2459 * @remark rc is referenced multiple times.
2461 #define AssertReleaseRCSuccessReturn(rc, rcRet) AssertReleaseMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
2463 /** @def AssertReleaseRCSuccessReturnVoid
2464 * Asserts that an iprt status code equals VINF_SUCCESS.
2466 * On failure information about the error will be printed, a breakpoint hit
2467 * and finally returning from the function if the breakpoint is somehow ignored.
2469 * @param rc iprt status code.
2470 * @remark rc is referenced multiple times.
2472 #define AssertReleaseRCSuccessReturnVoid(rc) AssertReleaseMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2474 /** @def AssertReleaseRCSuccessBreak
2475 * Asserts that an iprt status code equals VINF_SUCCESS.
2477 * On failure information about the error will be printed, a breakpoint hit
2478 * and finally breaking the current statement if the breakpoint is somehow ignored.
2480 * @param rc iprt status code.
2481 * @remark rc is referenced multiple times.
2483 #define AssertReleaseRCSuccessBreak(rc) AssertReleaseMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2485 /** @def AssertReleaseRCSuccessBreakStmt
2486 * Asserts that an iprt status code equals VINF_SUCCESS.
2488 * On failure information about the error will be printed, a breakpoint hit
2489 * and finally the break statement will be issued if the breakpoint is somehow ignored.
2491 * @param rc iprt status code.
2492 * @param stmt Statement to execute before break in case of a failed assertion.
2493 * @remark rc is referenced multiple times.
2495 #define AssertReleaseRCSuccessBreakStmt(rc, stmt) AssertReleaseMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
2498 /** @def AssertFatalRC
2499 * Asserts a iprt status code successful.
2501 * On failure information about the error will be printed and a breakpoint hit.
2503 * @param rc iprt status code.
2504 * @remark rc is referenced multiple times.
2506 #define AssertFatalRC(rc) AssertFatalMsgRC(rc, ("%Rra\n", (rc)))
2508 /** @def AssertReleaseMsgRC
2509 * Asserts a iprt status code successful.
2511 * On failure a custom message is printed and a breakpoint is hit.
2513 * @param rc iprt status code.
2514 * @param msg printf argument list (in parenthesis).
2515 * @remark rc is referenced multiple times.
2517 #define AssertFatalMsgRC(rc, msg) AssertFatalMsg(RT_SUCCESS_NP(rc), msg)
2519 /** @def AssertFatalRCSuccess
2520 * Asserts that an iprt status code equals VINF_SUCCESS.
2522 * On failure information about the error will be printed and a breakpoint hit.
2524 * @param rc iprt status code.
2525 * @remark rc is referenced multiple times.
2527 #define AssertFatalRCSuccess(rc) AssertFatalMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2531 * Asserts that a pointer is valid.
2533 * @param pv The pointer.
2535 #define AssertPtr(pv) AssertMsg(VALID_PTR(pv), ("%p\n", (pv)))
2537 /** @def AssertPtrReturn
2538 * Asserts that a pointer is valid.
2540 * @param pv The pointer.
2541 * @param rcRet What is to be presented to return.
2543 #define AssertPtrReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv), ("%p\n", (pv)), rcRet)
2545 /** @def AssertPtrReturnVoid
2546 * Asserts that a pointer is valid.
2548 * @param pv The pointer.
2550 #define AssertPtrReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv), ("%p\n", (pv)))
2552 /** @def AssertPtrBreak
2553 * Asserts that a pointer is valid.
2555 * @param pv The pointer.
2557 #define AssertPtrBreak(pv) AssertMsgBreak(VALID_PTR(pv), ("%p\n", (pv)))
2559 /** @def AssertPtrBreakStmt
2560 * Asserts that a pointer is valid.
2562 * @param pv The pointer.
2563 * @param stmt Statement to execute before break in case of a failed assertion.
2565 #define AssertPtrBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv), ("%p\n", (pv)), stmt)
2567 /** @def AssertPtrNull
2568 * Asserts that a pointer is valid or NULL.
2570 * @param pv The pointer.
2572 #define AssertPtrNull(pv) AssertMsg(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
2574 /** @def AssertPtrNullReturn
2575 * Asserts that a pointer is valid or NULL.
2577 * @param pv The pointer.
2578 * @param rcRet What is to be presented to return.
2580 #define AssertPtrNullReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), rcRet)
2582 /** @def AssertPtrNullReturnVoid
2583 * Asserts that a pointer is valid or NULL.
2585 * @param pv The pointer.
2587 #define AssertPtrNullReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
2589 /** @def AssertPtrNullBreak
2590 * Asserts that a pointer is valid or NULL.
2592 * @param pv The pointer.
2594 #define AssertPtrNullBreak(pv) AssertMsgBreak(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
2596 /** @def AssertPtrNullBreakStmt
2597 * Asserts that a pointer is valid or NULL.
2599 * @param pv The pointer.
2600 * @param stmt Statement to execute before break in case of a failed assertion.
2602 #define AssertPtrNullBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt)
2604 /** @def AssertGCPhys32
2605 * Asserts that the high dword of a physical address is zero
2607 * @param GCPhys The address (RTGCPHYS).
2609 #define AssertGCPhys32(GCPhys) AssertMsg(VALID_PHYS32(GCPhys), ("%RGp\n", (RTGCPHYS)(GCPhys)))
2611 /** @def AssertGCPtr32
2612 * Asserts that the high dword of a physical address is zero
2614 * @param GCPtr The address (RTGCPTR).
2616 #if GC_ARCH_BITS == 32
2617 # define AssertGCPtr32(GCPtr) do { } while (0)
2619 # define AssertGCPtr32(GCPtr) AssertMsg(!((GCPtr) & UINT64_C(0xffffffff00000000)), ("%RGv\n", GCPtr))
2622 /** @def AssertForEach
2623 * Equivalent to Assert for each value of the variable from the starting
2624 * value to the finishing one.
2626 * @param var Name of the counter variable.
2627 * @param vartype Type of the counter variable.
2628 * @param first Lowest inclusive value of the counter variable.
2629 * This must be free from side effects.
2630 * @param end Highest exclusive value of the counter variable.
2631 * This must be free from side effects.
2632 * @param expr Expression which should be true for each value of @a var.
2634 #define AssertForEach(var, vartype, first, end, expr) \
2637 Assert((first) == (first) && (end) == (end)); /* partial check for side effects */ \
2638 for (var = (first); var < (end); var++) \
2639 AssertMsg(expr, ("%s = %#RX64 (%RI64)", #var, (uint64_t)var, (int64_t)var)); \
2642 #ifdef RT_OS_WINDOWS
2644 /** @def AssertNtStatus
2645 * Asserts that the NT_SUCCESS() returns true for the given NTSTATUS value.
2647 * @param a_rcNt The NTSTATUS to check. Will be evaluated twice and
2648 * subjected to NOREF().
2651 # define AssertNtStatus(a_rcNt) \
2652 do { AssertMsg(NT_SUCCESS(a_rcNt), ("%#x\n", (a_rcNt))); NOREF(a_rcNt); } while (0)
2654 /** @def AssertNtStatusSuccess
2655 * Asserts that the given NTSTATUS value equals STATUS_SUCCESS.
2657 * @param a_rcNt The NTSTATUS to check. Will be evaluated twice and
2658 * subjected to NOREF().
2659 * @sa AssertRCSuccess()
2661 # define AssertNtStatusSuccess(a_rcNt) \
2662 do { AssertMsg((a_rcNt) == STATUS_SUCCESS, ("%#x\n", (a_rcNt))); NOREF(a_rcNt); } while (0)
2664 #endif /* RT_OS_WINDOWS */