VirtualBox

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


Ignore:
Timestamp:
Jan 24, 2011 5:35:59 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
69620
Message:

Debugger console: more cleanup.

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

Legend:

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

    r35673 r35694  
    3737
    3838/**
    39  * Command helper for writing text to the debug console.
    40  *
    41  * @returns VBox status.
    42  * @param   pCmdHlp     Pointer to the command callback structure.
    43  * @param   pvBuf       What to write.
    44  * @param   cbBuf       Number of bytes to write.
    45  * @param   pcbWritten  Where to store the number of bytes actually written.
    46  *                      If NULL the entire buffer must be successfully written.
    47  */
    48 static DECLCALLBACK(int) dbgcHlpWrite(PDBGCCMDHLP pCmdHlp, const void *pvBuf, size_t cbBuf, size_t *pcbWritten)
    49 {
    50     PDBGC   pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
    51     return pDbgc->pBack->pfnWrite(pDbgc->pBack, pvBuf, cbBuf, pcbWritten);
    52 }
    53 
    54 
    55 /**
    56  * Command helper for writing formatted text to the debug console.
    57  *
    58  * @returns VBox status.
    59  * @param   pCmdHlp     Pointer to the command callback structure.
    60  * @param   pcb         Where to store the number of bytes written.
    61  * @param   pszFormat   The format string.
    62  *                      This is using the log formatter, so it's format extensions can be used.
    63  * @param   ...         Arguments specified in the format string.
     39 * @interface_method_impl{DBGCCMDHLP,pfnPrintf}
    6440 */
    6541static DECLCALLBACK(int) dbgcHlpPrintf(PDBGCCMDHLP pCmdHlp, size_t *pcbWritten, const char *pszFormat, ...)
     
    7753
    7854/**
    79  * Callback to format non-standard format specifiers.
     55 * Callback to format non-standard format specifiers, employed by dbgcPrintfV
     56 * and others.
    8057 *
    8158 * @returns The number of bytes formatted.
     
    190167
    191168/**
    192  * Output callback.
     169 * Output callback employed by dbgcHlpPrintfV.
    193170 *
    194171 * @returns number of bytes written.
     
    199176static DECLCALLBACK(size_t) dbgcFormatOutput(void *pvArg, const char *pachChars, size_t cbChars)
    200177{
    201     PDBGC   pDbgc = (PDBGC)pvArg;
     178    PDBGC pDbgc = (PDBGC)pvArg;
    202179    if (cbChars)
    203180    {
    204181        int rc = pDbgc->pBack->pfnWrite(pDbgc->pBack, pachChars, cbChars, NULL);
    205         if (RT_FAILURE(rc))
     182        if (RT_SUCCESS(rc))
     183            pDbgc->chLastOutput = pachChars[cbChars - 1];
     184        else
    206185        {
    207186            pDbgc->rcOutput = rc;
     
    216195
    217196/**
    218  * Command helper for writing formatted text to the debug console.
    219  *
    220  * @returns VBox status.
    221  * @param   pCmdHlp     Pointer to the command callback structure.
    222  * @param   pcbWritten  Where to store the number of bytes written.
    223  * @param   pszFormat   The format string.
    224  *                      This is using the log formatter, so it's format extensions can be used.
    225  * @param   args        Arguments specified in the format string.
     197 * @interface_method_impl{DBGCCMDHLP,pfnPrintfV}
    226198 */
    227199static DECLCALLBACK(int) dbgcHlpPrintfV(PDBGCCMDHLP pCmdHlp, size_t *pcbWritten, const char *pszFormat, va_list args)
     
    243215
    244216/**
    245  * Reports an error from a DBGF call.
    246  *
    247  * @returns VBox status code appropriate to return from a command.
    248  * @param   pCmdHlp     Pointer to command helpers.
    249  * @param   rc          The VBox status code returned by a DBGF call.
    250  * @param   pszFormat   Format string for additional messages. Can be NULL.
    251  * @param   ...         Format arguments, optional.
     217 * @interface_method_impl{DBGCCMDHLP,pfnVBoxErrorV}
    252218 */
    253219static DECLCALLBACK(int) dbgcHlpVBoxErrorV(PDBGCCMDHLP pCmdHlp, int rc, const char *pszFormat, va_list args)
     
    271237
    272238/**
    273  * Reports an error from a DBGF call.
    274  *
    275  * @returns VBox status code appropriate to return from a command.
    276  * @param   pCmdHlp     Pointer to command helpers.
    277  * @param   rc          The VBox status code returned by a DBGF call.
    278  * @param   pszFormat   Format string for additional messages. Can be NULL.
    279  * @param   ...         Format arguments, optional.
     239 * @interface_method_impl{DBGCCMDHLP,pfnVBoxError}
    280240 */
    281241static DECLCALLBACK(int) dbgcHlpVBoxError(PDBGCCMDHLP pCmdHlp, int rc, const char *pszFormat, ...)
     
    290250
    291251/**
    292  * Command helper for reading memory specified by a DBGC variable.
    293  *
    294  * @returns VBox status code appropriate to return from a command.
    295  * @param   pCmdHlp     Pointer to the command callback structure.
    296  * @param   pVM         VM handle if GC or physical HC address.
    297  * @param   pvBuffer    Where to store the read data.
    298  * @param   cbRead      Number of bytes to read.
    299  * @param   pVarPointer DBGC variable specifying where to start reading.
    300  * @param   pcbRead     Where to store the number of bytes actually read.
    301  *                      This optional, but it's useful when read GC virtual memory where a
    302  *                      page in the requested range might not be present.
    303  *                      If not specified not-present failure or end of a HC physical page
    304  *                      will cause failure.
     252 * @interface_method_impl{DBGCCMDHLP,pfnMemRead}
    305253 */
    306254static DECLCALLBACK(int) dbgcHlpMemRead(PDBGCCMDHLP pCmdHlp, PVM pVM, void *pvBuffer, size_t cbRead, PCDBGCVAR pVarPointer, size_t *pcbRead)
     
    472420}
    473421
    474 /**
    475  * Command helper for writing memory specified by a DBGC variable.
    476  *
    477  * @returns VBox status code appropriate to return from a command.
    478  * @param   pCmdHlp     Pointer to the command callback structure.
    479  * @param   pVM         VM handle if GC or physical HC address.
    480  * @param   pvBuffer    What to write.
    481  * @param   cbWrite     Number of bytes to write.
    482  * @param   pVarPointer DBGC variable specifying where to start reading.
    483  * @param   pcbWritten  Where to store the number of bytes written.
    484  *                      This is optional. If NULL be aware that some of the buffer
    485  *                      might have been written to the specified address.
     422
     423/**
     424 * @interface_method_impl{DBGCCMDHLP,pfnMemWrite}
    486425 */
    487426static DECLCALLBACK(int) dbgcHlpMemWrite(PDBGCCMDHLP pCmdHlp, PVM pVM, const void *pvBuffer, size_t cbWrite, PCDBGCVAR pVarPointer, size_t *pcbWritten)
     
    618557
    619558/**
    620  * Executes one command expression.
    621  * (Hopefully the parser and functions are fully reentrant.)
    622  *
    623  * @returns VBox status code appropriate to return from a command.
    624  * @param   pCmdHlp     Pointer to the command callback structure.
    625  * @param   pszExpr     The expression. Format string with the format DBGC extensions.
    626  * @param   ...         Format arguments.
     559 * @interface_method_impl{DBGCCMDHLP,pfnHlpExec}
    627560 */
    628561static DECLCALLBACK(int) dbgcHlpExec(PDBGCCMDHLP pCmdHlp, const char *pszExpr, ...)
     
    694627    if (RT_FAILURE(pDbgc->rcOutput))
    695628        return pDbgc->rcOutput;
     629    if (pDbgc->chLastOutput != '\n')
     630        dbgcFormatOutput(pDbgc, "\n", 1);
     631    return VERR_DBGC_COMMAND_FAILED;
     632}
     633
     634
     635/**
     636 * @copydoc DBGCCMDHLP::pfnFailV
     637 */
     638static DECLCALLBACK(int) dbgcHlpFailRcV(PDBGCCMDHLP pCmdHlp, PCDBGCCMD pCmd, int rc, const char *pszFormat, va_list va)
     639{
     640    PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
     641
     642    /*
     643     * Do the formatting and output.
     644     */
     645    pDbgc->rcOutput = VINF_SUCCESS;
     646    RTStrFormat(dbgcFormatOutput, pDbgc, dbgcStringFormatter, pDbgc, "%s: error: ", pCmd->pszCmd);
     647    if (RT_FAILURE(pDbgc->rcOutput))
     648        return pDbgc->rcOutput;
     649    RTStrFormatV(dbgcFormatOutput, pDbgc, dbgcStringFormatter, pDbgc, pszFormat, va);
     650    if (RT_FAILURE(pDbgc->rcOutput))
     651        return pDbgc->rcOutput;
     652    RTStrFormat(dbgcFormatOutput, pDbgc, dbgcStringFormatter, pDbgc, ": %Rrc\n", rc);
     653    if (RT_FAILURE(pDbgc->rcOutput))
     654        return pDbgc->rcOutput;
     655
    696656    return VERR_DBGC_COMMAND_FAILED;
    697657}
     
    778738
    779739/**
    780  * Converts a DBGC variable to a number.
    781  *
    782  * @returns VBox status code.
    783  * @param   pCmdHlp     Pointer to the command callback structure.
    784  * @param   pVar        The variable to convert.
    785  * @param   pu64Number  Where to store the number value.
     740 * @interface_method_impl{DBGCCMDHLP,pfnVarToNumber}
    786741 */
    787742static DECLCALLBACK(int) dbgcHlpVarToNumber(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVar, uint64_t *pu64Number)
     
    823778
    824779/**
    825  * Converts a DBGC variable to a boolean.
    826  *
    827  * @returns VBox status code.
    828  * @param   pCmdHlp     Pointer to the command callback structure.
    829  * @param   pVar        The variable to convert.
    830  * @param   pf          Where to store the boolean.
     780 * @interface_method_impl{DBGCCMDHLP,pfnVarToBool}
    831781 */
    832782static DECLCALLBACK(int) dbgcHlpVarToBool(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVar, bool *pf)
     
    12551205
    12561206/**
    1257  * Info helper callback wrapper - print formatted string.
    1258  *
    1259  * @param   pHlp        Pointer to this structure.
    1260  * @param   pszFormat   The format string.
    1261  * @param   ...         Arguments.
     1207 * @interface_method_impl{DBGFINFOHLP,pfnPrintf}
    12621208 */
    12631209static DECLCALLBACK(void) dbgcHlpGetDbgfOutputHlp_Printf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...)
     
    12721218
    12731219/**
    1274  * Info helper callback wrapper - print formatted string.
    1275  *
    1276  * @param   pHlp        Pointer to this structure.
    1277  * @param   pszFormat   The format string.
    1278  * @param   args        Argument list.
     1220 * @interface_method_impl{DBGFINFOHLP,pfnPrintfV}
    12791221 */
    12801222static DECLCALLBACK(void) dbgcHlpGetDbgfOutputHlp_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args)
     
    13101252void dbgcInitCmdHlp(PDBGC pDbgc)
    13111253{
    1312     pDbgc->CmdHlp.pfnWrite              = dbgcHlpWrite;
     1254    pDbgc->CmdHlp.u32Magic              = DBGCCMDHLP_MAGIC;
    13131255    pDbgc->CmdHlp.pfnPrintfV            = dbgcHlpPrintfV;
    13141256    pDbgc->CmdHlp.pfnPrintf             = dbgcHlpPrintf;
     
    13201262    pDbgc->CmdHlp.pfnExec               = dbgcHlpExec;
    13211263    pDbgc->CmdHlp.pfnFailV              = dbgcHlpFailV;
     1264    pDbgc->CmdHlp.pfnFailRcV            = dbgcHlpFailRcV;
    13221265    pDbgc->CmdHlp.pfnVarToDbgfAddr      = dbgcHlpVarToDbgfAddr;
    13231266    pDbgc->CmdHlp.pfnVarFromDbgfAddr    = dbgcHlpVarFromDbgfAddr;
     
    13271270    pDbgc->CmdHlp.pfnVarConvert         = dbgcHlpVarConvert;
    13281271    pDbgc->CmdHlp.pfnGetDbgfOutputHlp   = dbgcHlpGetDbgfOutputHlp;
    1329 }
    1330 
     1272    pDbgc->CmdHlp.u32EndMarker          = DBGCCMDHLP_MAGIC;
     1273}
     1274
  • trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp

    r35673 r35694  
    390390static DECLCALLBACK(int) dbgcCmdGo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
    391391{
     392    DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM);
     393
    392394    /*
    393395     * Check if the VM is halted or not before trying to resume it.
    394396     */
    395397    if (!DBGFR3IsHalted(pVM))
    396         pCmdHlp->pfnPrintf(pCmdHlp, NULL, "warning: The VM is already running...\n");
    397     else
    398     {
    399         int rc = DBGFR3Resume(pVM);
    400         if (RT_FAILURE(rc))
    401             return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Executing DBGFR3Resume().");
    402     }
    403 
    404     NOREF(pCmd);
    405     NOREF(paArgs);
    406     NOREF(cArgs);
    407     NOREF(pResult);
    408     return 0;
     398        return DBGCCmdHlpFail(pCmdHlp, pCmd, "The VM is already running");
     399
     400    int rc = DBGFR3Resume(pVM);
     401    if (RT_FAILURE(rc))
     402        return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3Resume");
     403
     404    NOREF(paArgs); NOREF(cArgs); NOREF(pResult);
     405    return VINF_SUCCESS;
    409406}
    410407
     
    422419static DECLCALLBACK(int) dbgcCmdBrkAccess(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
    423420{
     421    DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM);
     422
    424423    /*
    425424     * Interpret access type.
     
    427426    if (    !strchr("xrwi", paArgs[0].u.pszString[0])
    428427        ||  paArgs[0].u.pszString[1])
    429         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid access type '%s' for '%s'. Valid types are 'e', 'r', 'w' and 'i'.\n",
    430                                   paArgs[0].u.pszString, pCmd->pszCmd);
     428        return DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid access type '%s' for '%s'. Valid types are 'e', 'r', 'w' and 'i'",
     429                              paArgs[0].u.pszString, pCmd->pszCmd);
    431430    uint8_t fType = 0;
    432431    switch (paArgs[0].u.pszString[0])
     
    442441     */
    443442    if (fType == X86_DR7_RW_EO && paArgs[1].u.u64Number != 1)
    444         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid access size %RX64 for '%s'. 'x' access type requires size 1!\n",
    445                                   paArgs[1].u.u64Number, pCmd->pszCmd);
     443        return DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid access size %RX64 for '%s'. 'x' access type requires size 1!",
     444                              paArgs[1].u.u64Number, pCmd->pszCmd);
    446445    switch (paArgs[1].u.u64Number)
    447446    {
     
    452451        /*case 8: - later*/
    453452        default:
    454             return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid access size %RX64 for '%s'. 1, 2 or 4!\n",
    455                                       paArgs[1].u.u64Number, pCmd->pszCmd);
     453            return DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid access size %RX64 for '%s'. 1, 2 or 4!",
     454                                  paArgs[1].u.u64Number, pCmd->pszCmd);
    456455    }
    457456    uint8_t cb = (uint8_t)paArgs[1].u.u64Number;
     
    461460     */
    462461    DBGFADDRESS Address;
    463     int rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[2], &Address);
     462    int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &paArgs[2], &Address);
    464463    if (RT_FAILURE(rc))
    465         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Couldn't convert '%DV' to a DBGF address, rc=%Rrc.\n", &paArgs[2], rc);
     464        return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,%DV,)", &paArgs[2]);
    466465
    467466    /*
     
    491490     * Try set the breakpoint.
    492491     */
    493     RTUINT iBp;
     492    uint32_t iBp;
    494493    rc = DBGFR3BpSetReg(pVM, &Address, iHitTrigger, iHitDisable, fType, cb, &iBp);
    495494    if (RT_SUCCESS(rc))
     
    498497        rc = dbgcBpAdd(pDbgc, iBp, pszCmds);
    499498        if (RT_SUCCESS(rc))
    500             return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Set access breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
     499            return DBGCCmdHlpPrintf(pCmdHlp, "Set access breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
    501500        if (rc == VERR_DBGC_BP_EXISTS)
    502501        {
    503502            rc = dbgcBpUpdate(pDbgc, iBp, pszCmds);
    504503            if (RT_SUCCESS(rc))
    505                 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Updated access breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
     504                return DBGCCmdHlpPrintf(pCmdHlp, "Updated access breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
    506505        }
    507506        int rc2 = DBGFR3BpClear(pDbgc->pVM, iBp);
    508507        AssertRC(rc2);
    509508    }
    510     return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Failed to set access breakpoint at %RGv, rc=%Rrc.\n", Address.FlatPtr, rc);
     509    return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set access breakpoint at %RGv", Address.FlatPtr);
    511510}
    512511
     
    524523static DECLCALLBACK(int) dbgcCmdBrkClear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
    525524{
     525    DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM);
     526
    526527    /*
    527528     * Enumerate the arguments.
    528529     */
    529530    PDBGC   pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
    530     int     rc = VINF_SUCCESS;
     531    int     rc    = VINF_SUCCESS;
    531532    for (unsigned iArg = 0; iArg < cArgs && RT_SUCCESS(rc); iArg++)
    532533    {
     
    534535        {
    535536            /* one */
    536             RTUINT iBp = (RTUINT)paArgs[iArg].u.u64Number;
    537             if (iBp != paArgs[iArg].u.u64Number)
     537            uint32_t iBp = (uint32_t)paArgs[iArg].u.u64Number;
     538            if (iBp == paArgs[iArg].u.u64Number)
    538539            {
    539                 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Breakpoint id %RX64 is too large!\n", paArgs[iArg].u.u64Number);
    540                 break;
     540                int rc2 = DBGFR3BpClear(pVM, iBp);
     541                if (RT_FAILURE(rc2))
     542                    rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpClear(,%#x)", iBp);
     543                if (RT_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND)
     544                    dbgcBpDelete(pDbgc, iBp);
    541545            }
    542             int rc2 = DBGFR3BpClear(pVM, iBp);
    543             if (RT_FAILURE(rc2))
    544                 rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc2, "DBGFR3BpClear failed for breakpoint %u!\n", iBp);
    545             if (RT_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND)
    546                 dbgcBpDelete(pDbgc, iBp);
     546            else
     547                rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Breakpoint id %RX64 is too large", paArgs[iArg].u.u64Number);
    547548        }
    548549        else if (!strcmp(paArgs[iArg].u.pszString, "all"))
     
    552553            while (pBp)
    553554            {
    554                 RTUINT iBp = pBp->iBp;
     555                uint32_t iBp = pBp->iBp;
    555556                pBp = pBp->pNext;
    556557
    557558                int rc2 = DBGFR3BpClear(pVM, iBp);
    558559                if (RT_FAILURE(rc2))
    559                     rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc2, "DBGFR3BpClear failed for breakpoint %u!\n", iBp);
     560                    rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpClear(,%#x)", iBp);
    560561                if (RT_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND)
    561562                    dbgcBpDelete(pDbgc, iBp);
     
    563564        }
    564565        else
    565         {
    566             /* invalid parameter */
    567             rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid argument '%s' to '%s'!\n", paArgs[iArg].u.pszString, pCmd->pszCmd);
    568             break;
    569         }
     566            rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid argument '%s'", paArgs[iArg].u.pszString);
    570567    }
    571568    return rc;
     
    594591        {
    595592            /* one */
    596             RTUINT iBp = (RTUINT)paArgs[iArg].u.u64Number;
    597             if (iBp != paArgs[iArg].u.u64Number)
     593            uint32_t iBp = (uint32_t)paArgs[iArg].u.u64Number;
     594            if (iBp == paArgs[iArg].u.u64Number)
    598595            {
    599                 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Breakpoint id %RX64 is too large!\n", paArgs[iArg].u.u64Number);
    600                 break;
     596                rc = DBGFR3BpDisable(pVM, iBp);
     597                if (RT_FAILURE(rc))
     598                    rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3BpDisable failed for breakpoint %#x", iBp);
    601599            }
    602             rc = DBGFR3BpDisable(pVM, iBp);
    603             if (RT_FAILURE(rc))
    604                 rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpDisable failed for breakpoint %u!\n", iBp);
     600            else
     601                rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Breakpoint id %RX64 is too large", paArgs[iArg].u.u64Number);
    605602        }
    606603        else if (!strcmp(paArgs[iArg].u.pszString, "all"))
     
    610607            for (PDBGCBP pBp = pDbgc->pFirstBp; pBp; pBp = pBp->pNext)
    611608            {
    612                 rc = DBGFR3BpDisable(pVM, pBp->iBp);
    613                 if (RT_FAILURE(rc))
    614                     rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpDisable failed for breakpoint %u!\n", pBp->iBp);
     609                int rc2 = DBGFR3BpDisable(pVM, pBp->iBp);
     610                if (RT_FAILURE(rc2))
     611                    rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpDisable failed for breakpoint %#x", pBp->iBp);
    615612            }
    616613        }
    617614        else
    618         {
    619             /* invalid parameter */
    620             rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid argument '%s' to '%s'!\n", paArgs[iArg].u.pszString, pCmd->pszCmd);
    621             break;
    622         }
     615            rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid argument '%s'", paArgs[iArg].u.pszString);
    623616    }
    624617    return rc;
     
    638631static DECLCALLBACK(int) dbgcCmdBrkEnable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
    639632{
     633    DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM);
     634
    640635    /*
    641636     * Enumerate the arguments.
     
    647642        {
    648643            /* one */
    649             RTUINT iBp = (RTUINT)paArgs[iArg].u.u64Number;
    650             if (iBp != paArgs[iArg].u.u64Number)
     644            uint32_t iBp = (uint32_t)paArgs[iArg].u.u64Number;
     645            if (iBp == paArgs[iArg].u.u64Number)
    651646            {
    652                 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Breakpoint id %RX64 is too large!\n", paArgs[iArg].u.u64Number);
    653                 break;
     647                rc = DBGFR3BpEnable(pVM, iBp);
     648                if (RT_FAILURE(rc))
     649                    rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3BpEnable failed for breakpoint %#x", iBp);
    654650            }
    655             rc = DBGFR3BpEnable(pVM, iBp);
    656             if (RT_FAILURE(rc))
    657                 rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpEnable failed for breakpoint %u!\n", iBp);
     651            else
     652                rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Breakpoint id %RX64 is too large", paArgs[iArg].u.u64Number);
    658653        }
    659654        else if (!strcmp(paArgs[iArg].u.pszString, "all"))
     
    663658            for (PDBGCBP pBp = pDbgc->pFirstBp; pBp; pBp = pBp->pNext)
    664659            {
    665                 rc = DBGFR3BpEnable(pVM, pBp->iBp);
    666                 if (RT_FAILURE(rc))
    667                     rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpEnable failed for breakpoint %u!\n", pBp->iBp);
     660                int rc2 = DBGFR3BpEnable(pVM, pBp->iBp);
     661                if (RT_FAILURE(rc2))
     662                    rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpEnable failed for breakpoint %#x", pBp->iBp);
    668663            }
    669664        }
    670665        else
    671         {
    672             /* invalid parameter */
    673             rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid argument '%s' to '%s'!\n", paArgs[iArg].u.pszString, pCmd->pszCmd);
    674             break;
    675         }
     666            rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid argument '%s'", paArgs[iArg].u.pszString);
    676667    }
    677668    return rc;
     
    689680static DECLCALLBACK(int) dbgcEnumBreakpointsCallback(PVM pVM, void *pvUser, PCDBGFBP pBp)
    690681{
    691     PDBGC pDbgc = (PDBGC)pvUser;
     682    PDBGC   pDbgc  = (PDBGC)pvUser;
    692683    PDBGCBP pDbgcBp = dbgcBpGet(pDbgc, pBp->iBp);
    693684
     
    722713    }
    723714
    724     pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%2u %c %d %c %RGv %04RX64 (%04RX64 to ",
    725                             pBp->iBp, pBp->fEnabled ? 'e' : 'd', cb, chType,
    726                             pBp->GCPtr, pBp->cHits, pBp->iHitTrigger);
     715    DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%4#x %c %d %c %RGv %04RX64 (%04RX64 to ",
     716                     pBp->iBp, pBp->fEnabled ? 'e' : 'd', cb, chType,
     717                     pBp->GCPtr, pBp->cHits, pBp->iHitTrigger);
    727718    if (pBp->iHitDisable == ~(uint64_t)0)
    728         pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "~0)  ");
     719        DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "~0)  ");
    729720    else
    730         pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%04RX64)");
     721        DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%04RX64)");
    731722
    732723    /*
     
    740731    {
    741732        if (!off)
    742             pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%s", Sym.szName);
     733            DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s", Sym.szName);
    743734        else if (off > 0)
    744             pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%s+%RGv", Sym.szName, off);
     735            DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s+%RGv", Sym.szName, off);
    745736        else
    746             pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%s+%RGv", Sym.szName, -off);
     737            DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s+%RGv", Sym.szName, -off);
    747738    }
    748739
     
    753744    {
    754745        if (pDbgcBp->cchCmd)
    755             pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\n  cmds: '%s'\n",
    756                                     pDbgcBp->szCmd);
     746            DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "\n  cmds: '%s'\n", pDbgcBp->szCmd);
    757747        else
    758             pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\n");
     748            DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "\n");
    759749    }
    760750    else
    761         pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, " [unknown bp]\n");
     751        DBGCCmdHlpPrintf(&pDbgc->CmdHlp, " [unknown bp]\n");
    762752
    763753    return VINF_SUCCESS;
     
    775765 * @param   cArgs       Number of arguments in the array.
    776766 */
    777 static DECLCALLBACK(int) dbgcCmdBrkList(PCDBGCCMD /*pCmd*/, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR /*paArgs*/, unsigned /*cArgs*/, PDBGCVAR /*pResult*/)
    778 {
     767static DECLCALLBACK(int) dbgcCmdBrkList(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR /*paArgs*/, unsigned cArgs, PDBGCVAR /*pResult*/)
     768{
     769    DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM);
     770    DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, -1, cArgs == 0);
     771
     772    /*
     773     * Enumerate the breakpoints.
     774     */
    779775    PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
    780 
    781     /*
    782      * Enumerate the breakpoints.
    783      */
    784776    int rc = DBGFR3BpEnum(pVM, dbgcEnumBreakpointsCallback, pDbgc);
    785777    if (RT_FAILURE(rc))
    786         return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpEnum failed.\n");
     778        return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3BpEnum");
    787779    return rc;
    788780}
     
    799791 * @param   cArgs       Number of arguments in the array.
    800792 */
    801 static DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD /*pCmd*/, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
     793static DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
    802794{
    803795    /*
     
    805797     */
    806798    DBGFADDRESS Address;
    807     int rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[0], &Address);
     799    int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &paArgs[0], &Address);
    808800    if (RT_FAILURE(rc))
    809         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Couldn't convert '%DV' to a DBGF address, rc=%Rrc.\n", &paArgs[0], rc);
     801        return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,'%DV',)", &paArgs[0]);
    810802
    811803    /*
     
    835827     * Try set the breakpoint.
    836828     */
    837     RTUINT iBp;
     829    uint32_t iBp;
    838830    rc = DBGFR3BpSet(pVM, &Address, iHitTrigger, iHitDisable, &iBp);
    839831    if (RT_SUCCESS(rc))
    840832    {
    841         PDBGC   pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
     833        PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
    842834        rc = dbgcBpAdd(pDbgc, iBp, pszCmds);
    843835        if (RT_SUCCESS(rc))
    844             return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Set breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
     836            return DBGCCmdHlpPrintf(pCmdHlp, "Set breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
    845837        if (rc == VERR_DBGC_BP_EXISTS)
    846838        {
    847839            rc = dbgcBpUpdate(pDbgc, iBp, pszCmds);
    848840            if (RT_SUCCESS(rc))
    849                 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Updated breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
     841                return DBGCCmdHlpPrintf(pCmdHlp, "Updated breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
    850842        }
    851843        int rc2 = DBGFR3BpClear(pDbgc->pVM, iBp);
    852844        AssertRC(rc2);
    853845    }
    854     return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Failed to set breakpoint at %RGv, rc=%Rrc.\n", Address.FlatPtr, rc);
     846    return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set breakpoint at %RGv", Address.FlatPtr);
    855847}
    856848
     
    866858 * @param   cArgs       Number of arguments in the array.
    867859 */
    868 static DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD /*pCmd*/, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
     860static DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)
    869861{
    870862    /*
     
    872864     */
    873865    DBGFADDRESS Address;
    874     int rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[0], &Address);
     866    int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &paArgs[0], &Address);
    875867    if (RT_FAILURE(rc))
    876         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Couldn't convert '%DV' to a DBGF address, rc=%Rrc.\n", &paArgs[0], rc);
     868        return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,'%DV',)", &paArgs[0]);
    877869
    878870    /*
     
    902894     * Try set the breakpoint.
    903895     */
    904     RTUINT iBp;
     896    uint32_t iBp;
    905897    rc = DBGFR3BpSetREM(pVM, &Address, iHitTrigger, iHitDisable, &iBp);
    906898    if (RT_SUCCESS(rc))
     
    909901        rc = dbgcBpAdd(pDbgc, iBp, pszCmds);
    910902        if (RT_SUCCESS(rc))
    911             return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Set REM breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
     903            return DBGCCmdHlpPrintf(pCmdHlp, "Set REM breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
    912904        if (rc == VERR_DBGC_BP_EXISTS)
    913905        {
    914906            rc = dbgcBpUpdate(pDbgc, iBp, pszCmds);
    915907            if (RT_SUCCESS(rc))
    916                 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Updated REM breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
     908                return DBGCCmdHlpPrintf(pCmdHlp, "Updated REM breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
    917909        }
    918910        int rc2 = DBGFR3BpClear(pDbgc->pVM, iBp);
    919911        AssertRC(rc2);
    920912    }
    921     return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Failed to set REM breakpoint at %RGv, rc=%Rrc.\n", Address.FlatPtr, rc);
     913    return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set REM breakpoint at %RGv", Address.FlatPtr);
    922914}
    923915
  • trunk/src/VBox/Debugger/DBGCInternal.h

    r35673 r35694  
    8080    struct DBGCBP  *pNext;
    8181    /** The breakpoint identifier. */
    82     RTUINT          iBp;
     82    uint32_t        iBp;
    8383    /** The size of the command. */
    8484    size_t          cchCmd;
     
    239239    /** rc from the last dbgcHlpPrintfV(). */
    240240    int                 rcOutput;
     241    /** The last character we wrote. */
     242    char                chLastOutput;
     243
    241244    /** rc from the last command. */
    242245    int                 rcCmd;
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