Changeset 72778 in vbox for trunk/src/VBox/VMM/VMMR3
- Timestamp:
- Jun 29, 2018 8:02:35 PM (7 years ago)
- Location:
- trunk/src/VBox/VMM/VMMR3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/VM.cpp
r72642 r72778 107 107 #endif 108 108 static int vmR3InitDoCompleted(PVM pVM, VMINITCOMPLETED enmWhat); 109 #ifdef LOG_ENABLED110 static DECLCALLBACK(size_t) vmR3LogPrefixCallback(PRTLOGGER pLogger, char *pchBuf, size_t cchBuf, void *pvUser);111 #endif112 109 static void vmR3DestroyUVM(PUVM pUVM, uint32_t cMilliesEMTWait); 113 110 static bool vmR3ValidateStateTransition(VMSTATE enmStateOld, VMSTATE enmStateNew); … … 709 706 */ 710 707 vmR3SetState(pVM, VMSTATE_CREATED, VMSTATE_CREATING); 711 712 #ifdef LOG_ENABLED713 RTLogSetCustomPrefixCallback(NULL, vmR3LogPrefixCallback, pUVM);714 #endif715 708 return VINF_SUCCESS; 716 709 } … … 1218 1211 1219 1212 1220 #ifdef LOG_ENABLED1221 /**1222 * Logger callback for inserting a custom prefix.1223 *1224 * @returns Number of chars written.1225 * @param pLogger The logger.1226 * @param pchBuf The output buffer.1227 * @param cchBuf The output buffer size.1228 * @param pvUser Pointer to the UVM structure.1229 */1230 static DECLCALLBACK(size_t) vmR3LogPrefixCallback(PRTLOGGER pLogger, char *pchBuf, size_t cchBuf, void *pvUser)1231 {1232 AssertReturn(cchBuf >= 2, 0);1233 PUVM pUVM = (PUVM)pvUser;1234 PUVMCPU pUVCpu = (PUVMCPU)RTTlsGet(pUVM->vm.s.idxTLS);1235 if (pUVCpu)1236 {1237 static const char s_szHex[17] = "0123456789abcdef";1238 VMCPUID const idCpu = pUVCpu->idCpu;1239 pchBuf[1] = s_szHex[ idCpu & 15];1240 pchBuf[0] = s_szHex[(idCpu >> 4) & 15];1241 }1242 else1243 {1244 pchBuf[0] = 'x';1245 pchBuf[1] = 'y';1246 }1247 1248 NOREF(pLogger);1249 return 2;1250 }1251 #endif /* LOG_ENABLED */1252 1253 1254 1213 /** 1255 1214 * Calls the relocation functions for all VMM components so they can update … … 2749 2708 * Clean up and flush logs. 2750 2709 */ 2751 #ifdef LOG_ENABLED2752 RTLogSetCustomPrefixCallback(NULL, NULL, NULL);2753 #endif2754 2710 RTLogFlush(NULL); 2755 2711 } -
trunk/src/VBox/VMM/VMMR3/VMM.cpp
r72617 r72778 157 157 #define VMM_SAVED_STATE_VERSION_3_0 3 158 158 159 /** Macro for flushing the ring-0 logging. */ 160 #define VMM_FLUSH_R0_LOG(a_pR0Logger, a_pR3Logger) \ 161 do { \ 162 PVMMR0LOGGER pVmmLogger = (a_pR0Logger); \ 163 if (!pVmmLogger || pVmmLogger->Logger.offScratch == 0) \ 164 { /* likely? */ } \ 165 else \ 166 RTLogFlushR0(a_pR3Logger, &pVmmLogger->Logger); \ 167 } while (0) 168 159 169 160 170 /********************************************************************************************************************************* … … 417 427 #endif /* LOG_ENABLED */ 418 428 429 /* 430 * Release logging. 431 */ 432 PRTLOGGER pRelLogger = RTLogRelGetDefaultInstance(); 433 if (pRelLogger) 434 { 419 435 #ifdef VBOX_WITH_RC_RELEASE_LOGGING 420 /* 421 * Allocate RC release logger instances (finalized in the relocator). 422 */ 423 if (VM_IS_RAW_MODE_ENABLED(pVM)) 424 { 425 PRTLOGGER pRelLogger = RTLogRelGetDefaultInstance(); 426 if (pRelLogger) 436 /* 437 * Allocate RC release logger instances (finalized in the relocator). 438 */ 439 if (VM_IS_RAW_MODE_ENABLED(pVM)) 427 440 { 428 441 pVM->vmm.s.cbRCRelLogger = RT_OFFSETOF(RTLOGGERRC, afGroups[pRelLogger->cGroups]); … … 432 445 pVM->vmm.s.pRCRelLoggerRC = MMHyperR3ToRC(pVM, pVM->vmm.s.pRCRelLoggerR3); 433 446 } 434 } 435 #endif /* VBOX_WITH_RC_RELEASE_LOGGING */ 447 #endif 448 449 /* 450 * Ring-0 release logger. 451 */ 452 RTR0PTR pfnLoggerWrapper = NIL_RTR0PTR; 453 rc = PDMR3LdrGetSymbolR0(pVM, VMMR0_MAIN_MODULE_NAME, "vmmR0LoggerWrapper", &pfnLoggerWrapper); 454 AssertReleaseMsgRCReturn(rc, ("vmmR0LoggerWrapper not found! rc=%Rra\n", rc), rc); 455 456 RTR0PTR pfnLoggerFlush = NIL_RTR0PTR; 457 rc = PDMR3LdrGetSymbolR0(pVM, VMMR0_MAIN_MODULE_NAME, "vmmR0LoggerFlush", &pfnLoggerFlush); 458 AssertReleaseMsgRCReturn(rc, ("vmmR0LoggerFlush not found! rc=%Rra\n", rc), rc); 459 460 size_t const cbLogger = RTLogCalcSizeForR0(pLogger->cGroups, 0); 461 462 for (VMCPUID i = 0; i < pVM->cCpus; i++) 463 { 464 PVMCPU pVCpu = &pVM->aCpus[i]; 465 rc = MMR3HyperAllocOnceNoRelEx(pVM, cbLogger, PAGE_SIZE, MM_TAG_VMM, MMHYPER_AONR_FLAGS_KERNEL_MAPPING, 466 (void **)&pVCpu->vmm.s.pR0RelLoggerR3); 467 if (RT_FAILURE(rc)) 468 return rc; 469 PVMMR0LOGGER pVmmLogger = pVCpu->vmm.s.pR0RelLoggerR3; 470 RTR0PTR R0PtrVmmLogger = MMHyperR3ToR0(pVM, pVmmLogger); 471 pVCpu->vmm.s.pR0RelLoggerR0 = R0PtrVmmLogger; 472 pVmmLogger->pVM = pVM->pVMR0; 473 pVmmLogger->cbLogger = (uint32_t)cbLogger; 474 pVmmLogger->fCreated = false; 475 pVmmLogger->fFlushingDisabled = false; 476 pVmmLogger->fRegistered = false; 477 pVmmLogger->idCpu = i; 478 479 char szR0ThreadName[16]; 480 RTStrPrintf(szR0ThreadName, sizeof(szR0ThreadName), "EMT-%u-R0", i); 481 rc = RTLogCreateForR0(&pVmmLogger->Logger, pVmmLogger->cbLogger, R0PtrVmmLogger + RT_OFFSETOF(VMMR0LOGGER, Logger), 482 pfnLoggerWrapper, pfnLoggerFlush, 483 RTLOGFLAGS_BUFFERED, RTLOGDEST_DUMMY, szR0ThreadName); 484 AssertReleaseMsgRCReturn(rc, ("RTLogCreateForR0 failed! rc=%Rra\n", rc), rc); 485 486 /* We only update the release log instance here. */ 487 rc = RTLogCopyGroupsAndFlagsForR0(&pVmmLogger->Logger, R0PtrVmmLogger + RT_OFFSETOF(VMMR0LOGGER, Logger), 488 pRelLogger, RTLOGFLAGS_BUFFERED, UINT32_MAX); 489 AssertReleaseMsgRCReturn(rc, ("RTLogCopyGroupsAndFlagsForR0 failed! rc=%Rra\n", rc), rc); 490 491 pVmmLogger->fCreated = true; 492 } 493 } 494 436 495 return VINF_SUCCESS; 437 496 } … … 581 640 */ 582 641 #ifdef LOG_ENABLED 583 if ( pVCpu->vmm.s.pR0LoggerR3 584 && pVCpu->vmm.s.pR0LoggerR3->Logger.offScratch > 0) 585 RTLogFlushR0(NULL, &pVCpu->vmm.s.pR0LoggerR3->Logger); 586 #endif 642 VMM_FLUSH_R0_LOG(pVCpu->vmm.s.pR0LoggerR3, NULL); 643 #endif 644 VMM_FLUSH_R0_LOG(pVCpu->vmm.s.pR0RelLoggerR3, RTLogRelGetDefaultInstance()); 587 645 if (rc != VINF_VMM_CALL_HOST) 588 646 break; … … 833 891 */ 834 892 #ifdef LOG_ENABLED 835 if ( pVCpu->vmm.s.pR0LoggerR3 836 && pVCpu->vmm.s.pR0LoggerR3->Logger.offScratch > 0) 837 RTLogFlushR0(NULL, &pVCpu->vmm.s.pR0LoggerR3->Logger); 838 #endif 893 VMM_FLUSH_R0_LOG(pVCpu->vmm.s.pR0LoggerR3, NULL); 894 #endif 895 VMM_FLUSH_R0_LOG(pVCpu->vmm.s.pR0RelLoggerR3, RTLogRelGetDefaultInstance()); 839 896 if (rc != VINF_VMM_CALL_HOST) 840 897 break; … … 1035 1092 AssertReleaseMsgRCReturn(rc, ("RTLogCreateForR0 failed! rc=%Rra\n", rc), rc); 1036 1093 1037 RTR0PTR pfnLoggerPrefix = NIL_RTR0PTR;1038 rc = PDMR3LdrGetSymbolR0(pVM, VMMR0_MAIN_MODULE_NAME, "vmmR0LoggerPrefix", &pfnLoggerPrefix);1039 AssertReleaseMsgRCReturn(rc, ("vmmR0LoggerPrefix not found! rc=%Rra\n", rc), rc);1040 rc = RTLogSetCustomPrefixCallbackForR0(&pR0LoggerR3->Logger,1041 pVCpu->vmm.s.pR0LoggerR0 + RT_OFFSETOF(VMMR0LOGGER, Logger),1042 pfnLoggerPrefix, NIL_RTR0PTR);1043 AssertReleaseMsgRCReturn(rc, ("RTLogSetCustomPrefixCallback failed! rc=%Rra\n", rc), rc);1044 1045 1094 pR0LoggerR3->idCpu = i; 1046 1095 pR0LoggerR3->fCreated = true; 1047 1096 pR0LoggerR3->fFlushingDisabled = false; 1048 1049 1097 } 1050 1098 … … 1447 1495 #endif 1448 1496 1497 /* 1498 * Flush the logs 1499 */ 1449 1500 #ifdef LOG_ENABLED 1450 /* 1451 * Flush the log 1452 */ 1453 PVMMR0LOGGER pR0LoggerR3 = pVCpu->vmm.s.pR0LoggerR3; 1454 if ( pR0LoggerR3 1455 && pR0LoggerR3->Logger.offScratch > 0) 1456 RTLogFlushR0(NULL, &pR0LoggerR3->Logger); 1457 #endif /* !LOG_ENABLED */ 1501 VMM_FLUSH_R0_LOG(pVCpu->vmm.s.pR0LoggerR3, NULL); 1502 #endif 1503 VMM_FLUSH_R0_LOG(pVCpu->vmm.s.pR0RelLoggerR3, RTLogRelGetDefaultInstance()); 1458 1504 if (rc != VINF_VMM_CALL_HOST) 1459 1505 { … … 1493 1539 } while (rcStrict == VINF_EM_RAW_INTERRUPT_HYPER); 1494 1540 1541 /* 1542 * Flush the logs 1543 */ 1495 1544 #ifdef LOG_ENABLED 1496 /* 1497 * Flush the log 1498 */ 1499 PVMMR0LOGGER pR0LoggerR3 = pVCpu->vmm.s.pR0LoggerR3; 1500 if ( pR0LoggerR3 1501 && pR0LoggerR3->Logger.offScratch > 0) 1502 RTLogFlushR0(NULL, &pR0LoggerR3->Logger); 1503 #endif /* !LOG_ENABLED */ 1545 VMM_FLUSH_R0_LOG(pVCpu->vmm.s.pR0LoggerR3, NULL); 1546 #endif 1547 VMM_FLUSH_R0_LOG(pVCpu->vmm.s.pR0RelLoggerR3, RTLogRelGetDefaultInstance()); 1504 1548 if (rcStrict != VINF_VMM_CALL_HOST) 1505 1549 return rcStrict; … … 2590 2634 */ 2591 2635 #ifdef LOG_ENABLED 2592 if ( pVCpu->vmm.s.pR0LoggerR3 2593 && pVCpu->vmm.s.pR0LoggerR3->Logger.offScratch > 0) 2594 RTLogFlushR0(NULL, &pVCpu->vmm.s.pR0LoggerR3->Logger); 2595 #endif 2636 VMM_FLUSH_R0_LOG(pVCpu->vmm.s.pR0LoggerR3, NULL); 2637 #endif 2638 VMM_FLUSH_R0_LOG(pVCpu->vmm.s.pR0RelLoggerR3, RTLogRelGetDefaultInstance()); 2596 2639 if (rc != VINF_VMM_CALL_HOST) 2597 2640 break;
Note:
See TracChangeset
for help on using the changeset viewer.