VirtualBox

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

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

AssertBreakVoid -> AssertBreak

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

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