VirtualBox

Changeset 9266 in vbox for trunk/include


Ignore:
Timestamp:
May 31, 2008 2:32:20 AM (17 years ago)
Author:
vboxsync
Message:

DISFormatYasm(Ex).

File:
1 edited

Legend:

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

    r9216 r9266  
    335335typedef struct _OP_PARAMETER
    336336{
     337    /** @todo switch param and parval and move disp64 and flags up here with the other 64-bit vars to get more natural alignment and save space. */
    337338    int             param;
    338339    uint64_t        parval;
     340#ifndef DIS_SEPARATE_FORMATTER
    339341    char            szParam[32];
     342#endif
    340343
    341344    int32_t         disp8, disp16, disp32;
     
    475478} DISCPUSTATE;
    476479
     480/** Pointer to a const disassembler CPU state. */
     481typedef DISCPUSTATE const *PCDISCPUSTATE;
     482
    477483/** Opcode. */
    478484#pragma pack(4)
     
    617623DISDECL(int) DISPtrReg64(PCPUMCTXCORE pCtx, unsigned reg64, uint64_t **ppReg);
    618624
     625
     626/**
     627 * Try resolve an address into a symbol name.
     628 *
     629 * For use with DISFormatYasmEx(), DISFormatMasmEx() and DISFormatGasEx().
     630 *
     631 * @returns VBox status code.
     632 * @retval  VINF_SUCCESS on success, pszBuf contains the full symbol name.
     633 * @retval  VINF_BUFFER_OVERFLOW if pszBuf is too small the symbol name. The
     634 *          content of pszBuf is truncated and zero terminated.
     635 * @retval  VERR_SYMBOL_NOT_FOUND if no matching symbol was found for the address.
     636 *
     637 * @param   pCpu        Pointer to the disassembler CPU state.
     638 * @param   u32Sel      The selector value. Use DIS_FMT_SEL_IS_REG, DIS_FMT_SEL_GET_VALUE,
     639 *                      DIS_FMT_SEL_GET_REG to access this.
     640 * @param   uAddress    The segment address.
     641 * @param   pszBuf      Where to store the symbol name
     642 * @param   cchBuf      The size of the buffer.
     643 * @param   poff        If not a perfect match, then this is where the offset from the return
     644 *                      symbol to the specified address is returned.
     645 * @param   pvUser      The user argument.
     646 */
     647typedef DECLCALLBACK(int) FNDISGETSYMBOL(uint32_t u32Sel, RTUINTPTR uAddress, char *pszBuf, size_t cchBuf, RTINTPTR *poff);
     648/** Pointer to a FNDISGETSYMBOL(). */
     649typedef FNDISGETSYMBOL *PFNDISGETSYMBOL;
     650
     651/**
     652 * Checks if the FNDISGETSYMBOL argument u32Sel is a register or not.
     653 */
     654#define DIS_FMT_SEL_IS_REG(u32Sel)          ( !!((u32Sel) & RT_BIT(31)) )
     655
     656/**
     657 * Extracts the selector value from the FNDISGETSYMBOL argument u32Sel.
     658 * @returns Selector value.
     659 */
     660#define DIS_FMT_SEL_GET_VALUE(u32Sel)       ( (RTSEL)(u32Sel) )
     661
     662/**
     663 * Extracts the register number from the FNDISGETSYMBOL argument u32Sel.
     664 * @returns USE_REG_CS, USE_REG_SS, USE_REG_DS, USE_REG_ES, USE_REG_FS or USE_REG_FS.
     665 */
     666#define DIS_FMT_SEL_GET_REG(u32Sel)         ( ((u32Sel) >> 16) & 0xf )
     667
     668/** @internal */
     669#define DIS_FMT_SEL_FROM_REG(uReg)          ( ((uReg) << 16) | RT_BIT(31) | 0xffff )
     670/** @internal */
     671#define DIS_FMT_SEL_FROM_VALUE(Sel)         ( (Sel) & 0xffff )
     672
     673
     674/** @name Flags for use with DISFormatYasmEx(), DISFormatMasmEx() and DISFormatGasEx().
     675 * @{
     676 */
     677/** Put the address to the right. */
     678#define DIS_FMT_FLAGS_ADDR_RIGHT            RT_BIT_32(0)
     679/** Put the address to the left. */
     680#define DIS_FMT_FLAGS_ADDR_LEFT             RT_BIT_32(1)
     681/** Put the address in comments.
     682 * For some assemblers this implies placing it to the right. */
     683#define DIS_FMT_FLAGS_ADDR_COMMENT          RT_BIT_32(2)
     684/** Put the instruction bytes to the right of the disassembly. */
     685#define DIS_FMT_FLAGS_BYTES_RIGHT           RT_BIT_32(3)
     686/** Put the instruction bytes to the left of the disassembly. */
     687#define DIS_FMT_FLAGS_BYTES_LEFT            RT_BIT_32(4)
     688/** Put the instruction bytes in comments.
     689 * For some assemblers this implies placing the bytes to the right. */
     690#define DIS_FMT_FLAGS_BYTES_COMMENT         RT_BIT_32(5)
     691/** Put the bytes in square brackets. */
     692#define DIS_FMT_FLAGS_BYTES_BRACKETS        RT_BIT_32(6)
     693/** Put spaces between the bytes. */
     694#define DIS_FMT_FLAGS_BYTES_SPACED          RT_BIT_32(7)
     695/** Display the relative +/- offset of branch instructions that uses relative addresses,
     696 * and put the target address in parenthesis. */
     697#define DIS_FMT_FLAGS_RELATIVE_BRANCH       RT_BIT_32(8)
     698/** Checks if the given flags are a valid combination. */
     699#define DIS_FMT_FLAGS_IS_VALID(fFlags) \
     700    (   !((fFlags) & ~UINT32_C(0x000001ff)) \
     701     && ((fFlags) & (DIS_FMT_FLAGS_ADDR_RIGHT  | DIS_FMT_FLAGS_ADDR_LEFT))  != (DIS_FMT_FLAGS_ADDR_RIGHT  | DIS_FMT_FLAGS_ADDR_LEFT) \
     702     && (   !((fFlags) & DIS_FMT_FLAGS_ADDR_COMMENT) \
     703         || (fFlags & (DIS_FMT_FLAGS_ADDR_RIGHT | DIS_FMT_FLAGS_ADDR_LEFT)) ) \
     704     && ((fFlags) & (DIS_FMT_FLAGS_BYTES_RIGHT | DIS_FMT_FLAGS_BYTES_LEFT)) != (DIS_FMT_FLAGS_BYTES_RIGHT | DIS_FMT_FLAGS_BYTES_LEFT) \
     705     && (   !((fFlags) & (DIS_FMT_FLAGS_BYTES_COMMENT | DIS_FMT_FLAGS_BYTES_BRACKETS)) \
     706         || (fFlags & (DIS_FMT_FLAGS_BYTES_RIGHT | DIS_FMT_FLAGS_BYTES_LEFT)) ) \
     707    )
     708/** @} */
     709
     710DISDECL(size_t) DISFormatYasm(  PCDISCPUSTATE pCpu, char *pszBuf, size_t cchBuf);
     711DISDECL(size_t) DISFormatYasmEx(PCDISCPUSTATE pCpu, char *pszBuf, size_t cchBuf, uint32_t fFlags, PFNDISGETSYMBOL pfnGetSymbol, void *pvUser);
     712DISDECL(size_t) DISFormatMasm(  PCDISCPUSTATE pCpu, char *pszBuf, size_t cchBuf);
     713DISDECL(size_t) DISFormatMasmEx(PCDISCPUSTATE pCpu, char *pszBuf, size_t cchBuf, uint32_t fFlags, PFNDISGETSYMBOL pfnGetSymbol, void *pvUser);
     714DISDECL(size_t) DISFormatGas(   PCDISCPUSTATE pCpu, char *pszBuf, size_t cchBuf);
     715DISDECL(size_t) DISFormatGasEx( PCDISCPUSTATE pCpu, char *pszBuf, size_t cchBuf, uint32_t fFlags, PFNDISGETSYMBOL pfnGetSymbol, void *pvUser);
     716
     717/** @todo DISAnnotate(PCDISCPUSTATE pCpu, char *pszBuf, size_t cchBuf, register reader, memory reader); */
     718
     719
    619720__END_DECLS
    620721
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