VirtualBox

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

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

VALID_PHYS32_PTR -> VALID_PHYS32. Fixed AssertGCPhys32 string. Moved the assertion function to the top of the file to help compiler caches.

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