VirtualBox

Changeset 19730 in vbox


Ignore:
Timestamp:
May 15, 2009 12:07:48 PM (16 years ago)
Author:
vboxsync
Message:

Backed out 47346

Location:
trunk
Files:
5 edited

Legend:

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

    r19729 r19730  
    12321232#ifdef IN_RING0
    12331233/**
    1234  * Changes the default logger instance for the specified thread.
     1234 * Changes the default logger instance for the current thread.
    12351235 *
    12361236 * @returns IPRT status code.
    1237  * @param   hNativeThread   Thread handle
    1238  * @param   pLogger         The logger instance. Pass NULL for deregistration.
    1239  * @param   uKey            Associated key for cleanup purposes. If pLogger is NULL,
    1240  *                          all instances with this key will be deregistered. So in
    1241  *                          order to only deregister the instance associated with the
    1242  *                          current thread use 0.
    1243  */
    1244 RTDECL(int) RTLogSetDefaultInstanceThread(RTNATIVETHREAD hNativeThread, PRTLOGGER pLogger, uintptr_t uKey);
     1237 * @param   pLogger     The logger instance. Pass NULL for deregistration.
     1238 * @param   uKey        Associated key for cleanup purposes. If pLogger is NULL,
     1239 *                      all instances with this key will be deregistered. So in
     1240 *                      order to only deregister the instance associated with the
     1241 *                      current thread use 0.
     1242 */
     1243RTDECL(int) RTLogSetDefaultInstanceThread(PRTLOGGER pLogger, uintptr_t uKey);
    12451244#endif /* IN_RING0 */
    12461245
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r19729 r19730  
    263263DECLASM(int)   UNWIND_WRAP(RTMpPokeCpu)(RTCPUID idCpu);
    264264/* RTLogRelDefaultInstance - not necessary. */
    265 DECLASM(int)   UNWIND_WRAP(RTLogSetDefaultInstanceThread)(RTNATIVETHREAD hNativeThread, PRTLOGGER pLogger, uintptr_t uKey);
     265DECLASM(int)   UNWIND_WRAP(RTLogSetDefaultInstanceThread)(PRTLOGGER pLogger, uintptr_t uKey);
    266266/* RTLogLogger            - can't wrap this buster.  */
    267267/* RTLogLoggerEx          - can't wrap this buster. */
     
    727727     * Remove logger instances related to this session.
    728728     */
    729     RTLogSetDefaultInstanceThread(NIL_RTNATIVETHREAD, NULL, (uintptr_t)pSession);
     729    RTLogSetDefaultInstanceThread(NULL, (uintptr_t)pSession);
    730730
    731731    /*
  • trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h

    r19729 r19730  
    188188 *            and renaming the related IOCtls too.
    189189 */
    190 #define SUPDRV_IOC_VERSION                              0x000d0001
     190#define SUPDRV_IOC_VERSION                              0x000c0001
    191191
    192192/** SUP_IOCTL_COOKIE. */
  • trunk/src/VBox/Runtime/common/log/log.cpp

    r19729 r19730  
    14761476#ifdef IN_RING0
    14771477/**
    1478  * Changes the default logger instance for the specified thread.
     1478 * Changes the default logger instance for the current thread.
    14791479 *
    14801480 * @returns IPRT status code.
    1481  * @param   hNativeThread   Thread handle
    1482  * @param   pLogger         The logger instance. Pass NULL for deregistration.
    1483  * @param   uKey            Associated key for cleanup purposes. If pLogger is NULL,
    1484  *                          all instances with this key will be deregistered. So in
    1485  *                          order to only deregister the instance associated with the
    1486  *                          current thread use 0.
    1487  */
    1488 RTDECL(int) RTLogSetDefaultInstanceThread(RTNATIVETHREAD hNativeThread, PRTLOGGER pLogger, uintptr_t uKey)
     1481 * @param   pLogger     The logger instance. Pass NULL for deregistration.
     1482 * @param   uKey        Associated key for cleanup purposes. If pLogger is NULL,
     1483 *                      all instances with this key will be deregistered. So in
     1484 *                      order to only deregister the instance associated with the
     1485 *                      current thread use 0.
     1486 */
     1487RTDECL(int) RTLogSetDefaultInstanceThread(PRTLOGGER pLogger, uintptr_t uKey)
    14891488{
    14901489    int             rc;
     1490    RTNATIVETHREAD  Self = RTThreadNativeSelf();
    14911491    if (pLogger)
    14921492    {
     
    15011501        i = RT_ELEMENTS(g_aPerThreadLoggers);
    15021502        while (i-- > 0)
    1503             if (g_aPerThreadLoggers[i].NativeThread == hNativeThread)
     1503            if (g_aPerThreadLoggers[i].NativeThread == Self)
    15041504            {
    15051505                ASMAtomicXchgPtr((void * volatile *)&g_aPerThreadLoggers[i].uKey, (void *)uKey);
     
    15251525                AssertCompile(sizeof(RTNATIVETHREAD) == sizeof(void*));
    15261526                if (    g_aPerThreadLoggers[i].NativeThread == NIL_RTNATIVETHREAD
    1527                     &&  ASMAtomicCmpXchgPtr((void * volatile *)&g_aPerThreadLoggers[i].NativeThread, (void *)hNativeThread, (void *)NIL_RTNATIVETHREAD))
     1527                    &&  ASMAtomicCmpXchgPtr((void * volatile *)&g_aPerThreadLoggers[i].NativeThread, (void *)Self, (void *)NIL_RTNATIVETHREAD))
    15281528                {
    15291529                    ASMAtomicXchgPtr((void * volatile *)&g_aPerThreadLoggers[i].uKey, (void *)uKey);
     
    15441544        int32_t i = RT_ELEMENTS(g_aPerThreadLoggers);
    15451545        while (i-- > 0)
    1546             if (    g_aPerThreadLoggers[i].NativeThread == hNativeThread
     1546            if (    g_aPerThreadLoggers[i].NativeThread == Self
    15471547                ||  g_aPerThreadLoggers[i].uKey == uKey)
    15481548            {
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r19729 r19730  
    188188        return VERR_INVALID_PARAMETER;
    189189
    190 #ifdef LOG_ENABLED
    191190    /*
    192      * Register the EMT logger instances for all VCPUs.
     191     * Register the EMT R0 logger instance for VCPU 0.
    193192     */
    194     for (unsigned i = 0; i < pVM->cCPUs; i++)
    195     {
    196         PVMCPU pVCpu = &pVM->aCpus[i];
    197 
    198         PVMMR0LOGGER pR0Logger = pVCpu->vmm.s.pR0LoggerR0;
    199         if (pR0Logger)
    200         {
    201 # if 0 /* testing of the logger. */
    202             LogCom(("vmmR0InitVM: before %p\n", RTLogDefaultInstance()));
    203             LogCom(("vmmR0InitVM: pfnFlush=%p actual=%p\n", pR0Logger->Logger.pfnFlush, vmmR0LoggerFlush));
    204             LogCom(("vmmR0InitVM: pfnLogger=%p actual=%p\n", pR0Logger->Logger.pfnLogger, vmmR0LoggerWrapper));
    205             LogCom(("vmmR0InitVM: offScratch=%d fFlags=%#x fDestFlags=%#x\n", pR0Logger->Logger.offScratch, pR0Logger->Logger.fFlags, pR0Logger->Logger.fDestFlags));
    206 
    207             RTLogSetDefaultInstanceThread(pVCpu->hNativeThread, &pR0Logger->Logger, (uintptr_t)pVM->pSession);
    208             LogCom(("vmmR0InitVM: after %p reg\n", RTLogDefaultInstance()));
    209             RTLogSetDefaultInstanceThread(NIL_RTNATIVETHREAD, NULL, 0);
    210             LogCom(("vmmR0InitVM: after %p dereg\n", RTLogDefaultInstance()));
    211 
    212             pR0Logger->Logger.pfnLogger("hello ring-0 logger\n");
    213             LogCom(("vmmR0InitVM: returned succesfully from direct logger call.\n"));
    214             pR0Logger->Logger.pfnFlush(&pR0Logger->Logger);
    215             LogCom(("vmmR0InitVM: returned succesfully from direct flush call.\n"));
    216 
    217             RTLogSetDefaultInstanceThread(&pR0Logger->Logger, (uintptr_t)pVM->pSession);
    218             LogCom(("vmmR0InitVM: after %p reg2\n", RTLogDefaultInstance()));
    219             pR0Logger->Logger.pfnLogger("hello ring-0 logger\n");
    220             LogCom(("vmmR0InitVM: returned succesfully from direct logger call (2). offScratch=%d\n", pR0Logger->Logger.offScratch));
    221             RTLogSetDefaultInstanceThread(NIL_RTNATIVETHREAD, NULL, 0);
    222             LogCom(("vmmR0InitVM: after %p dereg2\n", RTLogDefaultInstance()));
    223 
    224             RTLogLoggerEx(&pR0Logger->Logger, 0, ~0U, "hello ring-0 logger (RTLogLoggerEx)\n");
    225             LogCom(("vmmR0InitVM: RTLogLoggerEx returned fine offScratch=%d\n", pR0Logger->Logger.offScratch));
    226 
    227             RTLogSetDefaultInstanceThread(pVCpu->hNativeThread, &pR0Logger->Logger, (uintptr_t)pVM->pSession);
    228             RTLogPrintf("hello ring-0 logger (RTLogPrintf)\n");
    229             LogCom(("vmmR0InitVM: RTLogPrintf returned fine offScratch=%d\n", pR0Logger->Logger.offScratch));
    230 # endif
    231             Log(("CPU%d: Switching to per-thread logging instance %p (key=%p)\n", pVCpu->idCpu, &pR0Logger->Logger, pVM->pSession));
    232             RTLogSetDefaultInstanceThread(pVCpu->hNativeThread, &pR0Logger->Logger, (uintptr_t)pVM->pSession);
    233         }
    234     }
    235 #endif /* LOG_ENABLED */
     193    PVMCPU pVCpu = &pVM->aCpus[0];
     194
     195    PVMMR0LOGGER pR0Logger = pVCpu->vmm.s.pR0LoggerR0;
     196    if (pR0Logger)
     197    {
     198#if 0 /* testing of the logger. */
     199        LogCom(("vmmR0InitVM: before %p\n", RTLogDefaultInstance()));
     200        LogCom(("vmmR0InitVM: pfnFlush=%p actual=%p\n", pR0Logger->Logger.pfnFlush, vmmR0LoggerFlush));
     201        LogCom(("vmmR0InitVM: pfnLogger=%p actual=%p\n", pR0Logger->Logger.pfnLogger, vmmR0LoggerWrapper));
     202        LogCom(("vmmR0InitVM: offScratch=%d fFlags=%#x fDestFlags=%#x\n", pR0Logger->Logger.offScratch, pR0Logger->Logger.fFlags, pR0Logger->Logger.fDestFlags));
     203
     204        RTLogSetDefaultInstanceThread(&pR0Logger->Logger, (uintptr_t)pVM->pSession);
     205        LogCom(("vmmR0InitVM: after %p reg\n", RTLogDefaultInstance()));
     206        RTLogSetDefaultInstanceThread(NULL, 0);
     207        LogCom(("vmmR0InitVM: after %p dereg\n", RTLogDefaultInstance()));
     208
     209        pR0Logger->Logger.pfnLogger("hello ring-0 logger\n");
     210        LogCom(("vmmR0InitVM: returned succesfully from direct logger call.\n"));
     211        pR0Logger->Logger.pfnFlush(&pR0Logger->Logger);
     212        LogCom(("vmmR0InitVM: returned succesfully from direct flush call.\n"));
     213
     214        RTLogSetDefaultInstanceThread(&pR0Logger->Logger, (uintptr_t)pVM->pSession);
     215        LogCom(("vmmR0InitVM: after %p reg2\n", RTLogDefaultInstance()));
     216        pR0Logger->Logger.pfnLogger("hello ring-0 logger\n");
     217        LogCom(("vmmR0InitVM: returned succesfully from direct logger call (2). offScratch=%d\n", pR0Logger->Logger.offScratch));
     218        RTLogSetDefaultInstanceThread(NULL, 0);
     219        LogCom(("vmmR0InitVM: after %p dereg2\n", RTLogDefaultInstance()));
     220
     221        RTLogLoggerEx(&pR0Logger->Logger, 0, ~0U, "hello ring-0 logger (RTLogLoggerEx)\n");
     222        LogCom(("vmmR0InitVM: RTLogLoggerEx returned fine offScratch=%d\n", pR0Logger->Logger.offScratch));
     223
     224        RTLogSetDefaultInstanceThread(&pR0Logger->Logger, (uintptr_t)pVM->pSession);
     225        RTLogPrintf("hello ring-0 logger (RTLogPrintf)\n");
     226        LogCom(("vmmR0InitVM: RTLogPrintf returned fine offScratch=%d\n", pR0Logger->Logger.offScratch));
     227#endif
     228        Log(("Switching to per-thread logging instance %p (key=%p)\n", &pR0Logger->Logger, pVM->pSession));
     229        RTLogSetDefaultInstanceThread(&pR0Logger->Logger, (uintptr_t)pVM->pSession);
     230    }
    236231
    237232    /*
     
    266261        }
    267262    }
    268     RTLogSetDefaultInstanceThread(NIL_RTNATIVETHREAD, NULL, (uintptr_t)pVM->pSession);
     263    RTLogSetDefaultInstanceThread(NULL, 0);
    269264    return rc;
    270265}
     
    300295     * Deregister the logger.
    301296     */
    302     RTLogSetDefaultInstanceThread(NIL_RTNATIVETHREAD, NULL, (uintptr_t)pVM->pSession);
     297    RTLogSetDefaultInstanceThread(NULL, 0);
    303298    return VINF_SUCCESS;
    304299}
     
    770765                return VERR_INVALID_PARAMETER;
    771766
     767#ifdef LOG_ENABLED
     768            /* Register the ring 0 logger for this thread here as well. */
     769            PVMCPU       pVCpu = &pVM->aCpus[idCpu];
     770            PVMMR0LOGGER pR0Logger = pVCpu->vmm.s.pR0LoggerR0;
     771            if (pR0Logger)
     772                RTLogSetDefaultInstanceThread(&pR0Logger->Logger, (uintptr_t)pVM->pSession);
     773#endif
    772774            return GVMMR0RegisterVCpu(pVM, idCpu);
    773775        }
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