VirtualBox

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

Last change on this file since 73768 was 73762, checked in by vboxsync, 6 years ago

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

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

© 2023 Oracle
ContactPrivacy policyTerms of Use