Changeset 8663 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- May 7, 2008 3:15:05 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/log/log.cpp
r8274 r8663 103 103 static PRTLOGGER g_pRelLogger; 104 104 #endif /* !IN_GC */ 105 #ifdef IN_RING3 106 /** The RTThreadGetWriteLockCount() change caused by the logger mutex semaphore. */ 107 static uint32_t volatile g_cLoggerLockCount; 108 #endif 105 109 #ifdef IN_RING0 106 110 /** Number of per-thread loggers. */ … … 413 417 414 418 /* 415 * Create mutex. 419 * Create mutex and check how much it counts when entering the lock 420 * so that we can report the values for RTLOGFLAGS_PREFIX_LOCK_COUNTS. 416 421 */ 417 422 if (RT_SUCCESS(rc)) … … 420 425 if (RT_SUCCESS(rc)) 421 426 { 427 #ifdef IN_RING3 /** @todo do counters in ring-0 too? */ 428 RTTHREAD Thread = RTThreadSelf(); 429 if (Thread != NIL_RTTHREAD) 430 { 431 int32_t c = RTThreadGetWriteLockCount(Thread); 432 RTSemFastMutexRequest(pLogger->MutexSem); 433 c = RTThreadGetWriteLockCount(Thread) - c; 434 RTSemFastMutexRelease(pLogger->MutexSem); 435 ASMAtomicWriteU32(&g_cLoggerLockCount, c); 436 } 437 #endif 422 438 *ppLogger = pLogger; 423 439 return VINF_SUCCESS; 424 440 } 425 else if (pszErrorMsg) 441 442 if (pszErrorMsg) 426 443 RTStrPrintf(pszErrorMsg, cchErrorMsg, "failed to create sempahore"); 427 444 } … … 1214 1231 { "dec", sizeof("dec" ) - 1, RTLOGFLAGS_DECIMAL_TS, false }, 1215 1232 { "hex", sizeof("hex" ) - 1, RTLOGFLAGS_DECIMAL_TS, true }, 1233 { "lockcnts", sizeof("lockcnts" ) - 1, RTLOGFLAGS_PREFIX_LOCK_COUNTS, false }, 1216 1234 { "cpuid", sizeof("cpuid" ) - 1, RTLOGFLAGS_PREFIX_CPUID, false }, 1217 1235 { "pid", sizeof("pid" ) - 1, RTLOGFLAGS_PREFIX_PID, false }, … … 1917 1935 /* 1918 1936 * Flush the buffer if there isn't enough room for the maximum prefix config. 1919 * Max is 2 14, add a couple of extra bytes.1937 * Max is 224, add a couple of extra bytes. 1920 1938 */ 1921 if (cb < 2 14 + 16)1939 if (cb < 224 + 16) 1922 1940 { 1923 1941 rtlogFlush(pLogger); … … 2093 2111 psz += RTStrFormatNumber(psz, idCpu, 16, sizeof(idCpu) * 2, 0, RTSTR_F_ZEROPAD); 2094 2112 *psz++ = ' '; /* +17 */ 2113 } 2114 if (pLogger->fFlags & RTLOGFLAGS_PREFIX_LOCK_COUNTS) 2115 { 2116 #ifdef IN_RING3 /** @todo implement these counters in ring-0 too? */ 2117 RTTHREAD Thread = RTThreadSelf(); 2118 if (Thread != NIL_RTTHREAD) 2119 { 2120 uint32_t cReadLocks = RTThreadGetReadLockCount(Thread); 2121 uint32_t cWriteLocks = RTThreadGetWriteLockCount(Thread) - g_cLoggerLockCount; 2122 cReadLocks = RT_MIN(0xfff, cReadLocks); 2123 cWriteLocks = RT_MIN(0xfff, cWriteLocks); 2124 psz += RTStrFormatNumber(psz, cReadLocks, 16, 3, 0, RTSTR_F_ZEROPAD); 2125 *psz++ = '/'; 2126 psz += RTStrFormatNumber(psz, cWriteLocks, 16, 3, 0, RTSTR_F_ZEROPAD); 2127 } 2128 else 2129 #endif 2130 { 2131 *psz++ = '0'; 2132 *psz++ = '0'; 2133 *psz++ = '0'; 2134 *psz++ = '/'; 2135 *psz++ = '0'; 2136 *psz++ = '0'; 2137 *psz++ = '0'; 2138 } 2139 *psz++ = ' '; /* +8 */ 2095 2140 } 2096 2141 if (pLogger->fFlags & RTLOGFLAGS_PREFIX_FLAG_NO)
Note:
See TracChangeset
for help on using the changeset viewer.