VirtualBox

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

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

AssertMsgBreak -> AssertMsgBreakStmt.

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