VirtualBox

Changeset 6515 in vbox


Ignore:
Timestamp:
Jan 25, 2008 1:23:54 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
27525
Message:

Added a 'pid' prefix flag to the logger. This is primarily intended for ring-0 but may be useful in ring-3 as well.

Location:
trunk
Files:
3 edited

Legend:

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

    r5999 r6515  
    287287    RTLOGFLAGS_USECRLF          = 0x00000010,
    288288    /** Show relative timestamps with PREFIX_TSC and PREFIX_TS */
    289     RTLOGFLAGS_REL_TS           = 0x00010000,
     289    RTLOGFLAGS_REL_TS           = 0x00008000,
    290290    /** Show decimal timestamps with PREFIX_TSC and PREFIX_TS */
    291     RTLOGFLAGS_DECIMAL_TS       = 0x00020000,
     291    RTLOGFLAGS_DECIMAL_TS       = 0x00010000,
     292    /** New lines should be prefixed with the native process id. */
     293    RTLOGFLAGS_PREFIX_PID       = 0x00020000,
    292294    /** New lines should be prefixed with group flag number causing the output. */
    293295    RTLOGFLAGS_PREFIX_FLAG_NO   = 0x00040000,
  • trunk/src/VBox/Runtime/VBox/log-vbox.cpp

    r6407 r6515  
    390390         */
    391391# if defined(DEBUG_bird) && !defined(IN_GUEST)
    392         //RTLogGroupSettings(pLogger, "all=~0");
    393         //RTLogFlags(pLogger, "enabled unbuffered");
    394         RTLogGroupSettings(pLogger, "-all");
    395         RTLogFlags(pLogger, "disabled unbuffered");
    396         pLogger->fDestFlags |= /*RTLOGDEST_DEBUGGER |*/ RTLOGDEST_COM;
     392        RTLogGroupSettings(pLogger, "all=~0");
     393        RTLogFlags(pLogger, "enabled unbuffered pid");
     394        //RTLogGroupSettings(pLogger, "-all");
     395        //RTLogFlags(pLogger, "disabled unbuffered");
     396        pLogger->fDestFlags |= RTLOGDEST_DEBUGGER;/* | RTLOGDEST_COM;*/
    397397# endif
    398398# if defined(DEBUG_sandervl) && !defined(IN_GUEST)
  • trunk/src/VBox/Runtime/common/log/log.cpp

    r6493 r6515  
    3232#ifndef IN_GC
    3333# include <iprt/alloc.h>
     34# include <iprt/process.h>
     35# include <iprt/semaphore.h>
    3436# include <iprt/thread.h>
    35 # include <iprt/semaphore.h>
    3637#endif
    3738#ifdef IN_RING3
    38 # include <iprt/process.h>
    3939# include <iprt/file.h>
    4040# include <iprt/path.h>
     
    11961196            { "dec",          sizeof("dec"         ) - 1,   RTLOGFLAGS_DECIMAL_TS,          false },
    11971197            { "hex",          sizeof("hex"         ) - 1,   RTLOGFLAGS_DECIMAL_TS,          true  },
     1198            { "pid",          sizeof("pid"         ) - 1,   RTLOGFLAGS_PREFIX_PID,          false },
    11981199            { "flagno",       sizeof("flagno"      ) - 1,   RTLOGFLAGS_PREFIX_FLAG_NO,      false },
    11991200            { "flag",         sizeof("flag"        ) - 1,   RTLOGFLAGS_PREFIX_FLAG,         false },
     
    18701871                /*
    18711872                 * Flush the buffer if there isn't enough room for the maximum prefix config.
    1872                  * Max is 124, add a couple of extra bytes.
     1873                 * Max is 198, add a couple of extra bytes.
    18731874                 */
    1874                 if (cb < 128 + 18 + 22)
     1875                if (cb < 198 + 16)
    18751876                {
    18761877                    rtlogFlush(pLogger);
     
    18991900                    if (pLogger->fFlags & RTLOGFLAGS_REL_TS)
    19001901                    {
    1901                         static uint64_t s_u64LastTs;
     1902                        static volatile uint64_t s_u64LastTs;
    19021903                        uint64_t        u64DiffTs = u64 - s_u64LastTs;
    19031904                        s_u64LastTs = u64;
     
    19081909                    }
    19091910                    /* 1E15 nanoseconds = 11 days */
    1910                     psz += RTStrFormatNumber(psz, u64, iBase, 16, 0, fFlags);
     1911                    psz += RTStrFormatNumber(psz, u64, iBase, 16, 0, fFlags);                       /* +17 */
    19111912                    *psz++ = ' ';
    19121913                }
     
    19231924                    if (pLogger->fFlags & RTLOGFLAGS_REL_TS)
    19241925                    {
    1925                         static uint64_t s_u64LastTsc;
     1926                        static volatile uint64_t s_u64LastTsc;
    19261927                        uint64_t        u64DiffTsc = u64 - s_u64LastTsc;
    19271928                        s_u64LastTsc = u64;
     
    19321933                    }
    19331934                    /* 1E15 ticks at 4GHz = 69 hours */
    1934                     psz += RTStrFormatNumber(psz, u64, iBase, 16, 0, fFlags);
     1935                    psz += RTStrFormatNumber(psz, u64, iBase, 16, 0, fFlags);                       /* +17 */
    19351936                    *psz++ = ' ';
    19361937                }
     
    19591960                    *psz++ = '.';
    19601961                    psz += RTStrFormatNumber(psz, Time.u32Nanosecond / 1000000, 10, 3, 0, RTSTR_F_ZEROPAD);
    1961                     *psz++ = ' ';
     1962                    *psz++ = ' ';                                                                   /* +17 (3+1+3+1+3+1+4+1) */
    19621963#else
    19631964                    memset(psz, ' ', 13);
     
    19781979                    *psz++ = '.';
    19791980                    psz += RTStrFormatNumber(psz, u32 % 1000, 10, 3, 0, RTSTR_F_ZEROPAD);
    1980                     *psz++ = ' ';
     1981                    *psz++ = ' ';                                                               /* +20 (9+1+2+1+2+1+3+1) */
    19811982#else
    19821983                    memset(psz, ' ', 13);
     
    19931994                    memcpy(psz, szDate, cch);
    19941995                    psz += cch;
    1995                     *psz++ = ' ';
     1996                    *psz++ = ' ';                                                               /* +32 */
    19961997                }
    19971998# endif
     1999                if (pLogger->fFlags & RTLOGFLAGS_PREFIX_PID)
     2000                {
     2001#ifndef IN_GC
     2002                    RTPROCESS Process = RTProcSelf();
     2003#else
     2004                    RTPROCESS Process = NIL_RTPROCESS;
     2005#endif
     2006                    psz += RTStrFormatNumber(psz, Process, 16, sizeof(RTPROCESS) * 2, 0, RTSTR_F_ZEROPAD);
     2007                    *psz++ = ' ';                                                               /* +9 */
     2008                }
    19982009                if (pLogger->fFlags & RTLOGFLAGS_PREFIX_TID)
    19992010                {
    2000 #ifdef IN_RING3
     2011#ifndef IN_GC
    20012012                    RTNATIVETHREAD Thread = RTThreadNativeSelf();
    20022013#else
     
    20042015#endif
    20052016                    psz += RTStrFormatNumber(psz, Thread, 16, sizeof(RTNATIVETHREAD) * 2, 0, RTSTR_F_ZEROPAD);
    2006                     *psz++ = ' ';
     2017                    *psz++ = ' ';                                                               /* +17 */
    20072018                }
    20082019                if (pLogger->fFlags & RTLOGFLAGS_PREFIX_THREAD)
     
    20252036                    do
    20262037                        *psz++ = ' ';
    2027                     while (cch++ < 8);
     2038                    while (cch++ < 8);                                                          /* +17  */
    20282039                }
    20292040                if (pLogger->fFlags & RTLOGFLAGS_PREFIX_FLAG_NO)
    20302041                {
    20312042                    psz += RTStrFormatNumber(psz, pArgs->fFlags, 16, 8, 0, RTSTR_F_ZEROPAD);
    2032                     *psz++ = ' ';
     2043                    *psz++ = ' ';                                                               /* +9 */
    20332044                }
    20342045                if (pLogger->fFlags & RTLOGFLAGS_PREFIX_FLAG)
     
    20492060                    do
    20502061                        *psz++ = ' ';
    2051                     while (cch++ < 8);
     2062                    while (cch++ < 8);                                                          /* +17 */
    20522063                }
    20532064                if (pLogger->fFlags & RTLOGFLAGS_PREFIX_GROUP_NO)
     
    20622073                        memcpy(psz, "-1  ", sizeof("-1  ") - 1);
    20632074                        psz += sizeof("-1  ") - 1;
    2064                     }
     2075                    }                                                                           /* +9 */
    20652076                }
    20662077                if (pLogger->fFlags & RTLOGFLAGS_PREFIX_GROUP)
     
    21022113                    do
    21032114                        *psz++ = ' ';
    2104                     while (cch++ < 8);
     2115                    while (cch++ < 8);                                                          /* +17 */
    21052116                }
    21062117
     
    21092120                 */
    21102121                cb = psz - &pLogger->achScratch[pLogger->offScratch];
    2111                 Assert(cb <= 124);
     2122                Assert(cb <= 198);
    21122123                pLogger->offScratch += cb;
    21132124                cb = sizeof(pLogger->achScratch) - pLogger->offScratch - 1;
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