Changeset 19730 in vbox
- Timestamp:
- May 15, 2009 12:07:48 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/log.h
r19729 r19730 1232 1232 #ifdef IN_RING0 1233 1233 /** 1234 * Changes the default logger instance for the specifiedthread.1234 * Changes the default logger instance for the current thread. 1235 1235 * 1236 1236 * @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 */ 1243 RTDECL(int) RTLogSetDefaultInstanceThread(PRTLOGGER pLogger, uintptr_t uKey); 1245 1244 #endif /* IN_RING0 */ 1246 1245 -
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r19729 r19730 263 263 DECLASM(int) UNWIND_WRAP(RTMpPokeCpu)(RTCPUID idCpu); 264 264 /* RTLogRelDefaultInstance - not necessary. */ 265 DECLASM(int) UNWIND_WRAP(RTLogSetDefaultInstanceThread)( RTNATIVETHREAD hNativeThread,PRTLOGGER pLogger, uintptr_t uKey);265 DECLASM(int) UNWIND_WRAP(RTLogSetDefaultInstanceThread)(PRTLOGGER pLogger, uintptr_t uKey); 266 266 /* RTLogLogger - can't wrap this buster. */ 267 267 /* RTLogLoggerEx - can't wrap this buster. */ … … 727 727 * Remove logger instances related to this session. 728 728 */ 729 RTLogSetDefaultInstanceThread(N IL_RTNATIVETHREAD, NULL, (uintptr_t)pSession);729 RTLogSetDefaultInstanceThread(NULL, (uintptr_t)pSession); 730 730 731 731 /* -
trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h
r19729 r19730 188 188 * and renaming the related IOCtls too. 189 189 */ 190 #define SUPDRV_IOC_VERSION 0x000 d0001190 #define SUPDRV_IOC_VERSION 0x000c0001 191 191 192 192 /** SUP_IOCTL_COOKIE. */ -
trunk/src/VBox/Runtime/common/log/log.cpp
r19729 r19730 1476 1476 #ifdef IN_RING0 1477 1477 /** 1478 * Changes the default logger instance for the specifiedthread.1478 * Changes the default logger instance for the current thread. 1479 1479 * 1480 1480 * @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 */ 1487 RTDECL(int) RTLogSetDefaultInstanceThread(PRTLOGGER pLogger, uintptr_t uKey) 1489 1488 { 1490 1489 int rc; 1490 RTNATIVETHREAD Self = RTThreadNativeSelf(); 1491 1491 if (pLogger) 1492 1492 { … … 1501 1501 i = RT_ELEMENTS(g_aPerThreadLoggers); 1502 1502 while (i-- > 0) 1503 if (g_aPerThreadLoggers[i].NativeThread == hNativeThread)1503 if (g_aPerThreadLoggers[i].NativeThread == Self) 1504 1504 { 1505 1505 ASMAtomicXchgPtr((void * volatile *)&g_aPerThreadLoggers[i].uKey, (void *)uKey); … … 1525 1525 AssertCompile(sizeof(RTNATIVETHREAD) == sizeof(void*)); 1526 1526 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)) 1528 1528 { 1529 1529 ASMAtomicXchgPtr((void * volatile *)&g_aPerThreadLoggers[i].uKey, (void *)uKey); … … 1544 1544 int32_t i = RT_ELEMENTS(g_aPerThreadLoggers); 1545 1545 while (i-- > 0) 1546 if ( g_aPerThreadLoggers[i].NativeThread == hNativeThread1546 if ( g_aPerThreadLoggers[i].NativeThread == Self 1547 1547 || g_aPerThreadLoggers[i].uKey == uKey) 1548 1548 { -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r19729 r19730 188 188 return VERR_INVALID_PARAMETER; 189 189 190 #ifdef LOG_ENABLED191 190 /* 192 * Register the EMT logger instances for all VCPUs.191 * Register the EMT R0 logger instance for VCPU 0. 193 192 */ 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 } 236 231 237 232 /* … … 266 261 } 267 262 } 268 RTLogSetDefaultInstanceThread(N IL_RTNATIVETHREAD, NULL, (uintptr_t)pVM->pSession);263 RTLogSetDefaultInstanceThread(NULL, 0); 269 264 return rc; 270 265 } … … 300 295 * Deregister the logger. 301 296 */ 302 RTLogSetDefaultInstanceThread(N IL_RTNATIVETHREAD, NULL, (uintptr_t)pVM->pSession);297 RTLogSetDefaultInstanceThread(NULL, 0); 303 298 return VINF_SUCCESS; 304 299 } … … 770 765 return VERR_INVALID_PARAMETER; 771 766 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 772 774 return GVMMR0RegisterVCpu(pVM, idCpu); 773 775 }
Note:
See TracChangeset
for help on using the changeset viewer.