VirtualBox

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

Last change on this file since 13469 was 13314, checked in by vboxsync, 16 years ago

Created assert-r0drv-linux.c (finally).

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