VirtualBox

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

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

Fixed a few more broken break macros: AssertBreakVoid, AssertFailedBreakVoid, AssertMsgFailedBreakVoid, AssertReleaseBreakStmt, AssertReleaseMsgBreakVoid, AssertReleaseFailedBreakVoid and AssertReleaseMsgFailedBreakVoid

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