Changeset 25518 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Dec 20, 2009 4:40:37 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/assert.cpp
r21412 r25518 36 36 #include "internal/iprt.h" 37 37 38 #include <iprt/asm.h> 38 39 #include <iprt/log.h> 39 40 #include <iprt/string.h> … … 42 43 # include <stdio.h> 43 44 #endif 45 46 47 /******************************************************************************* 48 * Global Variables * 49 *******************************************************************************/ 50 /** Set if assertions are quiet. */ 51 static bool volatile g_fQuiet = false; 52 /** Set if assertions may panic. */ 53 static bool volatile g_fMayPanic = true; 54 55 56 RTDECL(bool) RTAssertSetQuiet(bool fQuiet) 57 { 58 return ASMAtomicXchgBool(&g_fQuiet, fQuiet); 59 } 60 61 62 RTDECL(bool) RTAssertAreQuiet(void) 63 { 64 return ASMAtomicUoReadBool(&g_fQuiet); 65 } 66 67 68 RTDECL(bool) RTAssertSetMayPanic(bool fMayPanic) 69 { 70 return ASMAtomicXchgBool(&g_fMayPanic, fMayPanic); 71 } 72 73 74 RTDECL(bool) RTAssertMayPanic(void) 75 { 76 return ASMAtomicUoReadBool(&g_fMayPanic); 77 } 44 78 45 79 … … 111 145 RTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction) 112 146 { 147 if (!RTAssertAreQuiet()) 148 { 113 149 #if !defined(IN_RING3) && !defined(LOG_NO_COM) 114 RTLogComPrintf("\n!!Assertion Failed!!\n" 115 "Expression: %s\n" 116 "Location : %s(%d) %s\n", 117 pszExpr, pszFile, uLine, pszFunction); 118 #endif 119 120 PRTLOGGER pLog = RTLogRelDefaultInstance(); 121 if (pLog) 122 { 123 RTLogRelPrintf("\n!!Assertion Failed!!\n" 150 RTLogComPrintf("\n!!Assertion Failed!!\n" 124 151 "Expression: %s\n" 125 152 "Location : %s(%d) %s\n", 126 153 pszExpr, pszFile, uLine, pszFunction); 127 #ifndef IN_RC /* flushing is done automatically in RC */ 128 RTLogFlush(pLog); 154 #endif 155 156 PRTLOGGER pLog = RTLogRelDefaultInstance(); 157 if (pLog) 158 { 159 RTLogRelPrintf("\n!!Assertion Failed!!\n" 160 "Expression: %s\n" 161 "Location : %s(%d) %s\n", 162 pszExpr, pszFile, uLine, pszFunction); 163 #ifndef IN_RC /* flushing is done automatically in RC */ 164 RTLogFlush(pLog); 165 #endif 166 } 167 168 #ifndef LOG_ENABLED 169 if (!pLog) 170 #endif 171 { 172 pLog = RTLogDefaultInstance(); 173 if (pLog) 174 { 175 RTLogPrintf("\n!!Assertion Failed!!\n" 176 "Expression: %s\n" 177 "Location : %s(%d) %s\n", 178 pszExpr, pszFile, uLine, pszFunction); 179 #ifndef IN_RC /* flushing is done automatically in RC */ 180 RTLogFlush(pLog); 181 #endif 182 } 183 } 184 185 #ifdef IN_RING3 186 /* print to stderr, helps user and gdb debugging. */ 187 fprintf(stderr, 188 "\n!!Assertion Failed!!\n" 189 "Expression: %s\n" 190 "Location : %s(%d) %s\n", 191 VALID_PTR(pszExpr) ? pszExpr : "<none>", 192 VALID_PTR(pszFile) ? pszFile : "<none>", 193 uLine, 194 VALID_PTR(pszFunction) ? pszFunction : ""); 195 fflush(stderr); 129 196 #endif 130 197 } 131 132 #ifndef LOG_ENABLED133 if (!pLog)134 #endif135 {136 pLog = RTLogDefaultInstance();137 if (pLog)138 {139 RTLogPrintf("\n!!Assertion Failed!!\n"140 "Expression: %s\n"141 "Location : %s(%d) %s\n",142 pszExpr, pszFile, uLine, pszFunction);143 #ifndef IN_RC /* flushing is done automatically in RC */144 RTLogFlush(pLog);145 #endif146 }147 }148 149 #ifdef IN_RING3150 /* print to stderr, helps user and gdb debugging. */151 fprintf(stderr,152 "\n!!Assertion Failed!!\n"153 "Expression: %s\n"154 "Location : %s(%d) %s\n",155 VALID_PTR(pszExpr) ? pszExpr : "<none>",156 VALID_PTR(pszFile) ? pszFile : "<none>",157 uLine,158 VALID_PTR(pszFunction) ? pszFunction : "");159 fflush(stderr);160 #endif161 198 162 199 RTStrPrintf(g_szRTAssertMsg1, sizeof(g_szRTAssertMsg1), … … 179 216 va_list args; 180 217 218 if (!RTAssertAreQuiet()) 219 { 181 220 #if !defined(IN_RING3) && !defined(LOG_NO_COM) 182 va_start(args, pszFormat);183 RTLogComPrintfV(pszFormat, args);184 va_end(args);185 #endif186 187 PRTLOGGER pLog = RTLogRelDefaultInstance();188 if (pLog)189 {190 221 va_start(args, pszFormat); 191 RTLog RelPrintfV(pszFormat, args);222 RTLogComPrintfV(pszFormat, args); 192 223 va_end(args); 193 #ifndef IN_RC /* flushing is done automatically in RC */ 194 RTLogFlush(pLog); 224 #endif 225 226 PRTLOGGER pLog = RTLogRelDefaultInstance(); 227 if (pLog) 228 { 229 va_start(args, pszFormat); 230 RTLogRelPrintfV(pszFormat, args); 231 va_end(args); 232 #ifndef IN_RC /* flushing is done automatically in RC */ 233 RTLogFlush(pLog); 234 #endif 235 } 236 237 pLog = RTLogDefaultInstance(); 238 if (pLog) 239 { 240 va_start(args, pszFormat); 241 RTLogPrintfV(pszFormat, args); 242 va_end(args); 243 #ifndef IN_RC /* flushing is done automatically in RC */ 244 RTLogFlush(pLog); 245 #endif 246 } 247 248 #ifdef IN_RING3 249 /* print to stderr, helps user and gdb debugging. */ 250 char szMsg[1024]; 251 va_start(args, pszFormat); 252 RTStrPrintfV(szMsg, sizeof(szMsg), pszFormat, args); 253 va_end(args); 254 fprintf(stderr, "%s", szMsg); 255 fflush(stderr); 195 256 #endif 196 257 } 197 198 pLog = RTLogDefaultInstance();199 if (pLog)200 {201 va_start(args, pszFormat);202 RTLogPrintfV(pszFormat, args);203 va_end(args);204 #ifndef IN_RC /* flushing is done automatically in RC */205 RTLogFlush(pLog);206 #endif207 }208 209 #ifdef IN_RING3210 /* print to stderr, helps user and gdb debugging. */211 char szMsg[1024];212 va_start(args, pszFormat);213 RTStrPrintfV(szMsg, sizeof(szMsg), pszFormat, args);214 va_end(args);215 fprintf(stderr, "%s", szMsg);216 fflush(stderr);217 #endif218 258 219 259 va_start(args, pszFormat);
Note:
See TracChangeset
for help on using the changeset viewer.