VirtualBox

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

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

The Big Sun Rebranding Header Change

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

© 2023 Oracle
ContactPrivacy policyTerms of Use