VirtualBox

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

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

Merged dmik/s2 branch (r25959:26751) to the trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 44.1 KB
Line 
1/** @file
2 * innotek Portable Runtime - Assertions.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
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
26#ifndef ___iprt_assert_h
27#define ___iprt_assert_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31
32/** @defgroup grp_rt_assert Assert - Assertions
33 * @ingroup grp_rt
34 * @{
35 */
36
37
38/** @def AssertBreakpoint()
39 * Assertion Breakpoint.
40 *
41 * @remark In the gnu world we add a nop instruction after the int3 to
42 * force gdb to remain at the int3 source line.
43 * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
44 */
45#ifdef RT_STRICT
46# ifdef __GNUC__
47# ifndef __L4ENV__
48# define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __asm__ __volatile__ ("int3\n\tnop"); } } while (0)
49# else
50# define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __asm__ __volatile__ ("int3; jmp 1f; 1:"); } } while (0)
51# endif
52# elif defined(_MSC_VER)
53# define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __debugbreak(); } } while (0)
54# else
55# error "Unknown compiler"
56# endif
57#else
58# define AssertBreakpoint() do { } while (0)
59#endif
60
61/**
62 * RTASSERTTYPE is the type the AssertCompile() macro redefines.
63 * It has no other function and shouldn't be used.
64 * Visual C++ uses this.
65 */
66typedef int RTASSERTTYPE[1];
67
68/**
69 * RTASSERTVAR is the type the AssertCompile() macro redefines.
70 * It has no other function and shouldn't be used.
71 * GCC uses this.
72 */
73#ifdef __GNUC__
74__BEGIN_DECLS
75#endif
76extern int RTASSERTVAR[1];
77#ifdef __GNUC__
78__END_DECLS
79#endif
80
81/** @def AssertCompile
82 * Asserts that a compile-time expression is true. If it's not break the build.
83 * @param expr Expression which should be true.
84 */
85#ifdef __GNUC__
86# define AssertCompile(expr) extern int RTASSERTVAR[1] __attribute__((unused)), RTASSERTVAR[(expr) ? 1 : 0] __attribute__((unused))
87#else
88# define AssertCompile(expr) typedef int RTASSERTTYPE[(expr) ? 1 : 0]
89#endif
90
91/** @def AssertCompileSize
92 * Asserts a size at compile.
93 * @param type The type.
94 * @param size The expected type size.
95 */
96#define AssertCompileSize(type, size) \
97 AssertCompile(sizeof(type) == (size))
98
99/** @def AssertCompileSizeAlignment
100 * Asserts a size alignment at compile.
101 * @param type The type.
102 * @param align The size alignment to assert.
103 */
104#define AssertCompileSizeAlignment(type, align) \
105 AssertCompile(!(sizeof(type) & ((align) - 1)))
106
107/** @def AssertCompileMemberAlignment
108 * Asserts a member offset alignment at compile.
109 * @param type The type.
110 * @param member The member.
111 * @param align The member offset alignment to assert.
112 */
113#if defined(__GNUC__) && defined(__cplusplus)
114# if __GNUC__ >= 4
115# define AssertCompileMemberAlignment(type, member, align) \
116 AssertCompile(!(__builtin_offsetof(type, member) & ((align) - 1)))
117# else
118# define AssertCompileMemberAlignment(type, member, align) \
119 AssertCompile(!(RT_OFFSETOF(type, member) & ((align) - 1)))
120# endif
121#else
122# define AssertCompileMemberAlignment(type, member, align) \
123 AssertCompile(!(RT_OFFSETOF(type, member) & ((align) - 1)))
124#endif
125
126
127/** @def AssertCompileMemberSize
128 * Asserts a member offset alignment at compile.
129 * @param type The type.
130 * @param member The member.
131 * @param size The member size to assert.
132 */
133#define AssertCompileMemberSize(type, member, size) \
134 AssertCompile(RT_SIZEOFMEMB(type, member) == (size))
135
136/** @def AssertCompileMemberSizeAlignment
137 * Asserts a member size alignment at compile.
138 * @param type The type.
139 * @param member The member.
140 * @param align The member size alignment to assert.
141 */
142#define AssertCompileMemberSizeAlignment(type, member, align) \
143 AssertCompile(!(RT_SIZEOFMEMB(type, member) & ((align) - 1)))
144
145
146/** @def Assert
147 * Assert that an expression is true. If it's not hit breakpoint.
148 * @param expr Expression which should be true.
149 */
150#ifdef RT_STRICT
151# define Assert(expr) \
152 do { \
153 if (RT_UNLIKELY(!(expr))) \
154 { \
155 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
156 AssertBreakpoint(); \
157 } \
158 } while (0)
159#else
160# define Assert(expr) do { } while (0)
161#endif
162
163
164/** @def AssertReturn
165 * Assert that an expression is true and returns if it isn't.
166 * In RT_STRICT mode it will hit a breakpoint before returning.
167 *
168 * @param expr Expression which should be true.
169 * @param rc What is to be presented to return.
170 */
171#ifdef RT_STRICT
172# define AssertReturn(expr, rc) \
173 do { \
174 if (RT_UNLIKELY(!(expr))) \
175 { \
176 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
177 AssertBreakpoint(); \
178 return (rc); \
179 } \
180 } while (0)
181#else
182# define AssertReturn(expr, rc) \
183 do { \
184 if (RT_UNLIKELY(!(expr))) \
185 return (rc); \
186 } while (0)
187#endif
188
189/** @def AssertReturnVoid
190 * Assert that an expression is true and returns if it isn't.
191 * In RT_STRICT mode it will hit a breakpoint before returning.
192 *
193 * @param expr Expression which should be true.
194 */
195#ifdef RT_STRICT
196# define AssertReturnVoid(expr) \
197 do { \
198 if (RT_UNLIKELY(!(expr))) \
199 { \
200 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
201 AssertBreakpoint(); \
202 return; \
203 } \
204 } while (0)
205#else
206# define AssertReturnVoid(expr) \
207 do { \
208 if (RT_UNLIKELY(!(expr))) \
209 return; \
210 } while (0)
211#endif
212
213
214/** @def AssertBreak
215 * Assert that an expression is true and breaks if it isn't.
216 * In RT_STRICT mode it will hit a breakpoint before doing break.
217 *
218 * @param expr Expression which should be true.
219 * @param stmt Statement to execute before break in case of a failed assertion.
220 */
221#ifdef RT_STRICT
222# define AssertBreak(expr, stmt) \
223 if (RT_UNLIKELY(!(expr))) { \
224 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
225 AssertBreakpoint(); \
226 stmt; \
227 break; \
228 } else do {} while (0)
229#else
230# define AssertBreak(expr, stmt) \
231 if (RT_UNLIKELY(!(expr))) { \
232 stmt; \
233 break; \
234 } else do {} while (0)
235#endif
236
237/** @def AssertBreakVoid
238 * Assert that an expression is true and breaks if it isn't.
239 * In RT_STRICT mode it will hit a breakpoint before returning.
240 *
241 * @param expr Expression which should be true.
242 */
243#ifdef RT_STRICT
244# define AssertBreakVoid(expr) \
245 do { \
246 if (RT_UNLIKELY(!(expr))) \
247 { \
248 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
249 AssertBreakpoint(); \
250 break; \
251 } \
252 } while (0)
253#else
254# define AssertBreakVoid(expr) \
255 do { \
256 if (RT_UNLIKELY(!(expr))) \
257 break; \
258 } while (0)
259#endif
260
261
262/** @def AssertMsg
263 * Assert that an expression is true. If it's not print message and hit breakpoint.
264 * @param expr Expression which should be true.
265 * @param a printf argument list (in parenthesis).
266 */
267#ifdef RT_STRICT
268# define AssertMsg(expr, a) \
269 do { \
270 if (RT_UNLIKELY(!(expr))) \
271 { \
272 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
273 AssertMsg2 a; \
274 AssertBreakpoint(); \
275 } \
276 } while (0)
277#else
278# define AssertMsg(expr, a) do { } while (0)
279#endif
280
281/** @def AssertMsgReturn
282 * Assert that an expression is true and returns if it isn't.
283 * In RT_STRICT mode it will hit a breakpoint before returning.
284 *
285 * @param expr Expression which should be true.
286 * @param a printf argument list (in parenthesis).
287 * @param rc What is to be presented to return.
288 */
289#ifdef RT_STRICT
290# define AssertMsgReturn(expr, a, rc) \
291 do { \
292 if (RT_UNLIKELY(!(expr))) \
293 { \
294 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
295 AssertMsg2 a; \
296 AssertBreakpoint(); \
297 return (rc); \
298 } \
299 } while (0)
300#else
301# define AssertMsgReturn(expr, a, rc) \
302 do { \
303 if (RT_UNLIKELY(!(expr))) \
304 return (rc); \
305 } while (0)
306#endif
307
308/** @def AssertMsgReturnVoid
309 * Assert that an expression is true and returns if it isn't.
310 * In RT_STRICT mode it will hit a breakpoint before returning.
311 *
312 * @param expr Expression which should be true.
313 * @param a printf argument list (in parenthesis).
314 */
315#ifdef RT_STRICT
316# define AssertMsgReturnVoid(expr, a) \
317 do { \
318 if (RT_UNLIKELY(!(expr))) \
319 { \
320 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
321 AssertMsg2 a; \
322 AssertBreakpoint(); \
323 return; \
324 } \
325 } while (0)
326#else
327# define AssertMsgReturnVoid(expr, a) \
328 do { \
329 if (RT_UNLIKELY(!(expr))) \
330 return; \
331 } while (0)
332#endif
333
334
335/** @def AssertMsgBreak
336 * Assert that an expression is true and breaks if it isn't.
337 * In RT_STRICT mode it will hit a breakpoint before doing break.
338 *
339 * @param expr Expression which should be true.
340 * @param a printf argument list (in parenthesis).
341 * @param stmt Statement to execute before break in case of a failed assertion.
342 */
343#ifdef RT_STRICT
344# define AssertMsgBreak(expr, a, stmt) \
345 if (RT_UNLIKELY(!(expr))) { \
346 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
347 AssertMsg2 a; \
348 AssertBreakpoint(); \
349 stmt; \
350 break; \
351 } else do {} while (0)
352#else
353# define AssertMsgBreak(expr, a, stmt) \
354 if (RT_UNLIKELY(!(expr))) { \
355 stmt; \
356 break; \
357 } else do {} while (0)
358#endif
359
360/** @def AssertMsgBreakVoid
361 * Assert that an expression is true and breaks 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 */
367#ifdef RT_STRICT
368# define AssertMsgBreakVoid(expr, a) \
369 do { \
370 if (RT_UNLIKELY(!(expr))) \
371 { \
372 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
373 AssertMsg2 a; \
374 AssertBreakpoint(); \
375 break; \
376 } \
377 } while (0)
378#else
379# define AssertMsgBreakVoid(expr, a) \
380 do { \
381 if (RT_UNLIKELY(!(expr))) \
382 break; \
383 } while (0)
384#endif
385
386
387/** @def AssertFailed
388 * An assertion failed hit breakpoint.
389 */
390#ifdef RT_STRICT
391# define AssertFailed() \
392 do { \
393 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
394 AssertBreakpoint(); \
395 } while (0)
396#else
397# define AssertFailed() do { } while (0)
398#endif
399
400/** @def AssertFailedReturn
401 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
402 *
403 * @param rc The rc to return.
404 */
405#ifdef RT_STRICT
406# define AssertFailedReturn(rc) \
407 do { \
408 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
409 AssertBreakpoint(); \
410 return (rc); \
411 } while (0)
412#else
413# define AssertFailedReturn(rc) \
414 do { \
415 return (rc); \
416 } while (0)
417#endif
418
419/** @def AssertFailedReturnVoid
420 * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
421 */
422#ifdef RT_STRICT
423# define AssertFailedReturnVoid() \
424 do { \
425 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
426 AssertBreakpoint(); \
427 return; \
428 } while (0)
429#else
430# define AssertFailedReturnVoid() \
431 do { \
432 return; \
433 } while (0)
434#endif
435
436
437/** @def AssertFailedBreak
438 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
439 * the given statement and break.
440 *
441 * @param stmt Statement to execute before break.
442 */
443#ifdef RT_STRICT
444# define AssertFailedBreak(stmt) \
445 if (1) { \
446 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
447 AssertBreakpoint(); \
448 stmt; \
449 break; \
450 } else do {} while (0)
451#else
452# define AssertFailedBreak(stmt) \
453 if (1) { \
454 stmt; \
455 break; \
456 } else do {} while (0)
457#endif
458
459/** @def AssertFailedBreakVoid
460 * An assertion failed, hit breakpoint (RT_STRICT mode only) and break.
461 */
462#ifdef RT_STRICT
463# define AssertFailedBreakVoid() \
464 do { \
465 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
466 AssertBreakpoint(); \
467 break; \
468 } while (0)
469#else
470# define AssertFailedBreakVoid() \
471 do { \
472 break; \
473 } while (0)
474#endif
475
476
477/** @def AssertMsgFailed
478 * An assertion failed print a message and a hit breakpoint.
479 *
480 * @param a printf argument list (in parenthesis).
481 */
482#ifdef RT_STRICT
483# define AssertMsgFailed(a) \
484 do { \
485 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
486 AssertMsg2 a; \
487 AssertBreakpoint(); \
488 } while (0)
489#else
490# define AssertMsgFailed(a) do { } while (0)
491#endif
492
493/** @def AssertMsgFailedReturn
494 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
495 *
496 * @param a printf argument list (in parenthesis).
497 * @param rc What is to be presented to return.
498 */
499#ifdef RT_STRICT
500# define AssertMsgFailedReturn(a, rc) \
501 do { \
502 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
503 AssertMsg2 a; \
504 AssertBreakpoint(); \
505 return (rc); \
506 } while (0)
507#else
508# define AssertMsgFailedReturn(a, rc) \
509 do { \
510 return (rc); \
511 } while (0)
512#endif
513
514/** @def AssertMsgFailedReturnVoid
515 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
516 *
517 * @param a printf argument list (in parenthesis).
518 */
519#ifdef RT_STRICT
520# define AssertMsgFailedReturnVoid(a) \
521 do { \
522 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
523 AssertMsg2 a; \
524 AssertBreakpoint(); \
525 return; \
526 } while (0)
527#else
528# define AssertMsgFailedReturnVoid(a) \
529 do { \
530 return; \
531 } while (0)
532#endif
533
534
535/** @def AssertMsgFailedBreak
536 * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
537 * the given statement and break.
538 *
539 * @param a printf argument list (in parenthesis).
540 * @param stmt Statement to execute before break.
541 */
542#ifdef RT_STRICT
543# define AssertMsgFailedBreak(a, stmt) \
544 if (1) { \
545 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
546 AssertMsg2 a; \
547 AssertBreakpoint(); \
548 stmt; \
549 break; \
550 } else do {} while (0)
551#else
552# define AssertMsgFailedBreak(a, stmt) \
553 if (1) { \
554 stmt; \
555 break; \
556 } else do {} while (0)
557#endif
558
559/** @def AssertMsgFailedBreakVoid
560 * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and break.
561 *
562 * @param a printf argument list (in parenthesis).
563 */
564#ifdef RT_STRICT
565# define AssertMsgFailedBreakVoid(a) \
566 do { \
567 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
568 AssertMsg2 a; \
569 AssertBreakpoint(); \
570 break; \
571 } while (0)
572#else
573# define AssertMsgFailedBreakVoid(a) \
574 do { \
575 break; \
576 } while (0)
577#endif
578
579
580/** @def AssertReleaseBreakpoint()
581 * Assertion Breakpoint.
582 *
583 * @remark In the gnu world we add a nop instruction after the int3 to
584 * force gdb to remain at the int3 source line.
585 * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
586 */
587#ifdef __GNUC__
588# ifndef __L4ENV__
589# define AssertReleaseBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3\n\tnop"); } while (0)
590# else
591# define AssertReleaseBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3; jmp 1f; 1:"); } while (0)
592# endif
593#elif defined(_MSC_VER)
594# define AssertReleaseBreakpoint() do { RTAssertDoBreakpoint(); __debugbreak(); } while (0)
595#else
596# error "Unknown compiler"
597#endif
598
599
600/** @def AssertRelease
601 * Assert that an expression is true. If it's not hit a breakpoint.
602 *
603 * @param expr Expression which should be true.
604 */
605#define AssertRelease(expr) \
606 do { \
607 if (RT_UNLIKELY(!(expr))) \
608 { \
609 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
610 AssertReleaseBreakpoint(); \
611 } \
612 } while (0)
613
614/** @def AssertReleaseReturn
615 * Assert that an expression is true, hit a breakpoing and return if it isn't.
616 *
617 * @param expr Expression which should be true.
618 * @param rc What is to be presented to return.
619 */
620#define AssertReleaseReturn(expr, rc) \
621 do { \
622 if (RT_UNLIKELY(!(expr))) \
623 { \
624 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
625 AssertReleaseBreakpoint(); \
626 return (rc); \
627 } \
628 } while (0)
629
630/** @def AssertReleaseReturnVoid
631 * Assert that an expression is true, hit a breakpoing and return if it isn't.
632 *
633 * @param expr Expression which should be true.
634 */
635#define AssertReleaseReturnVoid(expr) \
636 do { \
637 if (RT_UNLIKELY(!(expr))) \
638 { \
639 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
640 AssertReleaseBreakpoint(); \
641 return; \
642 } \
643 } while (0)
644
645
646/** @def AssertReleaseBreak
647 * Assert that an expression is true, hit a breakpoing and break if it isn't.
648 *
649 * @param expr Expression which should be true.
650 * @param stmt Statement to execute before break in case of a failed assertion.
651 */
652#define AssertReleaseBreak(expr, stmt) \
653 do { \
654 if (RT_UNLIKELY(!(expr))) \
655 { \
656 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
657 AssertReleaseBreakpoint(); \
658 stmt; \
659 break; \
660 } \
661 } while (0)
662
663/** @def AssertReleaseBreakVoid
664 * Assert that an expression is true, hit a breakpoing and break if it isn't.
665 *
666 * @param expr Expression which should be true.
667 */
668#define AssertReleaseBreakVoid(expr) \
669 do { \
670 if (RT_UNLIKELY(!(expr))) \
671 { \
672 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
673 AssertReleaseBreakpoint(); \
674 break; \
675 } \
676 } while (0)
677
678
679/** @def AssertReleaseMsg
680 * Assert that an expression is true, print the message and hit a breakpoint if it isn't.
681 *
682 * @param expr Expression which should be true.
683 * @param a printf argument list (in parenthesis).
684 */
685#define AssertReleaseMsg(expr, a) \
686 do { \
687 if (RT_UNLIKELY(!(expr))) \
688 { \
689 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
690 AssertMsg2 a; \
691 AssertReleaseBreakpoint(); \
692 } \
693 } while (0)
694
695/** @def AssertReleaseMsgReturn
696 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
697 *
698 * @param expr Expression which should be true.
699 * @param a printf argument list (in parenthesis).
700 * @param rc What is to be presented to return.
701 */
702#define AssertReleaseMsgReturn(expr, a, rc) \
703 do { \
704 if (RT_UNLIKELY(!(expr))) \
705 { \
706 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
707 AssertMsg2 a; \
708 AssertReleaseBreakpoint(); \
709 return (rc); \
710 } \
711 } while (0)
712
713/** @def AssertReleaseMsgReturnVoid
714 * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
715 *
716 * @param expr Expression which should be true.
717 * @param a printf argument list (in parenthesis).
718 */
719#define AssertReleaseMsgReturnVoid(expr, a) \
720 do { \
721 if (RT_UNLIKELY(!(expr))) \
722 { \
723 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
724 AssertMsg2 a; \
725 AssertReleaseBreakpoint(); \
726 return; \
727 } \
728 } while (0)
729
730
731/** @def AssertReleaseMsgBreak
732 * Assert that an expression is true, print the message and hit a breakpoing and break if it isn't.
733 *
734 * @param expr Expression which should be true.
735 * @param a printf argument list (in parenthesis).
736 * @param stmt Statement to execute before break in case of a failed assertion.
737 */
738#define AssertReleaseMsgBreak(expr, a, stmt) \
739 if (RT_UNLIKELY(!(expr))) { \
740 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
741 AssertMsg2 a; \
742 AssertReleaseBreakpoint(); \
743 stmt; \
744 break; \
745 } else do {} while (0)
746
747/** @def AssertReleaseMsgBreakVoid
748 * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
749 *
750 * @param expr Expression which should be true.
751 * @param a printf argument list (in parenthesis).
752 */
753#define AssertReleaseMsgBreakVoid(expr, a) \
754 do { \
755 if (RT_UNLIKELY(!(expr))) \
756 { \
757 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
758 AssertMsg2 a; \
759 AssertReleaseBreakpoint(); \
760 break; \
761 } \
762 } while (0)
763
764
765/** @def AssertReleaseFailed
766 * An assertion failed, hit a breakpoint.
767 */
768#define AssertReleaseFailed() \
769 do { \
770 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
771 AssertReleaseBreakpoint(); \
772 } while (0)
773
774/** @def AssertReleaseFailedReturn
775 * An assertion failed, hit a breakpoint and return.
776 *
777 * @param rc What is to be presented to return.
778 */
779#define AssertReleaseFailedReturn(rc) \
780 do { \
781 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
782 AssertReleaseBreakpoint(); \
783 return (rc); \
784 } while (0)
785
786/** @def AssertReleaseFailedReturnVoid
787 * An assertion failed, hit a breakpoint and return.
788 */
789#define AssertReleaseFailedReturnVoid() \
790 do { \
791 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
792 AssertReleaseBreakpoint(); \
793 return; \
794 } while (0)
795
796
797/** @def AssertReleaseFailedBreak
798 * An assertion failed, hit a breakpoint and break.
799 *
800 * @param stmt Statement to execute before break.
801 */
802#define AssertReleaseFailedBreak(stmt) \
803 if (1) { \
804 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
805 AssertReleaseBreakpoint(); \
806 stmt; \
807 break; \
808 } else do {} while (0)
809
810/** @def AssertReleaseFailedBreakVoid
811 * An assertion failed, hit a breakpoint and break.
812 */
813#define AssertReleaseFailedBreakVoid() \
814 do { \
815 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
816 AssertReleaseBreakpoint(); \
817 break; \
818 } while (0)
819
820
821/** @def AssertReleaseMsgFailed
822 * An assertion failed, print a message and hit a breakpoint.
823 *
824 * @param a printf argument list (in parenthesis).
825 */
826#define AssertReleaseMsgFailed(a) \
827 do { \
828 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
829 AssertMsg2 a; \
830 AssertReleaseBreakpoint(); \
831 } while (0)
832
833/** @def AssertReleaseMsgFailedReturn
834 * An assertion failed, print a message, hit a breakpoint and return.
835 *
836 * @param a printf argument list (in parenthesis).
837 * @param rc What is to be presented to return.
838 */
839#define AssertReleaseMsgFailedReturn(a, rc) \
840 do { \
841 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
842 AssertMsg2 a; \
843 AssertReleaseBreakpoint(); \
844 return (rc); \
845 } while (0)
846
847/** @def AssertReleaseMsgFailedReturnVoid
848 * An assertion failed, print a message, hit a breakpoint and return.
849 *
850 * @param a printf argument list (in parenthesis).
851 */
852#define AssertReleaseMsgFailedReturnVoid(a) \
853 do { \
854 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
855 AssertMsg2 a; \
856 AssertReleaseBreakpoint(); \
857 return; \
858 } while (0)
859
860
861/** @def AssertReleaseMsgFailedBreak
862 * An assertion failed, print a message, hit a breakpoint and break.
863 *
864 * @param a printf argument list (in parenthesis).
865 * @param stmt Statement to execute before break.
866 */
867#define AssertReleaseMsgFailedBreak(a, stmt) \
868 if (1) { \
869 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
870 AssertMsg2 a; \
871 AssertReleaseBreakpoint(); \
872 stmt; \
873 break; \
874 } else do {} while (0)
875
876/** @def AssertReleaseMsgFailedBreakVoid
877 * An assertion failed, print a message, hit a breakpoint and break.
878 *
879 * @param a printf argument list (in parenthesis).
880 */
881#define AssertReleaseMsgFailedBreakVoid(a) \
882 do { \
883 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
884 AssertMsg2 a; \
885 AssertReleaseBreakpoint(); \
886 break; \
887 } while (0)
888
889
890/** @def AssertFatal
891 * Assert that an expression is true. If it's not hit a breakpoint (for ever).
892 *
893 * @param expr Expression which should be true.
894 */
895#define AssertFatal(expr) \
896 do { \
897 if (RT_UNLIKELY(!(expr))) \
898 for (;;) \
899 { \
900 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
901 AssertReleaseBreakpoint(); \
902 } \
903 } while (0)
904
905/** @def AssertFatalMsg
906 * Assert that an expression is true, print the message and hit a breakpoint (for ever) if it isn't.
907 *
908 * @param expr Expression which should be true.
909 * @param a printf argument list (in parenthesis).
910 */
911#define AssertFatalMsg(expr, a) \
912 do { \
913 if (RT_UNLIKELY(!(expr))) \
914 for (;;) \
915 { \
916 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
917 AssertMsg2 a; \
918 AssertReleaseBreakpoint(); \
919 } \
920 } while (0)
921
922/** @def AssertFatalFailed
923 * An assertion failed, hit a breakpoint (for ever).
924 */
925#define AssertFatalFailed() \
926 do { \
927 for (;;) \
928 { \
929 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
930 AssertReleaseBreakpoint(); \
931 } \
932 } while (0)
933
934/** @def AssertFatalMsgFailed
935 * An assertion failed, print a message and hit a breakpoint (for ever).
936 *
937 * @param a printf argument list (in parenthesis).
938 */
939#define AssertFatalMsgFailed(a) \
940 do { \
941 for (;;) \
942 { \
943 AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
944 AssertMsg2 a; \
945 AssertReleaseBreakpoint(); \
946 } \
947 } while (0)
948
949
950/** @def AssertRC
951 * Asserts a iprt status code successful.
952 *
953 * On failure it will print info about the rc and hit a breakpoint.
954 *
955 * @param rc iprt status code.
956 * @remark rc is references multiple times. In release mode is NOREF()'ed.
957 */
958#define AssertRC(rc) AssertMsgRC(rc, ("%Vra\n", (rc)))
959
960/** @def AssertRCReturn
961 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
962 *
963 * @param rc iprt status code.
964 * @param rcRet What is to be presented to return.
965 * @remark rc is references multiple times. In release mode is NOREF()'ed.
966 */
967#define AssertRCReturn(rc, rcRet) AssertMsgRCReturn(rc, ("%Vra\n", (rc)), rcRet)
968
969/** @def AssertRCReturnVoid
970 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
971 *
972 * @param rc iprt status code.
973 * @remark rc is references multiple times. In release mode is NOREF()'ed.
974 */
975#define AssertRCReturnVoid(rc) AssertMsgRCReturnVoid(rc, ("%Vra\n", (rc)))
976
977/** @def AssertRCBreak
978 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
979 *
980 * @param rc iprt status code.
981 * @param stmt Statement to execute before break in case of a failed assertion.
982 * @remark rc is references multiple times. In release mode is NOREF()'ed.
983 */
984#define AssertRCBreak(rc, stmt) AssertMsgRCBreak(rc, ("%Vra\n", (rc)), stmt)
985
986/** @def AssertRCBreakVoid
987 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
988 *
989 * @param rc iprt status code.
990 * @remark rc is references multiple times. In release mode is NOREF()'ed.
991 */
992#define AssertRCBreakVoid(rc) AssertMsgRCBreakVoid(rc, ("%Vra\n", (rc)))
993
994/** @def AssertMsgRC
995 * Asserts a iprt status code successful.
996 *
997 * It prints a custom message and hits a breakpoint on FAILURE.
998 *
999 * @param rc iprt status code.
1000 * @param msg printf argument list (in parenthesis).
1001 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1002 */
1003#define AssertMsgRC(rc, msg) \
1004 do { AssertMsg(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
1005
1006/** @def AssertMsgRCReturn
1007 * Asserts a iprt status code successful and if it's not return the specified status code.
1008 *
1009 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
1010 *
1011 * @param rc iprt status code.
1012 * @param msg printf argument list (in parenthesis).
1013 * @param rcRet What is to be presented to return.
1014 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1015 */
1016#define AssertMsgRCReturn(rc, msg, rcRet) \
1017 do { AssertMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet); NOREF(rc); } while (0)
1018
1019/** @def AssertMsgRCReturnVoid
1020 * Asserts a iprt status code successful and if it's not return.
1021 *
1022 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
1023 *
1024 * @param rc iprt status code.
1025 * @param msg printf argument list (in parenthesis).
1026 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1027 */
1028#define AssertMsgRCReturnVoid(rc, msg) \
1029 do { AssertMsgReturnVoid(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
1030
1031/** @def AssertMsgRCBreak
1032 * Asserts a iprt status code successful and break if it's not.
1033 *
1034 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
1035 *
1036 * @param rc iprt status code.
1037 * @param msg printf argument list (in parenthesis).
1038 * @param stmt Statement to execute before break in case of a failed assertion.
1039 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1040 */
1041#define AssertMsgRCBreak(rc, msg, stmt) \
1042 do { AssertMsgBreak(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
1043
1044/** @def AssertMsgRCBreakVoid
1045 * Asserts a iprt status code successful and if it's not break.
1046 *
1047 * If RT_STRICT is defined the message will be printed and a breakpoint hit before it breaks
1048 *
1049 * @param rc iprt status code.
1050 * @param msg printf argument list (in parenthesis).
1051 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1052 */
1053#define AssertMsgRCBreakVoid(rc, msg) \
1054 do { AssertMsgBreakVoid(RT_SUCCESS(rc), msg); NOREF(rc); } while (0)
1055
1056/** @def AssertRCSuccess
1057 * Asserts an iprt status code equals VINF_SUCCESS.
1058 *
1059 * On failure it will print info about the rc and hit a breakpoint.
1060 *
1061 * @param rc iprt status code.
1062 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1063 */
1064#define AssertRCSuccess(rc) AssertMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1065
1066/** @def AssertRCSuccessReturn
1067 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
1068 *
1069 * @param rc iprt status code.
1070 * @param rcRet What is to be presented to return.
1071 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1072 */
1073#define AssertRCSuccessReturn(rc, rcRet) AssertMsgReturn((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), rcRet)
1074
1075/** @def AssertRCSuccessReturnVoid
1076 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
1077 *
1078 * @param rc iprt status code.
1079 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1080 */
1081#define AssertRCSuccessReturnVoid(rc) AssertMsgReturnVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1082
1083/** @def AssertRCSuccessBreak
1084 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
1085 *
1086 * @param rc iprt status code.
1087 * @param stmt Statement to execute before break in case of a failed assertion.
1088 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1089 */
1090#define AssertRCSuccessBreak(rc, stmt) AssertMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
1091
1092/** @def AssertRCSuccessBreakVoid
1093 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
1094 *
1095 * @param rc iprt status code.
1096 * @remark rc is references multiple times. In release mode is NOREF()'ed.
1097 */
1098#define AssertRCSuccessBreakVoid(rc) AssertMsgBreakVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1099
1100
1101/** @def AssertReleaseRC
1102 * Asserts a iprt status code successful.
1103 *
1104 * On failure information about the error will be printed and a breakpoint hit.
1105 *
1106 * @param rc iprt status code.
1107 * @remark rc is references multiple times.
1108 */
1109#define AssertReleaseRC(rc) AssertReleaseMsgRC(rc, ("%Vra\n", (rc)))
1110
1111/** @def AssertReleaseRCReturn
1112 * Asserts a iprt status code successful, returning if it isn't.
1113 *
1114 * On failure information about the error will be printed, a breakpoint hit
1115 * and finally returning from the function if the breakpoint is somehow ignored.
1116 *
1117 * @param rc iprt status code.
1118 * @param rcRet What is to be presented to return.
1119 * @remark rc is references multiple times.
1120 */
1121#define AssertReleaseRCReturn(rc, rcRet) AssertReleaseMsgRCReturn(rc, ("%Vra\n", (rc)), rcRet)
1122
1123/** @def AssertReleaseRCReturnVoid
1124 * Asserts a iprt status code successful, returning if it isn't.
1125 *
1126 * On failure information about the error will be printed, a breakpoint hit
1127 * and finally returning from the function if the breakpoint is somehow ignored.
1128 *
1129 * @param rc iprt status code.
1130 * @remark rc is references multiple times.
1131 */
1132#define AssertReleaseRCReturnVoid(rc) AssertReleaseMsgRCReturnVoid(rc, ("%Vra\n", (rc)))
1133
1134/** @def AssertReleaseRCBreak
1135 * Asserts a iprt status code successful, break if it isn't.
1136 *
1137 * On failure information about the error will be printed, a breakpoint hit
1138 * and finally the break statement will be issued if the breakpoint is somehow ignored.
1139 *
1140 * @param rc iprt status code.
1141 * @param stmt Statement to execute before break in case of a failed assertion.
1142 * @remark rc is references multiple times.
1143 */
1144#define AssertReleaseRCBreak(rc, stmt) AssertReleaseMsgRCBreak(rc, ("%Vra\n", (rc)), stmt)
1145
1146/** @def AssertReleaseRCBreakVoid
1147 * Asserts a iprt status code successful, breaking if it isn't.
1148 *
1149 * On failure information about the error will be printed, a breakpoint hit
1150 * and finally breaking the current statement if the breakpoint is somehow ignored.
1151 *
1152 * @param rc iprt status code.
1153 * @remark rc is references multiple times.
1154 */
1155#define AssertReleaseRCBreakVoid(rc) AssertReleaseMsgRCBreakVoid(rc, ("%Vra\n", (rc)))
1156
1157/** @def AssertReleaseMsgRC
1158 * Asserts a iprt status code successful.
1159 *
1160 * On failure a custom message is printed and a breakpoint is hit.
1161 *
1162 * @param rc iprt status code.
1163 * @param msg printf argument list (in parenthesis).
1164 * @remark rc is references multiple times.
1165 */
1166#define AssertReleaseMsgRC(rc, msg) AssertReleaseMsg(RT_SUCCESS_NP(rc), msg)
1167
1168/** @def AssertReleaseMsgRCReturn
1169 * Asserts a iprt status code successful.
1170 *
1171 * On failure a custom message is printed, a breakpoint is hit, and finally
1172 * returning from the function if the breakpoint is showhow ignored.
1173 *
1174 * @param rc iprt status code.
1175 * @param msg printf argument list (in parenthesis).
1176 * @param rcRet What is to be presented to return.
1177 * @remark rc is references multiple times.
1178 */
1179#define AssertReleaseMsgRCReturn(rc, msg, rcRet) AssertReleaseMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
1180
1181/** @def AssertReleaseMsgRCReturnVoid
1182 * Asserts a iprt status code successful.
1183 *
1184 * On failure a custom message is printed, a breakpoint is hit, and finally
1185 * returning from the function if the breakpoint is showhow ignored.
1186 *
1187 * @param rc iprt status code.
1188 * @param msg printf argument list (in parenthesis).
1189 * @remark rc is references multiple times.
1190 */
1191#define AssertReleaseMsgRCReturnVoid(rc, msg) AssertReleaseMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
1192
1193/** @def AssertReleaseMsgRCBreak
1194 * Asserts a iprt status code successful.
1195 *
1196 * On failure a custom message is printed, a breakpoint is hit, and finally
1197 * the brean statement is issued if the breakpoint is showhow ignored.
1198 *
1199 * @param rc iprt status code.
1200 * @param msg printf argument list (in parenthesis).
1201 * @param stmt Statement to execute before break in case of a failed assertion.
1202 * @remark rc is references multiple times.
1203 */
1204#define AssertReleaseMsgRCBreak(rc, msg, stmt) AssertReleaseMsgBreak(RT_SUCCESS_NP(rc), msg, stmt)
1205
1206/** @def AssertReleaseMsgRCBreakVoid
1207 * Asserts a iprt status code successful.
1208 *
1209 * On failure a custom message is printed, a breakpoint is hit, and finally
1210 * breaking the current status if the breakpoint is showhow ignored.
1211 *
1212 * @param rc iprt status code.
1213 * @param msg printf argument list (in parenthesis).
1214 * @remark rc is references multiple times.
1215 */
1216#define AssertReleaseMsgRCBreakVoid(rc, msg) AssertReleaseMsgBreakVoid(RT_SUCCESS(rc), msg)
1217
1218/** @def AssertReleaseRCSuccess
1219 * Asserts that an iprt status code equals VINF_SUCCESS.
1220 *
1221 * On failure information about the error will be printed and a breakpoint hit.
1222 *
1223 * @param rc iprt status code.
1224 * @remark rc is references multiple times.
1225 */
1226#define AssertReleaseRCSuccess(rc) AssertReleaseMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1227
1228/** @def AssertReleaseRCSuccessReturn
1229 * Asserts that an iprt status code equals VINF_SUCCESS.
1230 *
1231 * On failure information about the error will be printed, a breakpoint hit
1232 * and finally returning from the function if the breakpoint is somehow ignored.
1233 *
1234 * @param rc iprt status code.
1235 * @param rcRet What is to be presented to return.
1236 * @remark rc is references multiple times.
1237 */
1238#define AssertReleaseRCSuccessReturn(rc, rcRet) AssertReleaseMsgReturn((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), rcRet)
1239
1240/** @def AssertReleaseRCSuccessReturnVoid
1241 * Asserts that an iprt status code equals VINF_SUCCESS.
1242 *
1243 * On failure information about the error will be printed, a breakpoint hit
1244 * and finally returning from the function if the breakpoint is somehow ignored.
1245 *
1246 * @param rc iprt status code.
1247 * @remark rc is references multiple times.
1248 */
1249#define AssertReleaseRCSuccessReturnVoid(rc) AssertReleaseMsgReturnVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1250
1251/** @def AssertReleaseRCSuccessBreak
1252 * Asserts that an iprt status code equals VINF_SUCCESS.
1253 *
1254 * On failure information about the error will be printed, a breakpoint hit
1255 * and finally the break statement will be issued if the breakpoint is somehow ignored.
1256 *
1257 * @param rc iprt status code.
1258 * @param stmt Statement to execute before break in case of a failed assertion.
1259 * @remark rc is references multiple times.
1260 */
1261#define AssertReleaseRCSuccessBreak(rc, stmt) AssertReleaseMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
1262
1263/** @def AssertReleaseRCSuccessBreakVoid
1264 * Asserts that an iprt status code equals VINF_SUCCESS.
1265 *
1266 * On failure information about the error will be printed, a breakpoint hit
1267 * and finally breaking the current statement if the breakpoint is somehow ignored.
1268 *
1269 * @param rc iprt status code.
1270 * @remark rc is references multiple times.
1271 */
1272#define AssertReleaseRCSuccessBreakVoid(rc) AssertReleaseMsgBreakVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1273
1274
1275/** @def AssertFatalRC
1276 * Asserts a iprt status code successful.
1277 *
1278 * On failure information about the error will be printed and a breakpoint hit.
1279 *
1280 * @param rc iprt status code.
1281 * @remark rc is references multiple times.
1282 */
1283#define AssertFatalRC(rc) AssertFatalMsgRC(rc, ("%Vra\n", (rc)))
1284
1285/** @def AssertReleaseMsgRC
1286 * Asserts a iprt status code successful.
1287 *
1288 * On failure a custom message is printed and a breakpoint is hit.
1289 *
1290 * @param rc iprt status code.
1291 * @param msg printf argument list (in parenthesis).
1292 * @remark rc is references multiple times.
1293 */
1294#define AssertFatalMsgRC(rc, msg) AssertFatalMsg(RT_SUCCESS_NP(rc), msg)
1295
1296/** @def AssertFatalRCSuccess
1297 * Asserts that an iprt status code equals VINF_SUCCESS.
1298 *
1299 * On failure information about the error will be printed and a breakpoint hit.
1300 *
1301 * @param rc iprt status code.
1302 * @remark rc is references multiple times.
1303 */
1304#define AssertFatalRCSuccess(rc) AssertFatalMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
1305
1306
1307/** @def AssertPtr
1308 * Asserts that a pointer is valid.
1309 *
1310 * @param pv The pointer.
1311 */
1312#define AssertPtr(pv) AssertMsg(VALID_PTR(pv), ("%p\n", (pv)))
1313
1314/** @def AssertPtrReturn
1315 * Asserts that a pointer is valid.
1316 *
1317 * @param pv The pointer.
1318 * @param rcRet What is to be presented to return.
1319 */
1320#define AssertPtrReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv), ("%p\n", (pv)), rcRet)
1321
1322/** @def AssertPtrReturnVoid
1323 * Asserts that a pointer is valid.
1324 *
1325 * @param pv The pointer.
1326 */
1327#define AssertPtrReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv), ("%p\n", (pv)))
1328
1329/** @def AssertPtrBreak
1330 * Asserts that a pointer is valid.
1331 *
1332 * @param pv The pointer.
1333 * @param stmt Statement to execute before break in case of a failed assertion.
1334 */
1335#define AssertPtrBreak(pv, stmt) AssertMsgBreak(VALID_PTR(pv), ("%p\n", (pv)), stmt)
1336
1337/** @def AssertPtrBreakVoid
1338 * Asserts that a pointer is valid.
1339 *
1340 * @param pv The pointer.
1341 */
1342#define AssertPtrBreakVoid(pv) AssertMsgBreakVoid(VALID_PTR(pv), ("%p\n", (pv)))
1343
1344/** @def AssertPtrNull
1345 * Asserts that a pointer is valid or NULL.
1346 *
1347 * @param pv The pointer.
1348 */
1349#define AssertPtrNull(pv) AssertMsg(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
1350
1351/** @def AssertPtrNullReturn
1352 * Asserts that a pointer is valid or NULL.
1353 *
1354 * @param pv The pointer.
1355 * @param rcRet What is to be presented to return.
1356 */
1357#define AssertPtrNullReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), rcRet)
1358
1359/** @def AssertPtrNullReturnVoid
1360 * Asserts that a pointer is valid or NULL.
1361 *
1362 * @param pv The pointer.
1363 */
1364#define AssertPtrNullReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
1365
1366/** @def AssertPtrNullBreak
1367 * Asserts that a pointer is valid or NULL.
1368 *
1369 * @param pv The pointer.
1370 * @param stmt Statement to execute before break in case of a failed assertion.
1371 */
1372#define AssertPtrNullBreak(pv, stmt) AssertMsgBreak(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt)
1373
1374/** @def AssertPtrNullBreakVoid
1375 * Asserts that a pointer is valid or NULL.
1376 *
1377 * @param pv The pointer.
1378 */
1379#define AssertPtrNullBreakVoid(pv) AssertMsgBreakVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
1380
1381
1382__BEGIN_DECLS
1383
1384/**
1385 * The 1st part of an assert message.
1386 *
1387 * @param pszExpr Expression. Can be NULL.
1388 * @param uLine Location line number.
1389 * @param pszFile Location file name.
1390 * @param pszFunction Location function name.
1391 * @remark This API exists in HC Ring-3 and GC.
1392 */
1393RTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction);
1394
1395/**
1396 * The 2nd (optional) part of an assert message.
1397 * @param pszFormat Printf like format string.
1398 * @param ... Arguments to that string.
1399 * @remark This API exists in HC Ring-3 and GC.
1400 */
1401RTDECL(void) AssertMsg2(const char *pszFormat, ...);
1402
1403/**
1404 * Overridable function that decides whether assertions executes the breakpoint or not.
1405 *
1406 * The generic implementation will return true.
1407 *
1408 * @returns true if the breakpoint should be hit, false if it should be ignored.
1409 * @remark The RTDECL() makes this a bit difficult to override on windows. Sorry.
1410 */
1411RTDECL(bool) RTAssertDoBreakpoint(void);
1412
1413/** The last assert message, 1st part. */
1414extern RTDATADECL(char) g_szRTAssertMsg1[1024];
1415/** The last assert message, 2nd part. */
1416extern RTDATADECL(char) g_szRTAssertMsg2[2048];
1417
1418__END_DECLS
1419
1420/** @} */
1421
1422#endif
1423
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