VirtualBox

Changeset 83088 in vbox for trunk/src/VBox/Debugger


Ignore:
Timestamp:
Feb 16, 2020 8:12:37 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
136144
Message:

DBGC: Added multistep command.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/DBGCCommands.cpp

    r82968 r83088  
    6565static FNDBGCCMD dbgcCmdLoadMap;
    6666static FNDBGCCMD dbgcCmdLoadSeg;
     67static FNDBGCCMD dbgcCmdMultiStep;
    6768static FNDBGCCMD dbgcCmdUnload;
    6869static FNDBGCCMD dbgcCmdSet;
     
    207208    /* cTimesMin,   cTimesMax,  enmCategory,            fFlags,                         pszName,        pszDescription */
    208209    {  0,           1,          DBGCVAR_CAT_STRING,     0,                              "flags",        "Flag modifier string (quote it!)." }
     210};
     211
     212/** multistep arguments. */
     213static const DBGCVARDESC    g_aArgMultiStep[] =
     214{
     215    /* cTimesMin,   cTimesMax,  enmCategory,            fFlags,                         pszName,        pszDescription */
     216    {  0,           1,          DBGCVAR_CAT_NUMBER_NO_RANGE, 0,                         "count",        "Number of steps to take, defaults to 64." },
     217    {  0,           1,          DBGCVAR_CAT_NUMBER_NO_RANGE, DBGCVD_FLAGS_DEP_PREV,     "stride",       "The length of each step, defaults to 1." },
    209218};
    210219
     
    283292    { "logflags",   0,        1,        &g_aArgLogFlags[0],  RT_ELEMENTS(g_aArgLogFlags),  0, dbgcCmdLogFlags,  "[flags string]",       "Displays or modifies the logging flags (VBOX_LOG_FLAGS)." },
    284293    { "logflush",   0,        0,        NULL,                0,                            0, dbgcCmdLogFlush,  "",                     "Flushes the log buffers." },
     294    { "multistep",  0,        2,        &g_aArgMultiStep[0], RT_ELEMENTS(g_aArgMultiStep), 0, dbgcCmdMultiStep, "[count [stride]",              "Performs the specified number of step-into operations. Stops early if non-step event occurs." },
    285295    { "quit",       0,        0,        NULL,                0,                            0, dbgcCmdQuit,      "",                     "Exits the debugger." },
    286296    { "runscript",  1,        1,        &g_aArgFilename[0],  RT_ELEMENTS(g_aArgFilename),  0, dbgcCmdRunScript, "<filename>",           "Runs the command listed in the script. Lines starting with '#' "
     
    859869    NOREF(pCmd);
    860870    NOREF(pUVM);
     871    return rc;
     872}
     873
     874
     875/**
     876 * @callback_method_impl{FNDBGCCMD, The 'multistep' command.}
     877 */
     878static DECLCALLBACK(int) dbgcCmdMultiStep(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
     879{
     880    PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
     881
     882    /*
     883     * Parse arguments.
     884     */
     885    uint32_t cSteps = 64;
     886    if (cArgs > 0)
     887    {
     888        if (paArgs[0].u.u64Number == 0 || paArgs[0].u.u64Number > _2G)
     889            return DBGCCmdHlpFailRc(pCmdHlp, pCmd, VERR_OUT_OF_RANGE,
     890                                    "The 'count' argument is out of range: %#llx - 1..2GiB\n", paArgs[0].u.u64Number);
     891        cSteps = (uint32_t)paArgs[0].u.u64Number;
     892    }
     893    uint32_t uStrideLength = 1;
     894    if (cArgs > 1)
     895    {
     896        if (paArgs[1].u.u64Number == 0 || paArgs[1].u.u64Number > _2G)
     897            return DBGCCmdHlpFailRc(pCmdHlp, pCmd, VERR_OUT_OF_RANGE,
     898                                    "The 'stride' argument is out of range: %#llx - 1..2GiB\n", paArgs[0].u.u64Number);
     899        uStrideLength = (uint32_t)paArgs[0].u.u64Number;
     900    }
     901
     902    /*
     903     * Take the first step.
     904     */
     905    int rc = DBGFR3StepEx(pUVM, pDbgc->idCpu, DBGF_STEP_F_INTO, NULL, NULL, 0, uStrideLength);
     906    if (RT_SUCCESS(rc))
     907    {
     908        pDbgc->cMultiStepsLeft          = cSteps;
     909        pDbgc->uMultiStepStrideLength   = uStrideLength;
     910        pDbgc->pMultiStepCmd            = pCmd;
     911        pDbgc->fReady                   = false;
     912    }
     913    else
     914        return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3StepEx(,,DBGF_STEP_F_INTO,) failed");
     915
     916    NOREF(pCmd);
    861917    return rc;
    862918}
  • trunk/src/VBox/Debugger/DBGCInternal.h

    r82968 r83088  
    138138    bool                fLog;
    139139
     140    /** Counter use to suppress the printing of the headers. */
     141    uint8_t             cPagingHierarchyDumps;
    140142    /** Indicates whether the register are terse or sparse. */
    141143    bool                fRegTerse;
     144
     145    /** @name Stepping
     146     * @{ */
    142147    /** Whether to display registers when tracing. */
    143148    bool                fStepTraceRegs;
    144     /** Counter use to suppress the printing of the headers. */
    145     uint8_t             cPagingHierarchyDumps;
     149    /** Number of multi-steps left, zero if not multi-stepping.   */
     150    uint32_t            cMultiStepsLeft;
     151    /** The multi-step stride length. */
     152    uint32_t            uMultiStepStrideLength;
     153    /** The active multi-step command. */
     154    PCDBGCCMD           pMultiStepCmd;
     155    /** @} */
    146156
    147157    /** Current disassembler position. */
  • trunk/src/VBox/Debugger/DBGConsole.cpp

    r82968 r83088  
    716716        case DBGFEVENT_STEPPED_HYPER:
    717717        {
    718             rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\ndbgf event: Single step! (%s)\n", dbgcGetEventCtx(pEvent->enmCtx));
     718            if (!pDbgc->cMultiStepsLeft)
     719                rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\ndbgf event: Single step! (%s)\n", dbgcGetEventCtx(pEvent->enmCtx));
     720            else
     721                pDbgc->cMultiStepsLeft -= 1;
    719722            if (RT_SUCCESS(rc))
    720723            {
     
    733736                        rc = pDbgc->CmdHlp.pfnExec(&pDbgc->CmdHlp, "%s", szCmd);
    734737                }
     738            }
     739
     740            /* If multi-stepping, take the next step: */
     741            if (pDbgc->cMultiStepsLeft > 0)
     742            {
     743                int rc2 = DBGFR3StepEx(pDbgc->pUVM, pDbgc->idCpu, DBGF_STEP_F_INTO, NULL, NULL, 0, pDbgc->uMultiStepStrideLength);
     744                if (RT_SUCCESS(rc2))
     745                    fPrintPrompt = false;
     746                else
     747                    DBGCCmdHlpFailRc(&pDbgc->CmdHlp, pDbgc->pMultiStepCmd, rc2, "DBGFR3StepEx(,,DBGF_STEP_F_INTO,) failed");
    735748            }
    736749            break;
     
    860873        if (RT_SUCCESS(rc))
    861874            pDbgc->pBack->pfnSetReady(pDbgc->pBack, true);
     875        pDbgc->cMultiStepsLeft = 0;
    862876    }
    863877
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette