VirtualBox

Changeset 935 in vbox for trunk/src


Ignore:
Timestamp:
Feb 15, 2007 7:49:19 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18670
Message:

moving it (part 1).

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/generic/RTAssertDoBreakpoint-generic.cpp

    r880 r935  
    11/* $Id$ */
    22/** @file
    3  * InnoTek Portable Runtime - Assertion Workers.
     3 * InnoTek Portable Runtime - Assertions, generic RTAssertDoBreakpoint.
    44 */
    55
     
    2525*******************************************************************************/
    2626#include <iprt/assert.h>
    27 #include <iprt/log.h>
    28 #include <iprt/string.h>
    29 #include <iprt/stdarg.h>
    30 #ifdef IN_RING3
    31 # include <stdio.h>
    32 #endif
    33 
    34 
    35 #ifdef IN_GUEST_R0
    36 #include <VBox/log.h>
    3727
    3828
    3929/**
    40  * The 1st part of an assert message.
    41  *
    42  * @param   pszExpr     Expression. Can be NULL.
    43  * @param   uLine       Location line number.
    44  * @param   pszFile     Location file name.
    45  * @param   pszFunction Location function name.
    46  * @remark  This API exists in HC Ring-3 and GC.
     30 * Overridable function that decides whether assertions executes the breakpoint or not.
     31 *
     32 * The generic implementation will return true.
     33 *
     34 * @returns true if the breakpoint should be hit, false if it should be ignored.
     35 * @remark  The RTDECL() makes this a bit difficult to override on windows. Sorry.
    4736 */
    48 RTDECL(void)    AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
    49 {
    50     RTLogBackdoorPrintf("\n!!Assertion Failed!!\n"
    51                         "Expression: %s\n"
    52                         "Location  : %s(%d) %s\n",
    53                         pszExpr, pszFile, uLine, pszFunction);
    54 }
    55 
    56 
    57 /**
    58  * The 2nd (optional) part of an assert message.
    59  *
    60  * @param   pszFormat   Printf like format string.
    61  * @param   ...         Arguments to that string.
    62  * @remark  This API exists in HC Ring-3 and GC.
    63  */
    64 RTDECL(void) AssertMsg2(const char *pszFormat, ...)
    65 {   /* forwarder. */
    66     va_list args;
    67     va_start(args, pszFormat);
    68     RTLogBackdoorPrintfV(pszFormat, args);
    69     va_end(args);
    70 }
    71 
    72 
    73 #elif defined(IN_RING0)
    74 
    75 
    76 #if 0 /* this code is totally unused */
    77 
    78 #include <VBox/sup.h>
    79 
    80 
    81 /**
    82  * The 1st part of an assert message.
    83  *
    84  * @param   pszExpr     Expression. Can be NULL.
    85  * @param   uLine       Location line number.
    86  * @param   pszFile     Location file name.
    87  * @param   pszFunction Location function name.
    88  * @remark  This API exists in HC Ring-3 and GC.
    89  */
    90 RTDECL(void)    AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
    91 {
    92     SUPR0Printf("\n!!Assertion Failed!!\n"
    93                 "Expression: %s\n"
    94                 "Location  : %s(%d) %s\n",
    95                 pszExpr, pszFile, uLine, pszFunction);
    96 #if !defined(IN_RING3) && !defined(LOG_NO_COM)
    97     RTLogComPrintf("\n!!Assertion Failed!!\n"
    98                    "Expression: %s\n"
    99                    "Location  : %s(%d) %s\n",
    100                    pszExpr, pszFile, uLine, pszFunction);
    101 #endif
    102 }
    103 
    104 
    105 /**
    106  * The 2nd (optional) part of an assert message.
    107  *
    108  * @param   pszFormat   Printf like format string.
    109  * @param   ...         Arguments to that string.
    110  * @remark  This API exists in HC Ring-3 and GC.
    111  */
    112 #ifdef __GNUC__
    113 /* asm (".globl AssertMsg2; AssertMsg2: jmp *SUPR0Printf"); - DEADLY! */
    114 #else
    115 __declspec(naked) void AssertMsg2(const char *pszFormat, ...)
    116 {   /* forwarder. */
    117     __asm jmp dword ptr [SUPR0Printf];
    118 }
    119 #endif
    120 
    121 #endif /* dead code */
    122 
    123 #else /* !IN_RING0 */
    124 
    125 
    126 /** The last assert message, 1st part. */
    127 RTDATADECL(char) g_szRTAssertMsg1[1024];
    128 /** The last assert message, 2nd part. */
    129 RTDATADECL(char) g_szRTAssertMsg2[2048];
    130 
    131 /**
    132  * The 1st part of an assert message.
    133  *
    134  * @param   pszExpr     Expression. Can be NULL.
    135  * @param   uLine       Location line number.
    136  * @param   pszFile     Location file name.
    137  * @param   pszFunction Location function name.
    138  * @remark  This API exists in HC Ring-3 and GC.
    139  */
    140 RTDECL(void)    AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
    141 {
    142 #if !defined(IN_RING3) && !defined(LOG_NO_COM)
    143     RTLogComPrintf("\n!!Assertion Failed!!\n"
    144                    "Expression: %s\n"
    145                    "Location  : %s(%d) %s\n",
    146                    pszExpr, pszFile, uLine, pszFunction);
    147 #endif
    148 
    149     PRTLOGGER pLog = RTLogRelDefaultInstance();
    150     if (pLog)
    151     {
    152         RTLogRelPrintf("\n!!Assertion Failed!!\n"
    153                        "Expression: %s\n"
    154                        "Location  : %s(%d) %s\n",
    155                        pszExpr, pszFile, uLine, pszFunction);
    156         RTLogFlush(pLog);
    157     }
    158 
    159     pLog = RTLogDefaultInstance();
    160     if (pLog)
    161     {
    162         RTLogPrintf("\n!!Assertion Failed!!\n"
    163                     "Expression: %s\n"
    164                     "Location  : %s(%d) %s\n",
    165                     pszExpr, pszFile, uLine, pszFunction);
    166         RTLogFlush(pLog);
    167     }
    168 
    169 #ifdef IN_RING3
    170     /* print to stderr, helps user and gdb debugging. */
    171     fprintf(stderr,
    172             "\n!!Assertion Failed!!\n"
    173             "Expression: %s\n"
    174             "Location  : %s(%d) %s\n",
    175             pszExpr, pszFile, uLine, pszFunction);
    176     fflush(stderr);
    177 #endif
    178 
    179     RTStrPrintf(g_szRTAssertMsg1, sizeof(g_szRTAssertMsg1),
    180                 "\n!!Assertion Failed!!\n"
    181                 "Expression: %s\n"
    182                 "Location  : %s(%d) %s\n",
    183                 pszExpr, pszFile, uLine, pszFunction);
    184 }
    185 
    186 
    187 /**
    188  * The 2nd (optional) part of an assert message.
    189  *
    190  * @param   pszFormat   Printf like format string.
    191  * @param   ...         Arguments to that string.
    192  * @remark  This API exists in HC Ring-3 and GC.
    193  */
    194 RTDECL(void)    AssertMsg2(const char *pszFormat, ...)
    195 {
    196     va_list args;
    197 
    198 #if !defined(IN_RING3) && !defined(LOG_NO_COM)
    199     va_start(args, pszFormat);
    200     RTLogComPrintfV(pszFormat, args);
    201     va_end(args);
    202 #endif
    203 
    204     PRTLOGGER pLog = RTLogRelDefaultInstance();
    205     if (pLog)
    206     {
    207         va_start(args, pszFormat);
    208         RTLogRelPrintfV(pszFormat, args);
    209         va_end(args);
    210         RTLogFlush(pLog);
    211     }
    212 
    213     pLog = RTLogDefaultInstance();
    214     if (pLog)
    215     {
    216         va_start(args, pszFormat);
    217         RTLogPrintfV(pszFormat, args);
    218         va_end(args);
    219         RTLogFlush(pLog);
    220     }
    221 
    222 #ifdef IN_RING3
    223     /* print to stderr, helps user and gdb debugging. */
    224     char szMsg[1024];
    225     va_start(args, pszFormat);
    226     RTStrPrintfV(szMsg, sizeof(szMsg), pszFormat, args);
    227     va_end(args);
    228     fprintf(stderr, "%s", szMsg);
    229     fflush(stderr);
    230 #endif
    231 
    232     va_start(args, pszFormat);
    233     RTStrPrintfV(g_szRTAssertMsg2, sizeof(g_szRTAssertMsg2), pszFormat, args);
    234     va_end(args);
    235 }
    236 
    237 #endif /* !IN_RING0 */
    238 
    239 
    240 /**
    241  * Check if we really want to hit a breakpoint.
    242  * Can jump back to ring-3 when the longjmp is armed.
    243  */
    244 RTDECL(bool) RTAssertDoBreakpoint(void)
     37RTDECL(bool)    RTAssertDoBreakpoint(void)
    24538{
    24639    return true;
    24740}
     41
Note: See TracChangeset for help on using the changeset viewer.

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