Changeset 8663 in vbox
- Timestamp:
- May 7, 2008 3:15:05 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/log.h
r8627 r8663 292 292 { 293 293 /** The logger instance is disabled for normal output. */ 294 RTLOGFLAGS_DISABLED = 0x00000001,294 RTLOGFLAGS_DISABLED = 0x00000001, 295 295 /** The logger instance is using buffered output. */ 296 RTLOGFLAGS_BUFFERED = 0x00000002,296 RTLOGFLAGS_BUFFERED = 0x00000002, 297 297 /** The logger instance expands LF to CR/LF. */ 298 RTLOGFLAGS_USECRLF = 0x00000010,298 RTLOGFLAGS_USECRLF = 0x00000010, 299 299 /** Show relative timestamps with PREFIX_TSC and PREFIX_TS */ 300 RTLOGFLAGS_REL_TS = 0x00000020,300 RTLOGFLAGS_REL_TS = 0x00000020, 301 301 /** Show decimal timestamps with PREFIX_TSC and PREFIX_TS */ 302 RTLOGFLAGS_DECIMAL_TS = 0x00000040, 303 /** New lines should be reprefixed with the CPU id (ApicID on intel/amd). */ 304 RTLOGFLAGS_PREFIX_CPUID = 0x00010000, 302 RTLOGFLAGS_DECIMAL_TS = 0x00000040, 303 /** New lines should be prefixed with the write and read lock counts. */ 304 RTLOGFLAGS_PREFIX_LOCK_COUNTS = 0x00008000, 305 /** New lines should be prefixed with the CPU id (ApicID on intel/amd). */ 306 RTLOGFLAGS_PREFIX_CPUID = 0x00010000, 305 307 /** New lines should be prefixed with the native process id. */ 306 RTLOGFLAGS_PREFIX_PID = 0x00020000,308 RTLOGFLAGS_PREFIX_PID = 0x00020000, 307 309 /** New lines should be prefixed with group flag number causing the output. */ 308 RTLOGFLAGS_PREFIX_FLAG_NO = 0x00040000,310 RTLOGFLAGS_PREFIX_FLAG_NO = 0x00040000, 309 311 /** New lines should be prefixed with group flag name causing the output. */ 310 RTLOGFLAGS_PREFIX_FLAG = 0x00080000,312 RTLOGFLAGS_PREFIX_FLAG = 0x00080000, 311 313 /** New lines should be prefixed with group number. */ 312 RTLOGFLAGS_PREFIX_GROUP_NO = 0x00100000,314 RTLOGFLAGS_PREFIX_GROUP_NO = 0x00100000, 313 315 /** New lines should be prefixed with group name. */ 314 RTLOGFLAGS_PREFIX_GROUP = 0x00200000,316 RTLOGFLAGS_PREFIX_GROUP = 0x00200000, 315 317 /** New lines should be prefixed with the native thread id. */ 316 RTLOGFLAGS_PREFIX_TID = 0x00400000,318 RTLOGFLAGS_PREFIX_TID = 0x00400000, 317 319 /** New lines should be prefixed with thread name. */ 318 RTLOGFLAGS_PREFIX_THREAD = 0x00800000,320 RTLOGFLAGS_PREFIX_THREAD = 0x00800000, 319 321 /** New lines should be prefixed with formatted timestamp since program start. */ 320 RTLOGFLAGS_PREFIX_TIME_PROG = 0x04000000,322 RTLOGFLAGS_PREFIX_TIME_PROG = 0x04000000, 321 323 /** New lines should be prefixed with formatted timestamp (UCT). */ 322 RTLOGFLAGS_PREFIX_TIME = 0x08000000,324 RTLOGFLAGS_PREFIX_TIME = 0x08000000, 323 325 /** New lines should be prefixed with milliseconds since program start. */ 324 RTLOGFLAGS_PREFIX_MS_PROG = 0x10000000,326 RTLOGFLAGS_PREFIX_MS_PROG = 0x10000000, 325 327 /** New lines should be prefixed with timestamp. */ 326 RTLOGFLAGS_PREFIX_TSC = 0x20000000,328 RTLOGFLAGS_PREFIX_TSC = 0x20000000, 327 329 /** New lines should be prefixed with timestamp. */ 328 RTLOGFLAGS_PREFIX_TS = 0x40000000,330 RTLOGFLAGS_PREFIX_TS = 0x40000000, 329 331 /** The prefix mask. */ 330 RTLOGFLAGS_PREFIX_MASK = 0x7cff0000332 RTLOGFLAGS_PREFIX_MASK = 0x7cff8000 331 333 } RTLOGFLAGS; 332 334 -
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.