VirtualBox

Changeset 41546 in vbox for trunk/src/VBox/Debugger


Ignore:
Timestamp:
Jun 1, 2012 2:34:33 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
78309
Message:

Debugger hacking.

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

Legend:

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

    r40097 r41546  
    370370            {
    371371                DBGCVAR Var2;
    372                 rc = dbgcOpAddrFlat(pDbgc, &Var, &Var2);
     372                rc = dbgcOpAddrFlat(pDbgc, &Var, DBGCVAR_CAT_ANY, &Var2);
    373373                if (RT_SUCCESS(rc))
    374374                {
     
    519519                /* convert to flat address */
    520520                DBGCVAR Var2;
    521                 rc = dbgcOpAddrFlat(pDbgc, &Var, &Var2);
     521                rc = dbgcOpAddrFlat(pDbgc, &Var, DBGCVAR_CAT_ANY, &Var2);
    522522                if (RT_FAILURE(rc))
    523523                {
  • trunk/src/VBox/Debugger/DBGCEval.cpp

    r35696 r41546  
    2626#include <iprt/asm.h>
    2727#include <iprt/assert.h>
     28#include <iprt/mem.h>
    2829#include <iprt/string.h>
    2930#include <iprt/ctype.h>
     
    490491                rc = dbgcEvalSubUnary(pDbgc, pszExpr2, cchExpr - (pszExpr2 - pszExpr), pOp->enmCatArg1, &Arg);
    491492            if (RT_SUCCESS(rc))
    492                 rc = pOp->pfnHandlerUnary(pDbgc, &Arg, pResult);
     493                rc = pOp->pfnHandlerUnary(pDbgc, &Arg, enmCategory, pResult);
    493494        }
    494495    }
     
    609610{
    610611    Log2(("dbgcEvalSub: cchExpr=%d pszExpr=%s\n", cchExpr, pszExpr));
     612
    611613    /*
    612614     * First we need to remove blanks in both ends.
     
    786788        if (RT_SUCCESS(rc))
    787789            /* apply the operator. */
    788             rc = pOpSplit->pfnHandlerUnary(pDbgc, &Arg, pResult);
     790            rc = pOpSplit->pfnHandlerUnary(pDbgc, &Arg, enmCategory, pResult);
    789791    }
    790792    else
     
    851853     * The parse loop.
    852854     */
    853     PDBGCVAR        pArg0 = &paArgs[0];
    854     PDBGCVAR        pArg = pArg0;
     855    PDBGCVAR        pArg0       = &paArgs[0];
     856    PDBGCVAR        pArg        = pArg0;
     857    PCDBGCVARDESC   pPrevDesc   = NULL;
     858    PCDBGCVARDESC   paVarDescs  = pCmd->paArgDescs;
     859    unsigned const  cVarDescs   = pCmd->cArgDescs;
     860    unsigned        cCurDesc    = 0;
     861    unsigned        iVar        = 0;
     862    unsigned        iVarDesc    = 0;
    855863    *pcArgs = 0;
    856864    do
     
    863871        if (pArg >= &paArgs[cArgs])
    864872            return VERR_PARSE_ARGUMENT_OVERFLOW;
     873#ifdef DEBUG_bird /* work in progress. */
     874        if (iVarDesc >= cVarDescs)
     875            return VERR_PARSE_TOO_MANY_ARGUMENTS;
     876
     877        /* Walk argument descriptors. */
     878        if (    (    paVarDescs[iVarDesc].fFlags & DBGCVD_FLAGS_DEP_PREV
     879                &&  &paVarDescs[iVarDesc - 1] != pPrevDesc)
     880            ||  cCurDesc >= paVarDescs[iVarDesc].cTimesMax)
     881        {
     882            iVarDesc++;
     883            if (iVarDesc >= cVarDescs)
     884                return VERR_PARSE_TOO_MANY_ARGUMENTS;
     885            cCurDesc = 0;
     886        }
     887#endif
    865888
    866889        /*
     
    972995        *pszEnd = '\0';
    973996        /* (psz = next char to process) */
    974 
     997        size_t cchArgs = strlen(pszArgs);
     998
     999
     1000#ifdef DEBUG_bird /* work in progress. */
     1001        /*
     1002         * Try optional arguments until we find something which matches
     1003         * or can easily be promoted to what the descriptor want.
     1004         */
     1005        for (;;)
     1006        {
     1007            char *pszArgsCopy = (char *)RTMemDup(pszArgs, cchArgs + 1);
     1008            if (!pszArgsCopy)
     1009                return VERR_NO_MEMORY;
     1010
     1011            int rc = dbgcEvalSub(pDbgc, pszArgs, strlen(pszArgs), paVarDescs[iVarDesc].enmCategory, pArg);
     1012            if (RT_SUCCESS(rc))
     1013            {
     1014                pArg->pDesc = pPrevDesc = &paVarDescs[iVarDesc];
     1015                cCurDesc++;
     1016                RTMemFree(pszArgsCopy);
     1017                break;
     1018            }
     1019
     1020            memcpy(pszArgs, pszArgsCopy, cchArgs + 1);
     1021            RTMemFree(pszArgsCopy);
     1022
     1023            /* can we advance? */
     1024            if (paVarDescs[iVarDesc].cTimesMin > cCurDesc)
     1025                return VERR_PARSE_ARGUMENT_TYPE_MISMATCH;
     1026            if (++iVarDesc >= cVarDescs)
     1027                return VERR_PARSE_ARGUMENT_TYPE_MISMATCH;
     1028            cCurDesc = 0;
     1029        }
     1030
     1031#else
    9751032        /*
    9761033         * Parse and evaluate the argument.
    9771034         */
    978         int rc = dbgcEvalSub(pDbgc, pszArgs, strlen(pszArgs), DBGCVAR_CAT_ANY, pArg);
     1035        int rc = dbgcEvalSub(pDbgc, pszArgs, cchArgs, DBGCVAR_CAT_ANY, pArg);
    9791036        if (RT_FAILURE(rc))
    9801037            return rc;
     1038#endif
    9811039
    9821040        /*
    9831041         * Next.
    9841042         */
     1043        iVar++;
    9851044        pArg++;
    9861045        (*pcArgs)++;
     
    10501109     */
    10511110    unsigned cArgs;
    1052     int rc = dbgcProcessArguments(pDbgc, pCmd, pszArgs, &pDbgc->aArgs[pDbgc->iArg], RT_ELEMENTS(pDbgc->aArgs) - pDbgc->iArg, &cArgs);
     1111    int rc = dbgcProcessArguments(pDbgc, pCmd, pszArgs, &pDbgc->aArgs[pDbgc->iArg],
     1112                                  RT_ELEMENTS(pDbgc->aArgs) - pDbgc->iArg, &cArgs);
    10531113    if (RT_SUCCESS(rc))
    10541114    {
     
    11521212
    11531213            default:
    1154                 rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "Error: Unknown error %d!\n", rc);
     1214                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "Error: Unknown error %Rrc (%d)!\n", rc, rc);
    11551215                break;
    11561216        }
  • trunk/src/VBox/Debugger/DBGCInternal.h

    r35694 r41546  
    278278 * @param   pDbgc       Debugger console instance data.
    279279 * @param   pArg        The argument.
     280 * @param   enmCat      The desired result category. Can be ignored.
    280281 * @param   pResult     Where to store the result.
    281282 */
    282 typedef DECLCALLBACK(int) FNDBGCOPUNARY(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult);
     283typedef DECLCALLBACK(int) FNDBGCOPUNARY(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
    283284/** Pointer to a unary operator handler function. */
    284285typedef FNDBGCOPUNARY *PFNDBGCOPUNARY;
     
    404405PCDBGCCMD   dbgcRoutineLookup(PDBGC pDbgc, const char *pachName, size_t cchName, bool fExternal);
    405406
    406 DECLCALLBACK(int) dbgcOpRegister(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult);
    407 DECLCALLBACK(int) dbgcOpAddrFlat(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult);
    408 DECLCALLBACK(int) dbgcOpAddrHost(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult);
    409 DECLCALLBACK(int) dbgcOpAddrPhys(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult);
    410 DECLCALLBACK(int) dbgcOpAddrHostPhys(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult);
     407DECLCALLBACK(int) dbgcOpRegister(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
     408DECLCALLBACK(int) dbgcOpAddrFlat(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
     409DECLCALLBACK(int) dbgcOpAddrHost(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
     410DECLCALLBACK(int) dbgcOpAddrPhys(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
     411DECLCALLBACK(int) dbgcOpAddrHostPhys(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
    411412
    412413void    dbgcInitCmdHlp(PDBGC pDbgc);
  • trunk/src/VBox/Debugger/DBGCOps.cpp

    r40076 r41546  
    3737*   Internal Functions                                                         *
    3838*******************************************************************************/
    39 static DECLCALLBACK(int) dbgcOpMinus(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult);
    40 static DECLCALLBACK(int) dbgcOpPluss(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult);
    41 static DECLCALLBACK(int) dbgcOpBooleanNot(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult);
    42 static DECLCALLBACK(int) dbgcOpBitwiseNot(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult);
    43 static DECLCALLBACK(int) dbgcOpVar(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult);
     39static DECLCALLBACK(int) dbgcOpMinus(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
     40static DECLCALLBACK(int) dbgcOpPluss(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
     41static DECLCALLBACK(int) dbgcOpBooleanNot(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
     42static DECLCALLBACK(int) dbgcOpBitwiseNot(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
     43static DECLCALLBACK(int) dbgcOpVar(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
    4444
    4545static DECLCALLBACK(int) dbgcOpAddrFar(PDBGC pDbgc, PCDBGCVAR pArg1, PCDBGCVAR pArg2, PDBGCVAR pResult);
     
    244244 * @param   pResult     Where to store the result.
    245245 */
    246 static DECLCALLBACK(int) dbgcOpMinus(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult)
     246static DECLCALLBACK(int) dbgcOpMinus(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult)
    247247{
    248248    LogFlow(("dbgcOpMinus\n"));
     
    289289 * @param   pResult     Where to store the result.
    290290 */
    291 static DECLCALLBACK(int) dbgcOpPluss(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult)
     291static DECLCALLBACK(int) dbgcOpPluss(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult)
    292292{
    293293    LogFlow(("dbgcOpPluss\n"));
     
    323323 * @param   pResult     Where to store the result.
    324324 */
    325 static DECLCALLBACK(int) dbgcOpBooleanNot(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult)
     325static DECLCALLBACK(int) dbgcOpBooleanNot(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult)
    326326{
    327327    LogFlow(("dbgcOpBooleanNot\n"));
     
    371371 * @param   pResult     Where to store the result.
    372372 */
    373 static DECLCALLBACK(int) dbgcOpBitwiseNot(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult)
     373static DECLCALLBACK(int) dbgcOpBitwiseNot(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult)
    374374{
    375375    LogFlow(("dbgcOpBitwiseNot\n"));
     
    416416 * @param   pResult     Where to store the result.
    417417 */
    418 static DECLCALLBACK(int) dbgcOpVar(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult)
     418static DECLCALLBACK(int) dbgcOpVar(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult)
    419419{
    420420    LogFlow(("dbgcOpVar: %s\n", pArg->u.pszString));
     
    453453 * @param   pResult     Where to store the result.
    454454 */
    455 DECLCALLBACK(int) dbgcOpRegister(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult)
     455DECLCALLBACK(int) dbgcOpRegister(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult)
    456456{
    457457    LogFlow(("dbgcOpRegister: %s\n", pArg->u.pszString));
     
    463463        && pArg->enmType != DBGCVAR_TYPE_SYMBOL)
    464464        return VERR_PARSE_INCORRECT_ARG_TYPE;
     465
     466    /*
     467     * If the desired result is a symbol, pass the argument along unmodified.
     468     * This is a great help for "r @eax" and such, since it will be translated to "r eax".
     469     */
     470    if (enmCat == DBGCVAR_CAT_SYMBOL)
     471    {
     472        int rc = DBGFR3RegNmValidate(pDbgc->pVM, pDbgc->idCpu, pArg->u.pszString);
     473        if (RT_SUCCESS(rc))
     474            DBGCVAR_INIT_STRING(pResult, pArg->u.pszString);
     475        return rc;
     476    }
    465477
    466478    /*
     
    527539 * @param   pResult     Where to store the result.
    528540 */
    529 DECLCALLBACK(int) dbgcOpAddrFlat(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult)
     541DECLCALLBACK(int) dbgcOpAddrFlat(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult)
    530542{
    531543    LogFlow(("dbgcOpAddrFlat\n"));
     
    545557 * @param   pResult     Where to store the result.
    546558 */
    547 DECLCALLBACK(int) dbgcOpAddrPhys(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult)
     559DECLCALLBACK(int) dbgcOpAddrPhys(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult)
    548560{
    549561    LogFlow(("dbgcOpAddrPhys\n"));
     
    563575 * @param   pResult     Where to store the result.
    564576 */
    565 DECLCALLBACK(int) dbgcOpAddrHostPhys(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult)
     577DECLCALLBACK(int) dbgcOpAddrHostPhys(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult)
    566578{
    567579    LogFlow(("dbgcOpAddrPhys\n"));
     
    580592 * @param   pResult     Where to store the result.
    581593 */
    582 DECLCALLBACK(int) dbgcOpAddrHost(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult)
     594DECLCALLBACK(int) dbgcOpAddrHost(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult)
    583595{
    584596    LogFlow(("dbgcOpAddrHost\n"));
     
    778790                default:
    779791                    *pResult = *pArg1;
    780                     rc = dbgcOpAddrFlat(pDbgc, pArg2, &Var);
     792                    rc = dbgcOpAddrFlat(pDbgc, pArg2, DBGCVAR_CAT_ANY, &Var);
    781793                    if (RT_FAILURE(rc))
    782794                        return rc;
     
    800812                    break;
    801813                default:
    802                     rc = dbgcOpAddrFlat(pDbgc, pArg1, pResult);
     814                    rc = dbgcOpAddrFlat(pDbgc, pArg1, DBGCVAR_CAT_ANY, pResult);
    803815                    if (RT_FAILURE(rc))
    804816                        return rc;
    805                     rc = dbgcOpAddrFlat(pDbgc, pArg2, &Var);
     817                    rc = dbgcOpAddrFlat(pDbgc, pArg2, DBGCVAR_CAT_ANY, &Var);
    806818                    if (RT_FAILURE(rc))
    807819                        return rc;
     
    822834                default:
    823835                    *pResult = *pArg1;
    824                     rc = dbgcOpAddrPhys(pDbgc, pArg2, &Var);
     836                    rc = dbgcOpAddrPhys(pDbgc, pArg2, DBGCVAR_CAT_ANY, &Var);
    825837                    if (RT_FAILURE(rc))
    826838                        return rc;
     
    837849        case DBGCVAR_TYPE_HC_FLAT:
    838850            *pResult = *pArg1;
    839             rc = dbgcOpAddrHost(pDbgc, pArg2, &Var2);
     851            rc = dbgcOpAddrHost(pDbgc, pArg2, DBGCVAR_CAT_ANY, &Var2);
    840852            if (RT_FAILURE(rc))
    841853                return rc;
    842             rc = dbgcOpAddrFlat(pDbgc, &Var2, &Var);
     854            rc = dbgcOpAddrFlat(pDbgc, &Var2, DBGCVAR_CAT_ANY, &Var);
    843855            if (RT_FAILURE(rc))
    844856                return rc;
     
    851863        case DBGCVAR_TYPE_HC_PHYS:
    852864            *pResult = *pArg1;
    853             rc = dbgcOpAddrHostPhys(pDbgc, pArg2, &Var);
     865            rc = dbgcOpAddrHostPhys(pDbgc, pArg2, DBGCVAR_CAT_ANY, &Var);
    854866            if (RT_FAILURE(rc))
    855867                return rc;
     
    976988        if (pOp)
    977989        {
    978             int rc = pOp(pDbgc, pArg1, &Sym1);
     990            int rc = pOp(pDbgc, pArg1, DBGCVAR_CAT_ANY, &Sym1);
    979991            if (RT_FAILURE(rc))
    980992                return rc;
     
    10031015                default:
    10041016                    *pResult = *pArg1;
    1005                     rc = dbgcOpAddrFlat(pDbgc, pArg2, &Var);
     1017                    rc = dbgcOpAddrFlat(pDbgc, pArg2, DBGCVAR_CAT_ANY, &Var);
    10061018                    if (RT_FAILURE(rc))
    10071019                        return rc;
     
    10251037                    break;
    10261038                default:
    1027                     rc = dbgcOpAddrFlat(pDbgc, pArg1, pResult);
     1039                    rc = dbgcOpAddrFlat(pDbgc, pArg1, DBGCVAR_CAT_ANY, pResult);
    10281040                    if (RT_FAILURE(rc))
    10291041                        return rc;
    1030                     rc = dbgcOpAddrFlat(pDbgc, pArg2, &Var);
     1042                    rc = dbgcOpAddrFlat(pDbgc, pArg2, DBGCVAR_CAT_ANY, &Var);
    10311043                    if (RT_FAILURE(rc))
    10321044                        return rc;
     
    10471059                default:
    10481060                    *pResult = *pArg1;
    1049                     rc = dbgcOpAddrPhys(pDbgc, pArg2, &Var);
     1061                    rc = dbgcOpAddrPhys(pDbgc, pArg2, DBGCVAR_CAT_ANY, &Var);
    10501062                    if (RT_FAILURE(rc))
    10511063                        return rc;
     
    10621074        case DBGCVAR_TYPE_HC_FLAT:
    10631075            *pResult = *pArg1;
    1064             rc = dbgcOpAddrHost(pDbgc, pArg2, &Var2);
     1076            rc = dbgcOpAddrHost(pDbgc, pArg2, DBGCVAR_CAT_ANY, &Var2);
    10651077            if (RT_FAILURE(rc))
    10661078                return rc;
    1067             rc = dbgcOpAddrFlat(pDbgc, &Var2, &Var);
     1079            rc = dbgcOpAddrFlat(pDbgc, &Var2, DBGCVAR_CAT_ANY, &Var);
    10681080            if (RT_FAILURE(rc))
    10691081                return rc;
     
    10761088        case DBGCVAR_TYPE_HC_PHYS:
    10771089            *pResult = *pArg1;
    1078             rc = dbgcOpAddrHostPhys(pDbgc, pArg2, &Var);
     1090            rc = dbgcOpAddrHostPhys(pDbgc, pArg2, DBGCVAR_CAT_ANY, &Var);
    10791091            if (RT_FAILURE(rc))
    10801092                return rc;
  • trunk/src/VBox/Debugger/DBGConsole.cpp

    r35829 r41546  
    216216            DBGCVAR Var;
    217217            DBGCVAR_INIT_STRING(&Var, pszSymbol);
    218             rc = dbgcOpRegister(pDbgc, &Var, pResult);
     218            rc = dbgcOpRegister(pDbgc, &Var, DBGCVAR_CAT_ANY, pResult);
    219219            if (RT_SUCCESS(rc))
    220220                return DBGCCmdHlpConvert(&pDbgc->CmdHlp, &Var, enmType, false /*fConvSyms*/, pResult);
  • trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp

    r38838 r41546  
    194194{
    195195    return VERR_INTERNAL_ERROR;
     196}
     197VMMR3DECL(int) DBGFR3RegNmValidate(PVM pVM, VMCPUID idDefCpu, const char *pszReg)
     198{
     199    return VINF_SUCCESS;
    196200}
    197201VMMR3DECL(int) DBGFR3RegCpuQueryU8(  PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint8_t     *pu8)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette