VirtualBox

Changeset 8663 in vbox


Ignore:
Timestamp:
May 7, 2008 3:15:05 PM (17 years ago)
Author:
vboxsync
Message:

New logger prefix: lockcnts Output: read/write

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/log.h

    r8627 r8663  
    292292{
    293293    /** The logger instance is disabled for normal output. */
    294     RTLOGFLAGS_DISABLED         = 0x00000001,
     294    RTLOGFLAGS_DISABLED             = 0x00000001,
    295295    /** The logger instance is using buffered output. */
    296     RTLOGFLAGS_BUFFERED         = 0x00000002,
     296    RTLOGFLAGS_BUFFERED             = 0x00000002,
    297297    /** The logger instance expands LF to CR/LF. */
    298     RTLOGFLAGS_USECRLF          = 0x00000010,
     298    RTLOGFLAGS_USECRLF              = 0x00000010,
    299299    /** Show relative timestamps with PREFIX_TSC and PREFIX_TS */
    300     RTLOGFLAGS_REL_TS           = 0x00000020,
     300    RTLOGFLAGS_REL_TS               = 0x00000020,
    301301    /** 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,
    305307    /** New lines should be prefixed with the native process id. */
    306     RTLOGFLAGS_PREFIX_PID       = 0x00020000,
     308    RTLOGFLAGS_PREFIX_PID           = 0x00020000,
    307309    /** New lines should be prefixed with group flag number causing the output. */
    308     RTLOGFLAGS_PREFIX_FLAG_NO   = 0x00040000,
     310    RTLOGFLAGS_PREFIX_FLAG_NO       = 0x00040000,
    309311    /** New lines should be prefixed with group flag name causing the output. */
    310     RTLOGFLAGS_PREFIX_FLAG      = 0x00080000,
     312    RTLOGFLAGS_PREFIX_FLAG          = 0x00080000,
    311313    /** New lines should be prefixed with group number. */
    312     RTLOGFLAGS_PREFIX_GROUP_NO  = 0x00100000,
     314    RTLOGFLAGS_PREFIX_GROUP_NO      = 0x00100000,
    313315    /** New lines should be prefixed with group name. */
    314     RTLOGFLAGS_PREFIX_GROUP     = 0x00200000,
     316    RTLOGFLAGS_PREFIX_GROUP         = 0x00200000,
    315317    /** New lines should be prefixed with the native thread id. */
    316     RTLOGFLAGS_PREFIX_TID       = 0x00400000,
     318    RTLOGFLAGS_PREFIX_TID           = 0x00400000,
    317319    /** New lines should be prefixed with thread name. */
    318     RTLOGFLAGS_PREFIX_THREAD    = 0x00800000,
     320    RTLOGFLAGS_PREFIX_THREAD        = 0x00800000,
    319321    /** New lines should be prefixed with formatted timestamp since program start. */
    320     RTLOGFLAGS_PREFIX_TIME_PROG = 0x04000000,
     322    RTLOGFLAGS_PREFIX_TIME_PROG     = 0x04000000,
    321323    /** New lines should be prefixed with formatted timestamp (UCT). */
    322     RTLOGFLAGS_PREFIX_TIME      = 0x08000000,
     324    RTLOGFLAGS_PREFIX_TIME          = 0x08000000,
    323325    /** New lines should be prefixed with milliseconds since program start. */
    324     RTLOGFLAGS_PREFIX_MS_PROG   = 0x10000000,
     326    RTLOGFLAGS_PREFIX_MS_PROG       = 0x10000000,
    325327    /** New lines should be prefixed with timestamp. */
    326     RTLOGFLAGS_PREFIX_TSC       = 0x20000000,
     328    RTLOGFLAGS_PREFIX_TSC           = 0x20000000,
    327329    /** New lines should be prefixed with timestamp. */
    328     RTLOGFLAGS_PREFIX_TS        = 0x40000000,
     330    RTLOGFLAGS_PREFIX_TS            = 0x40000000,
    329331    /** The prefix mask. */
    330     RTLOGFLAGS_PREFIX_MASK      = 0x7cff0000
     332    RTLOGFLAGS_PREFIX_MASK          = 0x7cff8000
    331333} RTLOGFLAGS;
    332334
  • trunk/src/VBox/Runtime/common/log/log.cpp

    r8274 r8663  
    103103static PRTLOGGER                    g_pRelLogger;
    104104#endif /* !IN_GC */
     105#ifdef IN_RING3
     106/** The RTThreadGetWriteLockCount() change caused by the logger mutex semaphore. */
     107static uint32_t volatile            g_cLoggerLockCount;
     108#endif
    105109#ifdef IN_RING0
    106110/** Number of per-thread loggers. */
     
    413417
    414418            /*
    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.
    416421             */
    417422            if (RT_SUCCESS(rc))
     
    420425                if (RT_SUCCESS(rc))
    421426                {
     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
    422438                    *ppLogger = pLogger;
    423439                    return VINF_SUCCESS;
    424440                }
    425                 else if (pszErrorMsg)
     441
     442                if (pszErrorMsg)
    426443                    RTStrPrintf(pszErrorMsg, cchErrorMsg, "failed to create sempahore");
    427444            }
     
    12141231            { "dec",          sizeof("dec"         ) - 1,   RTLOGFLAGS_DECIMAL_TS,          false },
    12151232            { "hex",          sizeof("hex"         ) - 1,   RTLOGFLAGS_DECIMAL_TS,          true  },
     1233            { "lockcnts",     sizeof("lockcnts"    ) - 1,   RTLOGFLAGS_PREFIX_LOCK_COUNTS,  false },
    12161234            { "cpuid",        sizeof("cpuid"       ) - 1,   RTLOGFLAGS_PREFIX_CPUID,        false },
    12171235            { "pid",          sizeof("pid"         ) - 1,   RTLOGFLAGS_PREFIX_PID,          false },
     
    19171935                /*
    19181936                 * Flush the buffer if there isn't enough room for the maximum prefix config.
    1919                  * Max is 214, add a couple of extra bytes.
     1937                 * Max is 224, add a couple of extra bytes.
    19201938                 */
    1921                 if (cb < 214 + 16)
     1939                if (cb < 224 + 16)
    19221940                {
    19231941                    rtlogFlush(pLogger);
     
    20932111                    psz += RTStrFormatNumber(psz, idCpu, 16, sizeof(idCpu) * 2, 0, RTSTR_F_ZEROPAD);
    20942112                    *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 */
    20952140                }
    20962141                if (pLogger->fFlags & RTLOGFLAGS_PREFIX_FLAG_NO)
Note: See TracChangeset for help on using the changeset viewer.

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