VirtualBox

Changeset 6814 in vbox


Ignore:
Timestamp:
Feb 5, 2008 8:57:58 PM (17 years ago)
Author:
vboxsync
Message:

Added a new family of assertions, AssertLogRel, that's intended for cases where you should use LogRel but wish for it to kick you in strict builds. Use with care!

Also added a bunch of @todos. The 'BreakVoid' stuff must be renamed 'Break', and the current 'Break' should be called 'BreakStmt'. Also, all 'BreakVoid' macros and possibly some of the 'BreakStmt' macros are broken. Both needs addressing, but some care needs to be taken wrt branches.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/assert.h

    r6076 r6814  
    3232/** @defgroup grp_rt_assert     Assert - Assertions
    3333 * @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 *
    3472 * @{
    3573 */
     
    240278 *
    241279 * @param   expr    Expression which should be true.
     280 * @todo Rename to AssertBreak.
     281 * @todo broken, use if.
    242282 */
    243283#ifdef RT_STRICT
     
    340380 * @param   a       printf argument list (in parenthesis).
    341381 * @param   stmt    Statement to execute before break in case of a failed assertion.
     382 * @todo Rename to AssertMsgBreakStmt.
    342383 */
    343384#ifdef RT_STRICT
     
    364405 * @param   expr    Expression which should be true.
    365406 * @param   a       printf argument list (in parenthesis).
     407 * @todo Rename to AssertMsgBreak.
     408 * @todo broken, use if.
    366409 */
    367410#ifdef RT_STRICT
     
    440483 *
    441484 * @param   stmt    Statement to execute before break.
     485 * @todo Rename to AssertFailedBreakStmt.
    442486 */
    443487#ifdef RT_STRICT
     
    459503/** @def AssertFailedBreakVoid
    460504 * An assertion failed, hit breakpoint (RT_STRICT mode only) and break.
     505 * @todo Rename to AssertFailedBreak.
    461506 */
    462507#ifdef RT_STRICT
     
    539584 * @param   a       printf argument list (in parenthesis).
    540585 * @param   stmt    Statement to execute before break.
     586 * @todo Rename to AssertMsgFailedBreakStmt.
    541587 */
    542588#ifdef RT_STRICT
     
    561607 *
    562608 * @param   a       printf argument list (in parenthesis).
     609 * @todo Rename to AssertMsgFailedBreak.
     610 * @todo broken
    563611 */
    564612#ifdef RT_STRICT
     
    576624    } while (0)
    577625#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
    578980
    579981
     
    6491051 * @param   expr    Expression which should be true.
    6501052 * @param   stmt    Statement to execute before break in case of a failed assertion.
     1053 * @todo Rename to AssertReleaseBreakStmt.
    6511054 */
    6521055#define AssertReleaseBreak(expr, stmt)  \
     
    6651068 *
    6661069 * @param   expr    Expression which should be true.
     1070 * @todo Rename to AssertReleaseBreak.
     1071 * @todo broken
    6671072 */
    6681073#define AssertReleaseBreakVoid(expr)  \
     
    7351140 * @param   a       printf argument list (in parenthesis).
    7361141 * @param   stmt    Statement to execute before break in case of a failed assertion.
     1142 * @todo Rename to AssertReleaseMsgBreakStmt.
    7371143 */
    7381144#define AssertReleaseMsgBreak(expr, a, stmt)  \
     
    7501156 * @param   expr    Expression which should be true.
    7511157 * @param   a       printf argument list (in parenthesis).
     1158 * @todo Rename to AssertReleaseMsgBreak.
     1159 * @todo broken
    7521160 */
    7531161#define AssertReleaseMsgBreakVoid(expr, a)  \
     
    7991207 *
    8001208 * @param   stmt    Statement to execute before break.
     1209 * @todo Rename to AssertReleaseMsgFailedStmt.
    8011210 */
    8021211#define AssertReleaseFailedBreak(stmt)  \
     
    8101219/** @def AssertReleaseFailedBreakVoid
    8111220 * An assertion failed, hit a breakpoint and break.
     1221 * @todo Rename to AssertReleaseFailedBreak.
     1222 * @todo broken, should use 'if' instead of 'do'.
    8121223 */
    8131224#define AssertReleaseFailedBreakVoid()  \
     
    8641275 * @param   a   printf argument list (in parenthesis).
    8651276 * @param   stmt    Statement to execute before break.
     1277 * @todo Rename to AssertReleaseMsgFailedBreakStmt.
    8661278 */
    8671279#define AssertReleaseMsgFailedBreak(a, stmt) \
     
    8781290 *
    8791291 * @param   a   printf argument list (in parenthesis).
     1292 * @todo Rename to AssertReleaseMsgFailedBreak.
     1293 * @todo broken
    8801294 */
    8811295#define AssertReleaseMsgFailedBreakVoid(a) \
     
    9811395 * @param   stmt    Statement to execute before break in case of a failed assertion.
    9821396 * @remark  rc is references multiple times. In release mode is NOREF()'ed.
     1397 * @todo Rename to AssertRCBreakStmt.
    9831398 */
    9841399#define AssertRCBreak(rc, stmt)   AssertMsgRCBreak(rc, ("%Vra\n", (rc)), stmt)
     
    9891404 * @param   rc      iprt status code.
    9901405 * @remark  rc is references multiple times. In release mode is NOREF()'ed.
     1406 * @todo Rename to AssertRCBreak.
    9911407 */
    9921408#define AssertRCBreakVoid(rc)   AssertMsgRCBreakVoid(rc, ("%Vra\n", (rc)))
     
    10381454 * @param   stmt    Statement to execute before break in case of a failed assertion.
    10391455 * @remark  rc is references multiple times. In release mode is NOREF()'ed.
     1456 * @todo Rename to AssertMsgRCBreakStmt.
    10401457 */
    10411458#define AssertMsgRCBreak(rc, msg, stmt) \
     
    10501467 * @param   msg     printf argument list (in parenthesis).
    10511468 * @remark  rc is references multiple times. In release mode is NOREF()'ed.
     1469 * @todo Rename to AssertMsgRCBreak.
    10521470 */
    10531471#define AssertMsgRCBreakVoid(rc, msg) \
     
    10871505 * @param   stmt    Statement to execute before break in case of a failed assertion.
    10881506 * @remark  rc is references multiple times. In release mode is NOREF()'ed.
     1507 * @todo Rename to AssertRCSuccessBreakStmt.
    10891508 */
    10901509#define AssertRCSuccessBreak(rc, stmt)    AssertMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
     
    10951514 * @param   rc      iprt status code.
    10961515 * @remark  rc is references multiple times. In release mode is NOREF()'ed.
     1516 * @todo Rename to AssertRCSuccessBreak.
    10971517 */
    10981518#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)
    10991651
    11001652
     
    11411693 * @param   stmt    Statement to execute before break in case of a failed assertion.
    11421694 * @remark  rc is references multiple times.
     1695 * @todo Rename to AssertReleaseRCBreakStmt.
    11431696 */
    11441697#define AssertReleaseRCBreak(rc, stmt) AssertReleaseMsgRCBreak(rc, ("%Vra\n", (rc)), stmt)
     
    11521705 * @param   rc      iprt status code.
    11531706 * @remark  rc is references multiple times.
     1707 * @todo Rename to AssertReleaseRCBreak.
    11541708 */
    11551709#define AssertReleaseRCBreakVoid(rc) AssertReleaseMsgRCBreakVoid(rc, ("%Vra\n", (rc)))
     
    12011755 * @param   stmt    Statement to execute before break in case of a failed assertion.
    12021756 * @remark  rc is references multiple times.
     1757 * @todo Rename to AssertReleaseMsgRCBreakStmt.
    12031758 */
    12041759#define AssertReleaseMsgRCBreak(rc, msg, stmt)    AssertReleaseMsgBreak(RT_SUCCESS_NP(rc), msg, stmt)
     
    12131768 * @param   msg     printf argument list (in parenthesis).
    12141769 * @remark  rc is references multiple times.
     1770 * @todo Rename to AssertReleaseMsgRCBreak.
    12151771 */
    12161772#define AssertReleaseMsgRCBreakVoid(rc, msg)    AssertReleaseMsgBreakVoid(RT_SUCCESS(rc), msg)
     
    12581814 * @param   stmt    Statement to execute before break in case of a failed assertion.
    12591815 * @remark  rc is references multiple times.
     1816 * @todo Rename to AssertReleaseRCSuccessBreakStmt.
    12601817 */
    12611818#define AssertReleaseRCSuccessBreak(rc, stmt)     AssertReleaseMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
     
    12691826 * @param   rc      iprt status code.
    12701827 * @remark  rc is references multiple times.
     1828 * @todo Rename to AssertReleaseRCSuccessBreak.
    12711829 */
    12721830#define AssertReleaseRCSuccessBreakVoid(rc)     AssertReleaseMsgBreakVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
     
    13321890 * @param   pv      The pointer.
    13331891 * @param   stmt    Statement to execute before break in case of a failed assertion.
     1892 * @todo Rename to AssertPtrBreakStmt.
    13341893 */
    13351894#define AssertPtrBreak(pv, stmt)  AssertMsgBreak(VALID_PTR(pv), ("%p\n", (pv)), stmt)
     
    13391898 *
    13401899 * @param   pv      The pointer.
     1900 * @todo Rename to AssertPtrBreak.
    13411901 */
    13421902#define AssertPtrBreakVoid(pv)  AssertMsgBreakVoid(VALID_PTR(pv), ("%p\n", (pv)))
     
    13691929 * @param   pv      The pointer.
    13701930 * @param   stmt    Statement to execute before break in case of a failed assertion.
     1931 * @todo Rename to AssertPtrNullBreakStmt.
    13711932 */
    13721933#define AssertPtrNullBreak(pv, stmt)  AssertMsgBreak(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt)
     
    13761937 *
    13771938 * @param   pv      The pointer.
     1939 * @todo Rename to AssertPtrNullBreak.
    13781940 */
    13791941#define AssertPtrNullBreakVoid(pv)  AssertMsgBreakVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
Note: See TracChangeset for help on using the changeset viewer.

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