Changeset 6814 in vbox
- Timestamp:
- Feb 5, 2008 8:57:58 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/assert.h
r6076 r6814 32 32 /** @defgroup grp_rt_assert Assert - Assertions 33 33 * @ingroup grp_rt 34 * 35 * WARNING! Each project has its own specific guidelines on how to use 36 * assertions, so the following is just the general idea from the IPRT 37 * point of view. 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 * 34 72 * @{ 35 73 */ … … 240 278 * 241 279 * @param expr Expression which should be true. 280 * @todo Rename to AssertBreak. 281 * @todo broken, use if. 242 282 */ 243 283 #ifdef RT_STRICT … … 340 380 * @param a printf argument list (in parenthesis). 341 381 * @param stmt Statement to execute before break in case of a failed assertion. 382 * @todo Rename to AssertMsgBreakStmt. 342 383 */ 343 384 #ifdef RT_STRICT … … 364 405 * @param expr Expression which should be true. 365 406 * @param a printf argument list (in parenthesis). 407 * @todo Rename to AssertMsgBreak. 408 * @todo broken, use if. 366 409 */ 367 410 #ifdef RT_STRICT … … 440 483 * 441 484 * @param stmt Statement to execute before break. 485 * @todo Rename to AssertFailedBreakStmt. 442 486 */ 443 487 #ifdef RT_STRICT … … 459 503 /** @def AssertFailedBreakVoid 460 504 * An assertion failed, hit breakpoint (RT_STRICT mode only) and break. 505 * @todo Rename to AssertFailedBreak. 461 506 */ 462 507 #ifdef RT_STRICT … … 539 584 * @param a printf argument list (in parenthesis). 540 585 * @param stmt Statement to execute before break. 586 * @todo Rename to AssertMsgFailedBreakStmt. 541 587 */ 542 588 #ifdef RT_STRICT … … 561 607 * 562 608 * @param a printf argument list (in parenthesis). 609 * @todo Rename to AssertMsgFailedBreak. 610 * @todo broken 563 611 */ 564 612 #ifdef RT_STRICT … … 576 624 } while (0) 577 625 #endif 626 627 628 629 /** @def AssertLogRelBreakpoint() 630 * Assertion LogRel Breakpoint. 631 * 632 * NOP in non-strict (release) builds, hardware breakpoint in strict builds, 633 * 634 * @remark In the gnu world we add a nop instruction after the int3 to 635 * force gdb to remain at the int3 source line. 636 * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp. 637 */ 638 #ifdef RT_STRICT 639 # ifdef __GNUC__ 640 # ifndef __L4ENV__ 641 # define AssertLogRelBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3\n\tnop"); } while (0) 642 # else 643 # define AssertLogRelBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3; jmp 1f; 1:"); } while (0) 644 # endif 645 # elif defined(_MSC_VER) 646 # define AssertLogRelBreakpoint() do { RTAssertDoBreakpoint(); __debugbreak(); } while (0) 647 # else 648 # error "Unknown compiler" 649 # endif 650 #else /* !RT_STRICT */ 651 # define AssertLogRelBreakpoint() do { } while (0) 652 #endif /* !RT_STRICT */ 653 654 655 /** @def AssertLogRelMsg1 656 * AssertMsg1 (strict builds) / LogRel wrapper (non-strict). 657 */ 658 #ifdef RT_STRICT 659 # define AssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \ 660 AssertMsg1(pszExpr, iLine, pszFile, pszFunction) 661 #else 662 # define AssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \ 663 LogRel(("AssertLogRel %s(%d): %s\n",\ 664 (pszFile), (iLine), (pszFile), (pszFunction), (pszExpr) )) 665 #endif 666 667 /** @def AssertLogRelMsg2 668 * AssertMsg2 (strict builds) / LogRel wrapper (non-strict). 669 */ 670 #ifdef RT_STRICT 671 # define AssertLogRelMsg2(a) AssertMsg2 a 672 #else 673 # define AssertLogRelMsg2(a) LogRel(a) 674 #endif 675 676 /** @def AssertLogRel 677 * Assert that an expression is true. 678 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 679 * 680 * @param expr Expression which should be true. 681 */ 682 #define AssertLogRel(expr) \ 683 do { \ 684 if (RT_UNLIKELY(!(expr))) \ 685 { \ 686 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 687 AssertLogRelBreakpoint(); \ 688 } \ 689 } while (0) 690 691 /** @def AssertLogRelReturn 692 * Assert that an expression is true, return \a rc if it isn't. 693 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 694 * 695 * @param expr Expression which should be true. 696 * @param rc What is to be presented to return. 697 */ 698 #define AssertLogRelReturn(expr, rc) \ 699 do { \ 700 if (RT_UNLIKELY(!(expr))) \ 701 { \ 702 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 703 AssertLogRelBreakpoint(); \ 704 return (rc); \ 705 } \ 706 } while (0) 707 708 /** @def AssertLogRelReturnVoid 709 * Assert that an expression is true, return void if it isn't. 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 AssertLogRelReturnVoid(expr) \ 715 do { \ 716 if (RT_UNLIKELY(!(expr))) \ 717 { \ 718 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 719 AssertLogRelBreakpoint(); \ 720 return; \ 721 } \ 722 } while (0) 723 724 /** @def AssertLogRelBreak 725 * Assert that an expression is true, break if it isn't. 726 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 727 * 728 * @param expr Expression which should be true. 729 */ 730 #define AssertLogRelBreak(expr) \ 731 if (RT_UNLIKELY(!(expr))) \ 732 { \ 733 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 734 AssertLogRelBreakpoint(); \ 735 break; \ 736 } \ 737 else do {} while (0) 738 739 /** @def AssertLogRelBreakStmt 740 * Assert that an expression is true, execute \a stmt and break if it isn't. 741 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 742 * 743 * @param expr Expression which should be true. 744 * @param stmt Statement to execute before break in case of a failed assertion. 745 */ 746 #define AssertLogRelBreakStmt(expr, stmt) \ 747 if (RT_UNLIKELY(!(expr))) \ 748 { \ 749 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 750 AssertLogRelBreakpoint(); \ 751 stmt; \ 752 break; \ 753 } else do {} while (0) 754 755 /** @def AssertLogRelMsg 756 * Assert that an expression is true. 757 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 758 * 759 * @param expr Expression which should be true. 760 * @param a printf argument list (in parenthesis). 761 */ 762 #define AssertLogRelMsg(expr, a) \ 763 do { \ 764 if (RT_UNLIKELY(!(expr))) \ 765 { \ 766 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 767 AssertLogRelMsg2(a); \ 768 AssertLogRelBreakpoint(); \ 769 } \ 770 } while (0) 771 772 /** @def AssertLogRelMsgReturn 773 * Assert that an expression is true, return \a rc if it isn't. 774 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 775 * 776 * @param expr Expression which should be true. 777 * @param a printf argument list (in parenthesis). 778 * @param rc What is to be presented to return. 779 */ 780 #define AssertLogRelMsgReturn(expr, a, rc) \ 781 do { \ 782 if (RT_UNLIKELY(!(expr))) \ 783 { \ 784 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 785 AssertLogRelMsg2(a); \ 786 AssertLogRelBreakpoint(); \ 787 return (rc); \ 788 } \ 789 } while (0) 790 791 /** @def AssertLogRelMsgReturnVoid 792 * Assert that an expression is true, return (void) if it isn't. 793 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 794 * 795 * @param expr Expression which should be true. 796 * @param a printf argument list (in parenthesis). 797 */ 798 #define AssertLogRelMsgReturnVoid(expr, a) \ 799 do { \ 800 if (RT_UNLIKELY(!(expr))) \ 801 { \ 802 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 803 AssertLogRelMsg2(a); \ 804 AssertLogRelBreakpoint(); \ 805 return; \ 806 } \ 807 } while (0) 808 809 /** @def AssertLogRelMsgBreak 810 * Assert that an expression is true, break if it isn't. 811 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 812 * 813 * @param expr Expression which should be true. 814 * @param a printf argument list (in parenthesis). 815 */ 816 #define AssertLogRelMsgBreak(expr, a) \ 817 if (RT_UNLIKELY(!(expr))) \ 818 { \ 819 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 820 AssertLogRelMsg2(a); \ 821 AssertLogRelBreakpoint(); \ 822 break; \ 823 } \ 824 else do {} while (0) 825 826 /** @def AssertLogRelMsgBreakStmt 827 * Assert that an expression is true, execute \a stmt and break if it isn't. 828 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 829 * 830 * @param expr Expression which should be true. 831 * @param a printf argument list (in parenthesis). 832 * @param stmt Statement to execute before break in case of a failed assertion. 833 */ 834 #define AssertLogRelMsgBreakStmt(expr, a, stmt) \ 835 if (RT_UNLIKELY(!(expr))) \ 836 { \ 837 AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 838 AssertLogRelMsg2(a); \ 839 AssertLogRelBreakpoint(); \ 840 stmt; \ 841 break; \ 842 } else do {} while (0) 843 844 /** @def AssertLogRelFailed 845 * An assertion failed. 846 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 847 */ 848 #define AssertLogRelFailed() \ 849 do { \ 850 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 851 AssertLogRelBreakpoint(); \ 852 } while (0) 853 854 /** @def AssertLogRelFailedReturn 855 * An assertion failed. 856 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 857 * 858 * @param rc What is to be presented to return. 859 */ 860 #define AssertLogRelFailedReturn(rc) \ 861 do { \ 862 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 863 AssertLogRelBreakpoint(); \ 864 return (rc); \ 865 } while (0) 866 867 /** @def AssertLogRelFailedReturnVoid 868 * An assertion failed, hit a breakpoint and return. 869 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 870 */ 871 #define AssertLogRelFailedReturnVoid() \ 872 do { \ 873 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 874 AssertLogRelBreakpoint(); \ 875 return; \ 876 } while (0) 877 878 /** @def AssertLogRelFailedBreak 879 * An assertion failed, break. 880 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 881 */ 882 #define AssertLogRelFailedBreak() \ 883 if (1) \ 884 { \ 885 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 886 AssertLogRelBreakpoint(); \ 887 break; \ 888 } else do {} while (0) 889 890 /** @def AssertLogRelFailedBreakStmt 891 * An assertion failed, execute \a stmt and break. 892 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 893 * 894 * @param stmt Statement to execute before break. 895 */ 896 #define AssertLogRelFailedBreakStmt(stmt) \ 897 if (1) \ 898 { \ 899 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 900 AssertLogRelBreakpoint(); \ 901 stmt; \ 902 break; \ 903 } else do {} while (0) 904 905 /** @def AssertLogRelMsgFailed 906 * An assertion failed. 907 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 908 * 909 * @param a printf argument list (in parenthesis). 910 */ 911 #define AssertLogRelMsgFailed(a) \ 912 do { \ 913 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 914 AssertLogRelMsg2(a); \ 915 AssertLogRelBreakpoint(); \ 916 } while (0) 917 918 /** @def AssertLogRelMsgFailedReturn 919 * An assertion failed, return \a rc. 920 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 921 * 922 * @param a printf argument list (in parenthesis). 923 * @param rc What is to be presented to return. 924 */ 925 #define AssertLogRelMsgFailedReturn(a, rc) \ 926 do { \ 927 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 928 AssertLogRelMsg2(a); \ 929 AssertLogRelBreakpoint(); \ 930 return (rc); \ 931 } while (0) 932 933 /** @def AssertLogRelMsgFailedReturnVoid 934 * An assertion failed, return void. 935 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 936 * 937 * @param a printf argument list (in parenthesis). 938 */ 939 #define AssertLogRelMsgFailedReturnVoid(a) \ 940 do { \ 941 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 942 AssertLogRelMsg2(a); \ 943 AssertLogRelBreakpoint(); \ 944 return; \ 945 } while (0) 946 947 /** @def AssertLogRelMsgFailedBreak 948 * An assertion failed, break. 949 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 950 * 951 * @param a printf argument list (in parenthesis). 952 */ 953 #define AssertLogRelMsgFailedBreak(a) \ 954 if (1)\ 955 { \ 956 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 957 AssertLogRelMsg2(a); \ 958 AssertLogRelBreakpoint(); \ 959 break; \ 960 } else do {} while (0) 961 962 /** @def AssertLogRelMsgFailedBreakStmt 963 * An assertion failed, execute \a stmt and break. 964 * Strict builds will hit a breakpoint, non-strict will only do LogRel. 965 * 966 * @param a printf argument list (in parenthesis). 967 * @param stmt Statement to execute before break. 968 * @todo Rename to AssertLogRelMsgFailedBreakStmt. 969 */ 970 #define AssertLogRelMsgFailedBreakStmt(a, stmt) \ 971 if (1) \ 972 { \ 973 AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 974 AssertLogRelMsg2(a); \ 975 AssertLogRelBreakpoint(); \ 976 stmt; \ 977 break; \ 978 } else do {} while (0) 979 578 980 579 981 … … 649 1051 * @param expr Expression which should be true. 650 1052 * @param stmt Statement to execute before break in case of a failed assertion. 1053 * @todo Rename to AssertReleaseBreakStmt. 651 1054 */ 652 1055 #define AssertReleaseBreak(expr, stmt) \ … … 665 1068 * 666 1069 * @param expr Expression which should be true. 1070 * @todo Rename to AssertReleaseBreak. 1071 * @todo broken 667 1072 */ 668 1073 #define AssertReleaseBreakVoid(expr) \ … … 735 1140 * @param a printf argument list (in parenthesis). 736 1141 * @param stmt Statement to execute before break in case of a failed assertion. 1142 * @todo Rename to AssertReleaseMsgBreakStmt. 737 1143 */ 738 1144 #define AssertReleaseMsgBreak(expr, a, stmt) \ … … 750 1156 * @param expr Expression which should be true. 751 1157 * @param a printf argument list (in parenthesis). 1158 * @todo Rename to AssertReleaseMsgBreak. 1159 * @todo broken 752 1160 */ 753 1161 #define AssertReleaseMsgBreakVoid(expr, a) \ … … 799 1207 * 800 1208 * @param stmt Statement to execute before break. 1209 * @todo Rename to AssertReleaseMsgFailedStmt. 801 1210 */ 802 1211 #define AssertReleaseFailedBreak(stmt) \ … … 810 1219 /** @def AssertReleaseFailedBreakVoid 811 1220 * An assertion failed, hit a breakpoint and break. 1221 * @todo Rename to AssertReleaseFailedBreak. 1222 * @todo broken, should use 'if' instead of 'do'. 812 1223 */ 813 1224 #define AssertReleaseFailedBreakVoid() \ … … 864 1275 * @param a printf argument list (in parenthesis). 865 1276 * @param stmt Statement to execute before break. 1277 * @todo Rename to AssertReleaseMsgFailedBreakStmt. 866 1278 */ 867 1279 #define AssertReleaseMsgFailedBreak(a, stmt) \ … … 878 1290 * 879 1291 * @param a printf argument list (in parenthesis). 1292 * @todo Rename to AssertReleaseMsgFailedBreak. 1293 * @todo broken 880 1294 */ 881 1295 #define AssertReleaseMsgFailedBreakVoid(a) \ … … 981 1395 * @param stmt Statement to execute before break in case of a failed assertion. 982 1396 * @remark rc is references multiple times. In release mode is NOREF()'ed. 1397 * @todo Rename to AssertRCBreakStmt. 983 1398 */ 984 1399 #define AssertRCBreak(rc, stmt) AssertMsgRCBreak(rc, ("%Vra\n", (rc)), stmt) … … 989 1404 * @param rc iprt status code. 990 1405 * @remark rc is references multiple times. In release mode is NOREF()'ed. 1406 * @todo Rename to AssertRCBreak. 991 1407 */ 992 1408 #define AssertRCBreakVoid(rc) AssertMsgRCBreakVoid(rc, ("%Vra\n", (rc))) … … 1038 1454 * @param stmt Statement to execute before break in case of a failed assertion. 1039 1455 * @remark rc is references multiple times. In release mode is NOREF()'ed. 1456 * @todo Rename to AssertMsgRCBreakStmt. 1040 1457 */ 1041 1458 #define AssertMsgRCBreak(rc, msg, stmt) \ … … 1050 1467 * @param msg printf argument list (in parenthesis). 1051 1468 * @remark rc is references multiple times. In release mode is NOREF()'ed. 1469 * @todo Rename to AssertMsgRCBreak. 1052 1470 */ 1053 1471 #define AssertMsgRCBreakVoid(rc, msg) \ … … 1087 1505 * @param stmt Statement to execute before break in case of a failed assertion. 1088 1506 * @remark rc is references multiple times. In release mode is NOREF()'ed. 1507 * @todo Rename to AssertRCSuccessBreakStmt. 1089 1508 */ 1090 1509 #define AssertRCSuccessBreak(rc, stmt) AssertMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt) … … 1095 1514 * @param rc iprt status code. 1096 1515 * @remark rc is references multiple times. In release mode is NOREF()'ed. 1516 * @todo Rename to AssertRCSuccessBreak. 1097 1517 */ 1098 1518 #define AssertRCSuccessBreakVoid(rc) AssertMsgBreakVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc))) 1519 1520 1521 /** @def AssertLogRelRC 1522 * Asserts a iprt status code successful. 1523 * 1524 * @param rc iprt status code. 1525 * @remark rc is references multiple times. 1526 */ 1527 #define AssertLogRelRC(rc) AssertLogRelMsgRC(rc, ("%Rra\n", (rc))) 1528 1529 /** @def AssertLogRelRCReturn 1530 * Asserts a iprt status code successful, returning \a rc if it isn't. 1531 * 1532 * @param rc iprt status code. 1533 * @param rcRet What is to be presented to return. 1534 * @remark rc is references multiple times. 1535 */ 1536 #define AssertLogRelRCReturn(rc, rcRet) AssertLogRelMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet) 1537 1538 /** @def AssertLogRelRCReturnVoid 1539 * Asserts a iprt status code successful, returning (void) if it isn't. 1540 * 1541 * @param rc iprt status code. 1542 * @remark rc is references multiple times. 1543 */ 1544 #define AssertLogRelRCReturnVoid(rc) AssertLogRelMsgRCReturnVoid(rc, ("%Rra\n", (rc))) 1545 1546 /** @def AssertLogRelRCBreak 1547 * Asserts a iprt status code successful, breaking if it isn't. 1548 * 1549 * @param rc iprt status code. 1550 * @remark rc is references multiple times. 1551 */ 1552 #define AssertLogRelRCBreak(rc) AssertLogRelMsgRCBreak(rc, ("%Rra\n", (rc))) 1553 1554 /** @def AssertLogRelRCBreakStmt 1555 * Asserts a iprt status code successful, execute \a statement and break if it isn't. 1556 * 1557 * @param rc iprt status code. 1558 * @param stmt Statement to execute before break in case of a failed assertion. 1559 * @remark rc is references multiple times. 1560 */ 1561 #define AssertLogRelRCBreakStmt(rc, stmt) AssertLogRelMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt) 1562 1563 /** @def AssertLogRelMsgRC 1564 * Asserts a iprt status code successful. 1565 * 1566 * @param rc iprt status code. 1567 * @param msg printf argument list (in parenthesis). 1568 * @remark rc is references multiple times. 1569 */ 1570 #define AssertLogRelMsgRC(rc, msg) AssertLogRelMsg(RT_SUCCESS_NP(rc), msg) 1571 1572 /** @def AssertLogRelMsgRCReturn 1573 * Asserts a iprt status code successful. 1574 * 1575 * @param rc iprt status code. 1576 * @param msg printf argument list (in parenthesis). 1577 * @param rcRet What is to be presented to return. 1578 * @remark rc is references multiple times. 1579 */ 1580 #define AssertLogRelMsgRCReturn(rc, msg, rcRet) AssertLogRelMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet) 1581 1582 /** @def AssertLogRelMsgRCReturnVoid 1583 * Asserts a iprt status code successful. 1584 * 1585 * @param rc iprt status code. 1586 * @param msg printf argument list (in parenthesis). 1587 * @remark rc is references multiple times. 1588 */ 1589 #define AssertLogRelMsgRCReturnVoid(rc, msg) AssertLogRelMsgReturnVoid(RT_SUCCESS_NP(rc), msg) 1590 1591 /** @def AssertLogRelMsgRCBreak 1592 * Asserts a iprt status code successful. 1593 * 1594 * @param rc iprt status code. 1595 * @param msg printf argument list (in parenthesis). 1596 * @remark rc is references multiple times. 1597 */ 1598 #define AssertLogRelMsgRCBreak(rc, msg) AssertLogRelMsgBreak(RT_SUCCESS(rc), msg) 1599 1600 /** @def AssertLogRelMsgRCBreakStmt 1601 * Asserts a iprt status code successful, execute \a stmt and break if it isn't. 1602 * 1603 * @param rc iprt status code. 1604 * @param msg printf argument list (in parenthesis). 1605 * @param stmt Statement to execute before break in case of a failed assertion. 1606 * @remark rc is references multiple times. 1607 */ 1608 #define AssertLogRelMsgRCBreakStmt(rc, msg, stmt) AssertLogRelMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt) 1609 1610 /** @def AssertLogRelRCSuccess 1611 * Asserts that an iprt status code equals VINF_SUCCESS. 1612 * 1613 * @param rc iprt status code. 1614 * @remark rc is references multiple times. 1615 */ 1616 #define AssertLogRelRCSuccess(rc) AssertLogRelMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc))) 1617 1618 /** @def AssertLogRelRCSuccessReturn 1619 * Asserts that an iprt status code equals VINF_SUCCESS. 1620 * 1621 * @param rc iprt status code. 1622 * @param rcRet What is to be presented to return. 1623 * @remark rc is references multiple times. 1624 */ 1625 #define AssertLogRelRCSuccessReturn(rc, rcRet) AssertLogRelMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet) 1626 1627 /** @def AssertLogRelRCSuccessReturnVoid 1628 * Asserts that an iprt status code equals VINF_SUCCESS. 1629 * 1630 * @param rc iprt status code. 1631 * @remark rc is references multiple times. 1632 */ 1633 #define AssertLogRelRCSuccessReturnVoid(rc) AssertLogRelMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc))) 1634 1635 /** @def AssertLogRelRCSuccessBreak 1636 * Asserts that an iprt status code equals VINF_SUCCESS. 1637 * 1638 * @param rc iprt status code. 1639 * @remark rc is references multiple times. 1640 */ 1641 #define AssertLogRelRCSuccessBreak(rc) AssertLogRelMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc))) 1642 1643 /** @def AssertLogRelRCSuccessBreakStmt 1644 * Asserts that an iprt status code equals VINF_SUCCESS. 1645 * 1646 * @param rc iprt status code. 1647 * @param stmt Statement to execute before break in case of a failed assertion. 1648 * @remark rc is references multiple times. 1649 */ 1650 #define AssertLogRelRCSuccessBreakStmt(rc, stmt) AssertLogRelMsgBreakStmt((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt) 1099 1651 1100 1652 … … 1141 1693 * @param stmt Statement to execute before break in case of a failed assertion. 1142 1694 * @remark rc is references multiple times. 1695 * @todo Rename to AssertReleaseRCBreakStmt. 1143 1696 */ 1144 1697 #define AssertReleaseRCBreak(rc, stmt) AssertReleaseMsgRCBreak(rc, ("%Vra\n", (rc)), stmt) … … 1152 1705 * @param rc iprt status code. 1153 1706 * @remark rc is references multiple times. 1707 * @todo Rename to AssertReleaseRCBreak. 1154 1708 */ 1155 1709 #define AssertReleaseRCBreakVoid(rc) AssertReleaseMsgRCBreakVoid(rc, ("%Vra\n", (rc))) … … 1201 1755 * @param stmt Statement to execute before break in case of a failed assertion. 1202 1756 * @remark rc is references multiple times. 1757 * @todo Rename to AssertReleaseMsgRCBreakStmt. 1203 1758 */ 1204 1759 #define AssertReleaseMsgRCBreak(rc, msg, stmt) AssertReleaseMsgBreak(RT_SUCCESS_NP(rc), msg, stmt) … … 1213 1768 * @param msg printf argument list (in parenthesis). 1214 1769 * @remark rc is references multiple times. 1770 * @todo Rename to AssertReleaseMsgRCBreak. 1215 1771 */ 1216 1772 #define AssertReleaseMsgRCBreakVoid(rc, msg) AssertReleaseMsgBreakVoid(RT_SUCCESS(rc), msg) … … 1258 1814 * @param stmt Statement to execute before break in case of a failed assertion. 1259 1815 * @remark rc is references multiple times. 1816 * @todo Rename to AssertReleaseRCSuccessBreakStmt. 1260 1817 */ 1261 1818 #define AssertReleaseRCSuccessBreak(rc, stmt) AssertReleaseMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt) … … 1269 1826 * @param rc iprt status code. 1270 1827 * @remark rc is references multiple times. 1828 * @todo Rename to AssertReleaseRCSuccessBreak. 1271 1829 */ 1272 1830 #define AssertReleaseRCSuccessBreakVoid(rc) AssertReleaseMsgBreakVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc))) … … 1332 1890 * @param pv The pointer. 1333 1891 * @param stmt Statement to execute before break in case of a failed assertion. 1892 * @todo Rename to AssertPtrBreakStmt. 1334 1893 */ 1335 1894 #define AssertPtrBreak(pv, stmt) AssertMsgBreak(VALID_PTR(pv), ("%p\n", (pv)), stmt) … … 1339 1898 * 1340 1899 * @param pv The pointer. 1900 * @todo Rename to AssertPtrBreak. 1341 1901 */ 1342 1902 #define AssertPtrBreakVoid(pv) AssertMsgBreakVoid(VALID_PTR(pv), ("%p\n", (pv))) … … 1369 1929 * @param pv The pointer. 1370 1930 * @param stmt Statement to execute before break in case of a failed assertion. 1931 * @todo Rename to AssertPtrNullBreakStmt. 1371 1932 */ 1372 1933 #define AssertPtrNullBreak(pv, stmt) AssertMsgBreak(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt) … … 1376 1937 * 1377 1938 * @param pv The pointer. 1939 * @todo Rename to AssertPtrNullBreak. 1378 1940 */ 1379 1941 #define AssertPtrNullBreakVoid(pv) AssertMsgBreakVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
Note:
See TracChangeset
for help on using the changeset viewer.