VirtualBox

Changeset 9273 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 31, 2008 6:46:03 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
31474
Message:

Use the new DISFormat* stuff so we can get useful disassembly in non-logging builds too.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/DBGFDisas.cpp

    r9154 r9273  
    2020 */
    2121
     22#define USE_DIS_FORMAT
    2223
    2324/*******************************************************************************
     
    9293static int dbgfR3DisasInstrFirst(PVM pVM, PSELMSELINFO pSelInfo, PGMMODE enmMode, RTGCPTR GCPtr, PDBGFDISASSTATE pState)
    9394{
    94     pState->Cpu.mode        = pSelInfo->Raw.Gen.u1DefBig ? CPUMODE_32BIT : CPUMODE_16BIT;
    95     pState->Cpu.pfnReadBytes = dbgfR3DisasInstrRead;
    9695    pState->GCPtrSegBase    = pSelInfo->GCPtrBase;
    9796    pState->GCPtrSegEnd     = pSelInfo->cbLimit + 1 + (RTGCUINTPTR)pSelInfo->GCPtrBase;
     
    104103    Assert((uintptr_t)GCPtr == GCPtr);
    105104    uint32_t cbInstr;
     105#ifdef USE_DIS_FORMAT
     106    int rc = DISCoreOneEx(GCPtr,
     107                          pSelInfo->Raw.Gen.u1DefBig
     108                          ? enmMode >= PGMMODE_AMD64 && pSelInfo->Raw.Gen.u1Reserved
     109                          ? CPUMODE_64BIT
     110                          : CPUMODE_32BIT
     111                          : CPUMODE_16BIT,
     112                          dbgfR3DisasInstrRead,
     113                          &pState->Cpu,
     114                          &pState->Cpu,
     115                          &cbInstr);
     116#else
     117    pState->Cpu.mode        = pSelInfo->Raw.Gen.u1DefBig ? CPUMODE_32BIT : CPUMODE_16BIT;
     118    pState->Cpu.pfnReadBytes = dbgfR3DisasInstrRead;
    106119    int rc = DISInstr(&pState->Cpu, GCPtr, 0, &cbInstr, NULL);
     120#endif
    107121    if (VBOX_SUCCESS(rc))
    108122    {
     
    231245
    232246
     247#ifdef USE_DIS_FORMAT
     248/**
     249 * @copydoc FNDISGETSYMBOL
     250 */
     251static DECLCALLBACK(int) dbgfR3DisasGetSymbol(PCDISCPUSTATE pCpu, uint32_t u32Sel, RTUINTPTR uAddress, char *pszBuf, size_t cchBuf, RTINTPTR *poff, void *pvUser)
     252{
     253    PDBGFDISASSTATE pState = (PDBGFDISASSTATE)pCpu;
     254    PCSELMSELINFO   pSelInfo = (PCSELMSELINFO)pvUser;
     255    DBGFSYMBOL      Sym;
     256    RTGCINTPTR      off;
     257    int             rc;
     258
     259    if (DIS_FMT_SEL_IS_REG(u32Sel))
     260    {
     261        if (DIS_FMT_SEL_GET_REG(u32Sel) == USE_REG_CS)
     262            rc = DBGFR3SymbolByAddr(pState->pVM, uAddress + pSelInfo->GCPtrBase, &off, &Sym);
     263        else
     264            rc = VERR_SYMBOL_NOT_FOUND; /** @todo implement this */
     265    }
     266    else
     267    {
     268        if (pSelInfo->Sel == DIS_FMT_SEL_GET_VALUE(u32Sel))
     269            rc = DBGFR3SymbolByAddr(pState->pVM, uAddress + pSelInfo->GCPtrBase, &off, &Sym);
     270        else
     271            rc = VERR_SYMBOL_NOT_FOUND; /** @todo implement this */
     272    }
     273
     274    if (RT_SUCCESS(rc))
     275    {
     276        size_t cchName = strlen(Sym.szName);
     277        if (cchName >= cchBuf)
     278            cchName = cchBuf - 1;
     279        memcpy(pszBuf, Sym.szName, cchName);
     280        pszBuf[cchName] = '\0';
     281
     282        *poff = off;
     283    }
     284
     285    return rc;
     286}
     287#else
    233288/**
    234289 * Copy a string and return pointer to the terminator char in the copy.
     
    240295    return pszDst + cch;
    241296}
     297#endif
    242298
    243299
     
    361417     * Format it.
    362418     */
     419#ifdef USE_DIS_FORMAT
     420    char szBuf[512];
     421    DISFormatYasmEx(&State.Cpu, szBuf, sizeof(szBuf),
     422                    DIS_FMT_FLAGS_RELATIVE_BRANCH,
     423                    fFlags & DBGF_DISAS_FLAGS_NO_SYMBOLS ? NULL : dbgfR3DisasGetSymbol,
     424                    &SelInfo);
     425#else
    363426    char szBuf[512];
    364427    char *psz = &szBuf[0];
     
    429492                        case CPUMODE_16BIT: GCPtrTarget &= UINT16_MAX; break;
    430493                        case CPUMODE_32BIT: GCPtrTarget &= UINT32_MAX; break;
     494                        case CPUMODE_64BIT: GCPtrTarget &= UINT64_MAX; break;
    431495                        default: break;
    432496                    }
     
    558622    } /* foreach char in pszFormat */
    559623    *psz = '\0';
     624#endif /* !USE_DIS_FORMAT */
    560625
    561626    /*
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