VirtualBox

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

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

AssertMsgFailedBreakVoid -> AssertMsgFailedBreak

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

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