VirtualBox

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

Last change on this file since 74334 was 73778, checked in by vboxsync, 6 years ago

IPRT/assert: Provide call stack dump on 64-bit windows (ring-3). Experimental. [build fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 83.3 KB
Line 
1/** @file
2 * IPRT - Assertions.
3 */
4
5/*
6 * Copyright (C) 2006-2017 Oracle Corporation
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#include <iprt/stdarg.h>
32#include <iprt/assertcompile.h>
33
34/** @defgroup grp_rt_assert Assert - Assertions
35 * @ingroup grp_rt
36 *
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.
41 *
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).
44 *
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.
50 *
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.
59 *
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... :-)
64 *
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.
68 *
69 * @{
70 */
71
72RT_C_DECLS_BEGIN
73
74#if !defined(IPRT_WITHOUT_ASSERT_STACK) \
75 && defined(IN_RING3) \
76 && !defined(IN_RT_STATIC) /* try keep static binaries small */ \
77 && (defined(RT_ARCH_AMD64) /*|| defined(RT_ARCH_X86)*/) \
78 && (defined(RT_OS_WINDOWS) /*|| ... */)
79/** @def IPRT_WITH_ASSERT_STACK
80 * Indicates that we collect a callstack stack on assertion. */
81# define IPRT_WITH_ASSERT_STACK
82#endif
83
84/**
85 * The 1st part of an assert message.
86 *
87 * @param pszExpr Expression. Can be NULL.
88 * @param uLine Location line number.
89 * @param pszFile Location file name.
90 * @param pszFunction Location function name.
91 */
92RTDECL(void) RTAssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction);
93/**
94 * Weak version of RTAssertMsg1 that can be overridden locally in a module to
95 * modify, redirect or otherwise mess with the assertion output.
96 *
97 * @copydoc RTAssertMsg1
98 */
99RTDECL(void) RTAssertMsg1Weak(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction);
100
101/**
102 * The 2nd (optional) part of an assert message.
103 *
104 * @param pszFormat Printf like format string.
105 * @param ... Arguments to that string.
106 */
107RTDECL(void) RTAssertMsg2(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
108/**
109 * Weak version of RTAssertMsg2 that forwards to RTAssertMsg2WeakV.
110 *
111 * There is not need to override this, check out RTAssertMsg2WeakV instead!
112 *
113 * @copydoc RTAssertMsg2
114 */
115RTDECL(void) RTAssertMsg2Weak(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
116
117/**
118 * The 2nd (optional) part of an assert message.
119 *
120 * @param pszFormat Printf like format string.
121 * @param va Arguments to that string.
122 */
123RTDECL(void) RTAssertMsg2V(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
124/**
125 * Weak version of RTAssertMsg2V that can be overridden locally in a module to
126 * modify, redirect or otherwise mess with the assertion output.
127 *
128 * @copydoc RTAssertMsg2V
129 */
130RTDECL(void) RTAssertMsg2WeakV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
131
132/**
133 * Additional information which should be appended to the 2nd part of an
134 * assertion message.
135 *
136 * @param pszFormat Printf like format string.
137 * @param ... Arguments to that string.
138 */
139RTDECL(void) RTAssertMsg2Add(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
140/**
141 * Weak version of RTAssertMsg2Add that forwards to RTAssertMsg2AddWeakV.
142 *
143 * There is not need to override this, check out RTAssertMsg2AddWeakV instead!
144 *
145 * @copydoc RTAssertMsg2Add
146 */
147RTDECL(void) RTAssertMsg2AddWeak(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
148
149/**
150 * Additional information which should be appended to the 2nd part of an
151 * assertion message.
152 *
153 * @param pszFormat Printf like format string.
154 * @param va Arguments to that string.
155 */
156RTDECL(void) RTAssertMsg2AddV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
157/**
158 * Weak version of RTAssertMsg2AddV that can be overridden locally in a module
159 * to modify, redirect or otherwise mess with the assertion output.
160 *
161 * @copydoc RTAssertMsg2AddV
162 */
163RTDECL(void) RTAssertMsg2AddWeakV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
164
165#ifdef IN_RING0
166/**
167 * Panics the system as the result of a fail assertion.
168 */
169RTR0DECL(void) RTR0AssertPanicSystem(void);
170#endif /* IN_RING0 */
171
172/**
173 * Overridable function that decides whether assertions executes the panic
174 * (breakpoint) or not.
175 *
176 * The generic implementation will return true.
177 *
178 * @returns true if the breakpoint should be hit, false if it should be ignored.
179 *
180 * @remark The RTDECL() makes this a bit difficult to override on Windows. So,
181 * you'll have to use RTASSERT_HAVE_SHOULD_PANIC or
182 * RTASSERT_HAVE_SHOULD_PANIC_PRIVATE there to control the kind of
183 * prototype.
184 */
185#if !defined(RTASSERT_HAVE_SHOULD_PANIC) && !defined(RTASSERT_HAVE_SHOULD_PANIC_PRIVATE)
186RTDECL(bool) RTAssertShouldPanic(void);
187#elif defined(RTASSERT_HAVE_SHOULD_PANIC_PRIVATE)
188bool RTAssertShouldPanic(void);
189#else
190DECLEXPORT(bool) RTCALL RTAssertShouldPanic(void);
191#endif
192
193/**
194 * Controls whether the assertions should be quiet or noisy (default).
195 *
196 * @returns The old setting.
197 * @param fQuiet The new setting.
198 */
199RTDECL(bool) RTAssertSetQuiet(bool fQuiet);
200
201/**
202 * Are assertions quiet or noisy?
203 *
204 * @returns True if they are quiet, false if noisy.
205 */
206RTDECL(bool) RTAssertAreQuiet(void);
207
208/**
209 * Makes the assertions panic (default) or not.
210 *
211 * @returns The old setting.
212 * @param fPanic The new setting.
213 */
214RTDECL(bool) RTAssertSetMayPanic(bool fPanic);
215
216/**
217 * Can assertion panic.
218 *
219 * @returns True if they can, false if not.
220 */
221RTDECL(bool) RTAssertMayPanic(void);
222
223
224/** @name Globals for crash analysis
225 * @remarks This is the full potential set, it
226 * @{
227 */
228/** The last assertion message, 1st part. */
229extern RTDATADECL(char) g_szRTAssertMsg1[1024];
230/** The last assertion message, 2nd part. */
231extern RTDATADECL(char) g_szRTAssertMsg2[4096];
232#ifdef IPRT_WITH_ASSERT_STACK
233/** The last assertion message, stack part. */
234extern RTDATADECL(char) g_szRTAssertStack[4096];
235#endif
236/** The last assertion message, expression. */
237extern RTDATADECL(const char * volatile) g_pszRTAssertExpr;
238/** The last assertion message, file name. */
239extern RTDATADECL(const char * volatile) g_pszRTAssertFile;
240/** The last assertion message, line number. */
241extern RTDATADECL(uint32_t volatile) g_u32RTAssertLine;
242/** The last assertion message, function name. */
243extern RTDATADECL(const char * volatile) g_pszRTAssertFunction;
244/** @} */
245
246RT_C_DECLS_END
247
248/** @def RTAssertDebugBreak()
249 * Debugger breakpoint instruction.
250 *
251 * @remarks This macro does not depend on RT_STRICT.
252 */
253#define RTAssertDebugBreak() do { RT_BREAKPOINT(); } while (0)
254
255
256
257/** @name Assertions
258 *
259 * These assertions will only trigger when RT_STRICT is defined. When it is
260 * undefined they will all be no-ops and generate no code.
261 *
262 * @{
263 */
264
265
266/** @def RTASSERT_QUIET
267 * This can be defined to shut up the messages for a file where this would be
268 * problematic because the message printing code path passes thru it.
269 * @internal */
270#ifdef DOXYGEN_RUNNING
271# define RTASSERT_QUIET
272#endif
273#if defined(RTASSERT_QUIET) && !defined(DOXYGEN_RUNNING)
274# define RTAssertMsg1Weak(pszExpr, uLine, pszfile, pszFunction) \
275 do { } while (0)
276# define RTAssertMsg2Weak if (1) {} else RTAssertMsg2Weak
277#endif
278
279/** @def RTAssertDoPanic
280 * Raises an assertion panic appropriate to the current context.
281 * @remarks This macro does not depend on RT_STRICT.
282 */
283#if defined(IN_RING0) \
284 && (defined(RT_OS_DARWIN) || defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS))
285# define RTAssertDoPanic() RTR0AssertPanicSystem()
286#else
287# define RTAssertDoPanic() RTAssertDebugBreak()
288#endif
289
290/** @def AssertBreakpoint()
291 * Assertion Breakpoint.
292 * @deprecated Use RTAssertPanic or RTAssertDebugBreak instead.
293 */
294#ifdef RT_STRICT
295# define AssertBreakpoint() RTAssertDebugBreak()
296#else
297# define AssertBreakpoint() do { } while (0)
298#endif
299
300/** @def RTAssertPanic()
301 * If RT_STRICT is defined this macro will invoke RTAssertDoPanic if
302 * RTAssertShouldPanic returns true. If RT_STRICT isn't defined it won't do any
303 * thing.
304 */
305#if defined(RT_STRICT) && !defined(RTASSERT_DONT_PANIC)
306# define RTAssertPanic() do { if (RTAssertShouldPanic()) RTAssertDoPanic(); } while (0)
307#else
308# define RTAssertPanic() do { } while (0)
309#endif
310
311/** @def Assert
312 * Assert that an expression is true. If false, hit breakpoint.
313 * @param expr Expression which should be true.
314 */
315#ifdef RT_STRICT
316# define Assert(expr) \
317 do { \
318 if (RT_LIKELY(!!(expr))) \
319 { /* likely */ } \
320 else \
321 { \
322 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
323 RTAssertPanic(); \
324 } \
325 } while (0)
326#else
327# define Assert(expr) do { } while (0)
328#endif
329
330
331/** @def AssertStmt
332 * Assert that an expression is true. If false, hit breakpoint and execute the
333 * statement.
334 * @param expr Expression which should be true.
335 * @param stmt Statement to execute on failure.
336 */
337#ifdef RT_STRICT
338# define AssertStmt(expr, stmt) \
339 do { \
340 if (RT_LIKELY(!!(expr))) \
341 { /* likely */ } \
342 else \
343 { \
344 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
345 RTAssertPanic(); \
346 stmt; \
347 } \
348 } while (0)
349#else
350# define AssertStmt(expr, stmt) \
351 do { \
352 if (RT_LIKELY(!!(expr))) \
353 { /* likely */ } \
354 else \
355 { \
356 stmt; \
357 } \
358 } while (0)
359#endif
360
361
362/** @def AssertReturn
363 * Assert that an expression is true and returns if it isn't.
364 * In RT_STRICT mode it will hit a breakpoint before returning.
365 *
366 * @param expr Expression which should be true.
367 * @param rc What is to be presented to return.
368 */
369#ifdef RT_STRICT
370# define AssertReturn(expr, rc) \
371 do { \
372 if (RT_LIKELY(!!(expr))) \
373 { /* likely */ } \
374 else \
375 { \
376 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
377 RTAssertPanic(); \
378 return (rc); \
379 } \
380 } while (0)
381#else
382# define AssertReturn(expr, rc) \
383 do { \
384 if (RT_LIKELY(!!(expr))) \
385 { /* likely */ } \
386 else \
387 return (rc); \
388 } while (0)
389#endif
390
391/** @def AssertReturnStmt
392 * Assert that an expression is true, if it isn't execute the given statement
393 * and return rc.
394 *
395 * In RT_STRICT mode it will hit a breakpoint before executing the statement and
396 * returning.
397 *
398 * @param expr Expression which should be true.
399 * @param stmt Statement to execute before returning on failure.
400 * @param rc What is to be presented to return.
401 */
402#ifdef RT_STRICT
403# define AssertReturnStmt(expr, stmt, rc) \
404 do { \
405 if (RT_LIKELY(!!(expr))) \
406 { /* likely */ } \
407 else \
408 { \
409 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
410 RTAssertPanic(); \
411 stmt; \
412 return (rc); \
413 } \
414 } while (0)
415#else
416# define AssertReturnStmt(expr, stmt, rc) \
417 do { \
418 if (RT_LIKELY(!!(expr))) \
419 { /* likely */ } \
420 else \
421 { \
422 stmt; \
423 return (rc); \
424 } \
425 } while (0)
426#endif
427
428/** @def AssertReturnVoid
429 * Assert that an expression is true and returns if it isn't.
430 * In RT_STRICT mode it will hit a breakpoint before returning.
431 *
432 * @param expr Expression which should be true.
433 */
434#ifdef RT_STRICT
435# define AssertReturnVoid(expr) \
436 do { \
437 if (RT_LIKELY(!!(expr))) \
438 { /* likely */ } \
439 else \
440 { \
441 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
442 RTAssertPanic(); \
443 return; \
444 } \
445 } while (0)
446#else
447# define AssertReturnVoid(expr) \
448 do { \
449 if (RT_LIKELY(!!(expr))) \
450 { /* likely */ } \
451 else \
452 return; \
453 } while (0)
454#endif
455
456/** @def AssertReturnVoidStmt
457 * Assert that an expression is true, if it isn't execute the given statement
458 * and return.
459 *
460 * In RT_STRICT mode it will hit a breakpoint before returning.
461 *
462 * @param expr Expression which should be true.
463 * @param stmt Statement to execute before returning on failure.
464 */
465#ifdef RT_STRICT
466# define AssertReturnVoidStmt(expr, stmt) \
467 do { \
468 if (RT_LIKELY(!!(expr))) \
469 { /* likely */ } \
470 else \
471 { \
472 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
473 RTAssertPanic(); \
474 stmt; \
475 return; \
476 } \
477 } while (0)
478#else
479# define AssertReturnVoidStmt(expr, stmt) \
480 do { \
481 if (RT_LIKELY(!!(expr))) \
482 { /* likely */ } \
483 else \
484 { \
485 stmt; \
486 return; \
487 } \
488 } while (0)
489#endif
490
491
492/** @def AssertBreak
493 * Assert that an expression is true and breaks if it isn't.
494 * In RT_STRICT mode it will hit a breakpoint before breaking.
495 *
496 * @param expr Expression which should be true.
497 */
498#ifdef RT_STRICT
499# define AssertBreak(expr) \
500 if (RT_LIKELY(!!(expr))) \
501 { /* likely */ } \
502 else if (1) \
503 { \
504 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
505 RTAssertPanic(); \
506 break; \
507 } else \
508 break
509#else
510# define AssertBreak(expr) \
511 if (RT_LIKELY(!!(expr))) \
512 { /* likely */ } \
513 else \
514 break
515#endif
516
517/** @def AssertContinue
518 * Assert that an expression is true and continue if it isn't.
519 * In RT_STRICT mode it will hit a breakpoint before continuing.
520 *
521 * @param expr Expression which should be true.
522 */
523#ifdef RT_STRICT
524# define AssertContinue(expr) \
525 if (RT_LIKELY(!!(expr))) \
526 { /* likely */ } \
527 else if (1) \
528 { \
529 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
530 RTAssertPanic(); \
531 continue; \
532 } else do {} while (0)
533#else
534# define AssertContinue(expr) \
535 if (RT_LIKELY(!!(expr))) \
536 { /* likely */ } \
537 else \
538 continue
539#endif
540
541/** @def AssertBreakStmt
542 * Assert that an expression is true and breaks if it isn't.
543 * In RT_STRICT mode it will hit a breakpoint before doing break.
544 *
545 * @param expr Expression which should be true.
546 * @param stmt Statement to execute before break in case of a failed assertion.
547 */
548#ifdef RT_STRICT
549# define AssertBreakStmt(expr, stmt) \
550 if (RT_LIKELY(!!(expr))) \
551 { /* likely */ } \
552 else if (1) \
553 { \
554 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
555 RTAssertPanic(); \
556 stmt; \
557 break; \
558 } else do {} while (0)
559#else
560# define AssertBreakStmt(expr, stmt) \
561 if (RT_LIKELY(!!(expr))) \
562 { /* likely */ } \
563 else if (1) \
564 { \
565 stmt; \
566 break; \
567 } else do {} while (0)
568#endif
569
570
571/** @def AssertMsg
572 * Assert that an expression is true. If it's not print message and hit breakpoint.
573 * @param expr Expression which should be true.
574 * @param a printf argument list (in parenthesis).
575 */
576#ifdef RT_STRICT
577# define AssertMsg(expr, a) \
578 do { \
579 if (RT_LIKELY(!!(expr))) \
580 { /* likely */ } \
581 else \
582 { \
583 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
584 RTAssertMsg2Weak a; \
585 RTAssertPanic(); \
586 } \
587 } while (0)
588#else
589# define AssertMsg(expr, a) do { } while (0)
590#endif
591
592/** @def AssertMsgStmt
593 * Assert that an expression is true. If it's not print message and hit
594 * breakpoint and execute the statement.
595 *
596 * @param expr Expression which should be true.
597 * @param a printf argument list (in parenthesis).
598 * @param stmt Statement to execute in case of a failed assertion.
599 *
600 * @remarks The expression and statement will be evaluated in all build types.
601 */
602#ifdef RT_STRICT
603# define AssertMsgStmt(expr, a, stmt) \
604 do { \
605 if (RT_LIKELY(!!(expr))) \
606 { /* likely */ } \
607 else \
608 { \
609 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
610 RTAssertMsg2Weak a; \
611 RTAssertPanic(); \
612 stmt; \
613 } \
614 } while (0)
615#else
616# define AssertMsgStmt(expr, a, stmt) \
617 do { \
618 if (RT_LIKELY(!!(expr))) \
619 { /* likely */ } \
620 else \
621 { \
622 stmt; \
623 } \
624 } while (0)
625#endif
626
627/** @def AssertMsgReturn
628 * Assert that an expression is true and returns if it isn't.
629 * In RT_STRICT mode it will hit a breakpoint before returning.
630 *
631 * @param expr Expression which should be true.
632 * @param a printf argument list (in parenthesis).
633 * @param rc What is to be presented to return.
634 */
635#ifdef RT_STRICT
636# define AssertMsgReturn(expr, a, rc) \
637 do { \
638 if (RT_LIKELY(!!(expr))) \
639 { /* likely */ } \
640 else \
641 { \
642 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
643 RTAssertMsg2Weak a; \
644 RTAssertPanic(); \
645 return (rc); \
646 } \
647 } while (0)
648#else
649# define AssertMsgReturn(expr, a, rc) \
650 do { \
651 if (RT_LIKELY(!!(expr))) \
652 { /* likely */ } \
653 else \
654 return (rc); \
655 } while (0)
656#endif
657
658/** @def AssertMsgReturnStmt
659 * Assert that an expression is true, if it isn't execute the statement and
660 * return.
661 *
662 * In RT_STRICT mode it will hit a breakpoint before returning.
663 *
664 * @param expr Expression which should be true.
665 * @param a printf argument list (in parenthesis).
666 * @param stmt Statement to execute before returning in case of a failed
667 * assertion.
668 * @param rc What is to be presented to return.
669 */
670#ifdef RT_STRICT
671# define AssertMsgReturnStmt(expr, a, stmt, rc) \
672 do { \
673 if (RT_LIKELY(!!(expr))) \
674 { /* likely */ } \
675 else \
676 { \
677 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
678 RTAssertMsg2Weak a; \
679 RTAssertPanic(); \
680 stmt; \
681 return (rc); \
682 } \
683 } while (0)
684#else
685# define AssertMsgReturnStmt(expr, a, stmt, rc) \
686 do { \
687 if (RT_LIKELY(!!(expr))) \
688 { /* likely */ } \
689 else \
690 { \
691 stmt; \
692 return (rc); \
693 } \
694 } while (0)
695#endif
696
697/** @def AssertMsgReturnVoid
698 * Assert that an expression is true and returns if it isn't.
699 * In RT_STRICT mode it will hit a breakpoint before returning.
700 *
701 * @param expr Expression which should be true.
702 * @param a printf argument list (in parenthesis).
703 */
704#ifdef RT_STRICT
705# define AssertMsgReturnVoid(expr, a) \
706 do { \
707 if (RT_LIKELY(!!(expr))) \
708 { /* likely */ } \
709 else \
710 { \
711 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
712 RTAssertMsg2Weak a; \
713 RTAssertPanic(); \
714 return; \
715 } \
716 } while (0)
717#else
718# define AssertMsgReturnVoid(expr, a) \
719 do { \
720 if (RT_LIKELY(!!(expr))) \
721 { /* likely */ } \
722 else \
723 return; \
724 } while (0)
725#endif
726
727/** @def AssertMsgReturnVoidStmt
728 * Assert that an expression is true, if it isn't execute the statement and
729 * return.
730 *
731 * In RT_STRICT mode it will hit a breakpoint before returning.
732 *
733 * @param expr Expression which should be true.
734 * @param a printf argument list (in parenthesis).
735 * @param stmt Statement to execute before return in case of a failed assertion.
736 */
737#ifdef RT_STRICT
738# define AssertMsgReturnVoidStmt(expr, a, stmt) \
739 do { \
740 if (RT_LIKELY(!!(expr))) \
741 { /* likely */ } \
742 else \
743 { \
744 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
745 RTAssertMsg2Weak a; \
746 RTAssertPanic(); \
747 stmt; \
748 return; \
749 } \
750 } while (0)
751#else
752# define AssertMsgReturnVoidStmt(expr, a, stmt) \
753 do { \
754 if (RT_LIKELY(!!(expr))) \
755 { /* likely */ } \
756 else \
757 { \
758 stmt; \
759 return; \
760 } \
761 } while (0)
762#endif
763
764
765/** @def AssertMsgBreak
766 * Assert that an expression is true and breaks if it isn't.
767 * In RT_STRICT mode it will hit a breakpoint before returning.
768 *
769 * @param expr Expression which should be true.
770 * @param a printf argument list (in parenthesis).
771 */
772#ifdef RT_STRICT
773# define AssertMsgBreak(expr, a) \
774 if (RT_LIKELY(!!(expr))) \
775 { /* likely */ } \
776 else if (1) \
777 { \
778 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
779 RTAssertMsg2Weak a; \
780 RTAssertPanic(); \
781 break; \
782 } else \
783 break
784#else
785# define AssertMsgBreak(expr, a) \
786 if (RT_LIKELY(!!(expr))) \
787 { /* likely */ } \
788 else \
789 break
790#endif
791
792/** @def AssertMsgBreakStmt
793 * Assert that an expression is true and breaks if it isn't.
794 * In RT_STRICT mode it will hit a breakpoint before doing break.
795 *
796 * @param expr Expression which should be true.
797 * @param a printf argument list (in parenthesis).
798 * @param stmt Statement to execute before break in case of a failed assertion.
799 */
800#ifdef RT_STRICT
801# define AssertMsgBreakStmt(expr, a, stmt) \
802 if (RT_LIKELY(!!(expr))) \
803 { /* likely */ } \
804 else if (1) \
805 { \
806 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
807 RTAssertMsg2Weak a; \
808 RTAssertPanic(); \
809 stmt; \
810 break; \
811 } else \
812 break
813#else
814# define AssertMsgBreakStmt(expr, a, stmt) \
815 if (RT_LIKELY(!!(expr))) \
816 { /* likely */ } \
817 else if (1) \
818 { \
819 stmt; \
820 break; \
821 } else \
822 break
823#endif
824
825/** @def AssertFailed
826 * An assertion failed, hit breakpoint.
827 */
828#ifdef RT_STRICT
829# define AssertFailed() \
830 do { \
831 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
832 RTAssertPanic(); \
833 } while (0)
834#else
835# define AssertFailed() do { } while (0)
836#endif
837
838/** @def AssertFailedStmt
839 * An assertion failed, hit breakpoint and execute statement.
840 */
841#ifdef RT_STRICT
842# define AssertFailedStmt(stmt) \
843 do { \
844 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
845 RTAssertPanic(); \
846 stmt; \
847 } while (0)
848#else
849# define AssertFailedStmt(stmt) do { stmt; } while (0)
850#endif
851
852/** @def AssertFailedReturn
853 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
854 *
855 * @param rc The rc to return.
856 */
857#ifdef RT_STRICT
858# define AssertFailedReturn(rc) \
859 do { \
860 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
861 RTAssertPanic(); \
862 return (rc); \
863 } while (0)
864#else
865# define AssertFailedReturn(rc) \
866 do { \
867 return (rc); \
868 } while (0)
869#endif
870
871/** @def AssertFailedReturnStmt
872 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a
873 * statement and return a value.
874 *
875 * @param stmt The statement to execute before returning.
876 * @param rc The value to return.
877 */
878#ifdef RT_STRICT
879# define AssertFailedReturnStmt(stmt, rc) \
880 do { \
881 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
882 RTAssertPanic(); \
883 stmt; \
884 return (rc); \
885 } while (0)
886#else
887# define AssertFailedReturnStmt(stmt, rc) \
888 do { \
889 stmt; \
890 return (rc); \
891 } while (0)
892#endif
893
894/** @def AssertFailedReturnVoid
895 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
896 */
897#ifdef RT_STRICT
898# define AssertFailedReturnVoid() \
899 do { \
900 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
901 RTAssertPanic(); \
902 return; \
903 } while (0)
904#else
905# define AssertFailedReturnVoid() \
906 do { \
907 return; \
908 } while (0)
909#endif
910
911/** @def AssertFailedReturnVoidStmt
912 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute a
913 * statement and return.
914 *
915 * @param stmt The statement to execute before returning.
916 */
917#ifdef RT_STRICT
918# define AssertFailedReturnVoidStmt(stmt) \
919 do { \
920 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
921 RTAssertPanic(); \
922 stmt; \
923 return; \
924 } while (0)
925#else
926# define AssertFailedReturnVoidStmt(stmt) \
927 do { \
928 stmt; \
929 return; \
930 } while (0)
931#endif
932
933
934/** @def AssertFailedBreak
935 * An assertion failed, hit breakpoint (RT_STRICT mode only) and break.
936 */
937#ifdef RT_STRICT
938# define AssertFailedBreak() \
939 if (1) { \
940 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
941 RTAssertPanic(); \
942 break; \
943 } else \
944 break
945#else
946# define AssertFailedBreak() \
947 if (1) \
948 break; \
949 else \
950 break
951#endif
952
953/** @def AssertFailedBreakStmt
954 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
955 * the given statement and break.
956 *
957 * @param stmt Statement to execute before break.
958 */
959#ifdef RT_STRICT
960# define AssertFailedBreakStmt(stmt) \
961 if (1) { \
962 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
963 RTAssertPanic(); \
964 stmt; \
965 break; \
966 } else \
967 break
968#else
969# define AssertFailedBreakStmt(stmt) \
970 if (1) { \
971 stmt; \
972 break; \
973 } else \
974 break
975#endif
976
977
978/** @def AssertMsgFailed
979 * An assertion failed print a message and a hit breakpoint.
980 *
981 * @param a printf argument list (in parenthesis).
982 */
983#ifdef RT_STRICT
984# define AssertMsgFailed(a) \
985 do { \
986 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
987 RTAssertMsg2Weak a; \
988 RTAssertPanic(); \
989 } while (0)
990#else
991# define AssertMsgFailed(a) do { } while (0)
992#endif
993
994/** @def AssertMsgFailedReturn
995 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
996 *
997 * @param a printf argument list (in parenthesis).
998 * @param rc What is to be presented to return.
999 */
1000#ifdef RT_STRICT
1001# define AssertMsgFailedReturn(a, rc) \
1002 do { \
1003 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1004 RTAssertMsg2Weak a; \
1005 RTAssertPanic(); \
1006 return (rc); \
1007 } while (0)
1008#else
1009# define AssertMsgFailedReturn(a, rc) \
1010 do { \
1011 return (rc); \
1012 } while (0)
1013#endif
1014
1015/** @def AssertMsgFailedReturnVoid
1016 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
1017 *
1018 * @param a printf argument list (in parenthesis).
1019 */
1020#ifdef RT_STRICT
1021# define AssertMsgFailedReturnVoid(a) \
1022 do { \
1023 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1024 RTAssertMsg2Weak a; \
1025 RTAssertPanic(); \
1026 return; \
1027 } while (0)
1028#else
1029# define AssertMsgFailedReturnVoid(a) \
1030 do { \
1031 return; \
1032 } while (0)
1033#endif
1034
1035
1036/** @def AssertMsgFailedBreak
1037 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and break.
1038 *
1039 * @param a printf argument list (in parenthesis).
1040 */
1041#ifdef RT_STRICT
1042# define AssertMsgFailedBreak(a) \
1043 if (1) { \
1044 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1045 RTAssertMsg2Weak a; \
1046 RTAssertPanic(); \
1047 break; \
1048 } else \
1049 break
1050#else
1051# define AssertMsgFailedBreak(a) \
1052 if (1) \
1053 break; \
1054 else \
1055 break
1056#endif
1057
1058/** @def AssertMsgFailedBreakStmt
1059 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
1060 * the given statement and break.
1061 *
1062 * @param a printf argument list (in parenthesis).
1063 * @param stmt Statement to execute before break.
1064 */
1065#ifdef RT_STRICT
1066# define AssertMsgFailedBreakStmt(a, stmt) \
1067 if (1) { \
1068 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1069 RTAssertMsg2Weak a; \
1070 RTAssertPanic(); \
1071 stmt; \
1072 break; \
1073 } else \
1074 break
1075#else
1076# define AssertMsgFailedBreakStmt(a, stmt) \
1077 if (1) { \
1078 stmt; \
1079 break; \
1080 } else \
1081 break
1082#endif
1083
1084/** @} */
1085
1086
1087
1088/** @name Release Log Assertions
1089 *
1090 * These assertions will work like normal strict assertion when RT_STRICT is
1091 * defined and LogRel statements when RT_STRICT is undefined. Typically used for
1092 * things which shouldn't go wrong, but when it does you'd like to know one way
1093 * or the other.
1094 *
1095 * @{
1096 */
1097
1098/** @def RTAssertLogRelMsg1
1099 * RTAssertMsg1Weak (strict builds) / LogRel wrapper (non-strict).
1100 */
1101#ifdef RT_STRICT
1102# define RTAssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
1103 RTAssertMsg1Weak(pszExpr, iLine, pszFile, pszFunction)
1104#else
1105# define RTAssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
1106 LogRel(("AssertLogRel %s(%d) %s: %s\n",\
1107 (pszFile), (iLine), (pszFunction), (pszExpr) ))
1108#endif
1109
1110/** @def RTAssertLogRelMsg2
1111 * RTAssertMsg2Weak (strict builds) / LogRel wrapper (non-strict).
1112 */
1113#ifdef RT_STRICT
1114# define RTAssertLogRelMsg2(a) RTAssertMsg2Weak a
1115#else
1116# define RTAssertLogRelMsg2(a) LogRel(a)
1117#endif
1118
1119/** @def AssertLogRel
1120 * Assert that an expression is true.
1121 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1122 *
1123 * @param expr Expression which should be true.
1124 */
1125#define AssertLogRel(expr) \
1126 do { \
1127 if (RT_LIKELY(!!(expr))) \
1128 { /* likely */ } \
1129 else \
1130 { \
1131 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1132 RTAssertPanic(); \
1133 } \
1134 } while (0)
1135
1136/** @def AssertLogRelReturn
1137 * Assert that an expression is true, return \a rc if it isn't.
1138 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1139 *
1140 * @param expr Expression which should be true.
1141 * @param rc What is to be presented to return.
1142 */
1143#define AssertLogRelReturn(expr, rc) \
1144 do { \
1145 if (RT_LIKELY(!!(expr))) \
1146 { /* likely */ } \
1147 else \
1148 { \
1149 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1150 RTAssertPanic(); \
1151 return (rc); \
1152 } \
1153 } while (0)
1154
1155/** @def AssertLogRelReturnVoid
1156 * Assert that an expression is true, return void if it isn't.
1157 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1158 *
1159 * @param expr Expression which should be true.
1160 */
1161#define AssertLogRelReturnVoid(expr) \
1162 do { \
1163 if (RT_LIKELY(!!(expr))) \
1164 { /* likely */ } \
1165 else \
1166 { \
1167 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1168 RTAssertPanic(); \
1169 return; \
1170 } \
1171 } while (0)
1172
1173/** @def AssertLogRelBreak
1174 * Assert that an expression is true, break if it isn't.
1175 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1176 *
1177 * @param expr Expression which should be true.
1178 */
1179#define AssertLogRelBreak(expr) \
1180 if (RT_LIKELY(!!(expr))) \
1181 { /* likely */ } \
1182 else if (1) \
1183 { \
1184 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1185 RTAssertPanic(); \
1186 break; \
1187 } \
1188 else \
1189 break
1190
1191/** @def AssertLogRelBreakStmt
1192 * Assert that an expression is true, execute \a stmt and break if it isn't.
1193 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1194 *
1195 * @param expr Expression which should be true.
1196 * @param stmt Statement to execute before break in case of a failed assertion.
1197 */
1198#define AssertLogRelBreakStmt(expr, stmt) \
1199 if (RT_LIKELY(!!(expr))) \
1200 { /* likely */ } \
1201 else if (1) \
1202 { \
1203 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1204 RTAssertPanic(); \
1205 stmt; \
1206 break; \
1207 } else \
1208 break
1209
1210/** @def AssertLogRelMsg
1211 * Assert that an expression is true.
1212 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1213 *
1214 * @param expr Expression which should be true.
1215 * @param a printf argument list (in parenthesis).
1216 */
1217#define AssertLogRelMsg(expr, a) \
1218 do { \
1219 if (RT_LIKELY(!!(expr))) \
1220 { /* likely */ } \
1221 else\
1222 { \
1223 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1224 RTAssertLogRelMsg2(a); \
1225 RTAssertPanic(); \
1226 } \
1227 } while (0)
1228
1229/** @def AssertLogRelMsgStmt
1230 * Assert that an expression is true, execute \a stmt and break if it isn't
1231 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1232 *
1233 * @param expr Expression which should be true.
1234 * @param a printf argument list (in parenthesis).
1235 * @param stmt Statement to execute in case of a failed assertion.
1236 */
1237#define AssertLogRelMsgStmt(expr, a, stmt) \
1238 do { \
1239 if (RT_LIKELY(!!(expr))) \
1240 { /* likely */ } \
1241 else\
1242 { \
1243 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1244 RTAssertLogRelMsg2(a); \
1245 RTAssertPanic(); \
1246 stmt; \
1247 } \
1248 } while (0)
1249
1250/** @def AssertLogRelMsgReturn
1251 * Assert that an expression is true, return \a rc if it isn't.
1252 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1253 *
1254 * @param expr Expression which should be true.
1255 * @param a printf argument list (in parenthesis).
1256 * @param rc What is to be presented to return.
1257 */
1258#define AssertLogRelMsgReturn(expr, a, rc) \
1259 do { \
1260 if (RT_LIKELY(!!(expr))) \
1261 { /* likely */ } \
1262 else\
1263 { \
1264 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1265 RTAssertLogRelMsg2(a); \
1266 RTAssertPanic(); \
1267 return (rc); \
1268 } \
1269 } while (0)
1270
1271/** @def AssertLogRelMsgReturnStmt
1272 * Assert that an expression is true, execute @a stmt and return @a rcRet if it
1273 * isn't.
1274 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1275 *
1276 * @param expr Expression which should be true.
1277 * @param a printf argument list (in parenthesis).
1278 * @param stmt Statement to execute before returning in case of a failed
1279 * assertion.
1280 * @param rcRet What is to be presented to return.
1281 */
1282#define AssertLogRelMsgReturnStmt(expr, a, stmt, rcRet) \
1283 do { \
1284 if (RT_LIKELY(!!(expr))) \
1285 { /* likely */ } \
1286 else\
1287 { \
1288 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1289 RTAssertLogRelMsg2(a); \
1290 RTAssertPanic(); \
1291 stmt; \
1292 return (rcRet); \
1293 } \
1294 } while (0)
1295
1296/** @def AssertLogRelMsgReturnVoid
1297 * Assert that an expression is true, return (void) if it isn't.
1298 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1299 *
1300 * @param expr Expression which should be true.
1301 * @param a printf argument list (in parenthesis).
1302 */
1303#define AssertLogRelMsgReturnVoid(expr, a) \
1304 do { \
1305 if (RT_LIKELY(!!(expr))) \
1306 { /* likely */ } \
1307 else\
1308 { \
1309 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1310 RTAssertLogRelMsg2(a); \
1311 RTAssertPanic(); \
1312 return; \
1313 } \
1314 } while (0)
1315
1316/** @def AssertLogRelMsgBreak
1317 * Assert that an expression is true, break if it isn't.
1318 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1319 *
1320 * @param expr Expression which should be true.
1321 * @param a printf argument list (in parenthesis).
1322 */
1323#define AssertLogRelMsgBreak(expr, a) \
1324 if (RT_LIKELY(!!(expr))) \
1325 { /* likely */ } \
1326 else if (1) \
1327 { \
1328 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1329 RTAssertLogRelMsg2(a); \
1330 RTAssertPanic(); \
1331 break; \
1332 } \
1333 else \
1334 break
1335
1336/** @def AssertLogRelMsgBreakStmt
1337 * Assert that an expression is true, execute \a stmt and break if it isn't.
1338 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1339 *
1340 * @param expr Expression which should be true.
1341 * @param a printf argument list (in parenthesis).
1342 * @param stmt Statement to execute before break in case of a failed assertion.
1343 */
1344#define AssertLogRelMsgBreakStmt(expr, a, stmt) \
1345 if (RT_LIKELY(!!(expr))) \
1346 { /* likely */ } \
1347 else if (1) \
1348 { \
1349 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1350 RTAssertLogRelMsg2(a); \
1351 RTAssertPanic(); \
1352 stmt; \
1353 break; \
1354 } else \
1355 break
1356
1357/** @def AssertLogRelFailed
1358 * An assertion failed.
1359 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1360 */
1361#define AssertLogRelFailed() \
1362 do { \
1363 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1364 RTAssertPanic(); \
1365 } while (0)
1366
1367/** @def AssertLogRelFailedReturn
1368 * An assertion failed.
1369 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1370 *
1371 * @param rc What is to be presented to return.
1372 */
1373#define AssertLogRelFailedReturn(rc) \
1374 do { \
1375 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1376 RTAssertPanic(); \
1377 return (rc); \
1378 } while (0)
1379
1380/** @def AssertLogRelFailedReturnVoid
1381 * An assertion failed, hit a breakpoint and return.
1382 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1383 */
1384#define AssertLogRelFailedReturnVoid() \
1385 do { \
1386 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1387 RTAssertPanic(); \
1388 return; \
1389 } while (0)
1390
1391/** @def AssertLogRelFailedBreak
1392 * An assertion failed, break.
1393 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1394 */
1395#define AssertLogRelFailedBreak() \
1396 if (1) \
1397 { \
1398 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1399 RTAssertPanic(); \
1400 break; \
1401 } else \
1402 break
1403
1404/** @def AssertLogRelFailedBreakStmt
1405 * An assertion failed, execute \a stmt and break.
1406 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1407 *
1408 * @param stmt Statement to execute before break.
1409 */
1410#define AssertLogRelFailedBreakStmt(stmt) \
1411 if (1) \
1412 { \
1413 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1414 RTAssertPanic(); \
1415 stmt; \
1416 break; \
1417 } else \
1418 break
1419
1420/** @def AssertLogRelMsgFailed
1421 * An assertion failed.
1422 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1423 *
1424 * @param a printf argument list (in parenthesis).
1425 */
1426#define AssertLogRelMsgFailed(a) \
1427 do { \
1428 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1429 RTAssertLogRelMsg2(a); \
1430 RTAssertPanic(); \
1431 } while (0)
1432
1433/** @def AssertLogRelMsgFailedStmt
1434 * An assertion failed, execute @a stmt.
1435 *
1436 * Strict builds will hit a breakpoint, non-strict will only do LogRel. The
1437 * statement will be executed in regardless of build type.
1438 *
1439 * @param a printf argument list (in parenthesis).
1440 * @param stmt Statement to execute after raising/logging the assertion.
1441 */
1442#define AssertLogRelMsgFailedStmt(a, stmt) \
1443 do { \
1444 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1445 RTAssertLogRelMsg2(a); \
1446 RTAssertPanic(); \
1447 stmt; \
1448 } while (0)
1449
1450/** @def AssertLogRelMsgFailedReturn
1451 * An assertion failed, return \a rc.
1452 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1453 *
1454 * @param a printf argument list (in parenthesis).
1455 * @param rc What is to be presented to return.
1456 */
1457#define AssertLogRelMsgFailedReturn(a, rc) \
1458 do { \
1459 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1460 RTAssertLogRelMsg2(a); \
1461 RTAssertPanic(); \
1462 return (rc); \
1463 } while (0)
1464
1465/** @def AssertLogRelMsgFailedReturnStmt
1466 * An assertion failed, execute @a stmt and return @a rc.
1467 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1468 *
1469 * @param a printf argument list (in parenthesis).
1470 * @param stmt Statement to execute before returning in case of a failed
1471 * assertion.
1472 * @param rc What is to be presented to return.
1473 */
1474#define AssertLogRelMsgFailedReturnStmt(a, stmt, rc) \
1475 do { \
1476 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1477 RTAssertLogRelMsg2(a); \
1478 RTAssertPanic(); \
1479 stmt; \
1480 return (rc); \
1481 } while (0)
1482
1483/** @def AssertLogRelMsgFailedReturnVoid
1484 * An assertion failed, return void.
1485 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1486 *
1487 * @param a printf argument list (in parenthesis).
1488 */
1489#define AssertLogRelMsgFailedReturnVoid(a) \
1490 do { \
1491 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1492 RTAssertLogRelMsg2(a); \
1493 RTAssertPanic(); \
1494 return; \
1495 } while (0)
1496
1497/** @def AssertLogRelMsgFailedReturnVoidStmt
1498 * An assertion failed, execute @a stmt and return void.
1499 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1500 *
1501 * @param a printf argument list (in parenthesis).
1502 * @param stmt Statement to execute before returning in case of a failed
1503 * assertion.
1504 */
1505#define AssertLogRelMsgFailedReturnVoidStmt(a, stmt) \
1506 do { \
1507 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1508 RTAssertLogRelMsg2(a); \
1509 RTAssertPanic(); \
1510 stmt; \
1511 return; \
1512 } while (0)
1513
1514/** @def AssertLogRelMsgFailedBreak
1515 * An assertion failed, break.
1516 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1517 *
1518 * @param a printf argument list (in parenthesis).
1519 */
1520#define AssertLogRelMsgFailedBreak(a) \
1521 if (1)\
1522 { \
1523 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1524 RTAssertLogRelMsg2(a); \
1525 RTAssertPanic(); \
1526 break; \
1527 } else \
1528 break
1529
1530/** @def AssertLogRelMsgFailedBreakStmt
1531 * An assertion failed, execute \a stmt and break.
1532 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1533 *
1534 * @param a printf argument list (in parenthesis).
1535 * @param stmt Statement to execute before break.
1536 */
1537#define AssertLogRelMsgFailedBreakStmt(a, stmt) \
1538 if (1) \
1539 { \
1540 RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1541 RTAssertLogRelMsg2(a); \
1542 RTAssertPanic(); \
1543 stmt; \
1544 break; \
1545 } else \
1546 break
1547
1548/** @} */
1549
1550
1551
1552/** @name Release Assertions
1553 *
1554 * These assertions are always enabled.
1555 * @{
1556 */
1557
1558/** @def RTAssertReleasePanic()
1559 * Invokes RTAssertShouldPanic and RTAssertDoPanic.
1560 *
1561 * It might seem odd that RTAssertShouldPanic is necessary when its result isn't
1562 * checked, but it's done since RTAssertShouldPanic is overrideable and might be
1563 * used to bail out before taking down the system (the VMMR0 case).
1564 */
1565#define RTAssertReleasePanic() do { RTAssertShouldPanic(); RTAssertDoPanic(); } while (0)
1566
1567
1568/** @def AssertRelease
1569 * Assert that an expression is true. If it's not hit a breakpoint.
1570 *
1571 * @param expr Expression which should be true.
1572 */
1573#define AssertRelease(expr) \
1574 do { \
1575 if (RT_LIKELY(!!(expr))) \
1576 { /* likely */ } \
1577 else \
1578 { \
1579 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1580 RTAssertReleasePanic(); \
1581 } \
1582 } while (0)
1583
1584/** @def AssertReleaseReturn
1585 * Assert that an expression is true, hit a breakpoint and return if it isn't.
1586 *
1587 * @param expr Expression which should be true.
1588 * @param rc What is to be presented to return.
1589 */
1590#define AssertReleaseReturn(expr, rc) \
1591 do { \
1592 if (RT_LIKELY(!!(expr))) \
1593 { /* likely */ } \
1594 else \
1595 { \
1596 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1597 RTAssertReleasePanic(); \
1598 return (rc); \
1599 } \
1600 } while (0)
1601
1602/** @def AssertReleaseReturnVoid
1603 * Assert that an expression is true, hit a breakpoint and return if it isn't.
1604 *
1605 * @param expr Expression which should be true.
1606 */
1607#define AssertReleaseReturnVoid(expr) \
1608 do { \
1609 if (RT_LIKELY(!!(expr))) \
1610 { /* likely */ } \
1611 else \
1612 { \
1613 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1614 RTAssertReleasePanic(); \
1615 return; \
1616 } \
1617 } while (0)
1618
1619
1620/** @def AssertReleaseBreak
1621 * Assert that an expression is true, hit a breakpoint and break if it isn't.
1622 *
1623 * @param expr Expression which should be true.
1624 */
1625#define AssertReleaseBreak(expr) \
1626 if (RT_LIKELY(!!(expr))) \
1627 { /* likely */ } \
1628 else if (1) \
1629 { \
1630 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1631 RTAssertReleasePanic(); \
1632 break; \
1633 } else \
1634 break
1635
1636/** @def AssertReleaseBreakStmt
1637 * Assert that an expression is true, hit a breakpoint and break if it isn't.
1638 *
1639 * @param expr Expression which should be true.
1640 * @param stmt Statement to execute before break in case of a failed assertion.
1641 */
1642#define AssertReleaseBreakStmt(expr, stmt) \
1643 if (RT_LIKELY(!!(expr))) \
1644 { /* likely */ } \
1645 else if (1) \
1646 { \
1647 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1648 RTAssertReleasePanic(); \
1649 stmt; \
1650 break; \
1651 } else \
1652 break
1653
1654
1655/** @def AssertReleaseMsg
1656 * Assert that an expression is true, print the message and hit a breakpoint if it isn't.
1657 *
1658 * @param expr Expression which should be true.
1659 * @param a printf argument list (in parenthesis).
1660 */
1661#define AssertReleaseMsg(expr, a) \
1662 do { \
1663 if (RT_LIKELY(!!(expr))) \
1664 { /* likely */ } \
1665 else \
1666 { \
1667 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1668 RTAssertMsg2Weak a; \
1669 RTAssertReleasePanic(); \
1670 } \
1671 } while (0)
1672
1673/** @def AssertReleaseMsgReturn
1674 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1675 *
1676 * @param expr Expression which should be true.
1677 * @param a printf argument list (in parenthesis).
1678 * @param rc What is to be presented to return.
1679 */
1680#define AssertReleaseMsgReturn(expr, a, rc) \
1681 do { \
1682 if (RT_LIKELY(!!(expr))) \
1683 { /* likely */ } \
1684 else \
1685 { \
1686 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1687 RTAssertMsg2Weak a; \
1688 RTAssertReleasePanic(); \
1689 return (rc); \
1690 } \
1691 } while (0)
1692
1693/** @def AssertReleaseMsgReturnVoid
1694 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1695 *
1696 * @param expr Expression which should be true.
1697 * @param a printf argument list (in parenthesis).
1698 */
1699#define AssertReleaseMsgReturnVoid(expr, a) \
1700 do { \
1701 if (RT_LIKELY(!!(expr))) \
1702 { /* likely */ } \
1703 else \
1704 { \
1705 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1706 RTAssertMsg2Weak a; \
1707 RTAssertReleasePanic(); \
1708 return; \
1709 } \
1710 } while (0)
1711
1712
1713/** @def AssertReleaseMsgBreak
1714 * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
1715 *
1716 * @param expr Expression which should be true.
1717 * @param a printf argument list (in parenthesis).
1718 */
1719#define AssertReleaseMsgBreak(expr, a) \
1720 if (RT_LIKELY(!!(expr))) \
1721 { /* likely */ } \
1722 else if (1) \
1723 { \
1724 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1725 RTAssertMsg2Weak a; \
1726 RTAssertReleasePanic(); \
1727 break; \
1728 } else \
1729 break
1730
1731/** @def AssertReleaseMsgBreakStmt
1732 * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
1733 *
1734 * @param expr Expression which should be true.
1735 * @param a printf argument list (in parenthesis).
1736 * @param stmt Statement to execute before break in case of a failed assertion.
1737 */
1738#define AssertReleaseMsgBreakStmt(expr, a, stmt) \
1739 if (RT_LIKELY(!!(expr))) \
1740 { /* likely */ } \
1741 else if (1) \
1742 { \
1743 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1744 RTAssertMsg2Weak a; \
1745 RTAssertReleasePanic(); \
1746 stmt; \
1747 break; \
1748 } else \
1749 break
1750
1751
1752/** @def AssertReleaseFailed
1753 * An assertion failed, hit a breakpoint.
1754 */
1755#define AssertReleaseFailed() \
1756 do { \
1757 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1758 RTAssertReleasePanic(); \
1759 } while (0)
1760
1761/** @def AssertReleaseFailedReturn
1762 * An assertion failed, hit a breakpoint and return.
1763 *
1764 * @param rc What is to be presented to return.
1765 */
1766#define AssertReleaseFailedReturn(rc) \
1767 do { \
1768 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1769 RTAssertReleasePanic(); \
1770 return (rc); \
1771 } while (0)
1772
1773/** @def AssertReleaseFailedReturnVoid
1774 * An assertion failed, hit a breakpoint and return.
1775 */
1776#define AssertReleaseFailedReturnVoid() \
1777 do { \
1778 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1779 RTAssertReleasePanic(); \
1780 return; \
1781 } while (0)
1782
1783
1784/** @def AssertReleaseFailedBreak
1785 * An assertion failed, hit a breakpoint and break.
1786 */
1787#define AssertReleaseFailedBreak() \
1788 if (1) { \
1789 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1790 RTAssertReleasePanic(); \
1791 break; \
1792 } else \
1793 break
1794
1795/** @def AssertReleaseFailedBreakStmt
1796 * An assertion failed, hit a breakpoint and break.
1797 *
1798 * @param stmt Statement to execute before break.
1799 */
1800#define AssertReleaseFailedBreakStmt(stmt) \
1801 if (1) { \
1802 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1803 RTAssertReleasePanic(); \
1804 stmt; \
1805 break; \
1806 } else \
1807 break
1808
1809
1810/** @def AssertReleaseMsgFailed
1811 * An assertion failed, print a message and hit a breakpoint.
1812 *
1813 * @param a printf argument list (in parenthesis).
1814 */
1815#define AssertReleaseMsgFailed(a) \
1816 do { \
1817 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1818 RTAssertMsg2Weak a; \
1819 RTAssertReleasePanic(); \
1820 } while (0)
1821
1822/** @def AssertReleaseMsgFailedReturn
1823 * An assertion failed, print a message, hit a breakpoint and return.
1824 *
1825 * @param a printf argument list (in parenthesis).
1826 * @param rc What is to be presented to return.
1827 */
1828#define AssertReleaseMsgFailedReturn(a, rc) \
1829 do { \
1830 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1831 RTAssertMsg2Weak a; \
1832 RTAssertReleasePanic(); \
1833 return (rc); \
1834 } while (0)
1835
1836/** @def AssertReleaseMsgFailedReturnVoid
1837 * An assertion failed, print a message, hit a breakpoint and return.
1838 *
1839 * @param a printf argument list (in parenthesis).
1840 */
1841#define AssertReleaseMsgFailedReturnVoid(a) \
1842 do { \
1843 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1844 RTAssertMsg2Weak a; \
1845 RTAssertReleasePanic(); \
1846 return; \
1847 } while (0)
1848
1849
1850/** @def AssertReleaseMsgFailedBreak
1851 * An assertion failed, print a message, hit a breakpoint and break.
1852 *
1853 * @param a printf argument list (in parenthesis).
1854 */
1855#define AssertReleaseMsgFailedBreak(a) \
1856 if (1) { \
1857 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1858 RTAssertMsg2Weak a; \
1859 RTAssertReleasePanic(); \
1860 break; \
1861 } else \
1862 break
1863
1864/** @def AssertReleaseMsgFailedBreakStmt
1865 * An assertion failed, print a message, hit a breakpoint and break.
1866 *
1867 * @param a printf argument list (in parenthesis).
1868 * @param stmt Statement to execute before break.
1869 */
1870#define AssertReleaseMsgFailedBreakStmt(a, stmt) \
1871 if (1) { \
1872 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1873 RTAssertMsg2Weak a; \
1874 RTAssertReleasePanic(); \
1875 stmt; \
1876 break; \
1877 } else \
1878 break
1879
1880/** @} */
1881
1882
1883
1884/** @name Fatal Assertions
1885 * These are similar to release assertions except that you cannot ignore them in
1886 * any way, they will loop for ever if RTAssertDoPanic returns.
1887 *
1888 * @{
1889 */
1890
1891/** @def AssertFatal
1892 * Assert that an expression is true. If it's not hit a breakpoint (for ever).
1893 *
1894 * @param expr Expression which should be true.
1895 */
1896#define AssertFatal(expr) \
1897 do { \
1898 if (RT_LIKELY(!!(expr))) \
1899 { /* likely */ } \
1900 else \
1901 for (;;) \
1902 { \
1903 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1904 RTAssertReleasePanic(); \
1905 } \
1906 } while (0)
1907
1908/** @def AssertFatalMsg
1909 * Assert that an expression is true, print the message and hit a breakpoint (for ever) if it isn't.
1910 *
1911 * @param expr Expression which should be true.
1912 * @param a printf argument list (in parenthesis).
1913 */
1914#define AssertFatalMsg(expr, a) \
1915 do { \
1916 if (RT_LIKELY(!!(expr))) \
1917 { /* likely */ } \
1918 else \
1919 for (;;) \
1920 { \
1921 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1922 RTAssertMsg2Weak a; \
1923 RTAssertReleasePanic(); \
1924 } \
1925 } while (0)
1926
1927/** @def AssertFatalFailed
1928 * An assertion failed, hit a breakpoint (for ever).
1929 */
1930#define AssertFatalFailed() \
1931 do { \
1932 for (;;) \
1933 { \
1934 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1935 RTAssertReleasePanic(); \
1936 } \
1937 } while (0)
1938
1939/** @def AssertFatalMsgFailed
1940 * An assertion failed, print a message and hit a breakpoint (for ever).
1941 *
1942 * @param a printf argument list (in parenthesis).
1943 */
1944#define AssertFatalMsgFailed(a) \
1945 do { \
1946 for (;;) \
1947 { \
1948 RTAssertMsg1Weak((const char *)0, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
1949 RTAssertMsg2Weak a; \
1950 RTAssertReleasePanic(); \
1951 } \
1952 } while (0)
1953
1954/** @} */
1955
1956
1957
1958/** @name Convenience Assertions Macros
1959 * @{
1960 */
1961
1962/** @def AssertRC
1963 * Asserts a iprt status code successful.
1964 *
1965 * On failure it will print info about the rc and hit a breakpoint.
1966 *
1967 * @param rc iprt status code.
1968 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1969 */
1970#define AssertRC(rc) AssertMsgRC(rc, ("%Rra\n", (rc)))
1971
1972/** @def AssertRCStmt
1973 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and execute
1974 * @a stmt if it isn't.
1975 *
1976 * @param rc iprt status code.
1977 * @param stmt Statement to execute before returning in case of a failed
1978 * assertion.
1979 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1980 */
1981#define AssertRCStmt(rc, stmt) AssertMsgRCStmt(rc, ("%Rra\n", (rc)), stmt)
1982
1983/** @def AssertRCReturn
1984 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
1985 *
1986 * @param rc iprt status code.
1987 * @param rcRet What is to be presented to return.
1988 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1989 */
1990#define AssertRCReturn(rc, rcRet) AssertMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
1991
1992/** @def AssertRCReturnStmt
1993 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
1994 * @a stmt and returns @a rcRet if it isn't.
1995 *
1996 * @param rc iprt status code.
1997 * @param stmt Statement to execute before returning in case of a failed
1998 * assertion.
1999 * @param rcRet What is to be presented to return.
2000 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2001 */
2002#define AssertRCReturnStmt(rc, stmt, rcRet) AssertMsgRCReturnStmt(rc, ("%Rra\n", (rc)), stmt, rcRet)
2003
2004/** @def AssertRCReturnVoid
2005 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
2006 *
2007 * @param rc iprt status code.
2008 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2009 */
2010#define AssertRCReturnVoid(rc) AssertMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
2011
2012/** @def AssertRCReturnVoidStmt
2013 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), and
2014 * execute the given statement/return if it isn't.
2015 *
2016 * @param rc iprt status code.
2017 * @param stmt Statement to execute before returning on failure.
2018 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2019 */
2020#define AssertRCReturnVoidStmt(rc, stmt) AssertMsgRCReturnVoidStmt(rc, ("%Rra\n", (rc)), stmt)
2021
2022/** @def AssertRCBreak
2023 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
2024 *
2025 * @param rc iprt status code.
2026 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2027 */
2028#define AssertRCBreak(rc) AssertMsgRCBreak(rc, ("%Rra\n", (rc)))
2029
2030/** @def AssertRCBreakStmt
2031 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
2032 *
2033 * @param rc iprt status code.
2034 * @param stmt Statement to execute before break in case of a failed assertion.
2035 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2036 */
2037#define AssertRCBreakStmt(rc, stmt) AssertMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
2038
2039/** @def AssertMsgRC
2040 * Asserts a iprt status code successful.
2041 *
2042 * It prints a custom message and hits a breakpoint on FAILURE.
2043 *
2044 * @param rc iprt status code.
2045 * @param msg printf argument list (in parenthesis).
2046 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2047 */
2048#define AssertMsgRC(rc, msg) \
2049 do { AssertMsg(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
2050
2051/** @def AssertMsgRCStmt
2052 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and
2053 * execute @a stmt if it isn't.
2054 *
2055 * @param rc iprt status code.
2056 * @param msg printf argument list (in parenthesis).
2057 * @param stmt Statement to execute before returning in case of a failed
2058 * assertion.
2059 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2060 */
2061#define AssertMsgRCStmt(rc, msg, stmt) \
2062 do { AssertMsgStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
2063
2064/** @def AssertMsgRCReturn
2065 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return
2066 * @a rcRet if it isn't.
2067 *
2068 * @param rc iprt status code.
2069 * @param msg printf argument list (in parenthesis).
2070 * @param rcRet What is to be presented to return.
2071 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2072 */
2073#define AssertMsgRCReturn(rc, msg, rcRet) \
2074 do { AssertMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet); NOREF(rc); } while (0)
2075
2076/** @def AssertMsgRCReturnStmt
2077 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
2078 * @a stmt and return @a rcRet if it isn't.
2079 *
2080 * @param rc iprt status code.
2081 * @param msg printf argument list (in parenthesis).
2082 * @param stmt Statement to execute before returning in case of a failed
2083 * assertion.
2084 * @param rcRet What is to be presented to return.
2085 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2086 */
2087#define AssertMsgRCReturnStmt(rc, msg, stmt, rcRet) \
2088 do { AssertMsgReturnStmt(RT_SUCCESS_NP(rc), msg, stmt, rcRet); NOREF(rc); } while (0)
2089
2090/** @def AssertMsgRCReturnVoid
2091 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return
2092 * void if it isn't.
2093 *
2094 * @param rc iprt status code.
2095 * @param msg printf argument list (in parenthesis).
2096 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2097 */
2098#define AssertMsgRCReturnVoid(rc, msg) \
2099 do { AssertMsgReturnVoid(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
2100
2101/** @def AssertMsgRCReturnVoidStmt
2102 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
2103 * @a stmt and return void if it isn't.
2104 *
2105 * @param rc iprt status code.
2106 * @param msg printf argument list (in parenthesis).
2107 * @param stmt Statement to execute before break in case of a failed assertion.
2108 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2109 */
2110#define AssertMsgRCReturnVoidStmt(rc, msg, stmt) \
2111 do { AssertMsgReturnVoidStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
2112
2113/** @def AssertMsgRCBreak
2114 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break
2115 * if it isn't.
2116 *
2117 * @param rc iprt status code.
2118 * @param msg printf argument list (in parenthesis).
2119 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2120 */
2121#define AssertMsgRCBreak(rc, msg) \
2122 if (1) { AssertMsgBreak(RT_SUCCESS(rc), msg); NOREF(rc); } else do {} while (0)
2123
2124/** @def AssertMsgRCBreakStmt
2125 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
2126 * @a stmt and break if it isn't.
2127 *
2128 * @param rc iprt status code.
2129 * @param msg printf argument list (in parenthesis).
2130 * @param stmt Statement to execute before break in case of a failed assertion.
2131 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2132 */
2133#define AssertMsgRCBreakStmt(rc, msg, stmt) \
2134 if (1) { AssertMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } else do {} while (0)
2135
2136/** @def AssertRCSuccess
2137 * Asserts an iprt status code equals VINF_SUCCESS.
2138 *
2139 * On failure it will print info about the rc and hit a breakpoint.
2140 *
2141 * @param rc iprt status code.
2142 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2143 */
2144#define AssertRCSuccess(rc) do { AssertMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc))); NOREF(rc); } while (0)
2145
2146/** @def AssertRCSuccessReturn
2147 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
2148 *
2149 * @param rc iprt status code.
2150 * @param rcRet What is to be presented to return.
2151 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2152 */
2153#define AssertRCSuccessReturn(rc, rcRet) AssertMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
2154
2155/** @def AssertRCSuccessReturnVoid
2156 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
2157 *
2158 * @param rc iprt status code.
2159 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2160 */
2161#define AssertRCSuccessReturnVoid(rc) AssertMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2162
2163/** @def AssertRCSuccessBreak
2164 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
2165 *
2166 * @param rc iprt status code.
2167 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2168 */
2169#define AssertRCSuccessBreak(rc) AssertMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2170
2171/** @def AssertRCSuccessBreakStmt
2172 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
2173 *
2174 * @param rc iprt status code.
2175 * @param stmt Statement to execute before break in case of a failed assertion.
2176 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
2177 */
2178#define AssertRCSuccessBreakStmt(rc, stmt) AssertMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
2179
2180
2181/** @def AssertLogRelRC
2182 * Asserts a iprt status code successful.
2183 *
2184 * @param rc iprt status code.
2185 * @remark rc is referenced multiple times.
2186 */
2187#define AssertLogRelRC(rc) AssertLogRelMsgRC(rc, ("%Rra\n", (rc)))
2188
2189/** @def AssertLogRelRCReturn
2190 * Asserts a iprt status code successful, returning \a rc if it isn't.
2191 *
2192 * @param rc iprt status code.
2193 * @param rcRet What is to be presented to return.
2194 * @remark rc is referenced multiple times.
2195 */
2196#define AssertLogRelRCReturn(rc, rcRet) AssertLogRelMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
2197
2198/** @def AssertLogRelRCReturnStmt
2199 * Asserts a iprt status code successful, executing \a stmt and returning \a rc
2200 * if it isn't.
2201 *
2202 * @param rc iprt status code.
2203 * @param stmt Statement to execute before returning in case of a failed
2204 * assertion.
2205 * @param rcRet What is to be presented to return.
2206 * @remark rc is referenced multiple times.
2207 */
2208#define AssertLogRelRCReturnStmt(rc, stmt, rcRet) AssertLogRelMsgRCReturnStmt(rc, ("%Rra\n", (rc)), stmt, rcRet)
2209
2210/** @def AssertLogRelRCReturnVoid
2211 * Asserts a iprt status code successful, returning (void) if it isn't.
2212 *
2213 * @param rc iprt status code.
2214 * @remark rc is referenced multiple times.
2215 */
2216#define AssertLogRelRCReturnVoid(rc) AssertLogRelMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
2217
2218/** @def AssertLogRelRCBreak
2219 * Asserts a iprt status code successful, breaking if it isn't.
2220 *
2221 * @param rc iprt status code.
2222 * @remark rc is referenced multiple times.
2223 */
2224#define AssertLogRelRCBreak(rc) AssertLogRelMsgRCBreak(rc, ("%Rra\n", (rc)))
2225
2226/** @def AssertLogRelRCBreakStmt
2227 * Asserts a iprt status code successful, execute \a statement and break if it isn't.
2228 *
2229 * @param rc iprt status code.
2230 * @param stmt Statement to execute before break in case of a failed assertion.
2231 * @remark rc is referenced multiple times.
2232 */
2233#define AssertLogRelRCBreakStmt(rc, stmt) AssertLogRelMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
2234
2235/** @def AssertLogRelMsgRC
2236 * Asserts a iprt status code successful.
2237 *
2238 * @param rc iprt status code.
2239 * @param msg printf argument list (in parenthesis).
2240 * @remark rc is referenced multiple times.
2241 */
2242#define AssertLogRelMsgRC(rc, msg) AssertLogRelMsg(RT_SUCCESS_NP(rc), msg)
2243
2244/** @def AssertLogRelMsgRCReturn
2245 * Asserts a iprt status code successful.
2246 *
2247 * @param rc iprt status code.
2248 * @param msg printf argument list (in parenthesis).
2249 * @param rcRet What is to be presented to return.
2250 * @remark rc is referenced multiple times.
2251 */
2252#define AssertLogRelMsgRCReturn(rc, msg, rcRet) AssertLogRelMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
2253
2254/** @def AssertLogRelMsgRCReturnStmt
2255 * Asserts a iprt status code successful, execute \a stmt and return on
2256 * failure.
2257 *
2258 * @param rc iprt status code.
2259 * @param msg printf argument list (in parenthesis).
2260 * @param stmt Statement to execute before returning in case of a failed
2261 * assertion.
2262 * @param rcRet What is to be presented to return.
2263 * @remark rc is referenced multiple times.
2264 */
2265#define AssertLogRelMsgRCReturnStmt(rc, msg, stmt, rcRet) AssertLogRelMsgReturnStmt(RT_SUCCESS_NP(rc), msg, stmt, rcRet)
2266
2267/** @def AssertLogRelMsgRCReturnVoid
2268 * Asserts a iprt status code successful.
2269 *
2270 * @param rc iprt status code.
2271 * @param msg printf argument list (in parenthesis).
2272 * @remark rc is referenced multiple times.
2273 */
2274#define AssertLogRelMsgRCReturnVoid(rc, msg) AssertLogRelMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
2275
2276/** @def AssertLogRelMsgRCBreak
2277 * Asserts a iprt status code successful.
2278 *
2279 * @param rc iprt status code.
2280 * @param msg printf argument list (in parenthesis).
2281 * @remark rc is referenced multiple times.
2282 */
2283#define AssertLogRelMsgRCBreak(rc, msg) AssertLogRelMsgBreak(RT_SUCCESS(rc), msg)
2284
2285/** @def AssertLogRelMsgRCBreakStmt
2286 * Asserts a iprt status code successful, execute \a stmt and break if it isn't.
2287 *
2288 * @param rc iprt status code.
2289 * @param msg printf argument list (in parenthesis).
2290 * @param stmt Statement to execute before break in case of a failed assertion.
2291 * @remark rc is referenced multiple times.
2292 */
2293#define AssertLogRelMsgRCBreakStmt(rc, msg, stmt) AssertLogRelMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
2294
2295/** @def AssertLogRelRCSuccess
2296 * Asserts that an iprt status code equals VINF_SUCCESS.
2297 *
2298 * @param rc iprt status code.
2299 * @remark rc is referenced multiple times.
2300 */
2301#define AssertLogRelRCSuccess(rc) AssertLogRelMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2302
2303/** @def AssertLogRelRCSuccessReturn
2304 * Asserts that an iprt status code equals VINF_SUCCESS.
2305 *
2306 * @param rc iprt status code.
2307 * @param rcRet What is to be presented to return.
2308 * @remark rc is referenced multiple times.
2309 */
2310#define AssertLogRelRCSuccessReturn(rc, rcRet) AssertLogRelMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
2311
2312/** @def AssertLogRelRCSuccessReturnVoid
2313 * Asserts that an iprt status code equals VINF_SUCCESS.
2314 *
2315 * @param rc iprt status code.
2316 * @remark rc is referenced multiple times.
2317 */
2318#define AssertLogRelRCSuccessReturnVoid(rc) AssertLogRelMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2319
2320/** @def AssertLogRelRCSuccessBreak
2321 * Asserts that an iprt status code equals VINF_SUCCESS.
2322 *
2323 * @param rc iprt status code.
2324 * @remark rc is referenced multiple times.
2325 */
2326#define AssertLogRelRCSuccessBreak(rc) AssertLogRelMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2327
2328/** @def AssertLogRelRCSuccessBreakStmt
2329 * Asserts that an iprt status code equals VINF_SUCCESS.
2330 *
2331 * @param rc iprt status code.
2332 * @param stmt Statement to execute before break in case of a failed assertion.
2333 * @remark rc is referenced multiple times.
2334 */
2335#define AssertLogRelRCSuccessBreakStmt(rc, stmt) AssertLogRelMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
2336
2337
2338/** @def AssertReleaseRC
2339 * Asserts a iprt status code successful.
2340 *
2341 * On failure information about the error will be printed and a breakpoint hit.
2342 *
2343 * @param rc iprt status code.
2344 * @remark rc is referenced multiple times.
2345 */
2346#define AssertReleaseRC(rc) AssertReleaseMsgRC(rc, ("%Rra\n", (rc)))
2347
2348/** @def AssertReleaseRCReturn
2349 * Asserts a iprt status code successful, returning if it isn't.
2350 *
2351 * On failure information about the error will be printed, a breakpoint hit
2352 * and finally returning from the function if the breakpoint is somehow ignored.
2353 *
2354 * @param rc iprt status code.
2355 * @param rcRet What is to be presented to return.
2356 * @remark rc is referenced multiple times.
2357 */
2358#define AssertReleaseRCReturn(rc, rcRet) AssertReleaseMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
2359
2360/** @def AssertReleaseRCReturnVoid
2361 * Asserts a iprt status code successful, returning if it isn't.
2362 *
2363 * On failure information about the error will be printed, a breakpoint hit
2364 * and finally returning from the function if the breakpoint is somehow ignored.
2365 *
2366 * @param rc iprt status code.
2367 * @remark rc is referenced multiple times.
2368 */
2369#define AssertReleaseRCReturnVoid(rc) AssertReleaseMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
2370
2371/** @def AssertReleaseRCBreak
2372 * Asserts a iprt status code successful, breaking if it isn't.
2373 *
2374 * On failure information about the error will be printed, a breakpoint hit
2375 * and finally breaking the current statement if the breakpoint is somehow ignored.
2376 *
2377 * @param rc iprt status code.
2378 * @remark rc is referenced multiple times.
2379 */
2380#define AssertReleaseRCBreak(rc) AssertReleaseMsgRCBreak(rc, ("%Rra\n", (rc)))
2381
2382/** @def AssertReleaseRCBreakStmt
2383 * Asserts a iprt status code successful, break if it isn't.
2384 *
2385 * On failure information about the error will be printed, a breakpoint hit
2386 * and finally the break statement will be issued if the breakpoint is somehow ignored.
2387 *
2388 * @param rc iprt status code.
2389 * @param stmt Statement to execute before break in case of a failed assertion.
2390 * @remark rc is referenced multiple times.
2391 */
2392#define AssertReleaseRCBreakStmt(rc, stmt) AssertReleaseMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
2393
2394/** @def AssertReleaseMsgRC
2395 * Asserts a iprt status code successful.
2396 *
2397 * On failure a custom message is printed and a breakpoint is hit.
2398 *
2399 * @param rc iprt status code.
2400 * @param msg printf argument list (in parenthesis).
2401 * @remark rc is referenced multiple times.
2402 */
2403#define AssertReleaseMsgRC(rc, msg) AssertReleaseMsg(RT_SUCCESS_NP(rc), msg)
2404
2405/** @def AssertReleaseMsgRCReturn
2406 * Asserts a iprt status code successful.
2407 *
2408 * On failure a custom message is printed, a breakpoint is hit, and finally
2409 * returning from the function if the breakpoint is somehow ignored.
2410 *
2411 * @param rc iprt status code.
2412 * @param msg printf argument list (in parenthesis).
2413 * @param rcRet What is to be presented to return.
2414 * @remark rc is referenced multiple times.
2415 */
2416#define AssertReleaseMsgRCReturn(rc, msg, rcRet) AssertReleaseMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
2417
2418/** @def AssertReleaseMsgRCReturnVoid
2419 * Asserts a iprt status code successful.
2420 *
2421 * On failure a custom message is printed, a breakpoint is hit, and finally
2422 * returning from the function if the breakpoint is somehow ignored.
2423 *
2424 * @param rc iprt status code.
2425 * @param msg printf argument list (in parenthesis).
2426 * @remark rc is referenced multiple times.
2427 */
2428#define AssertReleaseMsgRCReturnVoid(rc, msg) AssertReleaseMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
2429
2430/** @def AssertReleaseMsgRCBreak
2431 * Asserts a iprt status code successful.
2432 *
2433 * On failure a custom message is printed, a breakpoint is hit, and finally
2434 * breaking the current status if the breakpoint is somehow ignored.
2435 *
2436 * @param rc iprt status code.
2437 * @param msg printf argument list (in parenthesis).
2438 * @remark rc is referenced multiple times.
2439 */
2440#define AssertReleaseMsgRCBreak(rc, msg) AssertReleaseMsgBreak(RT_SUCCESS(rc), msg)
2441
2442/** @def AssertReleaseMsgRCBreakStmt
2443 * Asserts a iprt status code successful.
2444 *
2445 * On failure a custom message is printed, a breakpoint is hit, and finally
2446 * the break statement is issued if the breakpoint is somehow ignored.
2447 *
2448 * @param rc iprt status code.
2449 * @param msg printf argument list (in parenthesis).
2450 * @param stmt Statement to execute before break in case of a failed assertion.
2451 * @remark rc is referenced multiple times.
2452 */
2453#define AssertReleaseMsgRCBreakStmt(rc, msg, stmt) AssertReleaseMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
2454
2455/** @def AssertReleaseRCSuccess
2456 * Asserts that an iprt status code equals VINF_SUCCESS.
2457 *
2458 * On failure information about the error will be printed and a breakpoint hit.
2459 *
2460 * @param rc iprt status code.
2461 * @remark rc is referenced multiple times.
2462 */
2463#define AssertReleaseRCSuccess(rc) AssertReleaseMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2464
2465/** @def AssertReleaseRCSuccessReturn
2466 * Asserts that an iprt status code equals VINF_SUCCESS.
2467 *
2468 * On failure information about the error will be printed, a breakpoint hit
2469 * and finally returning from the function if the breakpoint is somehow ignored.
2470 *
2471 * @param rc iprt status code.
2472 * @param rcRet What is to be presented to return.
2473 * @remark rc is referenced multiple times.
2474 */
2475#define AssertReleaseRCSuccessReturn(rc, rcRet) AssertReleaseMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
2476
2477/** @def AssertReleaseRCSuccessReturnVoid
2478 * Asserts that an iprt status code equals VINF_SUCCESS.
2479 *
2480 * On failure information about the error will be printed, a breakpoint hit
2481 * and finally returning from the function if the breakpoint is somehow ignored.
2482 *
2483 * @param rc iprt status code.
2484 * @remark rc is referenced multiple times.
2485 */
2486#define AssertReleaseRCSuccessReturnVoid(rc) AssertReleaseMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2487
2488/** @def AssertReleaseRCSuccessBreak
2489 * Asserts that an iprt status code equals VINF_SUCCESS.
2490 *
2491 * On failure information about the error will be printed, a breakpoint hit
2492 * and finally breaking the current statement if the breakpoint is somehow ignored.
2493 *
2494 * @param rc iprt status code.
2495 * @remark rc is referenced multiple times.
2496 */
2497#define AssertReleaseRCSuccessBreak(rc) AssertReleaseMsgBreak((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2498
2499/** @def AssertReleaseRCSuccessBreakStmt
2500 * Asserts that an iprt status code equals VINF_SUCCESS.
2501 *
2502 * On failure information about the error will be printed, a breakpoint hit
2503 * and finally the break statement will be issued if the breakpoint is somehow ignored.
2504 *
2505 * @param rc iprt status code.
2506 * @param stmt Statement to execute before break in case of a failed assertion.
2507 * @remark rc is referenced multiple times.
2508 */
2509#define AssertReleaseRCSuccessBreakStmt(rc, stmt) AssertReleaseMsgBreakStmt((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
2510
2511
2512/** @def AssertFatalRC
2513 * Asserts a iprt status code successful.
2514 *
2515 * On failure information about the error will be printed and a breakpoint hit.
2516 *
2517 * @param rc iprt status code.
2518 * @remark rc is referenced multiple times.
2519 */
2520#define AssertFatalRC(rc) AssertFatalMsgRC(rc, ("%Rra\n", (rc)))
2521
2522/** @def AssertReleaseMsgRC
2523 * Asserts a iprt status code successful.
2524 *
2525 * On failure a custom message is printed and a breakpoint is hit.
2526 *
2527 * @param rc iprt status code.
2528 * @param msg printf argument list (in parenthesis).
2529 * @remark rc is referenced multiple times.
2530 */
2531#define AssertFatalMsgRC(rc, msg) AssertFatalMsg(RT_SUCCESS_NP(rc), msg)
2532
2533/** @def AssertFatalRCSuccess
2534 * Asserts that an iprt status code equals VINF_SUCCESS.
2535 *
2536 * On failure information about the error will be printed and a breakpoint hit.
2537 *
2538 * @param rc iprt status code.
2539 * @remark rc is referenced multiple times.
2540 */
2541#define AssertFatalRCSuccess(rc) AssertFatalMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
2542
2543
2544/** @def AssertPtr
2545 * Asserts that a pointer is valid.
2546 *
2547 * @param pv The pointer.
2548 */
2549#define AssertPtr(pv) AssertMsg(VALID_PTR(pv), ("%p\n", (pv)))
2550
2551/** @def AssertPtrReturn
2552 * Asserts that a pointer is valid.
2553 *
2554 * @param pv The pointer.
2555 * @param rcRet What is to be presented to return.
2556 */
2557#define AssertPtrReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv), ("%p\n", (pv)), rcRet)
2558
2559/** @def AssertPtrReturnVoid
2560 * Asserts that a pointer is valid.
2561 *
2562 * @param pv The pointer.
2563 */
2564#define AssertPtrReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv), ("%p\n", (pv)))
2565
2566/** @def AssertPtrBreak
2567 * Asserts that a pointer is valid.
2568 *
2569 * @param pv The pointer.
2570 */
2571#define AssertPtrBreak(pv) AssertMsgBreak(VALID_PTR(pv), ("%p\n", (pv)))
2572
2573/** @def AssertPtrBreakStmt
2574 * Asserts that a pointer is valid.
2575 *
2576 * @param pv The pointer.
2577 * @param stmt Statement to execute before break in case of a failed assertion.
2578 */
2579#define AssertPtrBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv), ("%p\n", (pv)), stmt)
2580
2581/** @def AssertPtrNull
2582 * Asserts that a pointer is valid or NULL.
2583 *
2584 * @param pv The pointer.
2585 */
2586#define AssertPtrNull(pv) AssertMsg(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
2587
2588/** @def AssertPtrNullReturn
2589 * Asserts that a pointer is valid or NULL.
2590 *
2591 * @param pv The pointer.
2592 * @param rcRet What is to be presented to return.
2593 */
2594#define AssertPtrNullReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), rcRet)
2595
2596/** @def AssertPtrNullReturnVoid
2597 * Asserts that a pointer is valid or NULL.
2598 *
2599 * @param pv The pointer.
2600 */
2601#define AssertPtrNullReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
2602
2603/** @def AssertPtrNullBreak
2604 * Asserts that a pointer is valid or NULL.
2605 *
2606 * @param pv The pointer.
2607 */
2608#define AssertPtrNullBreak(pv) AssertMsgBreak(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
2609
2610/** @def AssertPtrNullBreakStmt
2611 * Asserts that a pointer is valid or NULL.
2612 *
2613 * @param pv The pointer.
2614 * @param stmt Statement to execute before break in case of a failed assertion.
2615 */
2616#define AssertPtrNullBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt)
2617
2618/** @def AssertGCPhys32
2619 * Asserts that the high dword of a physical address is zero
2620 *
2621 * @param GCPhys The address (RTGCPHYS).
2622 */
2623#define AssertGCPhys32(GCPhys) AssertMsg(VALID_PHYS32(GCPhys), ("%RGp\n", (RTGCPHYS)(GCPhys)))
2624
2625/** @def AssertGCPtr32
2626 * Asserts that the high dword of a physical address is zero
2627 *
2628 * @param GCPtr The address (RTGCPTR).
2629 */
2630#if GC_ARCH_BITS == 32
2631# define AssertGCPtr32(GCPtr) do { } while (0)
2632#else
2633# define AssertGCPtr32(GCPtr) AssertMsg(!((GCPtr) & UINT64_C(0xffffffff00000000)), ("%RGv\n", GCPtr))
2634#endif
2635
2636/** @def AssertForEach
2637 * Equivalent to Assert for each value of the variable from the starting
2638 * value to the finishing one.
2639 *
2640 * @param var Name of the counter variable.
2641 * @param vartype Type of the counter variable.
2642 * @param first Lowest inclusive value of the counter variable.
2643 * This must be free from side effects.
2644 * @param end Highest exclusive value of the counter variable.
2645 * This must be free from side effects.
2646 * @param expr Expression which should be true for each value of @a var.
2647 */
2648#define AssertForEach(var, vartype, first, end, expr) \
2649 do { \
2650 vartype var; \
2651 Assert((first) == (first) && (end) == (end)); /* partial check for side effects */ \
2652 for (var = (first); var < (end); var++) \
2653 AssertMsg(expr, ("%s = %#RX64 (%RI64)", #var, (uint64_t)var, (int64_t)var)); \
2654 } while (0)
2655
2656#ifdef RT_OS_WINDOWS
2657
2658/** @def AssertNtStatus
2659 * Asserts that the NT_SUCCESS() returns true for the given NTSTATUS value.
2660 *
2661 * @param a_rcNt The NTSTATUS to check. Will be evaluated twice and
2662 * subjected to NOREF().
2663 * @sa AssertRC()
2664 */
2665# define AssertNtStatus(a_rcNt) \
2666 do { AssertMsg(NT_SUCCESS(a_rcNt), ("%#x\n", (a_rcNt))); NOREF(a_rcNt); } while (0)
2667
2668/** @def AssertNtStatusSuccess
2669 * Asserts that the given NTSTATUS value equals STATUS_SUCCESS.
2670 *
2671 * @param a_rcNt The NTSTATUS to check. Will be evaluated twice and
2672 * subjected to NOREF().
2673 * @sa AssertRCSuccess()
2674 */
2675# define AssertNtStatusSuccess(a_rcNt) \
2676 do { AssertMsg((a_rcNt) == STATUS_SUCCESS, ("%#x\n", (a_rcNt))); NOREF(a_rcNt); } while (0)
2677
2678#endif /* RT_OS_WINDOWS */
2679
2680/** @} */
2681
2682/** @} */
2683
2684#endif
2685
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