VirtualBox

Changeset 46156 in vbox


Ignore:
Timestamp:
May 18, 2013 1:35:16 AM (12 years ago)
Author:
vboxsync
Message:

List near, unassemble, hyper register and more tiny debugger fixes.

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

Legend:

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

    r46114 r46156  
    689689    RTINTPTR    off;
    690690    DBGFADDRESS Addr;
    691     int rc = DBGFR3AsSymbolByAddr(pUVM, pDbgc->hDbgAs, DBGFR3AddrFromFlat(pDbgc->pUVM, &Addr, pBp->GCPtr), &off, &Sym, NULL);
     691    int rc = DBGFR3AsSymbolByAddr(pUVM, pDbgc->hDbgAs, DBGFR3AddrFromFlat(pDbgc->pUVM, &Addr, pBp->GCPtr),
     692                                  RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, &off, &Sym, NULL);
    692693    if (RT_SUCCESS(rc))
    693694    {
     
    697698            DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s+%RGv", Sym.szName, off);
    698699        else
    699             DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s+%RGv", Sym.szName, -off);
     700            DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s-%RGv", Sym.szName, -off);
    700701    }
    701702
     
    854855    }
    855856    return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set REM breakpoint at %RGv", Address.FlatPtr);
     857}
     858
     859
     860/**
     861 * Helps the unassmble ('u') command display symbols it starts at and passes.
     862 *
     863 * @param   pUVM            The user mode VM handle.
     864 * @param   pCmdHlp         The command helpers for printing via.
     865 * @param   hDbgAs          The address space to look up addresses in.
     866 * @param   pAddress        The current address.
     867 * @param   pcbCallAgain    Where to return the distance to the next check (in
     868 *                          instruction bytes).
     869 */
     870static void dbgcCmdUnassambleHelpListNear(PUVM pUVM, PDBGCCMDHLP pCmdHlp, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
     871                                         PRTUINTPTR pcbCallAgain)
     872{
     873    RTDBGSYMBOL Symbol;
     874    RTGCINTPTR  offDispSym;
     875    int rc = DBGFR3AsSymbolByAddr(pUVM, hDbgAs, pAddress, RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, &offDispSym, &Symbol, NULL);
     876    if (RT_FAILURE(rc) || offDispSym > _1G)
     877        rc = DBGFR3AsSymbolByAddr(pUVM, hDbgAs, pAddress, RTDBGSYMADDR_FLAGS_GREATER_OR_EQUAL, &offDispSym, &Symbol, NULL);
     878    if (RT_SUCCESS(rc) && offDispSym < _1G)
     879    {
     880        if (!offDispSym)
     881        {
     882            DBGCCmdHlpPrintf(pCmdHlp, "%s:\n", Symbol.szName);
     883            *pcbCallAgain = Symbol.cb;
     884        }
     885        else if (offDispSym > 0)
     886        {
     887            DBGCCmdHlpPrintf(pCmdHlp, "%s+%#llx:\n", Symbol.szName, (uint64_t)offDispSym);
     888            *pcbCallAgain = Symbol.cb > (RTGCUINTPTR)offDispSym ? Symbol.cb - (RTGCUINTPTR)offDispSym : 1;
     889        }
     890        else
     891        {
     892            DBGCCmdHlpPrintf(pCmdHlp, "%s-%#llx:\n", Symbol.szName, (uint64_t)-offDispSym);
     893            *pcbCallAgain = (RTGCUINTPTR)-offDispSym + Symbol.cb;
     894        }
     895    }
     896    else
     897        *pcbCallAgain = UINT32_MAX;
    856898}
    857899
     
    887929        case 'v':   fFlags |= DBGF_DISAS_FLAGS_16BIT_REAL_MODE; break;
    888930    }
     931
     932    /** @todo should use DBGFADDRESS for everything */
    889933
    890934    /*
     
    913957                fFlags |= DBGF_DISAS_FLAGS_CURRENT_GUEST;
    914958            else
    915                 fFlags |= DBGF_DISAS_FLAGS_CURRENT_HYPER;
     959                fFlags |= DBGF_DISAS_FLAGS_CURRENT_HYPER | DBGF_DISAS_FLAGS_HYPER;
    916960        }
    917961        pDbgc->DisasmPos.enmRangeType = DBGCVAR_RANGE_NONE;
     
    948992     * Convert physical and host addresses to guest addresses.
    949993     */
     994    RTDBGAS hDbgAs = pDbgc->hDbgAs;
    950995    int rc;
    951996    switch (pDbgc->DisasmPos.enmType)
     
    9551000            break;
    9561001        case DBGCVAR_TYPE_GC_PHYS:
     1002            hDbgAs = DBGF_AS_PHYS;
    9571003        case DBGCVAR_TYPE_HC_FLAT:
    9581004        case DBGCVAR_TYPE_HC_PHYS:
     
    9681014    }
    9691015
    970     /*
    971      * Print address.
    972      * todo: Change to list near.
    973      */
    974 #if 0
    975     rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "%DV:\n", &pDbgc->DisasmPos);
     1016    DBGFADDRESS CurAddr;
     1017    rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &pDbgc->DisasmPos, &CurAddr);
    9761018    if (RT_FAILURE(rc))
    977         return rc;
    978 #endif
     1019        return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr failed on '%Dv'", &pDbgc->DisasmPos);
     1020
     1021    if (CurAddr.fFlags & DBGFADDRESS_FLAGS_HMA)
     1022        fFlags |= DBGF_DISAS_FLAGS_HYPER; /* This crap is due to not using DBGFADDRESS as DBGFR3Disas* input. */
     1023
     1024    /*
     1025     * Figure out where we are and display it.  Also calculate when we need to
     1026     * check for a new symbol if possible.
     1027     */
     1028    RTGCUINTPTR cbCheckSymbol;
     1029    dbgcCmdUnassambleHelpListNear(pUVM, pCmdHlp, hDbgAs, &CurAddr, &cbCheckSymbol);
    9791030
    9801031    /*
     
    10081059        {
    10091060            /* bitch. */
    1010             rc = DBGCCmdHlpPrintf(pCmdHlp, "Failed to disassemble instruction, skipping one byte.\n");
    1011             if (RT_FAILURE(rc))
    1012                 return rc;
     1061            int rc2 = DBGCCmdHlpPrintf(pCmdHlp, "Failed to disassemble instruction, skipping one byte.\n");
     1062            if (RT_FAILURE(rc2))
     1063                return rc2;
    10131064            if (cTries-- > 0)
    10141065                return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Too many disassembly failures. Giving up");
     
    10291080            break;
    10301081        fFlags &= ~(DBGF_DISAS_FLAGS_CURRENT_GUEST | DBGF_DISAS_FLAGS_CURRENT_HYPER);
     1082
     1083        /* Print next symbol? */
     1084        if (cbCheckSymbol <= cbInstr)
     1085        {
     1086            rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &pDbgc->DisasmPos, &CurAddr);
     1087            if (RT_SUCCESS(rc))
     1088                dbgcCmdUnassambleHelpListNear(pUVM, pCmdHlp, hDbgAs, &CurAddr, &cbCheckSymbol);
     1089            else
     1090                cbCheckSymbol = UINT32_MAX;
     1091        }
     1092        else
     1093            cbCheckSymbol -= cbInstr;
    10311094    }
    10321095
     
    38183881        RTINTPTR    offDisp;
    38193882        DBGFADDRESS Addr;
    3820         rc = DBGFR3AsSymbolByAddr(pUVM, pDbgc->hDbgAs, DBGFR3AddrFromFlat(pDbgc->pUVM, &Addr, AddrVar.u.GCFlat), &offDisp, &Symbol, NULL);
     3883        rc = DBGFR3AsSymbolByAddr(pUVM, pDbgc->hDbgAs, DBGFR3AddrFromFlat(pDbgc->pUVM, &Addr, AddrVar.u.GCFlat),
     3884                                  RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, &offDisp, &Symbol, NULL);
    38213885        if (RT_FAILURE(rc))
    38223886            return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3ASymbolByAddr(,,%RGv,,)\n", AddrVar.u.GCFlat);
     
    38433907static DECLCALLBACK(int) dbgcCmdListNear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
    38443908{
     3909    PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
    38453910    if (!cArgs)
    38463911    {
     
    38493914         */
    38503915        DBGCVAR AddrVar;
    3851         int rc = DBGCCmdHlpEval(pCmdHlp, &AddrVar, "%%(cs:eip)");
     3916        const char *pszFmtExpr = pDbgc->fRegCtxGuest ? "%%(cs:eip)" : "%%(.cs:.eip)";
     3917        int rc = DBGCCmdHlpEval(pCmdHlp, &AddrVar, pszFmtExpr);
    38523918        if (RT_FAILURE(rc))
    3853             return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "%%(cs:eip)\n");
     3919            return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "%s\n", pszFmtExpr + 1);
    38543920        return dbgcDoListNear(pCmdHlp, pUVM, &AddrVar);
    38553921    }
  • trunk/src/VBox/Debugger/DBGCOps.cpp

    r44528 r46156  
    456456    AssertReturn(pArg->enmType == DBGCVAR_TYPE_SYMBOL, VERR_DBGC_PARSE_BUG);
    457457
     458    /* Detect references to hypervisor registers. */
     459    const char *pszReg = pArg->u.pszString;
     460    VMCPUID idCpu = pDbgc->idCpu;
     461    if (pszReg[0] == '.')
     462    {
     463        pszReg++;
     464        idCpu |= DBGFREG_HYPER_VMCPUID;
     465    }
     466
    458467    /*
    459468     * If the desired result is a symbol, pass the argument along unmodified.
     
    462471    if (enmCat == DBGCVAR_CAT_SYMBOL)
    463472    {
    464         int rc = DBGFR3RegNmValidate(pDbgc->pUVM, pDbgc->idCpu, pArg->u.pszString);
     473        int rc = DBGFR3RegNmValidate(pDbgc->pUVM, idCpu, pszReg);
    465474        if (RT_SUCCESS(rc))
    466475            DBGCVAR_INIT_STRING(pResult, pArg->u.pszString);
     
    473482    DBGFREGVALTYPE  enmType;
    474483    DBGFREGVAL      Value;
    475     int rc = DBGFR3RegNmQuery(pDbgc->pUVM, pDbgc->idCpu, pArg->u.pszString, &Value, &enmType);
     484    int rc = DBGFR3RegNmQuery(pDbgc->pUVM, idCpu, pszReg, &Value, &enmType);
    476485    if (RT_SUCCESS(rc))
    477486    {
  • trunk/src/VBox/Debugger/DBGConsole.cpp

    r46137 r46156  
    237237        "ip;"
    238238    ;
    239     size_t const cchSymbol = strlen(pszSymbol);
    240     if (    (cchSymbol == 2 && strstr(s_szTwoLetterRegisters,   pszSymbol))
    241         ||  (cchSymbol == 3 && strstr(s_szThreeLetterRegisters, pszSymbol))
    242         ||  (cchSymbol == 6 && strstr(s_szSixLetterRegisters,   pszSymbol)))
     239    const char  *pszRegSym = *pszSymbol == '.' ? pszSymbol + 1 : pszSymbol;
     240    size_t const cchRegSym = strlen(pszRegSym);
     241    if (    (cchRegSym == 2 && strstr(s_szTwoLetterRegisters,   pszRegSym))
     242        ||  (cchRegSym == 3 && strstr(s_szThreeLetterRegisters, pszRegSym))
     243        ||  (cchRegSym == 6 && strstr(s_szSixLetterRegisters,   pszRegSym)))
    243244    {
    244245        if (!strchr(pszSymbol, ';'))
  • trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp

    r46137 r46156  
    169169    return VERR_INTERNAL_ERROR;
    170170}
    171 VMMR3DECL(int) DBGFR3AsSymbolByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, PRTGCINTPTR poffDisplacement, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod)
     171VMMR3DECL(int) DBGFR3AsSymbolByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, uint32_t fFlags, PRTGCINTPTR poffDisplacement, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod)
    172172{
    173173    return VERR_INTERNAL_ERROR;
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