VirtualBox

Changeset 13306 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Oct 15, 2008 9:17:04 PM (16 years ago)
Author:
vboxsync
Message:

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

Location:
trunk/src/VBox/Runtime
Files:
6 edited
3 moved

Legend:

Unmodified
Added
Removed
  • 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-generic.cpp \
     
    12611261        common/misc/thread.cpp \
    12621262        common/string/memchr.asm \
    1263         generic/RTAssertDoBreakpoint-generic.cpp \
     1263        generic/RTAssertShouldPanic-generic.cpp \
    12641264        generic/RTTimerCreate-generic.cpp \
    12651265        r0drv/memobj-r0drv.cpp \
     
    13441344        common/time/timesup.cpp \
    13451345        gc/initterm-gc.cpp \
    1346         generic/RTAssertDoBreakpoint-generic.cpp \
     1346        generic/RTAssertShouldPanic-generic.cpp \
    13471347        VBox/strformat-vbox.cpp \
    13481348
  • trunk/src/VBox/Runtime/VBox/RTAssertShouldPanic-vbox.cpp

    r13298 r13306  
    11/* $Id$ */
    22/** @file
    3  * IPRT - Assertions, generic RTAssertDoBreakpoint.
     3 * IPRT - Assertions, generic RTAssertShouldPanic.
    44 */
    55
     
    5656
    5757
    58 RTDECL(bool)    RTAssertDoBreakpoint(void)
     58RTDECL(bool) RTAssertShouldPanic(void)
    5959{
    6060    /*
     
    6767        return true;
    6868
    69     /* 'breakpoint' means default behaviour. */
    70     if (!strcmp(psz, "breakpoint"))
     69    /* 'breakpoint' or 'panic' means default behaviour. */
     70    if (!strcmp(psz, "breakpoint") || !strcmp(psz, "panic"))
    7171        return true;
    7272
     
    8282        /* Try find a suitable terminal program. */
    8383        const char *pszTerm = RTEnvGet("VBOX_ASSERT_TERM");
    84         if (    !pszTerm 
     84        if (    !pszTerm
    8585            ||  !RTPathExists(pszTerm))
    8686        {
     
    9191                if (!RTPathExists(pszTerm))
    9292                {
    93                     pszTerm ="/usr/bin/xterm"; 
     93                    pszTerm ="/usr/bin/xterm";
    9494                    if (!RTPathExists(pszTerm))
    9595                        return true;
     
    100100        /* And find gdb. */
    101101        const char *pszGdb = RTEnvGet("VBOX_ASSERT_GDB");
    102         if (    !pszGdb 
     102        if (    !pszGdb
    103103            ||  !RTPathExists(pszGdb))
    104104        {
  • trunk/src/VBox/Runtime/VBox/VBoxRTDeps.cpp

    r11794 r13306  
    3434#include <VBox/sup.h>
    3535#include <iprt/system.h>
     36#include <iprt/assert.h>
    3637
    3738
     
    4243{
    4344    (PFNRT)SUPR3Init,
    44     (PFNRT)SUPPageLock
     45    (PFNRT)SUPPageLock,
     46    (PFNRT)RTAssertShouldPanic
    4547};
     48
  • trunk/src/VBox/Runtime/VBox/log-vbox.cpp

    r10608 r13306  
    197197#define ASSERT_LOG_GROUP(grp)  ASSERT_LOG_GROUP2(LOG_GROUP_##grp, #grp)
    198198#define ASSERT_LOG_GROUP2(def, str) \
    199     do { if (strcmp(g_apszGroups[def], str)) {printf("%s='%s' expects '%s'\n", #def, g_apszGroups[def], str); AssertReleaseBreakpoint(); } } while (0)
     199    do { if (strcmp(g_apszGroups[def], str)) {printf("%s='%s' expects '%s'\n", #def, g_apszGroups[def], str); RTAssertDoPanic(); } } while (0)
    200200    ASSERT_LOG_GROUP(DEFAULT);
    201201    ASSERT_LOG_GROUP(CFGM);
  • trunk/src/VBox/Runtime/generic/RTAssertShouldPanic-generic.cpp

    r13298 r13306  
    11/* $Id$ */
    22/** @file
    3  * IPRT - Assertions, generic RTAssertDoBreakpoint.
     3 * IPRT - Assertions, generic RTAssertShouldPanic.
    44 */
    55
     
    2929 */
    3030
    31 
    3231/*******************************************************************************
    3332*   Header Files                                                               *
     
    3635
    3736
    38 /**
    39  * Overridable function that decides whether assertions executes the breakpoint or not.
    40  *
    41  * The generic implementation will return true.
    42  *
    43  * @returns true if the breakpoint should be hit, false if it should be ignored.
    44  * @remark  The RTDECL() makes this a bit difficult to override on windows. Sorry.
    45  */
    46 RTDECL(bool)    RTAssertDoBreakpoint(void)
     37RTDECL(bool) RTAssertShouldPanic(void)
    4738{
    4839    return true;
  • trunk/src/VBox/Runtime/r0drv/darwin/assert-r0drv-darwin.cpp

    r11645 r13306  
    4444*******************************************************************************/
    4545/** The last assert message, 1st part. */
    46 RTDATADECL(char) g_szRTAssertMsg1[1024];
     46RTDATADECL(char)                    g_szRTAssertMsg1[1024];
    4747/** The last assert message, 2nd part. */
    48 RTDATADECL(char) g_szRTAssertMsg2[2048];
     48RTDATADECL(char)                    g_szRTAssertMsg2[2048];
     49/** The last assert message, file name. */
     50RTDATADECL(const char *) volatile   g_pszRTAssertFile;
     51/** The last assert message, line number. */
     52RTDATADECL(uint32_t) volatile       g_u32RTAssertLine;
     53/** The last assert message, function name. */
     54RTDATADECL(const char *) volatile   g_pszRTAssertFunction;
    4955
    5056
     
    6874                "Location  : %s(%d) %s\n",
    6975                pszExpr, pszFile, uLine, pszFunction);
     76    ASMAtomicUoWritePtr(&g_pszRTAssertFile, pszFile);
     77    ASMAtomicUoWriteU32(&g_u32RTAssertLine, uLine);
     78    ASMAtomicUoWritePtr(&g_pszRTAssertFunction, pszFunction);
    7079}
    7180
     
    91100    RTStrPrintfV(g_szRTAssertMsg2, sizeof(g_szRTAssertMsg2), pszFormat, va);
    92101    va_end(va);
     102}
    93103
     104
     105RTR0DECL(void) RTR0AssertPanicSystem(void)
     106{
    94107    panic("%s%s", g_szRTAssertMsg1, g_szRTAssertMsg2);
    95108}
  • trunk/src/VBox/Runtime/r0drv/os2/RTR0AssertPanicSystem-r0drv-os2.asm

    r13298 r13306  
    11; $Id$
    22;; @file
    3 ; IPRT - DevHelp_GetDOSVar, Ring-0 Driver, OS/2.
     3; IPRT - RTR0AssertPanicSystem, Ring-0 Driver, OS/2.
    44;
    55
     
    5555BEGINCODE
    5656
    57 BEGINPROC_EXPORTED RTAssertDoBreakpoint
     57BEGINPROC_EXPORTED RTR0AssertPanicSystem
    5858    push    ebp
    5959    mov     ebp, esp
     
    7171    ;
    7272    call    KernThunkStackTo16
    73     ;jmp far dword NAME(RTAssertDoBreakpoint_16) wrt CODE16
     73    ;jmp far dword NAME(RTR0AssertPanicSystem_16) wrt CODE16
    7474    db      066h
    7575    db      0eah
    76     dw      NAME(RTAssertDoBreakpoint_16) wrt CODE16
     76    dw      NAME(RTR0AssertPanicSystem_16) wrt CODE16
    7777    dw      CODE16
    7878BEGINCODE16
    79 GLOBALNAME RTAssertDoBreakpoint_16
     79GLOBALNAME RTR0AssertPanicSystem_16
    8080    ; mov     ax, seg NAME(g_szRTAssertMsg) - makes wlink crash.
    8181    mov     ax, DATA16
     
    8787
    8888    ; Doesn't normally return, but in case it does...
    89     ;jmp far dword NAME(RTAssertDoBreakpoint_32)
     89    ;jmp far dword NAME(RTR0AssertPanicSystem_32)
    9090    db      066h
    9191    db      0eah
    92     dd      NAME(RTAssertDoBreakpoint_32)
     92    dd      NAME(RTR0AssertPanicSystem_32)
    9393    dw      TEXT32 wrt FLAT
    9494BEGINCODE32:
    95 GLOBALNAME RTAssertDoBreakpoint_32
     95GLOBALNAME RTR0AssertPanicSystem_32
    9696    call KernThunkStackTo32
    9797    mov     eax, 1
     
    101101    leave
    102102    ret
    103 ENDPROC RTAssertDoBreakpoint
     103ENDPROC RTR0AssertPanicSystem
    104104
  • trunk/src/VBox/Runtime/r0drv/solaris/assert-r0drv-solaris.c

    r8245 r13306  
    4141
    4242
     43/*******************************************************************************
     44*   Global Variables                                                           *
     45*******************************************************************************/
     46/** The last assert message, 1st part. */
     47RTDATADECL(char)                    g_szRTAssertMsg1[1024];
     48/** The last assert message, 2nd part. */
     49RTDATADECL(char)                    g_szRTAssertMsg2[2048];
     50/** The last assert message, file name. */
     51RTDATADECL(const char *) volatile   g_pszRTAssertFile;
     52/** The last assert message, line number. */
     53RTDATADECL(uint32_t) volatile       g_u32RTAssertLine;
     54/** The last assert message, function name. */
     55RTDATADECL(const char *) volatile   g_pszRTAssertFunction;
     56
     57
    4358RTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
    4459{
     
    5469            "Location  : %s(%d) %s\r\n",
    5570            pszExpr, pszFile, uLine, pszFunction);
     71
     72    RTStrPrintf(g_szRTAssertMsg1, sizeof(g_szRTAssertMsg1),
     73                "\n!!Assertion Failed!!\n"
     74                "Expression: %s\n"
     75                "Location  : %s(%d) %s\n",
     76                pszExpr, pszFile, uLine, pszFunction);
     77    ASMAtomicUoWritePtr(&g_pszRTAssertFile, pszFile);
     78    ASMAtomicUoWriteU32(&g_u32RTAssertLine, uLine);
     79    ASMAtomicUoWritePtr(&g_pszRTAssertFunction, pszFunction);
    5680}
    5781
     
    7397    va_end(va);
    7498    uprintf("%s", szMsg);
     99
     100    va_start(va, pszFormat);
     101    RTStrPrintfV(g_szRTAssertMsg2, sizeof(g_szRTAssertMsg2), pszFormat, va);
     102    va_end(va);
    75103}
    76104
     105
     106RTR0DECL(void) RTR0AssertPanicSystem(void)
     107{
     108    const char *psz    = &g_szRTAssertMsg2[0];
     109    const char *pszEnd = &g_szRTAssertMsg2[sizeof(g_szRTAssertMsg2)];
     110    while (psz < pszEnd && (*psz == ' ' || *psz == '\t' || *psz == '\n' || *psz == '\r'))
     111        psz++;
     112
     113    if (psz >= pszEnd || *psz)
     114        assfail(psz, g_pszRTAssertFile, g_u32RTAssertLine);
     115    else
     116        assfail(g_szRTAssertMsg1, g_pszRTAssertFile, g_u32RTAssertLine);
     117}
     118
  • trunk/src/VBox/Runtime/r3/alloc-ef.cpp

    r11019 r13306  
    8585    vfprintf(stderr, pszFormat, args);
    8686    va_end(args);
    87     AssertReleaseBreakpoint();
     87    RTAssertDoPanic();
    8888}
    8989
     
    368368    for (unsigned i = 0; i < ELEMENTS(gapvRTMemFreeWatch); i++)
    369369        if (gapvRTMemFreeWatch[i] == pv)
    370             AssertReleaseBreakpoint();
     370            RTAssertDoPanic();
    371371
    372372#ifdef RTALLOC_EFENCE_TRACE
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