Changeset 25528 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Dec 20, 2009 11:24:59 PM (15 years ago)
- Location:
- trunk/src/VBox/Runtime/common/misc
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/RTAssertMsg1Weak.cpp
r21337 r25528 39 39 40 40 41 RTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)41 RTDECL(void) RTAssertMsg1Weak(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction) 42 42 { 43 43 RTAssertMsg1(pszExpr, uLine, pszFile, pszFunction); 44 44 } 45 RT_EXPORT_SYMBOL( AssertMsg1);45 RT_EXPORT_SYMBOL(RTAssertMsg1Weak); 46 46 -
trunk/src/VBox/Runtime/common/misc/RTAssertMsg2Weak.cpp
r21337 r25528 5 5 6 6 /* 7 * Copyright (C) 2008 Sun Microsystems, Inc.7 * Copyright (C) 2008-2009 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 39 39 40 40 41 RTDECL(void) AssertMsg2(const char *pszFormat, ...)41 RTDECL(void) RTAssertMsg2Weak(const char *pszFormat, ...) 42 42 { 43 43 va_list va; 44 44 va_start(va, pszFormat); 45 RTAssertMsg2 V(pszFormat, va);45 RTAssertMsg2WeakV(pszFormat, va); 46 46 va_end(va); 47 47 } 48 RT_EXPORT_SYMBOL( AssertMsg2);48 RT_EXPORT_SYMBOL(RTAssertMsg2Weak); 49 49 -
trunk/src/VBox/Runtime/common/misc/assert.cpp
r25525 r25528 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Assertion Workers.3 * IPRT - Assertions, common code. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-200 7Sun Microsystems, Inc.7 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 43 43 # include <stdio.h> 44 44 #endif 45 #include "internal/assert.h" 45 46 46 47 … … 48 49 * Global Variables * 49 50 *******************************************************************************/ 51 /** The last assert message, 1st part. */ 52 RTDATADECL(char) g_szRTAssertMsg1[1024]; 53 RT_EXPORT_SYMBOL(g_szRTAssertMsg1); 54 /** The last assert message, 2nd part. */ 55 RTDATADECL(char) g_szRTAssertMsg2[2048]; 56 RT_EXPORT_SYMBOL(g_szRTAssertMsg2); 57 /** The last assert message, expression. */ 58 RTDATADECL(const char * volatile) g_pszRTAssertExpr; 59 RT_EXPORT_SYMBOL(g_pszRTAssertExpr); 60 /** The last assert message, function name. */ 61 RTDATADECL(const char * volatile) g_pszRTAssertFunction; 62 RT_EXPORT_SYMBOL(g_pszRTAssertFunction); 63 /** The last assert message, file name. */ 64 RTDATADECL(const char * volatile) g_pszRTAssertFile; 65 RT_EXPORT_SYMBOL(g_pszRTAssertFile); 66 /** The last assert message, line number. */ 67 RTDATADECL(uint32_t volatile) g_u32RTAssertLine; 68 RT_EXPORT_SYMBOL(g_u32RTAssertLine); 69 70 50 71 /** Set if assertions are quiet. */ 51 static bool volatile g_fQuiet = false;72 static bool volatile g_fQuiet = false; 52 73 /** Set if assertions may panic. */ 53 static bool volatile g_fMayPanic = true;74 static bool volatile g_fMayPanic = true; 54 75 55 76 … … 58 79 return ASMAtomicXchgBool(&g_fQuiet, fQuiet); 59 80 } 81 RT_EXPORT_SYMBOL(RTAssertSetQuiet); 60 82 61 83 … … 64 86 return ASMAtomicUoReadBool(&g_fQuiet); 65 87 } 88 RT_EXPORT_SYMBOL(RTAssertAreQuiet); 66 89 67 90 … … 70 93 return ASMAtomicXchgBool(&g_fMayPanic, fMayPanic); 71 94 } 95 RT_EXPORT_SYMBOL(RTAssertSetMayPanic); 72 96 73 97 … … 76 100 return ASMAtomicUoReadBool(&g_fMayPanic); 77 101 } 78 79 80 #ifdef IN_RING0 81 82 /* OS specific. */ 83 84 #else /* !IN_RING0 */ 85 86 87 /** The last assert message, 1st part. */ 88 RTDATADECL(char) g_szRTAssertMsg1[1024]; 89 /** The last assert message, 2nd part. */ 90 RTDATADECL(char) g_szRTAssertMsg2[2048]; 91 92 /** 93 * The 1st part of an assert message. 94 * 95 * @param pszExpr Expression. Can be NULL. 96 * @param uLine Location line number. 97 * @param pszFile Location file name. 98 * @param pszFunction Location function name. 99 * @remark This API exists in HC Ring-3 and GC. 100 */ 101 RTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction) 102 { 102 RT_EXPORT_SYMBOL(RTAssertMayPanic); 103 104 105 RTDECL(void) RTAssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction) 106 { 107 /* 108 * Fill in the globals. 109 */ 110 ASMAtomicUoWritePtr((void * volatile *)&g_pszRTAssertExpr, (void *)pszExpr); 111 ASMAtomicUoWritePtr((void * volatile *)&g_pszRTAssertFile, (void *)pszFile); 112 ASMAtomicUoWritePtr((void * volatile *)&g_pszRTAssertFunction, (void *)pszFunction); 113 ASMAtomicUoWriteU32(&g_u32RTAssertLine, uLine); 114 RTStrPrintf(g_szRTAssertMsg1, sizeof(g_szRTAssertMsg1), 115 "\n!!Assertion Failed!!\n" 116 "Expression: %s\n" 117 "Location : %s(%d) %s\n", 118 pszExpr, pszFile, uLine, pszFunction); 119 120 /* 121 * If not quiet, make noise. 122 */ 103 123 if (!RTAssertAreQuiet()) 104 124 { 105 #if !defined(IN_RING3) && !defined(LOG_NO_COM) 125 #ifdef IN_RING0 126 # ifdef IN_GUEST_R0 127 RTLogBackdoorPrintf("\n!!Assertion Failed!!\n" 128 "Expression: %s\n" 129 "Location : %s(%d) %s\n", 130 pszExpr, pszFile, uLine, pszFunction); 131 # endif 132 /** @todo fully integrate this with the logger... play safe a bit for now. */ 133 rtR0AssertNativeMsg1(pszExpr, uLine, pszFile, pszFunction); 134 135 #else /* !IN_RING0 */ 136 # if !defined(IN_RING3) && !defined(LOG_NO_COM) 106 137 RTLogComPrintf("\n!!Assertion Failed!!\n" 107 138 "Expression: %s\n" 108 139 "Location : %s(%d) %s\n", 109 140 pszExpr, pszFile, uLine, pszFunction); 110 # endif141 # endif 111 142 112 143 PRTLOGGER pLog = RTLogRelDefaultInstance(); … … 117 148 "Location : %s(%d) %s\n", 118 149 pszExpr, pszFile, uLine, pszFunction); 119 # ifndef IN_RC /* flushing is done automatically in RC */150 # ifndef IN_RC /* flushing is done automatically in RC */ 120 151 RTLogFlush(pLog); 121 # endif122 } 123 124 # ifndef LOG_ENABLED152 # endif 153 } 154 155 # ifndef LOG_ENABLED 125 156 if (!pLog) 126 # endif157 # endif 127 158 { 128 159 pLog = RTLogDefaultInstance(); … … 133 164 "Location : %s(%d) %s\n", 134 165 pszExpr, pszFile, uLine, pszFunction); 135 # ifndef IN_RC /* flushing is done automatically in RC */166 # ifndef IN_RC /* flushing is done automatically in RC */ 136 167 RTLogFlush(pLog); 137 # endif168 # endif 138 169 } 139 170 } 140 171 141 # ifdef IN_RING3172 # ifdef IN_RING3 142 173 /* print to stderr, helps user and gdb debugging. */ 143 174 fprintf(stderr, … … 150 181 VALID_PTR(pszFunction) ? pszFunction : ""); 151 182 fflush(stderr); 152 #endif 183 # endif 184 #endif /* !IN_RING0 */ 153 185 } 154 155 RTStrPrintf(g_szRTAssertMsg1, sizeof(g_szRTAssertMsg1), 156 "\n!!Assertion Failed!!\n" 157 "Expression: %s\n" 158 "Location : %s(%d) %s\n", 159 pszExpr, pszFile, uLine, pszFunction); 160 } 161 162 163 /** 164 * The 2nd (optional) part of an assert message. 165 * 166 * @param pszFormat Printf like format string. 167 * @param ... Arguments to that string. 168 * @remark This API exists in HC Ring-3 and GC. 169 */ 170 RTDECL(void) AssertMsg2(const char *pszFormat, ...) 171 { 172 va_list args; 173 186 } 187 RT_EXPORT_SYMBOL(RTAssertMsg1); 188 189 190 RTDECL(void) RTAssertMsg2V(const char *pszFormat, va_list va) 191 { 192 va_list vaCopy; 193 194 /* 195 * The global first. 196 */ 197 va_copy(vaCopy, va); 198 RTStrPrintfV(g_szRTAssertMsg2, sizeof(g_szRTAssertMsg2), pszFormat, vaCopy); 199 va_end(vaCopy); 200 201 /* 202 * If not quiet, make some noise. 203 */ 174 204 if (!RTAssertAreQuiet()) 175 205 { 176 #if !defined(IN_RING3) && !defined(LOG_NO_COM) 177 va_start(args, pszFormat); 178 RTLogComPrintfV(pszFormat, args); 179 va_end(args); 180 #endif 206 #ifdef IN_RING0 207 # ifdef IN_GUEST_R0 208 va_copy(vaCopy, va); 209 RTLogBackdoorPrintfV(pszFormat, vaCopy); 210 va_end(vaCopy); 211 # endif 212 /** @todo fully integrate this with the logger... play safe a bit for now. */ 213 rtR0AssertNativeMsg2V(pszFormat, va); 214 215 #else /* !IN_RING0 */ 216 # if !defined(IN_RING3) && !defined(LOG_NO_COM) 217 va_copy(vaCopy, va); 218 RTLogComPrintfV(pszFormat, vaCopy); 219 va_end(vaCopy); 220 # endif 181 221 182 222 PRTLOGGER pLog = RTLogRelDefaultInstance(); 183 223 if (pLog) 184 224 { 185 va_start(args, pszFormat); 186 RTLogRelPrintfV(pszFormat, args); 187 va_end(args); 188 #ifndef IN_RC /* flushing is done automatically in RC */ 225 va_copy(vaCopy, va); 226 RTLogRelPrintfV(pszFormat, vaCopy); 227 va_end(vaCopy); 228 # ifndef IN_RC /* flushing is done automatically in RC */ 229 RTLogFlush(pLog); 230 # endif 231 } 232 233 pLog = RTLogDefaultInstance(); 234 if (pLog) 235 { 236 va_copy(vaCopy, va); 237 RTLogPrintfV(pszFormat, vaCopy); 238 va_end(vaCopy); 239 # ifndef IN_RC /* flushing is done automatically in RC */ 189 240 RTLogFlush(pLog); 190 241 #endif 191 242 } 192 243 193 pLog = RTLogDefaultInstance(); 194 if (pLog) 195 { 196 va_start(args, pszFormat); 197 RTLogPrintfV(pszFormat, args); 198 va_end(args); 199 #ifndef IN_RC /* flushing is done automatically in RC */ 200 RTLogFlush(pLog); 201 #endif 202 } 203 204 #ifdef IN_RING3 244 # ifdef IN_RING3 205 245 /* print to stderr, helps user and gdb debugging. */ 206 246 char szMsg[1024]; 207 va_ start(args, pszFormat);208 RTStrPrintfV(szMsg, sizeof(szMsg), pszFormat, args);209 va_end( args);247 va_copy(vaCopy, va); 248 RTStrPrintfV(szMsg, sizeof(szMsg), pszFormat, vaCopy); 249 va_end(vaCopy); 210 250 fprintf(stderr, "%s", szMsg); 211 251 fflush(stderr); 212 #endif 252 # endif 253 #endif /* !IN_RING0 */ 213 254 } 214 255 215 va_start(args, pszFormat); 216 RTStrPrintfV(g_szRTAssertMsg2, sizeof(g_szRTAssertMsg2), pszFormat, args); 217 va_end(args); 218 } 219 220 #endif /* !IN_RING0 */ 221 256 } 257 RT_EXPORT_SYMBOL(RTAssertMsg2V); 258 -
trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp
r25519 r25528 819 819 PRTTHREADINT pCur, PCRTLOCKVALIDATORSRCPOS pSrcPos) 820 820 { 821 AssertMsg1(pCur == pThread ? "!!Deadlock detected!!" : "!!Deadlock exists!!", pSrcPos->uLine, pSrcPos->pszFile, pSrcPos->pszFunction);821 RTAssertMsg1Weak(pCur == pThread ? "!!Deadlock detected!!" : "!!Deadlock exists!!", pSrcPos->uLine, pSrcPos->pszFile, pSrcPos->pszFunction); 822 822 823 823 /* … … 832 832 * Print info on pCur. Determin next while doing so. 833 833 */ 834 AssertMsg2(" #%u: %RTthrd/%RTnthrd %s: %s(%u) %RTptr\n",835 iEntry, pCur, pCur->Core.Key, pCur->szName,836 pCur->LockValidator.SrcPos.pszFile, pCur->LockValidator.SrcPos.uLine,837 pCur->LockValidator.SrcPos.pszFunction, pCur->LockValidator.SrcPos.uId);834 RTAssertMsg2Weak(" #%u: %RTthrd/%RTnthrd %s: %s(%u) %RTptr\n", 835 iEntry, pCur, pCur->Core.Key, pCur->szName, 836 pCur->LockValidator.SrcPos.pszFile, pCur->LockValidator.SrcPos.uLine, 837 pCur->LockValidator.SrcPos.pszFunction, pCur->LockValidator.SrcPos.uId); 838 838 PRTTHREADINT pNext = NULL; 839 839 RTTHREADSTATE enmCurState = rtThreadGetState(pCur); … … 853 853 if (enmCurState2 != enmCurState) 854 854 { 855 AssertMsg2(" Impossible!!! enmState=%s -> %s (%d)\n",856 RTThreadStateName(enmCurState), RTThreadStateName(enmCurState2), enmCurState2);855 RTAssertMsg2Weak(" Impossible!!! enmState=%s -> %s (%d)\n", 856 RTThreadStateName(enmCurState), RTThreadStateName(enmCurState2), enmCurState2); 857 857 break; 858 858 } … … 860 860 && pCurRec->u32Magic == RTLOCKVALIDATORREC_MAGIC) 861 861 { 862 AssertMsg2(" Waiting on %s %p [%s]: Entered %s(%u) %s %p\n",863 RTThreadStateName(enmCurState), pCurRec->hLock, pCurRec->pszName,864 pCurRec->SrcPos.pszFile, pCurRec->SrcPos.uLine, pCurRec->SrcPos.pszFunction, pCurRec->SrcPos.uId);862 RTAssertMsg2Weak(" Waiting on %s %p [%s]: Entered %s(%u) %s %p\n", 863 RTThreadStateName(enmCurState), pCurRec->hLock, pCurRec->pszName, 864 pCurRec->SrcPos.pszFile, pCurRec->SrcPos.uLine, pCurRec->SrcPos.pszFunction, pCurRec->SrcPos.uId); 865 865 pNext = pCurRec->hThread; 866 866 } 867 867 else if (VALID_PTR(pCurRec)) 868 AssertMsg2(" Waiting on %s pCurRec=%p: invalid magic number: %#x\n",869 RTThreadStateName(enmCurState), pCurRec, pCurRec->u32Magic);868 RTAssertMsg2Weak(" Waiting on %s pCurRec=%p: invalid magic number: %#x\n", 869 RTThreadStateName(enmCurState), pCurRec, pCurRec->u32Magic); 870 870 else 871 AssertMsg2(" Waiting on %s pCurRec=%p: invalid pointer\n",872 RTThreadStateName(enmCurState), pCurRec);871 RTAssertMsg2Weak(" Waiting on %s pCurRec=%p: invalid pointer\n", 872 RTThreadStateName(enmCurState), pCurRec); 873 873 break; 874 874 } 875 875 876 876 default: 877 AssertMsg2(" Impossible!!! enmState=%s (%d)\n", RTThreadStateName(enmCurState), enmCurState);877 RTAssertMsg2Weak(" Impossible!!! enmState=%s (%d)\n", RTThreadStateName(enmCurState), enmCurState); 878 878 break; 879 879 } … … 887 887 if (apSeenThreads[i] == pCur) 888 888 { 889 AssertMsg2(" Cycle!\n");889 RTAssertMsg2Weak(" Cycle!\n"); 890 890 pNext = NULL; 891 891 break; -
trunk/src/VBox/Runtime/common/misc/thread.cpp
r25436 r25528 192 192 g_ThreadSpinlock = NIL_RTSPINLOCK; 193 193 if (g_ThreadTree != NULL) 194 AssertMsg2("WARNING: g_ThreadTree=%p\n", g_ThreadTree);194 RTAssertMsg2Weak("WARNING: g_ThreadTree=%p\n", g_ThreadTree); 195 195 #endif 196 196 }
Note:
See TracChangeset
for help on using the changeset viewer.