VirtualBox

Changeset 31600 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 12, 2010 2:17:05 PM (14 years ago)
Author:
vboxsync
Message:

Extra debug command

Location:
trunk/src/VBox/VMM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PGM.cpp

    r31593 r31600  
    631631static DECLCALLBACK(int)  pgmR3CmdAssertCR3(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
    632632# endif
     633# ifdef DEBUG_sandervl
     634static DECLCALLBACK(int)  pgmR3CmdCountPhysWrites(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
     635# endif
    633636static DECLCALLBACK(int)  pgmR3CmdPhysToFile(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
    634637#endif
     
    653656};
    654657
     658# ifdef DEBUG_sandervl
     659static const DBGCVARDESC g_aPgmCountPhysWritesArgs[] =
     660{
     661    /* cTimesMin,   cTimesMax,  enmCategory,            fFlags,                         pszName,        pszDescription */
     662    {  1,           1,          DBGCVAR_CAT_STRING,     0,                              "enabled",      "on/off." },
     663    {  1,           1,          DBGCVAR_CAT_NUMBER_NO_RANGE,     0,                     "interval",     "Interval in ms." },
     664};
     665# endif
     666
    655667/** Command descriptors. */
    656668static const DBGCCMD    g_aCmds[] =
     
    661673    { "pgmerror",      0, 1,        &g_aPgmErrorArgs[0],      1,            NULL,               0,          pgmR3CmdError,      "",                     "Enables inject runtime of errors into parts of PGM." },
    662674    { "pgmerroroff",   0, 1,        &g_aPgmErrorArgs[0],      1,            NULL,               0,          pgmR3CmdError,      "",                     "Disables inject runtime errors into parts of PGM." },
    663 #ifdef VBOX_STRICT
     675# ifdef VBOX_STRICT
    664676    { "pgmassertcr3",  0, 0,        NULL,                     0,            NULL,               0,          pgmR3CmdAssertCR3,  "",                     "Check the shadow CR3 mapping." },
    665 #endif
    666 #if defined(VBOX_STRICT) && HC_ARCH_BITS == 64
     677#  if HC_ARCH_BITS == 64
    667678    { "pgmcheckduppages", 0, 0,     NULL,                     0,            NULL,               0,          pgmR3CmdCheckDuplicatePages,  "",           "Check for duplicate pages in all running VMs." },
    668679    { "pgmsharedmodules", 0, 0,     NULL,                     0,            NULL,               0,          pgmR3CmdShowSharedModules,  "",             "Print shared modules info." },
    669 #endif
     680#  endif
     681# endif
     682# ifdef DEBUG_sandervl
     683    { "pgmcountphyswrites", 2, 2,   &g_aPgmCountPhysWritesArgs[0], 2,       NULL,               0,          pgmR3CmdCountPhysWrites, "",                "Count physical page writes."},
     684# endif
    670685    { "pgmsyncalways", 0, 0,        NULL,                     0,            NULL,               0,          pgmR3CmdSyncAlways, "",                     "Toggle permanent CR3 syncing." },
    671686    { "pgmphystofile", 1, 2,        &g_aPgmPhysToFileArgs[0], 2,            NULL,               0,          pgmR3CmdPhysToFile, "",                     "Save the physical memory to file." },
     
    16561671        rc = STAMR3RegisterF(pVM, a, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, c, b); \
    16571672        AssertRC(rc);
     1673
     1674#ifdef DEBUG_sandervl
     1675    PGM_REG_COUNTER(&pPGM->StatRZFTPhysPageWrite,             "/PGM/FT/RZ/PageWrite",               "The number of times a physical page was written to (FT stats).");
     1676    PGM_REG_COUNTER(&pPGM->StatR3FTPhysPageWrite,             "/PGM/FT/R3/PageWrite",               "The number of times a physical page was written to (FT stats).");
     1677#endif
    16581678
    16591679    PGMSTATS *pStats = pVM->pgm.s.pStatsR3;
     
    42874307    return VINF_SUCCESS;
    42884308}
     4309
     4310/**
     4311 * Internal timer callback function.
     4312 *
     4313 * @param   pVM             The VM.
     4314 * @param   pTimer          The timer handle.
     4315 * @param   pvUser          User argument specified upon timer creation.
     4316 */
     4317DECLCALLBACK(void) pgmR3PhysWriteCountTMCallback(PVM pVM, PTMTIMER pTimer, void *pvUser)
     4318{
     4319    uint32_t uInterval = (uint32_t) pvUser;
     4320
     4321    if (pVM->pgm.s.fCountingPhysWrites)
     4322    {
     4323        pgmR3PoolClearAll(pVM, true/* fFlushRemTlb */);
     4324
     4325        /* Program next invocation. */
     4326        int rc = TMTimerSetMillies(pVM->pgm.s.pPhysWritesCountTimer, uInterval);
     4327        AssertRC(rc);
     4328    }
     4329}
     4330
     4331# ifdef DEBUG_sandervl
     4332/**
     4333 * The '.pgmcountphyswrites' command.
     4334 *
     4335 * @returns VBox status.
     4336 * @param   pCmd        Pointer to the command descriptor (as registered).
     4337 * @param   pCmdHlp     Pointer to command helper functions.
     4338 * @param   pVM         Pointer to the current VM (if any).
     4339 * @param   paArgs      Pointer to (readonly) array of arguments.
     4340 * @param   cArgs       Number of arguments in the array.
     4341 */
     4342static DECLCALLBACK(int) pgmR3CmdCountPhysWrites(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
     4343{
     4344    /*
     4345     * Validate input.
     4346     */
     4347    if (!pVM)
     4348        return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: The command requires a VM to be selected.\n");
     4349    if (    cArgs != 2
     4350        ||  paArgs[0].enmType != DBGCVAR_TYPE_STRING
     4351        ||  paArgs[1].enmType != DBGCVAR_CAT_NUMBER_NO_RANGE)
     4352        return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: parser error, invalid arguments.\n");
     4353
     4354    if (!strcmp(paArgs[0].u.pszString, "off"))
     4355    {
     4356        if (!pVM->pgm.s.fCountingPhysWrites)
     4357            return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: not enabled!\n");
     4358
     4359        TMTimerStop(pVM->pgm.s.pPhysWritesCountTimer);
     4360        TMR3TimerDestroy(pVM->pgm.s.pPhysWritesCountTimer);
     4361        pVM->pgm.s.pPhysWritesCountTimer = NULL;
     4362        pVM->pgm.s.fCountingPhysWrites = false;
     4363        return VINF_SUCCESS;
     4364    }
     4365    else
     4366    if (strcmp(paArgs[0].u.pszString, "on"))
     4367        return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid 1st argument '%s', must be 'on' or 'off'.\n", paArgs[0].u.pszString);
     4368
     4369    if (    paArgs[1].u.u64Number < 10
     4370        ||  paArgs[1].u.u64Number > 1000)
     4371        return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid 2nd argument '%d', must be between 10 and 1000 ms.\n", paArgs[1].u.u64Number);
     4372
     4373    int rc = TMR3TimerCreateInternal(pVM, TMCLOCK_REAL, pgmR3PhysWriteCountTMCallback, (void *)(uint32_t)paArgs[1].u.u64Number, "Physical page write counting timer", &pVM->pgm.s.pPhysWritesCountTimer);
     4374    if (RT_FAILURE(rc))
     4375        return rc;
     4376
     4377    pVM->pgm.s.fCountingPhysWrites = true;
     4378    rc = TMTimerSetMillies(pVM->pgm.s.pPhysWritesCountTimer, paArgs[1].u.u64Number);
     4379    AssertRC(rc);
     4380    return VINF_SUCCESS;
     4381}
     4382# endif /* DEBUG_sandervl */
     4383
    42894384#endif /* VBOX_STRICT */
    42904385
  • trunk/src/VBox/VMM/PGMInternal.h

    r31593 r31600  
    31413141    /** @} */
    31423142
     3143#ifdef VBOX_STRICT
     3144    PTMTIMERR3                      pPhysWritesCountTimer;
     3145    bool                            fCountingPhysWrites;
     3146    uint8_t                         u8Alignment[7];
     3147
     3148    STAMCOUNTER                     StatR3FTPhysPageWrite;              /**< R3: The number of times a physical page was written to (FT stats) */
     3149    STAMCOUNTER                     StatRZFTPhysPageWrite;              /**< RC/R0: The number of times a physical page was written to (FT stats) */
     3150#endif
     3151
    31433152#ifdef VBOX_WITH_STATISTICS
    31443153    /** @name Statistics on the heap.
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r31593 r31600  
    10001000            }
    10011001        }
    1002         /** @todo else: WTF are we here? */
     1002        /** @todo else: why are we here? */
    10031003
    10041004#   if PGM_WITH_PAGING(PGM_GST_TYPE, PGM_SHW_TYPE) && defined(VBOX_STRICT)
     
    18801880                                   )
    18811881#endif /* else: CSAM not active */
    1882                                     PGM_BTH_NAME(SyncPageWorker)(pVCpu, &pPTDst->a[iPTDst], PdeSrc, PteSrc, pShwPage, iPTDst);
     1882                                   PGM_BTH_NAME(SyncPageWorker)(pVCpu, &pPTDst->a[iPTDst], PdeSrc, PteSrc, pShwPage, iPTDst);
    18831883                                Log2(("SyncPage: 4K+ %RGv PteSrc:{P=%d RW=%d U=%d raw=%08llx} PteDst=%08llx%s\n",
    18841884                                      GCPtrCurPage, PteSrc.n.u1Present,
     
    21412141
    21422142                PGM_BTH_NAME(SyncPageWorker)(pVCpu, &pPTDst->a[iPTDst], PdeSrc, PteSrc, pShwPage, iPTDst);
     2143#ifdef VBOX_STRICT
     2144                if (pVM->pgm.s.fCountingPhysWrites)
     2145                    pPTDst->a[iPTDst].n.u1Write = 0;
     2146#endif
    21432147
    21442148                Log2(("SyncPage: 4K+ %RGv PteSrc:{P=%d RW=%d U=%d raw=%08llx} PteDst=%08llx%s\n",
     
    21632167        RTGCPTR         GCPtrCurPage = (GCPtrPage & ~(RTGCPTR)(SHW_PT_MASK << SHW_PT_SHIFT)) | (iPTDst << PAGE_SHIFT);
    21642168        GSTPTE          PteSrc;
     2169
     2170#ifdef DEBUG_sandervl
     2171        if (    pVM->pgm.s.fCountingPhysWrites
     2172            &&  ((uErr & (X86_TRAP_PF_RW|X86_TRAP_PF_P)) == X86_TRAP_PF_RW))
     2173        {
     2174            STAM_COUNTER_INC(&pVM->pgm.s.CTX_MID_Z(Stat, FTPhysPageWrite));
     2175        }
     2176#endif
    21652177
    21662178        /* Fake the page table entry */
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