VirtualBox

Changeset 13306

Show
Ignore:
Timestamp:
10/15/08 23:17:04 (3 months ago)
Author:
vboxsync
Message:

IPRT,++: some assert.h cleanup, making a suitable place to call panic() in ring-0.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Config.kmk

    r13269 r13306  
    19581958TEMPLATE_VBOXR0_ASTOOL              = $(VBOX_ASTOOL) 
    19591959TEMPLATE_VBOXR0_ASFLAGS             = $(VBOX_ASFLAGS) 
    1960 TEMPLATE_VBOXR0_DEFS                = IN_RING0 $(ARCH_BITS_DEFS) 
     1960TEMPLATE_VBOXR0_DEFS                = IN_RING0 IN_RING0_AGNOSTIC $(ARCH_BITS_DEFS) 
    19611961 
    19621962ifeq ($(VBOX_LDR_FMT),pe) 
  • trunk/include/iprt/assert.h

    r11190 r13306  
    9898RTDECL(void)    AssertMsg2(const char *pszFormat, ...); 
    9999 
     100#ifdef IN_RING0 
    100101/** 
    101  * Overridable function that decides whether assertions executes the breakpoint or not. 
     102 * Panics the system as the result of a fail assertion. 
     103 */ 
     104RTR0DECL(void)  RTR0AssertPanicSystem(void); 
     105#endif /* IN_RING0 */ 
     106 
     107/** 
     108 * Overridable function that decides whether assertions executes the panic 
     109 * (breakpoint) or not. 
    102110 * 
    103111 * The generic implementation will return true. 
    104112 * 
    105113 * @returns true if the breakpoint should be hit, false if it should be ignored. 
    106  * @remark  The RTDECL() makes this a bit difficult to override on windows. Sorry. 
    107  */ 
    108 RTDECL(bool)    RTAssertDoBreakpoint(void); 
     114 * 
     115 * @remark  The RTDECL() makes this a bit difficult to override on Windows. So, 
     116 *          you'll have ot use RTASSERT_HAVE_SHOULD_PANIC or 
     117 *          RTASSERT_HAVE_SHOULD_PANIC_PRIVATE there to control the kind of 
     118 *          prototype. 
     119 */ 
     120#if !defined(RTASSERT_HAVE_SHOULD_PANIC) && !defined(RTASSERT_HAVE_SHOULD_PANIC_PRIVATE) 
     121RTDECL(bool)    RTAssertShouldPanic(void); 
     122#elif defined(RTASSERT_HAVE_SHOULD_PANIC_PRIVATE) 
     123bool            RTAssertShouldPanic(void); 
     124#else 
     125DECLEXPORT(bool) RTCALL RTAssertShouldPanic(void); 
     126#endif 
    109127 
    110128/** The last assert message, 1st part. */ 
     
    115133__END_DECLS 
    116134 
    117  
    118 /** @def AssertBreakpoint() 
    119  * Assertion Breakpoint. 
    120  * 
    121  * @remark  In the gnu world we add a nop instruction after the int3 to 
     135/** @def RTAssertDebugBreak() 
     136 * Debugger breakpoint instruction. 
     137 * 
     138 * @remarks In the gnu world we add a nop instruction after the int3 to 
    122139 *          force gdb to remain at the int3 source line. 
    123  * @remark  The L4 kernel will try make sense of the breakpoint, thus the jmp. 
    124  */ 
    125 #ifdef RT_STRICT 
    126 # ifdef __GNUC__ 
    127 #  ifndef __L4ENV__ 
    128 #   define AssertBreakpoint()   do { if (RTAssertDoBreakpoint()) { __asm__ __volatile__ ("int3\n\tnop"); } } while (0) 
    129 #  else 
    130 #   define AssertBreakpoint()   do { if (RTAssertDoBreakpoint()) { __asm__ __volatile__ ("int3; jmp 1f; 1:"); } } while (0) 
    131 #  endif 
    132 # elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING) 
    133 #  define AssertBreakpoint()    do { if (RTAssertDoBreakpoint()) { __debugbreak(); } } while (0) 
     140 * @remarks The L4 kernel will try make sense of the breakpoint, thus the jmp. 
     141 * @remarks This macro does not depend on RT_STRICT. 
     142 */ 
     143#ifdef __GNUC__ 
     144# ifndef __L4ENV__ 
     145#  define RTAssertDebugBreak()  do { __asm__ __volatile__ ("int3\n\tnop"); } while (0) 
    134146# else 
    135 error "Unknown compiler" 
     147define RTAssertDebugBreak()  do { __asm__ __volatile__ ("int3; jmp 1f; 1:"); } while (0) 
    136148# endif 
    137 #else 
    138 # define AssertBreakpoint()     do { } while (0) 
    139 #endif 
     149#elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING) 
     150# define RTAssertDebugBreak()   do { __debugbreak(); } while (0) 
     151#else 
     152# error "Unknown compiler" 
     153#endif 
     154 
     155 
     156 
     157/** @name Compile time assertions. 
     158 * 
     159 * These assertions are used to check structure sizes, memember/size alignments 
     160 * and similar compile time expressions. 
     161 * 
     162 * @{ 
     163 */ 
    140164 
    141165/** 
     
    241265#endif 
    242266 
     267/** @} */ 
     268 
     269 
     270 
     271/** @name Assertions 
     272 * 
     273 * These assertions will only trigger when RT_STRICT is defined. When it is 
     274 * undefined they will all be noops and generate no code. 
     275 * 
     276 * @{ 
     277 */ 
     278 
     279/** @def RTAssertDoPanic 
     280 * Raises an assertion panic appropriate to the current context. 
     281 * @remarks This macro does not depend on RT_STRICT. 
     282 */ 
     283#if (defined(IN_RING0) && !defined(IN_RING0_AGNOSTIC)) \ 
     284 && (defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS)) 
     285# define RTAssertDoPanic()      RTR0AssertPanicSystem 
     286#else 
     287# define RTAssertDoPanic()      RTAssertDebugBreak() 
     288#endif 
     289 
     290/** @def AssertBreakpoint() 
     291 * Assertion Breakpoint. 
     292 * @deprecated Use RTAssertPanic or RTAssertDebugBreak instead. 
     293 */ 
     294#ifdef RT_STRICT 
     295# define AssertBreakpoint()     RTAssertDebugBreak() 
     296#else 
     297# define AssertBreakpoint()     do { } while (0) 
     298#endif 
     299 
     300/** @def rtAssertPanic() 
     301 * If RT_STRICT is defined this macro will invoke RTAssertDoPanic if 
     302 * RTAssertShouldPanic returns true. If RT_STRICT isn't defined it won't do any 
     303 * thing. 
     304 */ 
     305#ifdef RT_STRICT 
     306# define RTAssertPanic()        do { if (RTAssertShouldPanic()) RTAssertDoPanic(); } while (0) 
     307#else 
     308# define RTAssertPanic()        do { } while (0) 
     309#endif 
    243310 
    244311/** @def Assert 
     
    252319        { \ 
    253320            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    254             AssertBreakpoint(); \ 
     321            RTAssertPanic(); \ 
    255322        } \ 
    256323    } while (0) 
     
    273340        { \ 
    274341            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    275             AssertBreakpoint(); \ 
     342            RTAssertPanic(); \ 
    276343            return (rc); \ 
    277344        } \ 
     
    297364        { \ 
    298365            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    299             AssertBreakpoint(); \ 
     366            RTAssertPanic(); \ 
    300367            return; \ 
    301368        } \ 
     
    321388    { \ 
    322389        AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    323         AssertBreakpoint(); \ 
     390        RTAssertPanic(); \ 
    324391        break; \ 
    325392    } else do {} while (0) 
     
    342409    if (RT_UNLIKELY(!(expr))) { \ 
    343410        AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    344         AssertBreakpoint(); \ 
     411        RTAssertPanic(); \ 
    345412        stmt; \ 
    346413        break; \ 
     
    367434            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    368435            AssertMsg2 a; \ 
    369             AssertBreakpoint(); \ 
     436            RTAssertPanic(); \ 
    370437        } \ 
    371438    } while (0) 
     
    389456            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    390457            AssertMsg2 a; \ 
    391             AssertBreakpoint(); \ 
     458            RTAssertPanic(); \ 
    392459            return (rc); \ 
    393460        } \ 
     
    415482            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    416483            AssertMsg2 a; \ 
    417             AssertBreakpoint(); \ 
     484            RTAssertPanic(); \ 
    418485            return; \ 
    419486        } \ 
     
    441508        AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    442509        AssertMsg2 a; \ 
    443         AssertBreakpoint(); \ 
     510        RTAssertPanic(); \ 
    444511        break; \ 
    445512    } else do {} while (0) 
     
    464531        AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    465532        AssertMsg2 a; \ 
    466         AssertBreakpoint(); \ 
     533        RTAssertPanic(); \ 
    467534        stmt; \ 
    468535        break; \ 
     
    483550    do { \ 
    484551        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    485         AssertBreakpoint(); \ 
     552        RTAssertPanic(); \ 
    486553    } while (0) 
    487554#else 
     
    498565    do { \ 
    499566        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    500         AssertBreakpoint(); \ 
     567        RTAssertPanic(); \ 
    501568        return (rc); \ 
    502569    } while (0) 
     
    515582    do { \ 
    516583        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    517         AssertBreakpoint(); \ 
     584        RTAssertPanic(); \ 
    518585        return; \ 
    519586    } while (0) 
     
    533600    if (1) { \ 
    534601        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    535         AssertBreakpoint(); \ 
     602        RTAssertPanic(); \ 
    536603        break; \ 
    537604    } else do {} while (0) 
     
    553620    if (1) { \ 
    554621        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    555         AssertBreakpoint(); \ 
     622        RTAssertPanic(); \ 
    556623        stmt; \ 
    557624        break; \ 
     
    576643        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    577644        AssertMsg2 a; \ 
    578         AssertBreakpoint(); \ 
     645        RTAssertPanic(); \ 
    579646    } while (0) 
    580647#else 
     
    593660        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    594661        AssertMsg2 a; \ 
    595         AssertBreakpoint(); \ 
     662        RTAssertPanic(); \ 
    596663        return (rc); \ 
    597664    } while (0) 
     
    613680        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    614681        AssertMsg2 a; \ 
    615         AssertBreakpoint(); \ 
     682        RTAssertPanic(); \ 
    616683        return; \ 
    617684    } while (0) 
     
    634701        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    635702        AssertMsg2 a; \ 
    636         AssertBreakpoint(); \ 
     703        RTAssertPanic(); \ 
    637704        break; \ 
    638705    } else do {} while (0) 
     
    656723        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    657724        AssertMsg2 a; \ 
    658         AssertBreakpoint(); \ 
     725        RTAssertPanic(); \ 
    659726        stmt; \ 
    660727        break; \ 
     
    668735#endif 
    669736 
    670  
    671  
    672 /** @def AssertLogRelBreakpoint() 
    673  * Assertion LogRel Breakpoint. 
    674  * 
    675  * NOP in non-strict (release) builds, hardware breakpoint in strict builds, 
    676  * 
    677  * @remark  In the gnu world we add a nop instruction after the int3 to 
    678  *          force gdb to remain at the int3 source line. 
    679  * @remark  The L4 kernel will try make sense of the breakpoint, thus the jmp. 
    680  */ 
    681 #ifdef RT_STRICT 
    682 # ifdef __GNUC__ 
    683 #  ifndef __L4ENV__ 
    684 #   define AssertLogRelBreakpoint()     do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3\n\tnop"); } while (0) 
    685 #  else 
    686 #   define AssertLogRelBreakpoint()     do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3; jmp 1f; 1:"); } while (0) 
    687 #  endif 
    688 # elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING) 
    689 #  define AssertLogRelBreakpoint()      do { RTAssertDoBreakpoint(); __debugbreak(); } while (0) 
    690 # else 
    691 #  error "Unknown compiler" 
    692 # endif 
    693 #else   /* !RT_STRICT */ 
    694 # define AssertLogRelBreakpoint()       do { } while (0) 
    695 #endif  /* !RT_STRICT */ 
    696  
    697  
    698 /** @def AssertLogRelMsg1 
     737/** @} */ 
     738 
     739 
     740 
     741/** @name Release Log Assertions 
     742 * 
     743 * These assertions will work like normal strict assertion when RT_STRICT is 
     744 * defined and LogRel statements when RT_STRICT is undefined. Typically used for 
     745 * things which shouldn't go wrong, but when it does you'd like to know one way 
     746 * or ther other. 
     747 * 
     748 * @{ 
     749 */ 
     750 
     751/** @def RTAssertLogRelMsg1 
    699752 * AssertMsg1 (strict builds) / LogRel wrapper (non-strict). 
    700753 */ 
    701754#ifdef RT_STRICT 
    702 # define AssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \ 
     755# define RTAssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \ 
    703756    AssertMsg1(pszExpr, iLine, pszFile, pszFunction) 
    704757#else 
    705 # define AssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \ 
     758# define RTAssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \ 
    706759    LogRel(("AssertLogRel %s(%d) %s: %s\n",\ 
    707760            (pszFile), (iLine), (pszFunction), (pszExpr) )) 
    708761#endif 
    709762 
    710 /** @def AssertLogRelMsg2 
     763/** @def RTAssertLogRelMsg2 
    711764 * AssertMsg2 (strict builds) / LogRel wrapper (non-strict). 
    712765 */ 
    713766#ifdef RT_STRICT 
    714 # define AssertLogRelMsg2(a) AssertMsg2 a 
    715 #else 
    716 # define AssertLogRelMsg2(a) LogRel(a) 
     767# define RTAssertLogRelMsg2(a) AssertMsg2 a 
     768#else 
     769# define RTAssertLogRelMsg2(a) LogRel(a) 
    717770#endif 
    718771 
     
    727780        if (RT_UNLIKELY(!(expr))) \ 
    728781        { \ 
    729             AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    730             AssertLogRelBreakpoint(); \ 
     782            RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     783            RTAssertPanic(); \ 
    731784        } \ 
    732785    } while (0) 
     
    743796        if (RT_UNLIKELY(!(expr))) \ 
    744797        { \ 
    745             AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    746             AssertLogRelBreakpoint(); \ 
     798            RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     799            RTAssertPanic(); \ 
    747800            return (rc); \ 
    748801        } \ 
     
    759812        if (RT_UNLIKELY(!(expr))) \ 
    760813        { \ 
    761             AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    762             AssertLogRelBreakpoint(); \ 
     814            RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     815            RTAssertPanic(); \ 
    763816            return; \ 
    764817        } \ 
     
    774827    if (RT_UNLIKELY(!(expr))) \ 
    775828    { \ 
    776         AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    777         AssertLogRelBreakpoint(); \ 
     829        RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     830        RTAssertPanic(); \ 
    778831        break; \ 
    779832    } \ 
     
    790843    if (RT_UNLIKELY(!(expr))) \ 
    791844    { \ 
    792         AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    793         AssertLogRelBreakpoint(); \ 
     845        RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     846        RTAssertPanic(); \ 
    794847        stmt; \ 
    795848        break; \ 
     
    807860        if (RT_UNLIKELY(!(expr))) \ 
    808861        { \ 
    809             AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    810             AssertLogRelMsg2(a); \ 
    811             AssertLogRelBreakpoint(); \ 
     862            RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     863            RTAssertLogRelMsg2(a); \ 
     864            RTAssertPanic(); \ 
    812865        } \ 
    813866    } while (0) 
     
    825878        if (RT_UNLIKELY(!(expr))) \ 
    826879        { \ 
    827             AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    828             AssertLogRelMsg2(a); \ 
    829             AssertLogRelBreakpoint(); \ 
     880            RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     881            RTAssertLogRelMsg2(a); \ 
     882            RTAssertPanic(); \ 
    830883            return (rc); \ 
    831884        } \ 
     
    843896        if (RT_UNLIKELY(!(expr))) \ 
    844897        { \ 
    845             AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    846             AssertLogRelMsg2(a); \ 
    847             AssertLogRelBreakpoint(); \ 
     898            RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     899            RTAssertLogRelMsg2(a); \ 
     900            RTAssertPanic(); \ 
    848901            return; \ 
    849902        } \ 
     
    860913    if (RT_UNLIKELY(!(expr))) \ 
    861914    { \ 
    862         AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    863         AssertLogRelMsg2(a); \ 
    864         AssertLogRelBreakpoint(); \ 
     915        RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     916        RTAssertLogRelMsg2(a); \ 
     917        RTAssertPanic(); \ 
    865918        break; \ 
    866919    } \ 
     
    878931    if (RT_UNLIKELY(!(expr))) \ 
    879932    { \ 
    880         AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    881         AssertLogRelMsg2(a); \ 
    882         AssertLogRelBreakpoint(); \ 
     933        RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     934        RTAssertLogRelMsg2(a); \ 
     935        RTAssertPanic(); \ 
    883936        stmt; \ 
    884937        break; \ 
     
    891944#define AssertLogRelFailed() \ 
    892945    do { \ 
    893         AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    894         AssertLogRelBreakpoint(); \ 
     946        RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     947        RTAssertPanic(); \ 
    895948    } while (0) 
    896949 
     
    903956#define AssertLogRelFailedReturn(rc) \ 
    904957    do { \ 
    905         AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    906         AssertLogRelBreakpoint(); \ 
     958        RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     959        RTAssertPanic(); \ 
    907960        return (rc); \ 
    908961    } while (0) 
     
    914967#define AssertLogRelFailedReturnVoid() \ 
    915968    do { \ 
    916         AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    917         AssertLogRelBreakpoint(); \ 
     969        RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     970        RTAssertPanic(); \ 
    918971        return; \ 
    919972    } while (0) 
     
    926979    if (1) \ 
    927980    { \ 
    928         AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    929         AssertLogRelBreakpoint(); \ 
     981        RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     982        RTAssertPanic(); \ 
    930983        break; \ 
    931984    } else do {} while (0) 
     
    940993    if (1) \ 
    941994    { \ 
    942         AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    943         AssertLogRelBreakpoint(); \ 
     995        RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     996        RTAssertPanic(); \ 
    944997        stmt; \ 
    945998        break; \ 
     
    9541007#define AssertLogRelMsgFailed(a) \ 
    9551008    do { \ 
    956         AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    957         AssertLogRelMsg2(a); \ 
    958         AssertLogRelBreakpoint(); \ 
     1009        RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     1010        RTAssertLogRelMsg2(a); \ 
     1011        RTAssertPanic(); \ 
    9591012    } while (0) 
    9601013 
     
    9681021#define AssertLogRelMsgFailedReturn(a, rc) \ 
    9691022    do { \ 
    970         AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    971         AssertLogRelMsg2(a); \ 
    972         AssertLogRelBreakpoint(); \ 
     1023        RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     1024        RTAssertLogRelMsg2(a); \ 
     1025        RTAssertPanic(); \ 
    9731026        return (rc); \ 
    9741027    } while (0) 
     
    9821035#define AssertLogRelMsgFailedReturnVoid(a) \ 
    9831036    do { \ 
    984         AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    985         AssertLogRelMsg2(a); \ 
    986         AssertLogRelBreakpoint(); \ 
     1037        RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     1038        RTAssertLogRelMsg2(a); \ 
     1039        RTAssertPanic(); \ 
    9871040        return; \ 
    9881041    } while (0) 
     
    9971050    if (1)\ 
    9981051    { \ 
    999         AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1000         AssertLogRelMsg2(a); \ 
    1001         AssertLogRelBreakpoint(); \ 
     1052        RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     1053        RTAssertLogRelMsg2(a); \ 
     1054        RTAssertPanic(); \ 
    10021055        break; \ 
    10031056    } else do {} while (0) 
     
    10131066    if (1) \ 
    10141067    { \ 
    1015         AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1016         AssertLogRelMsg2(a); \ 
    1017         AssertLogRelBreakpoint(); \ 
     1068        RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
     1069        RTAssertLogRelMsg2(a); \ 
     1070        RTAssertPanic(); \ 
    10181071        stmt; \ 
    10191072        break; \ 
    10201073    } else do {} while (0) 
    10211074 
    1022  
    1023  
    1024 /** @def AssertReleaseBreakpoint() 
    1025  * Assertion Breakpoint. 
    1026  * 
    1027  * @remark  In the gnu world we add a nop instruction after the int3 to 
    1028  *          force gdb to remain at the int3 source line. 
    1029  * @remark  The L4 kernel will try make sense of the breakpoint, thus the jmp. 
    1030  */ 
    1031 #ifdef __GNUC__ 
    1032 # ifndef __L4ENV__ 
    1033 #  define AssertReleaseBreakpoint()     do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3\n\tnop"); } while (0) 
    1034 # else 
    1035 #  define AssertReleaseBreakpoint()     do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3; jmp 1f; 1:"); } while (0) 
    1036 # endif 
    1037 #elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING) 
    1038 # define AssertReleaseBreakpoint()      do { RTAssertDoBreakpoint(); __debugbreak(); } while (0) 
    1039 #else 
    1040 # error "Unknown compiler" 
    1041 #endif 
     1075/** @} */ 
     1076 
     1077 
     1078 
     1079/** @name Release Asserions 
     1080 * 
     1081 * These assertions are always enabled. 
     1082 * @{ 
     1083 */ 
     1084 
     1085/** @def RTAssertReleasePanic() 
     1086 * Invokes RTAssertShouldPanic and RTAssertDoPanic. 
     1087 * 
     1088 * It might seem odd that RTAssertShouldPanic is necessary when its result isn't 
     1089 * checked, but it's done since RTAssertShouldPanic is overrideable and might be 
     1090 * used to bail out before taking down the system (the VMMR0 case). 
     1091 */ 
     1092#define RTAssertReleasePanic()   do { RTAssertShouldPanic(); RTAssertDoPanic(); } while (0) 
    10421093 
    10431094 
     
    10521103        { \ 
    10531104            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1054             AssertReleaseBreakpoint(); \ 
     1105            RTAssertReleasePanic(); \ 
    10551106        } \ 
    10561107    } while (0) 
     
    10671118        { \ 
    10681119            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1069             AssertReleaseBreakpoint(); \ 
     1120            RTAssertReleasePanic(); \ 
    10701121            return (rc); \ 
    10711122        } \ 
     
    10821133        { \ 
    10831134            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1084             AssertReleaseBreakpoint(); \ 
     1135            RTAssertReleasePanic(); \ 
    10851136            return; \ 
    10861137        } \ 
     
    10981149        { \ 
    10991150            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1100             AssertReleaseBreakpoint(); \ 
     1151            RTAssertReleasePanic(); \ 
    11011152            break; \ 
    11021153        } \ 
     
    11131164    { \ 
    11141165        AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1115         AssertReleaseBreakpoint(); \ 
     1166        RTAssertReleasePanic(); \ 
    11161167        stmt; \ 
    11171168        break; \ 
     
    11311182            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    11321183            AssertMsg2 a; \ 
    1133             AssertReleaseBreakpoint(); \ 
     1184            RTAssertReleasePanic(); \ 
    11341185        } \ 
    11351186    } while (0) 
     
    11481199            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    11491200            AssertMsg2 a; \ 
    1150             AssertReleaseBreakpoint(); \ 
     1201            RTAssertReleasePanic(); \ 
    11511202            return (rc); \ 
    11521203        } \ 
     
    11651216            AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    11661217            AssertMsg2 a; \ 
    1167             AssertReleaseBreakpoint(); \ 
     1218            RTAssertReleasePanic(); \ 
    11681219            return; \ 
    11691220        } \ 
     
    11821233        AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    11831234        AssertMsg2 a; \ 
    1184         AssertReleaseBreakpoint(); \ 
     1235        RTAssertReleasePanic(); \ 
    11851236        break; \ 
    11861237    } else do {} while (0) 
     
    11971248        AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    11981249        AssertMsg2 a; \ 
    1199         AssertReleaseBreakpoint(); \ 
     1250        RTAssertReleasePanic(); \ 
    12001251        stmt; \ 
    12011252        break; \ 
     
    12091260    do { \ 
    12101261        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1211         AssertReleaseBreakpoint(); \ 
     1262        RTAssertReleasePanic(); \ 
    12121263    } while (0) 
    12131264 
     
    12201271    do { \ 
    12211272        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1222         AssertReleaseBreakpoint(); \ 
     1273        RTAssertReleasePanic(); \ 
    12231274        return (rc); \ 
    12241275    } while (0) 
     
    12301281    do { \ 
    12311282        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1232         AssertReleaseBreakpoint(); \ 
     1283        RTAssertReleasePanic(); \ 
    12331284        return; \ 
    12341285    } while (0) 
     
    12411292    if (1) { \ 
    12421293        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1243         AssertReleaseBreakpoint(); \ 
     1294        RTAssertReleasePanic(); \ 
    12441295        break; \ 
    12451296    } else do {} while (0) 
     
    12531304    if (1) { \ 
    12541305        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1255         AssertReleaseBreakpoint(); \ 
     1306        RTAssertReleasePanic(); \ 
    12561307        stmt; \ 
    12571308        break; \ 
     
    12681319        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    12691320        AssertMsg2 a; \ 
    1270         AssertReleaseBreakpoint(); \ 
     1321        RTAssertReleasePanic(); \ 
    12711322    } while (0) 
    12721323 
     
    12811332        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    12821333        AssertMsg2 a; \ 
    1283         AssertReleaseBreakpoint(); \ 
     1334        RTAssertReleasePanic(); \ 
    12841335        return (rc); \ 
    12851336    } while (0) 
     
    12941345        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    12951346        AssertMsg2 a; \ 
    1296         AssertReleaseBreakpoint(); \ 
     1347        RTAssertReleasePanic(); \ 
    12971348        return; \ 
    12981349    } while (0) 
     
    13081359        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    13091360        AssertMsg2 a; \ 
    1310         AssertReleaseBreakpoint(); \ 
     1361        RTAssertReleasePanic(); \ 
    13111362        break; \ 
    13121363    } else do {} while (0) 
     
    13221373        AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    13231374        AssertMsg2 a; \ 
    1324         AssertReleaseBreakpoint(); \ 
     1375        RTAssertReleasePanic(); \ 
    13251376        stmt; \ 
    13261377        break; \ 
    13271378    } else do {} while (0) 
    13281379 
     1380/** @} */ 
     1381 
     1382 
     1383 
     1384/** @name Fatal Assertions 
     1385 * These are similar to release assertions except that you cannot ignore them in 
     1386 * any way, they will loop for ever if RTAssertDoPanic returns. 
     1387 * 
     1388 * @{ 
     1389 */ 
    13291390 
    13301391/** @def AssertFatal 
     
    13391400            { \ 
    13401401                AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1341                 AssertReleaseBreakpoint(); \ 
     1402                RTAssertReleasePanic(); \ 
    13421403            } \ 
    13431404    } while (0) 
     
    13561417                AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    13571418                AssertMsg2 a; \ 
    1358                 AssertReleaseBreakpoint(); \ 
     1419                RTAssertReleasePanic(); \ 
    13591420            } \ 
    13601421    } while (0) 
     
    13681429        { \ 
    13691430            AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    1370             AssertReleaseBreakpoint(); \ 
     1431            RTAssertReleasePanic(); \ 
    13711432        } \ 
    13721433    } while (0) 
     
    13831444            AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 
    13841445            AssertMsg2 a; \ 
    1385             AssertReleaseBreakpoint(); \ 
     1446            RTAssertReleasePanic(); \ 
    13861447        } \ 
    13871448    } while (0) 
    13881449 
     1450/** @} */ 
     1451 
     1452 
     1453 
     1454/** @name Convenience Assertions Macros 
     1455 * @{ 
     1456 */ 
    13891457 
    13901458/** @def AssertRC 
     
    19582026#define AssertGCPhys32(GCPhys)          AssertMsg(VALID_PHYS32(GCPhys), ("%RGp\n", (RTGCPHYS)(GCPhys))) 
    19592027 
    1960  
    19612028/** @} */ 
    19622029 
    1963 #endif 
    1964  
     2030/** @} */ 
     2031 
     2032#endif 
     2033 
  • trunk/src/VBox/HostDrivers/Support/linux/Makefile

    r13000 r13306  
    9090        r0drv/linux/time-r0drv-linux.o \ 
    9191        r0drv/linux/timer-r0drv-linux.o \ 
    92         common/err/RTErrConvertFromErrno.o 
     92        common/err/RTErrConvertFromErrno.o \ 
     93        generic/RTAssertShouldPanic-generic.o 
    9394ifeq ($(BUILD_TARGET_ARCH),x86) 
    9495OBJS += math/gcc/divdi3.o \ 
     
    237238 
    238239# By default we use remap_pfn_range() kernel API to make kernel pages 
    239 # visible for userland. Unfortuately, it leads to situation that   
    240 # during debug session all structures on that page (such as PVM pointer)  
    241 # are not accessible to the debugger (see #3214).  
    242 # This code enables experimental support  
     240# visible for userland. Unfortuately, it leads to situation that 
     241# during debug session all structures on that page (such as PVM pointer) 
     242# are not accessible to the debugger (see #3214). 
     243# This code enables experimental support 
    243244# for vm_insert_page() kernel API, allowing to export kernel pages 
    244 # to the userland in more debugger-friendly way. Due to stability  
     245# to the userland in more debugger-friendly way. Due to stability 
    245246# concerns, not enabled by default yet. 
    246247ifdef VBOX_USE_INSERT_PAGE 
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r12360 r13306  
    946946 
    947947/** @todo move to IPRT! */ 
    948 RTDECL(bool) RTAssertDoBreakpoint(void) 
    949 { 
    950     return true; 
    951 } 
    952  
    953  
    954 /** @todo move to IPRT! */ 
    955948RTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction) 
    956949{ 
  • trunk/src/VBox/HostDrivers/Support/linux/files_vboxdrv

    r12099 r13306  
    8989    ${PATH_ROOT}/src/VBox/Runtime/include/internal/string.h=>include/internal/string.h \ 
    9090    ${PATH_ROOT}/src/VBox/Runtime/include/internal/thread.h=>include/internal/thread.h \ 
     91    ${PATH_ROOT}/src/VBox/Runtime/generic/RTAssertShouldPanic-generic.cpp=>generic/RTAssertShouldPanic-generic.c \ 
    9192    ${PATH_ROOT}/src/VBox/Runtime/generic/RTLogWriteStdErr-stub-generic.cpp=>generic/RTLogWriteStdErr-stub-generic.c \ 
    9293    ${PATH_ROOT}/src/VBox/Runtime/generic/RTLogWriteStdOut-stub-generic.cpp=>generic/RTLogWriteStdOut-stub-generic.c \ 
  • trunk/src/VBox/Runtime/Makefile.kmk

    r13300 r13306  
    282282RuntimeR3_SOURCES += \ 
    283283        VBox/strformat-vbox.cpp \ 
    284         VBox/RTAssertDoBreakpoint-vbox.cpp \ 
     284        VBox/RTAssertShouldPanic-vbox.cpp \ 
    285285        VBox/log-vbox.cpp 
    286286ifneq ($(KBUILD_TARGET),win) 
     
    650650        common/string/utf-16.cpp \ 
    651651        generic/pathhost-generic.cpp \ 
    652         generic/RTAssertDoBreakpoint-generic.cpp \ 
     652        generic/RTAssertShouldPanic-generic.cpp \ 
    653653        r3/alloc.cpp \ 
    654654        r3/fileio.cpp \ 
     
    873873        common/table/avlu32.cpp \ 
    874874        common/time/timesup.cpp \ 
    875         generic/RTAssertDoBreakpoint-generic.cpp \ 
     875        generic/RTAssertShouldPanic-generic.cpp \ 
    876876        VBox/strformat-vbox.cpp 
    877877 
     
    973973        common/string/strpbrk.cpp \ 
    974974        common/err/RTErrConvertToErrno.cpp \ 
    975         generic/RTAssertDoBreakpoint-generic.cpp \ 
     975        generic/RTAssertShouldPanic-generic.cpp \ 
    976976        generic/RTLogWriteStdOut-stub-generic.cpp \ 
    977977        generic/mppresent-generic.cpp \ 
     
    10071007        common/string/strncmp.cpp \ 
    10081008        common/string/strpbrk.cpp \ 
    1009         generic/RTAssertDoBreakpoint-generic.cpp \ 
     1009        generic/RTAssertShouldPanic-generic.cpp \ 
    10101010        generic/RTLogWriteStdOut-stub-generic.cpp \ 
    10111011        generic/mppresent-generic.cpp \ 
     
    10421042        darwin/RTErrConvertFromDarwinIO.cpp \ 
    10431043        darwin/RTErrConvertFromDarwinKern.cpp \ 
    1044         generic/RTAssertDoBreakpoint-generic.cpp \ 
     1044        generic/RTAssertShouldPanic-generic.cpp \ 
    10451045        generic/RTMpCpuId-generic.cpp \ 
    10461046        generic/RTMpCpuIdFromSetIndex-generic.cpp \ 
     
    11201120        r0drv/os2/os2imports.imp \ 
    11211121        r0drv/os2/process-r0drv-os2.cpp \ 
    1122         r0drv/os2/RTAssertDoBreakpoint-r0drv-os2.asm \ 
     1122        r0drv/os2/RTR0AssertPanicSystem-r0drv-os2.asm \ 
    11231123        r0drv/os2/RTR0Os2DHQueryDOSVar.asm \ 
    11241124        r0drv/os2/RTR0Os2DHVMGlobalToProcess.asm \ 
     
    11421142        common/string/memcmp.asm \ 
    11431143        common/string/strchr.asm \ 
    1144         generic/RTAssertDoBreakpoint-generic.cpp \ 
     1144        generic/RTAssertShouldPanic-generic.cpp \ 
    11451145        generic/RTLogWriteDebugger-generic.cpp \ 
    11461146        generic/RTLogWriteStdOut-stub-generic.cpp \ 
     
    11811181        common/misc/thread.cpp \ 
    11821182        common/string/memchr.asm \ 
    1183         generic/RTAssertDoBreakpoint-generic.cpp \ 
     1183        generic/RTAssertShouldPanic-generic.cpp \ 
    11841184        generic/RTLogWriteStdOut-stub-generic.cpp \ 
    11851185        generic/RTTimerCreate-g