VirtualBox

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

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

AssertRCBreakVoid -> AssertRCBreak.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 62.8 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 AssertReleaseBreak
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 */
1078#define AssertReleaseBreak(expr) \
1079 if { \
1080 if (RT_UNLIKELY(!(expr))) \
1081 { \
1082 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1083 AssertReleaseBreakpoint(); \
1084 break; \
1085 } \
1086 } else do {} while (0)
1087
1088/** @def AssertReleaseBreakStmt
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 * @param stmt Statement to execute before break in case of a failed assertion.
1093 */
1094#define AssertReleaseBreakStmt(expr, stmt) \
1095 if (RT_UNLIKELY(!(expr))) \
1096 { \
1097 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1098 AssertReleaseBreakpoint(); \
1099 stmt; \
1100 break; \
1101 } else do {} while (0)
1102
1103
1104/** @def AssertReleaseMsg
1105 * Assert that an expression is true, print the message and hit a breakpoint if it isn't.
1106 *
1107 * @param expr Expression which should be true.
1108 * @param a printf argument list (in parenthesis).
1109 */
1110#define AssertReleaseMsg(expr, a) \
1111 do { \
1112 if (RT_UNLIKELY(!(expr))) \
1113 { \
1114 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1115 AssertMsg2 a; \
1116 AssertReleaseBreakpoint(); \
1117 } \
1118 } while (0)
1119
1120/** @def AssertReleaseMsgReturn
1121 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1122 *
1123 * @param expr Expression which should be true.
1124 * @param a printf argument list (in parenthesis).
1125 * @param rc What is to be presented to return.
1126 */
1127#define AssertReleaseMsgReturn(expr, a, rc) \
1128 do { \
1129 if (RT_UNLIKELY(!(expr))) \
1130 { \
1131 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1132 AssertMsg2 a; \
1133 AssertReleaseBreakpoint(); \
1134 return (rc); \
1135 } \
1136 } while (0)
1137
1138/** @def AssertReleaseMsgReturnVoid
1139 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
1140 *
1141 * @param expr Expression which should be true.
1142 * @param a printf argument list (in parenthesis).
1143 */
1144#define AssertReleaseMsgReturnVoid(expr, a) \
1145 do { \
1146 if (RT_UNLIKELY(!(expr))) \
1147 { \
1148 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1149 AssertMsg2 a; \
1150 AssertReleaseBreakpoint(); \
1151 return; \
1152 } \
1153 } while (0)
1154
1155
1156/** @def AssertReleaseMsgBreak
1157 * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
1158 *
1159 * @param expr Expression which should be true.
1160 * @param a printf argument list (in parenthesis).
1161 */
1162#define AssertReleaseMsgBreak(expr, a) \
1163 if (RT_UNLIKELY(!(expr))) \
1164 { \
1165 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1166 AssertMsg2 a; \
1167 AssertReleaseBreakpoint(); \
1168 break; \
1169 } else do {} while (0)
1170
1171/** @def AssertReleaseMsgBreakStmt
1172 * Assert that an expression is true, print the message and hit a breakpoing and break if it isn't.
1173 *
1174 * @param expr Expression which should be true.
1175 * @param a printf argument list (in parenthesis).
1176 * @param stmt Statement to execute before break in case of a failed assertion.
1177 */
1178#define AssertReleaseMsgBreakStmt(expr, a, stmt) \
1179 if (RT_UNLIKELY(!(expr))) { \
1180 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1181 AssertMsg2 a; \
1182 AssertReleaseBreakpoint(); \
1183 stmt; \
1184 break; \
1185 } else do {} while (0)
1186
1187
1188/** @def AssertReleaseFailed
1189 * An assertion failed, hit a breakpoint.
1190 */
1191#define AssertReleaseFailed() \
1192 do { \
1193 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1194 AssertReleaseBreakpoint(); \
1195 } while (0)
1196
1197/** @def AssertReleaseFailedReturn
1198 * An assertion failed, hit a breakpoint and return.
1199 *
1200 * @param rc What is to be presented to return.
1201 */
1202#define AssertReleaseFailedReturn(rc) \
1203 do { \
1204 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1205 AssertReleaseBreakpoint(); \
1206 return (rc); \
1207 } while (0)
1208
1209/** @def AssertReleaseFailedReturnVoid
1210 * An assertion failed, hit a breakpoint and return.
1211 */
1212#define AssertReleaseFailedReturnVoid() \
1213 do { \
1214 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1215 AssertReleaseBreakpoint(); \
1216 return; \
1217 } while (0)
1218
1219
1220/** @def AssertReleaseFailedBreak
1221 * An assertion failed, hit a breakpoint and break.
1222 */
1223#define AssertReleaseFailedBreak() \
1224 if (1) { \
1225 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1226 AssertReleaseBreakpoint(); \
1227 break; \
1228 } else do {} while (0)
1229
1230/** @def AssertReleaseFailedBreakStmt
1231 * An assertion failed, hit a breakpoint and break.
1232 *
1233 * @param stmt Statement to execute before break.
1234 */
1235#define AssertReleaseFailedBreakStmt(stmt) \
1236 if (1) { \
1237 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1238 AssertReleaseBreakpoint(); \
1239 stmt; \
1240 break; \
1241 } else do {} while (0)
1242
1243
1244/** @def AssertReleaseMsgFailed
1245 * An assertion failed, print a message and hit a breakpoint.
1246 *
1247 * @param a printf argument list (in parenthesis).
1248 */
1249#define AssertReleaseMsgFailed(a) \
1250 do { \
1251 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1252 AssertMsg2 a; \
1253 AssertReleaseBreakpoint(); \
1254 } while (0)
1255
1256/** @def AssertReleaseMsgFailedReturn
1257 * An assertion failed, print a message, hit a breakpoint and return.
1258 *
1259 * @param a printf argument list (in parenthesis).
1260 * @param rc What is to be presented to return.
1261 */
1262#define AssertReleaseMsgFailedReturn(a, rc) \
1263 do { \
1264 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1265 AssertMsg2 a; \
1266 AssertReleaseBreakpoint(); \
1267 return (rc); \
1268 } while (0)
1269
1270/** @def AssertReleaseMsgFailedReturnVoid
1271 * An assertion failed, print a message, hit a breakpoint and return.
1272 *
1273 * @param a printf argument list (in parenthesis).
1274 */
1275#define AssertReleaseMsgFailedReturnVoid(a) \
1276 do { \
1277 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1278 AssertMsg2 a; \
1279 AssertReleaseBreakpoint(); \
1280 return; \
1281 } while (0)
1282
1283
1284/** @def AssertReleaseMsgFailedBreak
1285 * An assertion failed, print a message, hit a breakpoint and break.
1286 *
1287 * @param a printf argument list (in parenthesis).
1288 */
1289#define AssertReleaseMsgFailedBreak(a) \
1290 if (1) { \
1291 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1292 AssertMsg2 a; \
1293 AssertReleaseBreakpoint(); \
1294 break; \
1295 } else do {} while (0)
1296
1297/** @def AssertReleaseMsgFailedBreakStmt
1298 * An assertion failed, print a message, hit a breakpoint and break.
1299 *
1300 * @param a printf argument list (in parenthesis).
1301 * @param stmt Statement to execute before break.
1302 */
1303#define AssertReleaseMsgFailedBreakStmt(a, stmt) \
1304 if (1) { \
1305 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1306 AssertMsg2 a; \
1307 AssertReleaseBreakpoint(); \
1308 stmt; \
1309 break; \
1310 } else do {} while (0)
1311
1312
1313/** @def AssertFatal
1314 * Assert that an expression is true. If it's not hit a breakpoint (for ever).
1315 *
1316 * @param expr Expression which should be true.
1317 */
1318#define AssertFatal(expr) \
1319 do { \
1320 if (RT_UNLIKELY(!(expr))) \
1321 for (;;) \
1322 { \
1323 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1324 AssertReleaseBreakpoint(); \
1325 } \
1326 } while (0)
1327
1328/** @def AssertFatalMsg
1329 * Assert that an expression is true, print the message and hit a breakpoint (for ever) if it isn't.
1330 *
1331 * @param expr Expression which should be true.
1332 * @param a printf argument list (in parenthesis).
1333 */
1334#define AssertFatalMsg(expr, a) \
1335 do { \
1336 if (RT_UNLIKELY(!(expr))) \
1337 for (;;) \
1338 { \
1339 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1340 AssertMsg2 a; \
1341 AssertReleaseBreakpoint(); \
1342 } \
1343 } while (0)
1344
1345/** @def AssertFatalFailed
1346 * An assertion failed, hit a breakpoint (for ever).
1347 */
1348#define AssertFatalFailed() \
1349 do { \
1350 for (;;) \
1351 { \
1352 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1353 AssertReleaseBreakpoint(); \
1354 } \
1355 } while (0)
1356
1357/** @def AssertFatalMsgFailed
1358 * An assertion failed, print a message and hit a breakpoint (for ever).
1359 *
1360 * @param a printf argument list (in parenthesis).
1361 */
1362#define AssertFatalMsgFailed(a) \
1363 do { \
1364 for (;;) \
1365 { \
1366 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1367 AssertMsg2 a; \
1368 AssertReleaseBreakpoint(); \
1369 } \
1370 } while (0)
1371
1372
1373/** @def AssertRC
1374 * Asserts a iprt status code successful.
1375 *
1376 * On failure it will print info about the rc and hit a breakpoint.
1377 *
1378 * @param rc iprt status code.
1379 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1380 */
1381#define AssertRC(rc) AssertMsgRC(rc, ("%Vra\n", (rc)))
1382
1383/** @def AssertRCReturn
1384 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
1385 *
1386 * @param rc iprt status code.
1387 * @param rcRet What is to be presented to return.
1388 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1389 */
1390#define AssertRCReturn(rc, rcRet) AssertMsgRCReturn(rc, ("%Vra\n", (rc)), rcRet)
1391
1392/** @def AssertRCReturnVoid
1393 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
1394 *
1395 * @param rc iprt status code.
1396 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1397 */
1398#define AssertRCReturnVoid(rc) AssertMsgRCReturnVoid(rc, ("%Vra\n", (rc)))
1399
1400/** @def AssertRCBreak
1401 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
1402 *
1403 * @param rc iprt status code.
1404 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1405 */
1406#define AssertRCBreak(rc) AssertMsgRCBreakVoid(rc, ("%Vra\n", (rc)))
1407
1408/** @def AssertRCBreakStmt
1409 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
1410 *
1411 * @param rc iprt status code.
1412 * @param stmt Statement to execute before break in case of a failed assertion.
1413 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1414 */
1415#define AssertRCBreakStmt(rc, stmt) AssertMsgRCBreakStmt(rc, ("%Vra\n", (rc)), stmt)
1416
1417/** @def AssertMsgRC
1418 * Asserts a iprt status code successful.
1419 *
1420 * It prints a custom message and hits a breakpoint on FAILURE.
1421 *
1422 * @param rc iprt status code.
1423 * @param msg printf argument list (in parenthesis).
1424 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1425 */
1426#define AssertMsgRC(rc, msg) \
1427 do { AssertMsg(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
1428
1429/** @def AssertMsgRCReturn
1430 * Asserts a iprt status code successful and if it's not return the specified status code.
1431 *
1432 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
1433 *
1434 * @param rc iprt status code.
1435 * @param msg printf argument list (in parenthesis).
1436 * @param rcRet What is to be presented to return.
1437 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1438 */
1439#define AssertMsgRCReturn(rc, msg, rcRet) \
1440 do { AssertMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet); NOREF(rc); } while (0)
1441
1442/** @def AssertMsgRCReturnVoid
1443 * Asserts a iprt status code successful and if it's not return.
1444 *
1445 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
1446 *
1447 * @param rc iprt status code.
1448 * @param msg printf argument list (in parenthesis).
1449 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1450 */
1451#define AssertMsgRCReturnVoid(rc, msg) \
1452 do { AssertMsgReturnVoid(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
1453
1454/** @def AssertMsgRCBreakStmt
1455 * Asserts a iprt status code successful and break if it's not.
1456 *
1457 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
1458 *
1459 * @param rc iprt status code.
1460 * @param msg printf argument list (in parenthesis).
1461 * @param stmt Statement to execute before break in case of a failed assertion.
1462 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1463 */
1464#define AssertMsgRCBreakStmt(rc, msg, stmt) \
1465 if (1) { AssertMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } else do {} while (0)
1466
1467/** @def AssertMsgRCBreakVoid
1468 * Asserts a iprt status code successful and if it's not break.
1469 *
1470 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it breaks
1471 *
1472 * @param rc iprt status code.
1473 * @param msg printf argument list (in parenthesis).
1474 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1475 * @todo Rename to AssertMsgRCBreak.
1476 */
1477#define AssertMsgRCBreakVoid(rc, msg) \
1478 if (1) { AssertMsgBreak(RT_SUCCESS(rc), msg); NOREF(rc); } else do {} while (0)
1479
1480/** @def AssertRCSuccess
1481 * Asserts an iprt status code equals VINF_SUCCESS.
1482 *
1483 * On failure it will print info about the rc and hit a breakpoint.
1484 *
1485 * @param rc iprt status code.
1486 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1487 */
1488#define AssertRCSuccess(rc) AssertMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1489
1490/** @def AssertRCSuccessReturn
1491 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
1492 *
1493 * @param rc iprt status code.
1494 * @param rcRet What is to be presented to return.
1495 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1496 */
1497#define AssertRCSuccessReturn(rc, rcRet) AssertMsgReturn((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), rcRet)
1498
1499/** @def AssertRCSuccessReturnVoid
1500 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
1501 *
1502 * @param rc iprt status code.
1503 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1504 */
1505#define AssertRCSuccessReturnVoid(rc) AssertMsgReturnVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1506
1507/** @def AssertRCSuccessBreakStmt
1508 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
1509 *
1510 * @param rc iprt status code.
1511 * @param stmt Statement to execute before break in case of a failed assertion.
1512 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1513 */
1514#define AssertRCSuccessBreakStmt(rc, stmt) AssertMsgBreakStmt((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
1515
1516/** @def AssertRCSuccessBreakVoid
1517 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
1518 *
1519 * @param rc iprt status code.
1520 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1521 * @todo Rename to AssertRCSuccessBreak.
1522 */
1523#define AssertRCSuccessBreakVoid(rc) AssertMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1524
1525
1526/** @def AssertLogRelRC
1527 * Asserts a iprt status code successful.
1528 *
1529 * @param rc iprt status code.
1530 * @remark rc is references multiple times.
1531 */
1532#define AssertLogRelRC(rc) AssertLogRelMsgRC(rc, ("%Rra\n", (rc)))
1533
1534/** @def AssertLogRelRCReturn
1535 * Asserts a iprt status code successful, returning \a rc if it isn't.
1536 *
1537 * @param rc iprt status code.
1538 * @param rcRet What is to be presented to return.
1539 * @remark rc is references multiple times.
1540 */
1541#define AssertLogRelRCReturn(rc, rcRet) AssertLogRelMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
1542
1543/** @def AssertLogRelRCReturnVoid
1544 * Asserts a iprt status code successful, returning (void) if it isn't.
1545 *
1546 * @param rc iprt status code.
1547 * @remark rc is references multiple times.
1548 */
1549#define AssertLogRelRCReturnVoid(rc) AssertLogRelMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
1550
1551/** @def AssertLogRelRCBreak
1552 * Asserts a iprt status code successful, breaking if it isn't.
1553 *
1554 * @param rc iprt status code.
1555 * @remark rc is references multiple times.
1556 */
1557#define AssertLogRelRCBreak(rc) AssertLogRelMsgRCBreak(rc, ("%Rra\n", (rc)))
1558
1559/** @def AssertLogRelRCBreakStmt
1560 * Asserts a iprt status code successful, execute \a statement and break if it isn't.
1561 *
1562 * @param rc iprt status code.
1563 * @param stmt Statement to execute before break in case of a failed assertion.
1564 * @remark rc is references multiple times.
1565 */
1566#define AssertLogRelRCBreakStmt(rc, stmt) AssertLogRelMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
1567
1568/** @def AssertLogRelMsgRC
1569 * Asserts a iprt status code successful.
1570 *
1571 * @param rc iprt status code.
1572 * @param msg printf argument list (in parenthesis).
1573 * @remark rc is references multiple times.
1574 */
1575#define AssertLogRelMsgRC(rc, msg) AssertLogRelMsg(RT_SUCCESS_NP(rc), msg)
1576
1577/** @def AssertLogRelMsgRCReturn
1578 * Asserts a iprt status code successful.
1579 *
1580 * @param rc iprt status code.
1581 * @param msg printf argument list (in parenthesis).
1582 * @param rcRet What is to be presented to return.
1583 * @remark rc is references multiple times.
1584 */
1585#define AssertLogRelMsgRCReturn(rc, msg, rcRet) AssertLogRelMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
1586
1587/** @def AssertLogRelMsgRCReturnVoid
1588 * Asserts a iprt status code successful.
1589 *
1590 * @param rc iprt status code.
1591 * @param msg printf argument list (in parenthesis).
1592 * @remark rc is references multiple times.
1593 */
1594#define AssertLogRelMsgRCReturnVoid(rc, msg) AssertLogRelMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
1595
1596/** @def AssertLogRelMsgRCBreak
1597 * Asserts a iprt status code successful.
1598 *
1599 * @param rc iprt status code.
1600 * @param msg printf argument list (in parenthesis).
1601 * @remark rc is references multiple times.
1602 */
1603#define AssertLogRelMsgRCBreak(rc, msg) AssertLogRelMsgBreak(RT_SUCCESS(rc), msg)
1604
1605/** @def AssertLogRelMsgRCBreakStmt
1606 * Asserts a iprt status code successful, execute \a stmt and break if it isn't.
1607 *
1608 * @param rc iprt status code.
1609 * @param msg printf argument list (in parenthesis).
1610 * @param stmt Statement to execute before break in case of a failed assertion.
1611 * @remark rc is references multiple times.
1612 */
1613#define AssertLogRelMsgRCBreakStmt(rc, msg, stmt) AssertLogRelMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
1614
1615/** @def AssertLogRelRCSuccess
1616 * Asserts that an iprt status code equals VINF_SUCCESS.
1617 *
1618 * @param rc iprt status code.
1619 * @remark rc is references multiple times.
1620 */
1621#define AssertLogRelRCSuccess(rc) AssertLogRelMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1622
1623/** @def AssertLogRelRCSuccessReturn
1624 * Asserts that an iprt status code equals VINF_SUCCESS.
1625 *
1626 * @param rc iprt status code.
1627 * @param rcRet What is to be presented to return.
1628 * @remark rc is references multiple times.
1629 */
1630#define AssertLogRelRCSuccessReturn(rc, rcRet) AssertLogRelMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
1631
1632/** @def AssertLogRelRCSuccessReturnVoid
1633 * Asserts that an iprt status code equals VINF_SUCCESS.
1634 *
1635 * @param rc iprt status code.
1636 * @remark rc is references multiple times.
1637 */
1638#define AssertLogRelRCSuccessReturnVoid(rc) AssertLogRelMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
1639
1640/** @def AssertLogRelRCSuccessBreak
1641 * Asserts that an iprt status code equals VINF_SUCCESS.
1642 *
1643 * @param rc iprt status code.
1644 * @remark rc is references multiple times.
1645 */
1646#define AssertLogRelRCSuccessBreak(rc) AssertLogRelMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1647
1648/** @def AssertLogRelRCSuccessBreakStmt
1649 * Asserts that an iprt status code equals VINF_SUCCESS.
1650 *
1651 * @param rc iprt status code.
1652 * @param stmt Statement to execute before break in case of a failed assertion.
1653 * @remark rc is references multiple times.
1654 */
1655#define AssertLogRelRCSuccessBreakStmt(rc, stmt) AssertLogRelMsgBreakStmt((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
1656
1657
1658/** @def AssertReleaseRC
1659 * Asserts a iprt status code successful.
1660 *
1661 * On failure information about the error will be printed and a breakpoint hit.
1662 *
1663 * @param rc iprt status code.
1664 * @remark rc is references multiple times.
1665 */
1666#define AssertReleaseRC(rc) AssertReleaseMsgRC(rc, ("%Vra\n", (rc)))
1667
1668/** @def AssertReleaseRCReturn
1669 * Asserts a iprt status code successful, returning if it isn't.
1670 *
1671 * On failure information about the error will be printed, a breakpoint hit
1672 * and finally returning from the function if the breakpoint is somehow ignored.
1673 *
1674 * @param rc iprt status code.
1675 * @param rcRet What is to be presented to return.
1676 * @remark rc is references multiple times.
1677 */
1678#define AssertReleaseRCReturn(rc, rcRet) AssertReleaseMsgRCReturn(rc, ("%Vra\n", (rc)), rcRet)
1679
1680/** @def AssertReleaseRCReturnVoid
1681 * Asserts a iprt status code successful, returning if it isn't.
1682 *
1683 * On failure information about the error will be printed, a breakpoint hit
1684 * and finally returning from the function if the breakpoint is somehow ignored.
1685 *
1686 * @param rc iprt status code.
1687 * @remark rc is references multiple times.
1688 */
1689#define AssertReleaseRCReturnVoid(rc) AssertReleaseMsgRCReturnVoid(rc, ("%Vra\n", (rc)))
1690
1691/** @def AssertReleaseRCBreakStmt
1692 * Asserts a iprt status code successful, break if it isn't.
1693 *
1694 * On failure information about the error will be printed, a breakpoint hit
1695 * and finally the break statement will be issued if the breakpoint is somehow ignored.
1696 *
1697 * @param rc iprt status code.
1698 * @param stmt Statement to execute before break in case of a failed assertion.
1699 * @remark rc is references multiple times.
1700 */
1701#define AssertReleaseRCBreakStmt(rc, stmt) AssertReleaseMsgRCBreakStmt(rc, ("%Vra\n", (rc)), stmt)
1702
1703/** @def AssertReleaseRCBreakVoid
1704 * Asserts a iprt status code successful, breaking if it isn't.
1705 *
1706 * On failure information about the error will be printed, a breakpoint hit
1707 * and finally breaking the current statement if the breakpoint is somehow ignored.
1708 *
1709 * @param rc iprt status code.
1710 * @remark rc is references multiple times.
1711 * @todo Rename to AssertReleaseRCBreak.
1712 */
1713#define AssertReleaseRCBreakVoid(rc) AssertReleaseMsgRCBreakVoid(rc, ("%Vra\n", (rc)))
1714
1715/** @def AssertReleaseMsgRC
1716 * Asserts a iprt status code successful.
1717 *
1718 * On failure a custom message is printed and a breakpoint is hit.
1719 *
1720 * @param rc iprt status code.
1721 * @param msg printf argument list (in parenthesis).
1722 * @remark rc is references multiple times.
1723 */
1724#define AssertReleaseMsgRC(rc, msg) AssertReleaseMsg(RT_SUCCESS_NP(rc), msg)
1725
1726/** @def AssertReleaseMsgRCReturn
1727 * Asserts a iprt status code successful.
1728 *
1729 * On failure a custom message is printed, a breakpoint is hit, and finally
1730 * returning from the function if the breakpoint is showhow ignored.
1731 *
1732 * @param rc iprt status code.
1733 * @param msg printf argument list (in parenthesis).
1734 * @param rcRet What is to be presented to return.
1735 * @remark rc is references multiple times.
1736 */
1737#define AssertReleaseMsgRCReturn(rc, msg, rcRet) AssertReleaseMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
1738
1739/** @def AssertReleaseMsgRCReturnVoid
1740 * Asserts a iprt status code successful.
1741 *
1742 * On failure a custom message is printed, a breakpoint is hit, and finally
1743 * returning from the function if the breakpoint is showhow ignored.
1744 *
1745 * @param rc iprt status code.
1746 * @param msg printf argument list (in parenthesis).
1747 * @remark rc is references multiple times.
1748 */
1749#define AssertReleaseMsgRCReturnVoid(rc, msg) AssertReleaseMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
1750
1751/** @def AssertReleaseMsgRCBreakStmt
1752 * Asserts a iprt status code successful.
1753 *
1754 * On failure a custom message is printed, a breakpoint is hit, and finally
1755 * the brean statement is issued if the breakpoint is showhow ignored.
1756 *
1757 * @param rc iprt status code.
1758 * @param msg printf argument list (in parenthesis).
1759 * @param stmt Statement to execute before break in case of a failed assertion.
1760 * @remark rc is references multiple times.
1761 */
1762#define AssertReleaseMsgRCBreakStmt(rc, msg, stmt) AssertReleaseMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
1763
1764/** @def AssertReleaseMsgRCBreakVoid
1765 * Asserts a iprt status code successful.
1766 *
1767 * On failure a custom message is printed, a breakpoint is hit, and finally
1768 * breaking the current status if the breakpoint is showhow ignored.
1769 *
1770 * @param rc iprt status code.
1771 * @param msg printf argument list (in parenthesis).
1772 * @remark rc is references multiple times.
1773 * @todo Rename to AssertReleaseMsgRCBreak.
1774 */
1775#define AssertReleaseMsgRCBreakVoid(rc, msg) AssertReleaseMsgBreak(RT_SUCCESS(rc), msg)
1776
1777/** @def AssertReleaseRCSuccess
1778 * Asserts that an iprt status code equals VINF_SUCCESS.
1779 *
1780 * On failure information about the error will be printed and a breakpoint hit.
1781 *
1782 * @param rc iprt status code.
1783 * @remark rc is references multiple times.
1784 */
1785#define AssertReleaseRCSuccess(rc) AssertReleaseMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1786
1787/** @def AssertReleaseRCSuccessReturn
1788 * Asserts that an iprt status code equals VINF_SUCCESS.
1789 *
1790 * On failure information about the error will be printed, a breakpoint hit
1791 * and finally returning from the function if the breakpoint is somehow ignored.
1792 *
1793 * @param rc iprt status code.
1794 * @param rcRet What is to be presented to return.
1795 * @remark rc is references multiple times.
1796 */
1797#define AssertReleaseRCSuccessReturn(rc, rcRet) AssertReleaseMsgReturn((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), rcRet)
1798
1799/** @def AssertReleaseRCSuccessReturnVoid
1800 * Asserts that an iprt status code equals VINF_SUCCESS.
1801 *
1802 * On failure information about the error will be printed, a breakpoint hit
1803 * and finally returning from the function if the breakpoint is somehow ignored.
1804 *
1805 * @param rc iprt status code.
1806 * @remark rc is references multiple times.
1807 */
1808#define AssertReleaseRCSuccessReturnVoid(rc) AssertReleaseMsgReturnVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1809
1810/** @def AssertReleaseRCSuccessBreakStmt
1811 * Asserts that an iprt status code equals VINF_SUCCESS.
1812 *
1813 * On failure information about the error will be printed, a breakpoint hit
1814 * and finally the break statement will be issued if the breakpoint is somehow ignored.
1815 *
1816 * @param rc iprt status code.
1817 * @param stmt Statement to execute before break in case of a failed assertion.
1818 * @remark rc is references multiple times.
1819 */
1820#define AssertReleaseRCSuccessBreakStmt(rc, stmt) AssertReleaseMsgBreakStmt((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
1821
1822/** @def AssertReleaseRCSuccessBreakVoid
1823 * Asserts that an iprt status code equals VINF_SUCCESS.
1824 *
1825 * On failure information about the error will be printed, a breakpoint hit
1826 * and finally breaking the current statement if the breakpoint is somehow ignored.
1827 *
1828 * @param rc iprt status code.
1829 * @remark rc is references multiple times.
1830 * @todo Rename to AssertReleaseRCSuccessBreak.
1831 */
1832#define AssertReleaseRCSuccessBreakVoid(rc) AssertReleaseMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1833
1834
1835/** @def AssertFatalRC
1836 * Asserts a iprt status code successful.
1837 *
1838 * On failure information about the error will be printed and a breakpoint hit.
1839 *
1840 * @param rc iprt status code.
1841 * @remark rc is references multiple times.
1842 */
1843#define AssertFatalRC(rc) AssertFatalMsgRC(rc, ("%Vra\n", (rc)))
1844
1845/** @def AssertReleaseMsgRC
1846 * Asserts a iprt status code successful.
1847 *
1848 * On failure a custom message is printed and a breakpoint is hit.
1849 *
1850 * @param rc iprt status code.
1851 * @param msg printf argument list (in parenthesis).
1852 * @remark rc is references multiple times.
1853 */
1854#define AssertFatalMsgRC(rc, msg) AssertFatalMsg(RT_SUCCESS_NP(rc), msg)
1855
1856/** @def AssertFatalRCSuccess
1857 * Asserts that an iprt status code equals VINF_SUCCESS.
1858 *
1859 * On failure information about the error will be printed and a breakpoint hit.
1860 *
1861 * @param rc iprt status code.
1862 * @remark rc is references multiple times.
1863 */
1864#define AssertFatalRCSuccess(rc) AssertFatalMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1865
1866
1867/** @def AssertPtr
1868 * Asserts that a pointer is valid.
1869 *
1870 * @param pv The pointer.
1871 */
1872#define AssertPtr(pv) AssertMsg(VALID_PTR(pv), ("%p\n", (pv)))
1873
1874/** @def AssertPtrReturn
1875 * Asserts that a pointer is valid.
1876 *
1877 * @param pv The pointer.
1878 * @param rcRet What is to be presented to return.
1879 */
1880#define AssertPtrReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv), ("%p\n", (pv)), rcRet)
1881
1882/** @def AssertPtrReturnVoid
1883 * Asserts that a pointer is valid.
1884 *
1885 * @param pv The pointer.
1886 */
1887#define AssertPtrReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv), ("%p\n", (pv)))
1888
1889/** @def AssertPtrBreakStmt
1890 * Asserts that a pointer is valid.
1891 *
1892 * @param pv The pointer.
1893 * @param stmt Statement to execute before break in case of a failed assertion.
1894 */
1895#define AssertPtrBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv), ("%p\n", (pv)), stmt)
1896
1897/** @def AssertPtrBreakVoid
1898 * Asserts that a pointer is valid.
1899 *
1900 * @param pv The pointer.
1901 * @todo Rename to AssertPtrBreak.
1902 */
1903#define AssertPtrBreakVoid(pv) AssertMsgBreak(VALID_PTR(pv), ("%p\n", (pv)))
1904
1905/** @def AssertPtrNull
1906 * Asserts that a pointer is valid or NULL.
1907 *
1908 * @param pv The pointer.
1909 */
1910#define AssertPtrNull(pv) AssertMsg(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
1911
1912/** @def AssertPtrNullReturn
1913 * Asserts that a pointer is valid or NULL.
1914 *
1915 * @param pv The pointer.
1916 * @param rcRet What is to be presented to return.
1917 */
1918#define AssertPtrNullReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), rcRet)
1919
1920/** @def AssertPtrNullReturnVoid
1921 * Asserts that a pointer is valid or NULL.
1922 *
1923 * @param pv The pointer.
1924 */
1925#define AssertPtrNullReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
1926
1927/** @def AssertPtrNullBreakStmt
1928 * Asserts that a pointer is valid or NULL.
1929 *
1930 * @param pv The pointer.
1931 * @param stmt Statement to execute before break in case of a failed assertion.
1932 */
1933#define AssertPtrNullBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt)
1934
1935/** @def AssertPtrNullBreakVoid
1936 * Asserts that a pointer is valid or NULL.
1937 *
1938 * @param pv The pointer.
1939 * @todo Rename to AssertPtrNullBreak.
1940 */
1941#define AssertPtrNullBreakVoid(pv) AssertMsgBreak(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
1942
1943/** @def AssertGCPhys32
1944 * Asserts that the high dword of a physical address is zero
1945 *
1946 * @param GCPhys The address (RTGCPHYS).
1947 */
1948#define AssertGCPhys32(GCPhys) AssertMsg(VALID_PHYS32(GCPhys), ("%RGp\n", (RTGCPHYS)(GCPhys)))
1949
1950
1951/** @} */
1952
1953#endif
1954
Note: See TracBrowser for help on using the repository browser.

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