VirtualBox

Changeset 35694 in vbox


Ignore:
Timestamp:
Jan 24, 2011 5:35:59 PM (14 years ago)
Author:
vboxsync
Message:

Debugger console: more cleanup.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/dbg.h

    r35673 r35694  
    371371typedef struct DBGCCMDHLP *PDBGCCMDHLP;
    372372
    373 /**
    374  * Command helper for writing text to the debug console.
    375  *
    376  * @returns VBox status.
    377  * @param   pCmdHlp     Pointer to the command callback structure.
    378  * @param   pvBuf       What to write.
    379  * @param   cbBuf       Number of bytes to write.
    380  * @param   pcbWritten  Where to store the number of bytes actually written.
    381  *                      If NULL the entire buffer must be successfully written.
    382  */
    383 typedef DECLCALLBACK(int) FNDBGCHLPWRITE(PDBGCCMDHLP pCmdHlp, const void *pvBuf, size_t cbBuf, size_t *pcbWritten);
    384 /** Pointer to a FNDBGCHLPWRITE() function. */
    385 typedef FNDBGCHLPWRITE *PFNDBGCHLPWRITE;
    386 
    387 /**
    388  * Command helper for writing formatted text to the debug console.
    389  *
    390  * @returns VBox status.
    391  * @param   pCmdHlp     Pointer to the command callback structure.
    392  * @param   pcb         Where to store the number of bytes written.
    393  * @param   pszFormat   The format string.
    394  *                      This is using the log formatter, so it's format extensions can be used.
    395  * @param   ...         Arguments specified in the format string.
    396  */
    397 typedef DECLCALLBACK(int) FNDBGCHLPPRINTF(PDBGCCMDHLP pCmdHlp, size_t *pcbWritten, const char *pszFormat, ...);
    398 /** Pointer to a FNDBGCHLPPRINTF() function. */
    399 typedef FNDBGCHLPPRINTF *PFNDBGCHLPPRINTF;
    400 
    401 /**
    402  * Command helper for writing formatted text to the debug console.
    403  *
    404  * @returns VBox status.
    405  * @param   pCmdHlp     Pointer to the command callback structure.
    406  * @param   pcb         Where to store the number of bytes written.
    407  * @param   pszFormat   The format string.
    408  *                      This is using the log formatter, so it's format extensions can be used.
    409  * @param   args        Arguments specified in the format string.
    410  */
    411 typedef DECLCALLBACK(int) FNDBGCHLPPRINTFV(PDBGCCMDHLP pCmdHlp, size_t *pcbWritten, const char *pszFormat, va_list args);
    412 /** Pointer to a FNDBGCHLPPRINTFV() function. */
    413 typedef FNDBGCHLPPRINTFV *PFNDBGCHLPPRINTFV;
    414 
    415 /**
    416  * Command helper for formatting and error message for a VBox status code.
    417  *
    418  * @returns VBox status code appropriate to return from a command.
    419  * @param   pCmdHlp     Pointer to the command callback structure.
    420  * @param   rc          The VBox status code.
    421  * @param   pszFormat   Format string for additional messages. Can be NULL.
    422  * @param   ...         Format arguments, optional.
    423  */
    424 typedef DECLCALLBACK(int) FNDBGCHLPVBOXERROR(PDBGCCMDHLP pCmdHlp, int rc, const char *pszFormat, ...);
    425 /** Pointer to a FNDBGCHLPVBOXERROR() function. */
    426 typedef FNDBGCHLPVBOXERROR *PFNDBGCHLPVBOXERROR;
    427 
    428 /**
    429  * Command helper for formatting and error message for a VBox status code.
    430  *
    431  * @returns VBox status code appropriate to return from a command.
    432  * @param   pCmdHlp     Pointer to the command callback structure.
    433  * @param   rc          The VBox status code.
    434  * @param   pcb         Where to store the number of bytes written.
    435  * @param   pszFormat   Format string for additional messages. Can be NULL.
    436  * @param   args        Format arguments, optional.
    437  */
    438 typedef DECLCALLBACK(int) FNDBGCHLPVBOXERRORV(PDBGCCMDHLP pCmdHlp, int rc, const char *pszFormat, va_list args);
    439 /** Pointer to a FNDBGCHLPVBOXERRORV() function. */
    440 typedef FNDBGCHLPVBOXERRORV *PFNDBGCHLPVBOXERRORV;
    441 
    442 /**
    443  * Command helper for reading memory specified by a DBGC variable.
    444  *
    445  * @returns VBox status code appropriate to return from a command.
    446  * @param   pCmdHlp     Pointer to the command callback structure.
    447  * @param   pVM         VM handle if GC or physical HC address.
    448  * @param   pvBuffer    Where to store the read data.
    449  * @param   cbRead      Number of bytes to read.
    450  * @param   pVarPointer DBGC variable specifying where to start reading.
    451  * @param   pcbRead     Where to store the number of bytes actually read.
    452  *                      This optional, but it's useful when read GC virtual memory where a
    453  *                      page in the requested range might not be present.
    454  *                      If not specified not-present failure or end of a HC physical page
    455  *                      will cause failure.
    456  */
    457 typedef DECLCALLBACK(int) FNDBGCHLPMEMREAD(PDBGCCMDHLP pCmdHlp, PVM pVM, void *pvBuffer, size_t cbRead, PCDBGCVAR pVarPointer, size_t *pcbRead);
    458 /** Pointer to a FNDBGCHLPMEMREAD() function. */
    459 typedef FNDBGCHLPMEMREAD *PFNDBGCHLPMEMREAD;
    460 
    461 /**
    462  * Command helper for writing memory specified by a DBGC variable.
    463  *
    464  * @returns VBox status code appropriate to return from a command.
    465  * @param   pCmdHlp     Pointer to the command callback structure.
    466  * @param   pVM         VM handle if GC or physical HC address.
    467  * @param   pvBuffer    What to write.
    468  * @param   cbWrite     Number of bytes to write.
    469  * @param   pVarPointer DBGC variable specifying where to start reading.
    470  * @param   pcbWritten  Where to store the number of bytes written.
    471  *                      This is optional. If NULL be aware that some of the buffer
    472  *                      might have been written to the specified address.
    473  */
    474 typedef DECLCALLBACK(int) FNDBGCHLPMEMWRITE(PDBGCCMDHLP pCmdHlp, PVM pVM, const void *pvBuffer, size_t cbWrite, PCDBGCVAR pVarPointer, size_t *pcbWritten);
    475 /** Pointer to a FNDBGCHLPMEMWRITE() function. */
    476 typedef FNDBGCHLPMEMWRITE *PFNDBGCHLPMEMWRITE;
    477 
    478 
    479 
    480 /**
    481  * Executes command an expression.
    482  * (Hopefully the parser and functions are fully reentrant.)
    483  *
    484  * @returns VBox status code appropriate to return from a command.
    485  * @param   pCmdHlp     Pointer to the command callback structure.
    486  * @param   pszExpr     The expression. Format string with the format DBGC extensions.
    487  * @param   ...         Format arguments.
    488  */
    489 typedef DECLCALLBACK(int) FNDBGCHLPEXEC(PDBGCCMDHLP pCmdHlp, const char *pszExpr, ...);
    490 /** Pointer to a FNDBGCHLPEVAL() function. */
    491 typedef FNDBGCHLPEXEC *PFNDBGCHLPEXEC;
    492 
    493373
    494374/**
     
    497377typedef struct DBGCCMDHLP
    498378{
    499     /** Pointer to a FNDBCHLPWRITE() function. */
    500     PFNDBGCHLPWRITE         pfnWrite;
    501     /** Pointer to a FNDBGCHLPPRINTF() function. */
    502     PFNDBGCHLPPRINTF        pfnPrintf;
    503     /** Pointer to a FNDBGCHLPPRINTFV() function. */
    504     PFNDBGCHLPPRINTFV       pfnPrintfV;
    505     /** Pointer to a FNDBGCHLPVBOXERROR() function. */
    506     PFNDBGCHLPVBOXERROR     pfnVBoxError;
    507     /** Pointer to a FNDBGCHLPVBOXERRORV() function. */
    508     PFNDBGCHLPVBOXERRORV    pfnVBoxErrorV;
    509     /** Pointer to a FNDBGCHLPMEMREAD() function. */
    510     PFNDBGCHLPMEMREAD       pfnMemRead;
    511     /** Pointer to a FNDBGCHLPMEMWRITE() function. */
    512     PFNDBGCHLPMEMWRITE      pfnMemWrite;
    513     /** Pointer to a FNDBGCHLPEXEC() function. */
    514     PFNDBGCHLPEXEC          pfnExec;
     379    /** Magic value (DBGCCMDHLP_MAGIC). */
     380    uint32_t                u32Magic;
     381
     382    /**
     383     * Command helper for writing formatted text to the debug console.
     384     *
     385     * @returns VBox status.
     386     * @param   pCmdHlp     Pointer to the command callback structure.
     387     * @param   pcb         Where to store the number of bytes written.
     388     * @param   pszFormat   The format string.
     389     *                      This is using the log formatter, so it's format extensions can be used.
     390     * @param   ...         Arguments specified in the format string.
     391     */
     392    DECLCALLBACKMEMBER(int, pfnPrintf)(PDBGCCMDHLP pCmdHlp, size_t *pcbWritten, const char *pszFormat, ...);
     393
     394    /**
     395     * Command helper for writing formatted text to the debug console.
     396     *
     397     * @returns VBox status.
     398     * @param   pCmdHlp     Pointer to the command callback structure.
     399     * @param   pcb         Where to store the number of bytes written.
     400     * @param   pszFormat   The format string.
     401     *                      This is using the log formatter, so it's format extensions can be used.
     402     * @param   args        Arguments specified in the format string.
     403     */
     404    DECLCALLBACKMEMBER(int, pfnPrintfV)(PDBGCCMDHLP pCmdHlp, size_t *pcbWritten, const char *pszFormat, va_list args);
     405
     406    /**
     407     * Command helper for formatting and error message for a VBox status code.
     408     *
     409     * @returns VBox status code appropriate to return from a command.
     410     * @param   pCmdHlp     Pointer to the command callback structure.
     411     * @param   rc          The VBox status code.
     412     * @param   pszFormat   Format string for additional messages. Can be NULL.
     413     * @param   ...         Format arguments, optional.
     414     */
     415    DECLCALLBACKMEMBER(int, pfnVBoxError)(PDBGCCMDHLP pCmdHlp, int rc, const char *pszFormat, ...);
     416
     417    /**
     418     * Command helper for formatting and error message for a VBox status code.
     419     *
     420     * @returns VBox status code appropriate to return from a command.
     421     * @param   pCmdHlp     Pointer to the command callback structure.
     422     * @param   rc          The VBox status code.
     423     * @param   pcb         Where to store the number of bytes written.
     424     * @param   pszFormat   Format string for additional messages. Can be NULL.
     425     * @param   args        Format arguments, optional.
     426     */
     427    DECLCALLBACKMEMBER(int, pfnVBoxErrorV)(PDBGCCMDHLP pCmdHlp, int rc, const char *pszFormat, va_list args);
     428
     429    /**
     430     * Command helper for reading memory specified by a DBGC variable.
     431     *
     432     * @returns VBox status code appropriate to return from a command.
     433     * @param   pCmdHlp     Pointer to the command callback structure.
     434     * @param   pVM         VM handle if GC or physical HC address.
     435     * @param   pvBuffer    Where to store the read data.
     436     * @param   cbRead      Number of bytes to read.
     437     * @param   pVarPointer DBGC variable specifying where to start reading.
     438     * @param   pcbRead     Where to store the number of bytes actually read.
     439     *                      This optional, but it's useful when read GC virtual memory where a
     440     *                      page in the requested range might not be present.
     441     *                      If not specified not-present failure or end of a HC physical page
     442     *                      will cause failure.
     443     */
     444    DECLCALLBACKMEMBER(int, pfnMemRead)(PDBGCCMDHLP pCmdHlp, PVM pVM, void *pvBuffer, size_t cbRead, PCDBGCVAR pVarPointer, size_t *pcbRead);
     445
     446    /**
     447     * Command helper for writing memory specified by a DBGC variable.
     448     *
     449     * @returns VBox status code appropriate to return from a command.
     450     * @param   pCmdHlp     Pointer to the command callback structure.
     451     * @param   pVM         VM handle if GC or physical HC address.
     452     * @param   pvBuffer    What to write.
     453     * @param   cbWrite     Number of bytes to write.
     454     * @param   pVarPointer DBGC variable specifying where to start reading.
     455     * @param   pcbWritten  Where to store the number of bytes written.
     456     *                      This is optional. If NULL be aware that some of the buffer
     457     *                      might have been written to the specified address.
     458     */
     459    DECLCALLBACKMEMBER(int, pfnMemWrite)(PDBGCCMDHLP pCmdHlp, PVM pVM, const void *pvBuffer, size_t cbWrite, PCDBGCVAR pVarPointer, size_t *pcbWritten);
     460
     461    /**
     462     * Executes command an expression.
     463     * (Hopefully the parser and functions are fully reentrant.)
     464     *
     465     * @returns VBox status code appropriate to return from a command.
     466     * @param   pCmdHlp     Pointer to the command callback structure.
     467     * @param   pszExpr     The expression. Format string with the format DBGC extensions.
     468     * @param   ...         Format arguments.
     469     */
     470    DECLCALLBACKMEMBER(int, pfnExec)(PDBGCCMDHLP pCmdHlp, const char *pszExpr, ...);
    515471
    516472    /**
     
    537493     */
    538494    DECLCALLBACKMEMBER(int, pfnFailV)(PDBGCCMDHLP pCmdHlp, PCDBGCCMD pCmd, const char *pszFormat, va_list va);
     495
     496    /**
     497     * Print an error and fail the current command.
     498     *
     499     * @returns VBox status code to pass upwards.
     500     *
     501     * @param   pCmdHlp     Pointer to the command callback structure.
     502     * @param   pCmd        The failing command.
     503     * @param   rc          The status code indicating the failure.  This will
     504     *                      be appended to the message after a colon (': ').
     505     * @param   pszFormat   The error message format string.
     506     * @param   va          Format arguments.
     507     *
     508     * @see     DBGCCmdHlpFailRc
     509     */
     510    DECLCALLBACKMEMBER(int, pfnFailRcV)(PDBGCCMDHLP pCmdHlp, PCDBGCCMD pCmd, int rc, const char *pszFormat, va_list va);
     511
     512    /**
     513     * Parser error.
     514     *
     515     * @returns VBox status code to pass upwards.
     516     *
     517     * @param   pCmdHlp     Pointer to the command callback structure.
     518     * @param   pCmd        The failing command, can be NULL but shouldn't.
     519     * @param   iArg        The offending argument, -1 when lazy.
     520     * @param   pszExpr     The expression.
     521     * @param   iLine       The line number.
     522     */
     523    DECLCALLBACKMEMBER(int, pfnParserError)(PDBGCCMDHLP pCmdHlp, PCDBGCCMD pCmd, int iArg, const char *pszExpr, unsigned iLine);
    539524
    540525    /**
     
    615600    DECLCALLBACKMEMBER(PCDBGFINFOHLP, pfnGetDbgfOutputHlp)(PDBGCCMDHLP pCmdHlp);
    616601
     602    /** End marker (DBGCCMDHLP_MAGIC). */
     603    uint32_t                u32EndMarker;
    617604} DBGCCMDHLP;
     605
     606/** Magic value for DBGCCMDHLP::u32Magic. (Fyodor Mikhaylovich Dostoyevsky) */
     607#define DBGCCMDHLP_MAGIC    UINT32_C(18211111)
    618608
    619609
     
    706696    return rc;
    707697}
     698
     699/**
     700 * Print an error and fail the current command.
     701 *
     702 * Usage example:
     703 * @code
     704    int rc = VMMR3Something(pVM);
     705    if (RT_FAILURE(rc))
     706        return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "VMMR3Something");
     707    return VINF_SUCCESS;
     708 * @endcode
     709 *
     710 * @returns VBox status code to pass upwards.
     711 *
     712 * @param   pCmdHlp     Pointer to the command callback structure.
     713 * @param   pCmd        The failing command.
     714 * @param   rc          The status code indicating the failure.
     715 * @param   pszFormat   The error message format string.
     716 * @param   ...         Format arguments.
     717 */
     718DECLINLINE(int) DBGCCmdHlpFailRc(PDBGCCMDHLP pCmdHlp, PCDBGCCMD pCmd, int rc, const char *pszFormat, ...)
     719{
     720    va_list va;
     721
     722    va_start(va, pszFormat);
     723    rc = pCmdHlp->pfnFailRcV(pCmdHlp, pCmd, rc, pszFormat, va);
     724    va_end(va);
     725
     726    return rc;
     727}
     728
     729/**
     730 * @copydoc DBGCCMDHLP::pfnParserError
     731 */
     732DECLINLINE(int) DBGCCmdHlpParserError(PDBGCCMDHLP pCmdHlp, PCDBGCCMD pCmd, int iArg, const char *pszExpr, unsigned iLine)
     733{
     734    return pCmdHlp->pfnParserError(pCmdHlp, pCmd, iArg, pszExpr, iLine);
     735}
     736
     737/** Assert+return like macro for checking parser sanity.
     738 * Returns with failure if the precodition is not met. */
     739#define DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, iArg, expr) \
     740    do { \
     741        if (!(expr)) \
     742            return DBGCCmdHlpParserError(pCmdHlp, pCmd, iArg, #expr, __LINE__); \
     743    } while (0)
     744
     745/** Assert+return like macro that the VM handle is present.
     746 * Returns with failure if the VM handle is NIL.  */
     747#define DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM) \
     748    do { \
     749        if (!(pVM)) \
     750            return DBGCCmdHlpFail(pCmdHlp, pCmd, "No VM selected"); \
     751    } while (0)
    708752
    709753/**
  • trunk/include/VBox/vmm/dbgf.h

    r35625 r35694  
    378378
    379379
    380 VMMR3DECL(int)  DBGFR3BpSet(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp);
     380VMMR3DECL(int)  DBGFR3BpSet(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
    381381VMMR3DECL(int)  DBGFR3BpSetReg(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable,
    382                                uint8_t fType, uint8_t cb, PRTUINT piBp);
    383 VMMR3DECL(int)  DBGFR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp);
    384 VMMR3DECL(int)  DBGFR3BpClear(PVM pVM, RTUINT iBp);
    385 VMMR3DECL(int)  DBGFR3BpEnable(PVM pVM, RTUINT iBp);
    386 VMMR3DECL(int)  DBGFR3BpDisable(PVM pVM, RTUINT iBp);
     382                               uint8_t fType, uint8_t cb, uint32_t *piBp);
     383VMMR3DECL(int)  DBGFR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
     384VMMR3DECL(int)  DBGFR3BpClear(PVM pVM, uint32_t iBp);
     385VMMR3DECL(int)  DBGFR3BpEnable(PVM pVM, uint32_t iBp);
     386VMMR3DECL(int)  DBGFR3BpDisable(PVM pVM, uint32_t iBp);
    387387
    388388/**
  • 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;
  • trunk/src/VBox/VMM/VMMR3/CSAM.cpp

    r35348 r35694  
    26632663
    26642664#ifdef VBOX_WITH_DEBUGGER
     2665
    26652666/**
    26662667 * The '.csamoff' command.
     
    26752676static DECLCALLBACK(int) csamr3CmdOff(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
    26762677{
    2677     /*
    2678      * Validate input.
    2679      */
    2680     if (!pVM)
    2681         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: The command requires VM to be selected.\n");
    2682 
    2683     CSAMDisableScanning(pVM);
    2684     return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "CSAM Scanning disabled\n");
     2678    DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM);
     2679
     2680    int rc = CSAMDisableScanning(pVM);
     2681    if (RT_FAILURE(rc))
     2682        return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "CSAMDisableScanning");
     2683    return DBGCCmdHlpPrintf(pCmdHlp, "CSAM Scanning disabled\n");
    26852684}
    26862685
     
    26972696static DECLCALLBACK(int) csamr3CmdOn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
    26982697{
    2699     /*
    2700      * Validate input.
    2701      */
    2702     if (!pVM)
    2703         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: The command requires VM to be selected.\n");
    2704 
    2705     CSAMEnableScanning(pVM);
    2706     return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "CSAM Scanning enabled\n");
    2707 }
    2708 #endif
     2698    DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM);
     2699
     2700    int rc = CSAMEnableScanning(pVM);
     2701    if (RT_FAILURE(rc))
     2702        return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "CSAMEnableScanning");
     2703    return DBGCCmdHlpPrintf(pCmdHlp, "CSAM Scanning enabled\n");
     2704}
     2705
     2706#endif /* VBOX_WITH_DEBUGGER */
  • trunk/src/VBox/VMM/VMMR3/DBGFBp.cpp

    r35346 r35694  
    3838RT_C_DECLS_BEGIN
    3939static DECLCALLBACK(int) dbgfR3BpSetReg(PVM pVM, PCDBGFADDRESS pAddress, uint64_t *piHitTrigger, uint64_t *piHitDisable,
    40                                         uint8_t u8Type, uint8_t cb, PRTUINT piBp);
    41 static DECLCALLBACK(int) dbgfR3BpSetInt3(PVM pVM, PCDBGFADDRESS pAddress, uint64_t *piHitTrigger, uint64_t *piHitDisable, PRTUINT piBp);
    42 static DECLCALLBACK(int) dbgfR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t *piHitTrigger, uint64_t *piHitDisable, PRTUINT piBp);
    43 static DECLCALLBACK(int) dbgfR3BpClear(PVM pVM, RTUINT iBp);
    44 static DECLCALLBACK(int) dbgfR3BpEnable(PVM pVM, RTUINT iBp);
    45 static DECLCALLBACK(int) dbgfR3BpDisable(PVM pVM, RTUINT iBp);
     40                                        uint8_t u8Type, uint8_t cb, uint32_t *piBp);
     41static DECLCALLBACK(int) dbgfR3BpSetInt3(PVM pVM, PCDBGFADDRESS pAddress, uint64_t *piHitTrigger, uint64_t *piHitDisable, uint32_t *piBp);
     42static DECLCALLBACK(int) dbgfR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t *piHitTrigger, uint64_t *piHitDisable, uint32_t *piBp);
     43static DECLCALLBACK(int) dbgfR3BpClear(PVM pVM, uint32_t iBp);
     44static DECLCALLBACK(int) dbgfR3BpEnable(PVM pVM, uint32_t iBp);
     45static DECLCALLBACK(int) dbgfR3BpDisable(PVM pVM, uint32_t iBp);
    4646static DECLCALLBACK(int) dbgfR3BpEnum(PVM pVM, PFNDBGFBPENUM pfnCallback, void *pvUser);
    4747static int dbgfR3BpRegArm(PVM pVM, PDBGFBP pBp);
     
    101101     * Determine which array to search.
    102102     */
    103     unsigned cBps;
    104     PRTUINT  pcBpsCur;
    105     PDBGFBP  paBps;
     103    unsigned    cBps;
     104    uint32_t   *pcBpsCur;
     105    PDBGFBP     paBps;
    106106    switch (enmType)
    107107    {
     
    149149 * @param   iBp     The breakpoint id.
    150150 */
    151 static PDBGFBP dbgfR3BpGet(PVM pVM, RTUINT iBp)
     151static PDBGFBP dbgfR3BpGet(PVM pVM, uint32_t iBp)
    152152{
    153153    /* Find it. */
     
    278278 * @thread  Any thread.
    279279 */
    280 VMMR3DECL(int) DBGFR3BpSet(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp)
     280VMMR3DECL(int) DBGFR3BpSet(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp)
    281281{
    282282    /*
     
    303303 * @thread  Any thread.
    304304 */
    305 static DECLCALLBACK(int) dbgfR3BpSetInt3(PVM pVM, PCDBGFADDRESS pAddress, uint64_t *piHitTrigger, uint64_t *piHitDisable, PRTUINT piBp)
     305static DECLCALLBACK(int) dbgfR3BpSetInt3(PVM pVM, PCDBGFADDRESS pAddress, uint64_t *piHitTrigger, uint64_t *piHitDisable, uint32_t *piBp)
    306306{
    307307    /*
     
    435435 */
    436436VMMR3DECL(int) DBGFR3BpSetReg(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable,
    437                               uint8_t fType, uint8_t cb, PRTUINT piBp)
     437                              uint8_t fType, uint8_t cb, uint32_t *piBp)
    438438{
    439439    /** @todo SMP - broadcast, VT-x/AMD-V. */
     
    466466 */
    467467static DECLCALLBACK(int) dbgfR3BpSetReg(PVM pVM, PCDBGFADDRESS pAddress, uint64_t *piHitTrigger, uint64_t *piHitDisable,
    468                                         uint8_t fType, uint8_t cb, PRTUINT piBp)
     468                                        uint8_t fType, uint8_t cb, uint32_t *piBp)
    469469{
    470470    /*
     
    603603 * @thread  Any thread.
    604604 */
    605 VMMR3DECL(int) DBGFR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp)
     605VMMR3DECL(int) DBGFR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp)
    606606{
    607607    /*
     
    628628 * @internal
    629629 */
    630 static DECLCALLBACK(int) dbgfR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t *piHitTrigger, uint64_t *piHitDisable, PRTUINT piBp)
     630static DECLCALLBACK(int) dbgfR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t *piHitTrigger, uint64_t *piHitDisable, uint32_t *piBp)
    631631{
    632632    /*
     
    695695 * @thread  Any thread.
    696696 */
    697 VMMR3DECL(int) DBGFR3BpClear(PVM pVM, RTUINT iBp)
     697VMMR3DECL(int) DBGFR3BpClear(PVM pVM, uint32_t iBp)
    698698{
    699699    /*
     
    715715 * @internal
    716716 */
    717 static DECLCALLBACK(int) dbgfR3BpClear(PVM pVM, RTUINT iBp)
     717static DECLCALLBACK(int) dbgfR3BpClear(PVM pVM, uint32_t iBp)
    718718{
    719719    /*
     
    768768 * @thread  Any thread.
    769769 */
    770 VMMR3DECL(int) DBGFR3BpEnable(PVM pVM, RTUINT iBp)
     770VMMR3DECL(int) DBGFR3BpEnable(PVM pVM, uint32_t iBp)
    771771{
    772772    /*
     
    788788 * @internal
    789789 */
    790 static DECLCALLBACK(int) dbgfR3BpEnable(PVM pVM, RTUINT iBp)
     790static DECLCALLBACK(int) dbgfR3BpEnable(PVM pVM, uint32_t iBp)
    791791{
    792792    /*
     
    841841 * @thread  Any thread.
    842842 */
    843 VMMR3DECL(int) DBGFR3BpDisable(PVM pVM, RTUINT iBp)
     843VMMR3DECL(int) DBGFR3BpDisable(PVM pVM, uint32_t iBp)
    844844{
    845845    /*
     
    861861 * @internal
    862862 */
    863 static DECLCALLBACK(int) dbgfR3BpDisable(PVM pVM, RTUINT iBp)
     863static DECLCALLBACK(int) dbgfR3BpDisable(PVM pVM, uint32_t iBp)
    864864{
    865865    /*
  • trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletionFile.cpp

    r35346 r35694  
    8686    {  1,           1,          DBGCVAR_CAT_STRING,     0,                              "direction",    "write/read." },
    8787    {  1,           1,          DBGCVAR_CAT_STRING,     0,                              "filename",     "Filename." },
    88     {  1,           1,          DBGCVAR_CAT_STRING,     0,                              "errcode",      "IPRT error code." },
     88    {  1,           1,          DBGCVAR_CAT_NUMBER,     0,                              "errcode",      "VBox status code." },
    8989};
    9090
     
    699699static DECLCALLBACK(int) pdmacEpFileErrorInject(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR pArgs, unsigned cArgs, PDBGCVAR pResult)
    700700{
    701     bool fWrite;
    702     PPDMASYNCCOMPLETIONEPCLASSFILE pEpClassFile;
    703 
    704701    /*
    705702     * Validate input.
    706703     */
    707     if (!pVM)
    708         return DBGCCmdHlpPrintf(pCmdHlp, "error: The command requires a VM to be selected.\n");
    709     if (    cArgs != 3
    710         ||  pArgs[0].enmType != DBGCVAR_TYPE_STRING
    711         ||  pArgs[1].enmType != DBGCVAR_TYPE_STRING
    712         ||  pArgs[2].enmType != DBGCVAR_TYPE_STRING)
    713         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: parser error, invalid arguments.\n");
    714 
     704    DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM);
     705    DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, -1, cArgs == 3);
     706    DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, pArgs[0].enmType == DBGCVAR_TYPE_STRING);
     707    DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 1, pArgs[1].enmType == DBGCVAR_TYPE_STRING);
     708    DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 2, pArgs[2].enmType == DBGCVAR_TYPE_NUMBER);
     709
     710    PPDMASYNCCOMPLETIONEPCLASSFILE pEpClassFile;
    715711    pEpClassFile = (PPDMASYNCCOMPLETIONEPCLASSFILE)pVM->pUVM->pdm.s.apAsyncCompletionEndpointClass[PDMASYNCCOMPLETIONEPCLASSTYPE_FILE];
    716712
    717713    /* Syntax is "read|write <filename> <status code>" */
     714    bool fWrite;
    718715    if (!RTStrCmp(pArgs[0].u.pszString, "read"))
    719716        fWrite = false;
     
    721718        fWrite = true;
    722719    else
    723     {
    724         DBGCCmdHlpPrintf(pCmdHlp, "error: invalid transefr direction '%s'.\n", pArgs[0].u.pszString);
    725         return VINF_SUCCESS;
    726     }
    727 
    728     /* Search for the matching endpoint. */
     720        return DBGCCmdHlpFail(pCmdHlp, pCmd, "invalid transfer direction '%s'", pArgs[0].u.pszString);
     721
     722    int32_t rcToInject = (int32_t)pArgs[2].u.u64Number;
     723    if ((uint64_t)rcToInject != pArgs[2].u.u64Number)
     724        return DBGCCmdHlpFail(pCmdHlp, pCmd, "The status code '%lld' is out of range", pArgs[0].u.u64Number);
     725
     726
     727    /*
     728     * Search for the matching endpoint.
     729     */
    729730    RTCritSectEnter(&pEpClassFile->Core.CritSect);
     731
    730732    PPDMASYNCCOMPLETIONENDPOINTFILE pEpFile = (PPDMASYNCCOMPLETIONENDPOINTFILE)pEpClassFile->Core.pEndpointsHead;
    731 
    732733    while (pEpFile)
    733734    {
     
    736737        pEpFile = (PPDMASYNCCOMPLETIONENDPOINTFILE)pEpFile->Core.pNext;
    737738    }
    738 
    739739    if (pEpFile)
    740740    {
    741         int rcToInject = RTStrToInt32(pArgs[2].u.pszString);
    742 
     741        /*
     742         * Do the job.
     743         */
    743744        if (fWrite)
    744745            ASMAtomicXchgS32(&pEpFile->rcReqWrite, rcToInject);
    745746        else
    746             ASMAtomicXchgS32(&pEpFile->rcReqRead, rcToInject);
    747 
    748             DBGCCmdHlpPrintf(pCmdHlp, "Injected %Rrc into '%s' for %s\n",
    749                              rcToInject, pArgs[1].u.pszString, pArgs[0].u.pszString);
    750     }
    751     else
    752         DBGCCmdHlpPrintf(pCmdHlp, "No file with name '%s' found\n", NULL, pArgs[1].u.pszString);
     747            ASMAtomicXchgS32(&pEpFile->rcReqRead,  rcToInject);
     748
     749        DBGCCmdHlpPrintf(pCmdHlp, "Injected %Rrc into '%s' for %s\n",
     750                         (int)rcToInject, pArgs[1].u.pszString, pArgs[0].u.pszString);
     751    }
    753752
    754753    RTCritSectLeave(&pEpClassFile->Core.CritSect);
     754
     755    if (!pEpFile)
     756        return DBGCCmdHlpFail(pCmdHlp, pCmd, "No file with name '%s' found", pArgs[1].u.pszString);
    755757    return VINF_SUCCESS;
    756758}
    757 #endif
     759#endif /* VBOX_WITH_DEBUGGER */
    758760
    759761static int pdmacFileInitialize(PPDMASYNCCOMPLETIONEPCLASS pClassGlobals, PCFGMNODE pCfgNode)
     
    830832    if (RT_SUCCESS(rc))
    831833    {
    832         rc = DBGCRegisterCommands(&g_aCmds[0], 1);
     834        rc = DBGCRegisterCommands(&g_aCmds[0], RT_ELEMENTS(g_aCmds));
    833835        AssertRC(rc);
    834836    }
  • trunk/src/VBox/VMM/VMMR3/STAM.cpp

    r35346 r35694  
    172172{
    173173    /* pszCmd,      cArgsMin, cArgsMax, paArgDesc,          cArgDescs,                  pResultDesc,        fFlags,     pfnHandler          pszSyntax,          ....pszDescription */
    174     { "stats",      0,        1,        &g_aArgPat[0],      RT_ELEMENTS(g_aArgPat),        NULL,               0,          stamR3CmdStats,     "[pattern]",        "Display statistics." },
    175     { "statsreset", 0,        1,        &g_aArgPat[0],      RT_ELEMENTS(g_aArgPat),        NULL,               0,          stamR3CmdStatsReset,"[pattern]",        "Resets statistics." }
     174    { "stats",      0,        1,        &g_aArgPat[0],      RT_ELEMENTS(g_aArgPat),     NULL,               0,          stamR3CmdStats,     "[pattern]",        "Display statistics." },
     175    { "statsreset", 0,        1,        &g_aArgPat[0],      RT_ELEMENTS(g_aArgPat),     NULL,               0,          stamR3CmdStatsReset,"[pattern]",        "Resets statistics." }
    176176};
    177177#endif
     
    19221922     * Validate input.
    19231923     */
    1924     if (!pVM)
    1925         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: The command requires VM to be selected.\n");
     1924    DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM);
    19261925    PUVM pUVM = pVM->pUVM;
    19271926    if (!pUVM->stam.s.pHead)
    1928         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Sorry, no statistics present.\n");
     1927        return DBGCCmdHlpFail(pCmdHlp, pCmd, "No statistics present");
    19291928
    19301929    /*
     
    19321931     */
    19331932    STAMR3PRINTONEARGS Args;
    1934     Args.pVM = pVM;
    1935     Args.pvArg = pCmdHlp;
    1936     Args.pfnPrintf = stamR3EnumDbgfPrintf;
     1933    Args.pVM        = pVM;
     1934    Args.pvArg      = pCmdHlp;
     1935    Args.pfnPrintf  = stamR3EnumDbgfPrintf;
    19371936
    19381937    return stamR3EnumU(pUVM, cArgs ? paArgs[0].u.pszString : NULL, true /* fUpdateRing0 */, stamR3PrintOne, &Args);
     
    19741973     * Validate input.
    19751974     */
    1976     if (!pVM)
    1977         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: The command requires VM to be selected.\n");
     1975    DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM);
    19781976    PUVM pUVM = pVM->pUVM;
    19791977    if (!pUVM->stam.s.pHead)
    1980         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Sorry, no statistics present.\n");
     1978        return DBGCCmdHlpFail(pCmdHlp, pCmd, "No statistics present");
    19811979
    19821980    /*
     
    19851983    int rc = STAMR3ResetU(pUVM, cArgs ? paArgs[0].u.pszString : NULL);
    19861984    if (RT_SUCCESS(rc))
    1987         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "info: Statistics reset.\n");
    1988 
    1989     return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Resetting statistics.\n");
     1985        return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "STAMR3ResetU");
     1986    return DBGCCmdHlpPrintf(pCmdHlp, "Statistics have been reset.\n");
    19901987}
    19911988
  • trunk/src/VBox/VMM/include/DBGFInternal.h

    r35601 r35694  
    245245    bool                        fSymInited;
    246246    /** Alignment padding. */
    247     RTUINT                      uAlignment0;
     247    uint32_t                    uAlignment0;
    248248
    249249    /** The number of hardware breakpoints. */
    250     RTUINT                      cHwBreakpoints;
     250    uint32_t                    cHwBreakpoints;
    251251    /** The number of active breakpoints. */
    252     RTUINT                      cBreakpoints;
     252    uint32_t                    cBreakpoints;
    253253    /** Array of hardware breakpoints. (0..3)
    254254     * This is shared among all the CPUs because life is much simpler that way. */
  • trunk/src/recompiler/VBoxRecompiler.c

    r35346 r35694  
    36693669static DECLCALLBACK(int) remR3CmdDisasEnableStepping(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult)
    36703670{
    3671     bool fEnable;
    36723671    int rc;
    36733672
    3674     /* print status */
    36753673    if (cArgs == 0)
    3676         return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "DisasStepping is %s\n",
    3677                                   pVM->rem.s.Env.state & CPU_EMULATE_SINGLE_STEP ? "enabled" : "disabled");
    3678 
    3679     /* convert the argument and change the mode. */
    3680     rc = pCmdHlp->pfnVarToBool(pCmdHlp, &paArgs[0], &fEnable);
    3681     if (RT_FAILURE(rc))
    3682         return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "boolean conversion failed!\n");
    3683     rc = REMR3DisasEnableStepping(pVM, fEnable);
    3684     if (RT_FAILURE(rc))
    3685         return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "REMR3DisasEnableStepping failed!\n");
     3674        /*
     3675         * Print the current status.
     3676         */
     3677        rc = DBGCCmdHlpPrintf(pCmdHlp, "DisasStepping is %s\n",
     3678                              pVM->rem.s.Env.state & CPU_EMULATE_SINGLE_STEP ? "enabled" : "disabled");
     3679    else
     3680    {
     3681        /*
     3682         * Convert the argument and change the mode.
     3683         */
     3684        bool fEnable;
     3685        rc = DBGCCmdHlpVarToBool(pCmdHlp, &paArgs[0], &fEnable);
     3686        if (RT_SUCCESS(rc))
     3687        {
     3688            rc = REMR3DisasEnableStepping(pVM, fEnable);
     3689            if (RT_SUCCESS(rc))
     3690                rc = DBGCCmdHlpPrintf(pCmdHlp, "DisasStepping was %s\n", fEnable ? "enabled" : "disabled");
     3691            else
     3692                rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "REMR3DisasEnableStepping");
     3693        }
     3694        else
     3695            rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToBool");
     3696    }
    36863697    return rc;
    36873698}
    3688 #endif
     3699#endif /* VBOX_WITH_DEBUGGER && !win.amd64 */
    36893700
    36903701
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