VirtualBox

Changeset 41874 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 22, 2012 12:14:56 AM (13 years ago)
Author:
vboxsync
Message:

DIS: Fixed two bugs in the size-only parsers that was introduced when changing the return from size to offset late in the refactoring. Added tests to make sure this doesn't break again so easily.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Disassembler/DisasmCore.cpp

    r41872 r41874  
    910910
    911911
    912 static size_t UseModRM(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
     912static size_t UseModRM(size_t const offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    913913{
    914914    unsigned vtype = OP_PARM_VTYPE(pParam->fParam);
     
    13101310    }
    13111311
    1312     offInstr += QueryModRM_SizeOnly(offInstr, pOp, pDis, pParam);
     1312    offInstr = QueryModRM_SizeOnly(offInstr, pOp, pDis, pParam);
    13131313
    13141314    /* UseModRM is not necessary here; we're only interested in the opcode size */
     
    14971497    /* Word for 16-bit operand-size or doubleword for 32 or 64-bit operand-size. */
    14981498    if (pDis->uOpMode == DISCPUMODE_16BIT)
    1499         return sizeof(uint16_t);
     1499        return offInstr + 2;
    15001500    return offInstr + 4;
    15011501}
  • trunk/src/VBox/Disassembler/testcase/tstDisasm-1.cpp

    r41797 r41874  
    7272                                  rc, off, Dis.cbInstr, enmDisCpuMode);
    7373        RTTestIPrintf(RTTESTLVL_ALWAYS, "%s\n", szOutput);
     74
     75        /* Check with size-only. */
     76        uint32_t        cbOnly = 1;
     77        DISSTATE        DisOnly;
     78        rc = DISInstWithPrefetchedBytes((uintptr_t)&pabInstrs[off], enmDisCpuMode,  0 /*fFilter - none */,
     79                                        Dis.abInstr, Dis.cbCachedInstr, NULL, NULL, &DisOnly, &cbOnly);
     80
     81        RTTESTI_CHECK_RC(rc, VINF_SUCCESS);
     82        RTTESTI_CHECK(cbOnly == DisOnly.cbInstr);
     83        RTTESTI_CHECK_MSG(cbOnly == cb, ("%#x vs %#x\n", cbOnly, cb));
     84
    7485        off += cb;
    7586    }
  • trunk/src/VBox/Disassembler/testcase/tstDisasm-1A.asm

    r41868 r41874  
    137137        pswapd      mm2, qword [es:esi*8]
    138138
    139         pmulhrwa mm0, qword [ds:ebp+edi*8+00f000001h]
    140 
     139        pmulhrwa    mm0, qword [ds:ebp+edi*8+00f000001h]
    141140
    142141        ; MMX
  • trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp

    r41863 r41874  
    357357        if (uHighlightAddr - State.uAddress < State.cbInstr)
    358358            RTPrintf("; ^^^^^^^^^^^^^^^^^^^^^\n");
     359
     360        /* Check that the size-only mode returns the smae size on success. */
     361        if (RT_SUCCESS(rc))
     362        {
     363            uint32_t cbInstrOnly = 32;
     364            uint8_t  abInstr[sizeof(State.Dis.abInstr)];
     365            memcpy(abInstr, State.Dis.abInstr, sizeof(State.Dis.abInstr));
     366            int rcOnly = DISInstWithPrefetchedBytes(State.uAddress, enmCpuMode, 0 /*fFilter - none */,
     367                                                    abInstr, State.Dis.cbCachedInstr, MyDisasInstrRead, &State,
     368                                                    &State.Dis, &cbInstrOnly);
     369            if (   rcOnly != rc
     370                || cbInstrOnly != State.cbInstr)
     371            {
     372                RTPrintf("; Instruction size only check failed rc=%Rrc cbInstrOnly=%#x exepcted %Rrc and %#x\n",
     373                         rcOnly, cbInstrOnly, rc, State.cbInstr);
     374                rcRet = VERR_GENERAL_FAILURE;
     375                break;
     376            }
     377        }
    359378
    360379        /* next */
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