VirtualBox

Changeset 4213 in vbox


Ignore:
Timestamp:
Aug 18, 2007 3:28:45 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
23707
Message:

multiplication and an operator associativity+precendency fix.

Location:
trunk
Files:
2 edited

Legend:

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

    r4071 r4213  
    9999} DBGCVARTYPE;
    100100
     101/** @todo Rename to DBGCVAR_IS_xyz. */
     102
    101103/** Checks if the specified variable type is of a pointer persuasion. */
    102 #define DBGCVAR_ISPOINTER(enmType)      (enmType >= DBGCVAR_TYPE_GC_FLAT && enmType <= DBGCVAR_TYPE_HC_PHYS)
     104#define DBGCVAR_ISPOINTER(enmType)      ((enmType) >= DBGCVAR_TYPE_GC_FLAT && enmType <= DBGCVAR_TYPE_HC_PHYS)
     105/** Checks if the specified variable type is of a pointer persuasion. */
     106#define DBGCVAR_IS_FAR_PTR(enmType)     ((enmType) == DBGCVAR_TYPE_GC_FAR || (enmType) == DBGCVAR_TYPE_HC_FAR)
    103107/** Checks if the specified variable type is of a pointer persuasion and of the guest context sort. */
    104 #define DBGCVAR_ISGCPOINTER(enmType)    (enmType >= DBGCVAR_TYPE_GC_FLAT && enmType <= DBGCVAR_TYPE_GC_PHYS)
     108#define DBGCVAR_ISGCPOINTER(enmType)    ((enmType) >= DBGCVAR_TYPE_GC_FLAT && (enmType) <= DBGCVAR_TYPE_GC_PHYS)
    105109/** Checks if the specified variable type is of a pointer persuasion and of the host context sort. */
    106 #define DBGCVAR_ISHCPOINTER(enmType)    (enmType >= DBGCVAR_TYPE_HC_FLAT && enmType <= DBGCVAR_TYPE_HC_PHYS)
     110#define DBGCVAR_ISHCPOINTER(enmType)    ((enmType) >= DBGCVAR_TYPE_HC_FLAT && (enmType) <= DBGCVAR_TYPE_HC_PHYS)
    107111
    108112
  • trunk/src/VBox/Debugger/DBGConsole.cpp

    r4212 r4213  
    853853    { {'!'},            1,       false,      1,              dbgcOpBooleanNot,   NULL,                       "Boolean not." },
    854854    { {'~'},            1,       false,      1,              dbgcOpBitwiseNot,   NULL,                       "Bitwise complement." },
    855     { {'%'},            1,       false,      1,              dbgcOpAddrFlat,     NULL,                       "Flat address." },
    856     { {'%','%'},        2,       false,      1,              dbgcOpAddrPhys,     NULL,                       "Physical address." },
    857     { {'#'},            1,       false,      1,              dbgcOpAddrHost,     NULL,                       "Flat host address." },
    858     { {'#','%','%'},    3,       false,      1,              dbgcOpAddrHostPhys, NULL,                       "Physical host address." },
    859     { {'$'},            1,       false,      1,              dbgcOpVar,          NULL,                       "Reference a variable." },
    860     { {':'},            1,       true,       9,              NULL,               dbgcOpAddrFar,              "Far pointer." },
     855    { {':'},            1,       true,       2,              NULL,               dbgcOpAddrFar,              "Far pointer." },
     856    { {'%'},            1,       false,      3,              dbgcOpAddrFlat,     NULL,                       "Flat address." },
     857    { {'%','%'},        2,       false,      3,              dbgcOpAddrPhys,     NULL,                       "Physical address." },
     858    { {'#'},            1,       false,      3,              dbgcOpAddrHost,     NULL,                       "Flat host address." },
     859    { {'#','%','%'},    3,       false,      3,              dbgcOpAddrHostPhys, NULL,                       "Physical host address." },
     860    { {'$'},            1,       false,      3,              dbgcOpVar,          NULL,                       "Reference a variable." },
    861861    { {'*'},            1,       true,       10,             NULL,               dbgcOpMult,                 "Multiplication." },
    862862    { {'/'},            1,       true,       11,             NULL,               dbgcOpDiv,                  "Division." },
     
    51405140
    51415141
    5142 
    51435142/**
    51445143 * Multiplication operator (binary).
     
    51545153static DECLCALLBACK(int) dbgcOpMult(PDBGC pDbgc, PCDBGCVAR pArg1, PCDBGCVAR pArg2, PDBGCVAR pResult)
    51555154{
    5156     LogFlow(("dbgcOpMult\n"));
    5157     NOREF(pDbgc); NOREF(pArg1); NOREF(pArg2); NOREF(pResult);
    5158     return -1;
     5155//    LogFlow(("dbgcOpMult\n"));
     5156    int     rc;
     5157
     5158    /*
     5159     * Switch the factors so we preserve pointers, far pointers are considered more
     5160     * important that physical and flat pointers.
     5161     */
     5162    if (    DBGCVAR_ISPOINTER(pArg2->enmType)
     5163        &&  (   !DBGCVAR_ISPOINTER(pArg1->enmType)
     5164             || (   DBGCVAR_IS_FAR_PTR(pArg2->enmType)
     5165                 && !DBGCVAR_IS_FAR_PTR(pArg1->enmType))))
     5166    {
     5167        PCDBGCVAR pTmp = pArg1;
     5168        pArg2 = pArg1;
     5169        pArg1 = pTmp;
     5170    }
     5171
     5172    /*
     5173     * Convert the 2nd number into a number we use multiply the first with.
     5174     */
     5175    DBGCVAR Factor2 = *pArg2;
     5176    if (    Factor2.enmType == DBGCVAR_TYPE_STRING
     5177        ||  Factor2.enmType == DBGCVAR_TYPE_SYMBOL)
     5178    {
     5179        rc = dbgcSymbolGet(pDbgc, pArg2->u.pszString, DBGCVAR_TYPE_NUMBER, &Factor2);
     5180        if (VBOX_FAILURE(rc))
     5181            return rc;
     5182    }
     5183    uint64_t u64Factor;
     5184    switch (Factor2.enmType)
     5185    {
     5186        case DBGCVAR_TYPE_GC_FLAT:  u64Factor = Factor2.u.GCFlat; break;
     5187        case DBGCVAR_TYPE_GC_FAR:   u64Factor = Factor2.u.GCFar.off; break;
     5188        case DBGCVAR_TYPE_GC_PHYS:  u64Factor = Factor2.u.GCPhys; break;
     5189        case DBGCVAR_TYPE_HC_FLAT:  u64Factor = (uintptr_t)Factor2.u.pvHCFlat; break;
     5190        case DBGCVAR_TYPE_HC_FAR:   u64Factor = Factor2.u.HCFar.off; break;
     5191        case DBGCVAR_TYPE_HC_PHYS:  u64Factor = Factor2.u.HCPhys; break;
     5192        case DBGCVAR_TYPE_NUMBER:   u64Factor = Factor2.u.u64Number; break;
     5193        default:
     5194            return VERR_PARSE_INCORRECT_ARG_TYPE;
     5195    }
     5196
     5197    /*
     5198     * Fix symbols in the 1st factor.
     5199     */
     5200    *pResult = *pArg1;
     5201    if (    pResult->enmType == DBGCVAR_TYPE_STRING
     5202        ||  pResult->enmType == DBGCVAR_TYPE_SYMBOL)
     5203    {
     5204        rc = dbgcSymbolGet(pDbgc, pArg1->u.pszString, DBGCVAR_TYPE_ANY, pResult);
     5205        if (VBOX_FAILURE(rc))
     5206            return rc;
     5207    }
     5208
     5209    /*
     5210     * Do the multiplication.
     5211     */
     5212    switch (pArg1->enmType)
     5213    {
     5214        case DBGCVAR_TYPE_GC_FLAT:  pResult->u.GCFlat *= u64Factor; break;
     5215        case DBGCVAR_TYPE_GC_FAR:   pResult->u.GCFar.off *= u64Factor; break;
     5216        case DBGCVAR_TYPE_GC_PHYS:  pResult->u.GCPhys *= u64Factor; break;
     5217        case DBGCVAR_TYPE_HC_FLAT:
     5218            pResult->u.pvHCFlat = (void *)(uintptr_t)((uintptr_t)pResult->u.pvHCFlat * u64Factor);
     5219            break;
     5220        case DBGCVAR_TYPE_HC_FAR:   pResult->u.HCFar.off *= u64Factor; break;
     5221        case DBGCVAR_TYPE_HC_PHYS:  pResult->u.HCPhys *= u64Factor; break;
     5222        case DBGCVAR_TYPE_NUMBER:   pResult->u.u64Number *= u64Factor; break;
     5223        default:
     5224            return VERR_PARSE_INCORRECT_ARG_TYPE;
     5225    }
     5226    return 0;
    51595227}
    51605228
     
    76037671
    76047672/**
    7605  * Evaluates one argument with though of unary operators.
     7673 * Evaluates one argument with respect to unary operators.
    76067674 *
    76077675 * @returns 0 on success. pResult contains the result.
     
    78357903    char       *pszOpSplit = NULL;
    78367904    PCDBGCOP    pOpSplit = NULL;
    7837     unsigned    iOpSplit = 0;
    78387905    unsigned    cBinaryOps = 0;
    78397906    unsigned    cPar = 0;
     
    78767943                 * Update the parse state and skip the operator.
    78777944                 */
    7878                 if (fBinary)
     7945                if (!pOpSplit)
     7946                {
     7947                    pOpSplit = pOp;
     7948                    pszOpSplit = psz;
     7949                    cBinaryOps = fBinary;
     7950                }
     7951                else if (fBinary)
    78797952                {
    78807953                    cBinaryOps++;
    7881                     if (iOpSplit < pOp->iPrecedence)
     7954                    if (pOp->iPrecedence >= pOpSplit->iPrecedence)
    78827955                    {
    78837956                        pOpSplit = pOp;
     
    78857958                    }
    78867959                }
     7960
    78877961                psz += pOp->cchName - 1;
    78887962                fBinary = false;
     
    79057979     */
    79067980    int rc;
    7907     if (cBinaryOps)
     7981    if (    cBinaryOps
     7982        &&  pOpSplit->fBinary)
    79087983    {
    79097984        /* process 1st sub expression. */
     
    79217996                rc = pOpSplit->pfnHandlerBinary(pDbgc, &Arg1, &Arg2, pResult);
    79227997        }
     7998    }
     7999    else if (cBinaryOps)
     8000    {
     8001        /* process sub expression. */
     8002        pszOpSplit += pOpSplit->cchName;
     8003        DBGCVAR     Arg;
     8004        rc = dbgcEvalSub(pDbgc, pszOpSplit, cchExpr - (pszOpSplit - pszExpr), &Arg);
     8005        if (VBOX_SUCCESS(rc))
     8006            /* apply the operator. */
     8007            rc = pOpSplit->pfnHandlerUnary(pDbgc, &Arg, pResult);
    79238008    }
    79248009    else
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