VirtualBox

Changeset 64499 in vbox for trunk/src


Ignore:
Timestamp:
Nov 1, 2016 9:06:26 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
111637
Message:

VMM/DBGFDisas: Add method internal to VMM which returns a very small part of the disassembler state along with the string (used by the control flow graph generator)

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/DBGFDisas.cpp

    r62637 r64499  
    412412 * @param       cbOutput        Size of the output buffer.
    413413 * @param       pcbInstr        Where to return the size of the instruction.
     414 * @param       pDisState       Where to store the disassembler state into.
    414415 */
    415416static DECLCALLBACK(int)
    416417dbgfR3DisasInstrExOnVCpu(PVM pVM, PVMCPU pVCpu, RTSEL Sel, PRTGCPTR pGCPtr, uint32_t fFlags,
    417                          char *pszOutput, uint32_t cbOutput, uint32_t *pcbInstr)
     418                         char *pszOutput, uint32_t cbOutput, uint32_t *pcbInstr, PDBGFDISSTATE pDisState)
    418419{
    419420    VMCPU_ASSERT_EMT(pVCpu);
     
    669670        *pcbInstr = State.Cpu.cbInstr;
    670671
     672    if (pDisState)
     673    {
     674        pDisState->pCurInstr = State.Cpu.pCurInstr;
     675        pDisState->cbInstr   = State.Cpu.cbInstr;
     676        pDisState->Param1    = State.Cpu.Param1;
     677        pDisState->Param2    = State.Cpu.Param2;
     678        pDisState->Param3    = State.Cpu.Param3;
     679        pDisState->Param4    = State.Cpu.Param4;
     680    }
     681
    671682    dbgfR3DisasInstrDone(&State);
    672683    return VINF_SUCCESS;
    673684}
    674685
     686
     687/**
     688 * Disassembles the one instruction according to the specified flags and address
     689 * returning part of the disassembler state.
     690 *
     691 * @returns VBox status code.
     692 * @param   pUVM            The user mode VM handle.
     693 * @param   idCpu           The ID of virtual CPU.
     694 * @param   pAddr           The code address.
     695 * @param   fFlags          Flags controlling where to start and how to format.
     696 *                          A combination of the DBGF_DISAS_FLAGS_* \#defines.
     697 * @param   pszOutput       Output buffer.  This will always be properly
     698 *                          terminated if @a cbOutput is greater than zero.
     699 * @param   cbOutput        Size of the output buffer.
     700 * @param   pDisState       The disassembler state to fill in.
     701 *
     702 * @remarks May have to switch to the EMT of the virtual CPU in order to do
     703 *          address conversion.
     704 */
     705DECLHIDDEN(int) dbgfR3DisasInstrStateEx(PUVM pUVM, VMCPUID idCpu, PDBGFADDRESS pAddr, uint32_t fFlags,
     706                                        char *pszOutput, uint32_t cbOutput, PDBGFDISSTATE pDisState)
     707{
     708    AssertReturn(cbOutput > 0, VERR_INVALID_PARAMETER);
     709    *pszOutput = '\0';
     710    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     711    PVM pVM = pUVM->pVM;
     712    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     713    AssertReturn(idCpu < pUVM->cCpus, VERR_INVALID_CPU_ID);
     714    AssertReturn(!(fFlags & ~DBGF_DISAS_FLAGS_VALID_MASK), VERR_INVALID_PARAMETER);
     715    AssertReturn((fFlags & DBGF_DISAS_FLAGS_MODE_MASK) <= DBGF_DISAS_FLAGS_64BIT_MODE, VERR_INVALID_PARAMETER);
     716
     717    /*
     718     * Optimize the common case where we're called on the EMT of idCpu since
     719     * we're using this all the time when logging.
     720     */
     721    int     rc;
     722    PVMCPU  pVCpu = VMMGetCpu(pVM);
     723    if (    pVCpu
     724        &&  pVCpu->idCpu == idCpu)
     725        rc = dbgfR3DisasInstrExOnVCpu(pVM, pVCpu, pAddr->Sel, &pAddr->off, fFlags, pszOutput, cbOutput, NULL, pDisState);
     726    else
     727        rc = VMR3ReqPriorityCallWait(pVM, idCpu, (PFNRT)dbgfR3DisasInstrExOnVCpu, 9,
     728                                     pVM, VMMGetCpuById(pVM, idCpu), pAddr->Sel, &pAddr->off, fFlags, pszOutput, cbOutput, NULL, pDisState);
     729    return rc;
     730}
    675731
    676732/**
     
    713769    if (    pVCpu
    714770        &&  pVCpu->idCpu == idCpu)
    715         rc = dbgfR3DisasInstrExOnVCpu(pVM, pVCpu, Sel, &GCPtr, fFlags, pszOutput, cbOutput, pcbInstr);
     771        rc = dbgfR3DisasInstrExOnVCpu(pVM, pVCpu, Sel, &GCPtr, fFlags, pszOutput, cbOutput, pcbInstr, NULL);
    716772    else
    717         rc = VMR3ReqPriorityCallWait(pVM, idCpu, (PFNRT)dbgfR3DisasInstrExOnVCpu, 8,
    718                                      pVM, VMMGetCpuById(pVM, idCpu), Sel, &GCPtr, fFlags, pszOutput, cbOutput, pcbInstr);
     773        rc = VMR3ReqPriorityCallWait(pVM, idCpu, (PFNRT)dbgfR3DisasInstrExOnVCpu, 9,
     774                                     pVM, VMMGetCpuById(pVM, idCpu), Sel, &GCPtr, fFlags, pszOutput, cbOutput, pcbInstr, NULL);
    719775    return rc;
    720776}
     
    742798                                    DBGF_DISAS_FLAGS_CURRENT_GUEST | DBGF_DISAS_FLAGS_DEFAULT_MODE
    743799                                    | DBGF_DISAS_FLAGS_ANNOTATE_PATCHED,
    744                                     pszOutput, cbOutput, NULL);
     800                                    pszOutput, cbOutput, NULL, NULL);
    745801}
    746802
     
    798854    RTGCPTR GCPtrTmp = GCPtr;
    799855    int rc = dbgfR3DisasInstrExOnVCpu(pVCpu->pVMR3, pVCpu, Sel, &GCPtrTmp, DBGF_DISAS_FLAGS_DEFAULT_MODE,
    800                                       &szBuf[0], sizeof(szBuf), NULL);
     856                                      &szBuf[0], sizeof(szBuf), NULL, NULL);
    801857    if (RT_FAILURE(rc))
    802858        RTStrPrintf(szBuf, sizeof(szBuf), "DBGFR3DisasInstrLog(, %RTsel, %RGv) failed with rc=%Rrc\n", Sel, GCPtr, rc);
  • trunk/src/VBox/VMM/include/DBGFInternal.h

    r62478 r64499  
    2020
    2121#include <VBox/cdefs.h>
     22#ifdef IN_RING3
     23# include <VBox/dis.h>
     24#endif
    2225#include <VBox/types.h>
    2326#include <iprt/semaphore.h>
     
    460463
    461464#ifdef IN_RING3
     465/**
     466 * DBGF disassembler state (substate of DISSTATE).
     467 */
     468typedef struct DBGFDISSTATE
     469{
     470    /** Pointer to the current instruction. */
     471    PCDISOPCODE     pCurInstr;
     472    /** Size of the instruction in bytes. */
     473    uint32_t        cbInstr;
     474    /** Parameters.  */
     475    DISOPPARAM      Param1;
     476    DISOPPARAM      Param2;
     477    DISOPPARAM      Param3;
     478    DISOPPARAM      Param4;
     479} DBGFDISSTATE;
     480/** Pointer to a DBGF disassembler state. */
     481typedef DBGFDISSTATE *PDBGFDISSTATE;
     482
     483DECLHIDDEN(int) dbgfR3DisasInstrStateEx(PUVM pUVM, VMCPUID idCpu, PDBGFADDRESS pAddr, uint32_t fFlags,
     484                                        char *pszOutput, uint32_t cbOutput, PDBGFDISSTATE pDisState);
    462485
    463486#endif
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