VirtualBox

Changeset 35694 in vbox for trunk/include


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

Debugger console: more cleanup.

Location:
trunk/include/VBox
Files:
2 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/**
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