VirtualBox

Changeset 41669 in vbox


Ignore:
Timestamp:
Jun 12, 2012 1:34:07 PM (12 years ago)
Author:
vboxsync
Message:

DISInstr -> DISInstrToStr.

Location:
trunk
Files:
6 edited

Legend:

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

    r41668 r41669  
    550550
    551551
    552 DISDECL(int) DISInstr(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput);
     552DISDECL(int) DISInstrToStr(void const *pvInstr, DISCPUMODE enmCpuMode,
     553                           PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput, size_t cbOutput);
    553554DISDECL(int) DISInstrWithOff(PDISCPUSTATE pCpu, RTUINTPTR uInstrAddr, RTUINTPTR offRealAddr, uint32_t *pcbInstr, char *pszOutput);
    554555DISDECL(int) DISInstrWithReader(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PFNDISREADBYTES pfnReadBytes, void *pvUser,
  • trunk/src/VBox/Disassembler/Disasm.cpp

    r41668 r41669  
    3636 * @param   pCpu            Pointer to cpu structure which have DISCPUSTATE::mode
    3737 *                          set correctly.
    38  * @param   uInstrAddr      Pointer to the structure to disassemble.
     38 * @param   pvInstr         Pointer to the instruction to disassemble.
    3939 * @param   pcbInstr        Where to store the size of the instruction. NULL is
    4040 *                          allowed.
    4141 * @param   pszOutput       Storage for disassembled instruction
     42 * @param   cbOutput        Size of the output buffer.
    4243 *
    4344 * @todo    Define output callback.
    4445 */
    45 DISDECL(int) DISInstr(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput)
     46DISDECL(int) DISInstrToStr(void const *pvInstr, DISCPUMODE enmCpuMode, PDISCPUSTATE pCpu, uint32_t *pcbInstr,
     47                           char *pszOutput, size_t cbOutput)
    4648{
    47     return DISInstrEx(uInstrAddr, 0, enmCpuMode, NULL, NULL, OPTYPE_ALL,
     49    return DISInstrEx((uintptr_t)pvInstr, 0, enmCpuMode, NULL, NULL, OPTYPE_ALL,
    4850                      pCpu, pcbInstr, pszOutput);
    4951}
     
    5557 * @param   pCpu            Pointer to cpu structure which have DISCPUSTATE::mode
    5658 *                          set correctly.
    57  * @param   uInstrAddr      Pointer to the structure to disassemble.
     59 * @param   uInstrAddr      Pointer to the instruction to disassemble.
    5860 * @param   offRealAddr     Offset to add to instruction address to get the real
    5961 *                          virtual address.
  • trunk/src/VBox/Disassembler/DisasmTest.cpp

    r41658 r41669  
    4242    else
    4343    {
    44         RTUINTPTR pInstr = (uintptr_t)TestProc;
     44        uint8_t const *pbInstr = (uint8_t const *)(uintptr_t)TestProc;
    4545
    4646        for (int i=0;i<50;i++)
     
    5050            char        szOutput[256];
    5151
    52             if (RT_SUCCESS(DISInstr(pInstr, CPUMODE_32BIT, &cpu, &cb, szOutput)))
     52            if (RT_SUCCESS(DISInstrToStr(pbInstr, CPUMODE_32BIT, &cpu, &cb, szOutput, sizeof(szOutput))))
    5353            {
    5454                printf("%s", szOutput);
     
    5959                return 1;
    6060            }
    61             pInstr += cb;
     61            pbInstr += cb;
    6262        }
    6363
    6464#ifndef RT_OS_OS2
    6565        printf("\n64 bits disassembly\n");
    66         pInstr = (uintptr_t)TestProc64;
     66        pbInstr = (uint8_t const *)(uintptr_t)TestProc64;
    6767
    6868////__debugbreak();
     
    7373            char        szOutput[256];
    7474
    75             if (RT_SUCCESS(DISInstr(pInstr, CPUMODE_64BIT, &cpu, &cb, szOutput)))
     75            if (RT_SUCCESS(DISInstrToStr(pbInstr, CPUMODE_64BIT, &cpu, &cb, szOutput, sizeof(szOutput))))
    7676                printf("%s", szOutput);
    7777            else
     
    8080                return 1;
    8181            }
    82             pInstr += cb;
     82            pbInstr += cb;
    8383        }
    8484#endif
  • trunk/src/VBox/VMM/testcase/tstCompiler.cpp

    r41658 r41669  
    199199{
    200200    RTPrintf("tstBitFields: Disassembly of %s:\n", pszName);
    201     RTUINTPTR uCur = (uintptr_t)pv;
    202     RTUINTPTR uCurMax = uCur + 256;
    203     DISCPUSTATE Cpu;
    204 
    205     memset(&Cpu, 0, sizeof(Cpu));
     201    uint8_t const *pbCur    = (uint8_t const *)(uintptr_t)pv;
     202    uint8_t const *pbCurMax = pbCur + 256;
     203    DISCPUSTATE    Cpu;
     204
    206205    do
    207206    {
    208207        char        sz[256];
    209208        uint32_t    cbInstr = 0;
    210         if (RT_SUCCESS(DISInstr(uCur, CPUMODE_32BIT, &Cpu, &cbInstr, sz)))
     209        if (RT_SUCCESS(DISInstrToStr(pbCur, CPUMODE_32BIT, &Cpu, &cbInstr, sz, sizeof(sz))))
    211210        {
    212211            RTPrintf("tstBitFields: %s", sz);
    213             uCur += cbInstr;
     212            pbCur += cbInstr;
    214213        }
    215214        else
    216215        {
    217             RTPrintf("tstBitFields: %p: %02x - DISInstr failed!\n", uCur, *(uint8_t *)(uintptr_t)uCur);
    218             uCur += 1;
     216            RTPrintf("tstBitFields: %p: %02x - DISInstr failed!\n", pbCur, *pbCur);
     217            pbCur += 1;
    219218        }
    220     } while (Cpu.pCurInstr->opcode != OP_RETN || uCur > uCurMax);
     219    } while (Cpu.pCurInstr->opcode != OP_RETN || (uintptr_t)pbCur > (uintptr_t)pbCurMax);
    221220}
    222221
  • trunk/src/recompiler/VBoxREMWrapper.cpp

    r41658 r41669  
    652652    { REMPARMDESC_FLAGS_INT,        sizeof(RTGCUINTPTR),        NULL }
    653653};
    654 static const REMPARMDESC g_aArgsDISInstr[] =
    655 {
    656     { REMPARMDESC_FLAGS_INT,        sizeof(RTUINTPTR),          NULL },
     654static const REMPARMDESC g_aArgsDISInstrToStr[] =
     655{
     656    { REMPARMDESC_FLAGS_INT,        sizeof(uint8_t const *),    NULL },
    657657    { REMPARMDESC_FLAGS_INT,        sizeof(DISCPUMODE),         NULL },
    658658    { REMPARMDESC_FLAGS_INT,        sizeof(PDISCPUSTATE),       NULL },
    659659    { REMPARMDESC_FLAGS_INT,        sizeof(uint32_t *),         NULL },
    660     { REMPARMDESC_FLAGS_INT,        sizeof(char *),             NULL }
     660    { REMPARMDESC_FLAGS_INT,        sizeof(char *),             NULL },
     661    { REMPARMDESC_FLAGS_INT,        sizeof(size_t),             NULL }
    661662};
    662663static const REMPARMDESC g_aArgsEMR3FatalError[] =
     
    12331234    { "DBGFR3AsSymbolByAddr",                   VMM_FN(DBGFR3AsSymbolByAddr),           &g_aArgsDBGFR3AsSymbolByAddr[0],            RT_ELEMENTS(g_aArgsDBGFR3AsSymbolByAddr),              REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
    12341235    { "DBGFR3AddrFromFlat",                     VMM_FN(DBGFR3AddrFromFlat),             &g_aArgsDBGFR3AddrFromFlat[0],              RT_ELEMENTS(g_aArgsDBGFR3AddrFromFlat),                REMFNDESC_FLAGS_RET_INT,    sizeof(PDBGFADDRESS),       NULL },
    1235     { "DISInstr",                               VMM_FN(DISInstr),                       &g_aArgsDISInstr[0],                        RT_ELEMENTS(g_aArgsDISInstr),                          REMFNDESC_FLAGS_RET_INT,    sizeof(bool),       NULL },
     1236    { "DISInstrToStr",                          VMM_FN(DISInstrToStr),                  &g_aArgsDISInstrToStr[0],                   RT_ELEMENTS(g_aArgsDISInstrToStr),                     REMFNDESC_FLAGS_RET_INT,    sizeof(bool),       NULL },
    12361237    { "EMR3FatalError",                         VMM_FN(EMR3FatalError),                 &g_aArgsEMR3FatalError[0],                  RT_ELEMENTS(g_aArgsEMR3FatalError),                    REMFNDESC_FLAGS_RET_VOID,   0,                  NULL },
    12371238    { "EMRemLock",                              VMM_FN(EMRemLock),                      &g_aArgsVM[0],                              RT_ELEMENTS(g_aArgsVM),                                REMFNDESC_FLAGS_RET_VOID,   0,                  NULL },
  • trunk/src/recompiler/VBoxRecompiler.c

    r41658 r41669  
    40814081        {
    40824082            uint32_t cbInstr;
    4083             int rc = DISInstr((uintptr_t)pvCode + off, enmCpuMode, &Cpu, &cbInstr, szOutput);
     4083            int rc = DISInstrToStr((uint8_t const *)pvCode + off, enmCpuMode,
     4084                                   &Cpu, &cbInstr, szOutput, sizeof(szOutput));
    40844085            if (RT_SUCCESS(rc))
    40854086                RTLogPrintf("%s", szOutput);
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