VirtualBox

Changeset 19575 in vbox


Ignore:
Timestamp:
May 11, 2009 12:42:46 PM (16 years ago)
Author:
vboxsync
Message:

Updates for ring 0 call stack dumping. (not enabled nor tested)

Location:
trunk
Files:
9 edited

Legend:

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

    r19572 r19575  
    8989/** A physical address. */
    9090#define DBGFADDRESS_FLAGS_PHYS          4
     91/** A physical address. */
     92#define DBGFADDRESS_FLAGS_RING0         5
    9193/** The address type mask. */
    9294#define DBGFADDRESS_FLAGS_TYPE_MASK     7
  • trunk/include/VBox/vmm.h

    r19528 r19575  
    175175VMMR3DECL(void)     VMMR3SendInitIpi(PVM pVM, VMCPUID idCpu);
    176176VMMR3DECL(int)      VMMR3AtomicExecuteHandler(PVM pVM, PFNATOMICHANDLER pfnHandler, void *pvUser);
     177VMMR3DECL(int)      VMMR3ReadR0Stack(PVM pVM, VMCPUID idCpu, RTHCUINTPTR pAddress, void *pvBuf, size_t cbRead);
    177178/** @} */
    178179#endif /* IN_RING3 */
  • trunk/src/VBox/VMM/DBGFMem.cpp

    r19463 r19575  
    205205{
    206206    AssertReturn(idCpu < pVM->cCPUs, VERR_INVALID_PARAMETER);
    207 
    208     PVMREQ pReq;
    209     int rc = VMR3ReqCallU(pVM->pUVM, idCpu, &pReq, RT_INDEFINITE_WAIT, 0,
    210                           (PFNRT)dbgfR3MemRead, 5, pVM, idCpu, pAddress, pvBuf, cbRead);
    211     if (RT_SUCCESS(rc))
    212         rc = pReq->iStatus;
    213     VMR3ReqFree(pReq);
    214 
    215     return rc;
     207    if ((pAddress->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_RING0)
     208    {
     209        AssertCompile(sizeof(RTHCUINTPTR) == sizeof(pAddress->FlatPtr));
     210        return VMMR3ReadR0Stack(pVM, idCpu, (RTHCUINTPTR)pAddress->FlatPtr, pvBuf, cbRead);
     211    }
     212    else
     213    {
     214        PVMREQ pReq;
     215        int rc = VMR3ReqCallU(pVM->pUVM, idCpu, &pReq, RT_INDEFINITE_WAIT, 0,
     216                              (PFNRT)dbgfR3MemRead, 5, pVM, idCpu, pAddress, pvBuf, cbRead);
     217        if (RT_SUCCESS(rc))
     218            rc = pReq->iStatus;
     219        VMR3ReqFree(pReq);
     220        return rc;
     221    }
    216222}
    217223
  • trunk/src/VBox/VMM/DBGFStack.cpp

    r19572 r19575  
    100100        case DBGFADDRESS_FLAGS_FAR32: cbStackItem = 4; break;
    101101        case DBGFADDRESS_FLAGS_FAR64: cbStackItem = 8; break;
     102        case DBGFADDRESS_FLAGS_RING0: cbStackItem = sizeof(RTHCUINTPTR); break;
    102103        default:                      cbStackItem = 4; break; /// @todo 64-bit guests.
    103104    }
     
    281282                case DBGFADDRESS_FLAGS_FAR32: pCur->enmReturnType = DBGFRETURNTYPE_NEAR32; break;
    282283                case DBGFADDRESS_FLAGS_FAR64: pCur->enmReturnType = DBGFRETURNTYPE_NEAR64; break;
     284                case DBGFADDRESS_FLAGS_RING0: pCur->enmReturnType = (HC_ARCH_BITS == 64) ? DBGFRETURNTYPE_NEAR64 : DBGFRETURNTYPE_NEAR32; break;
    283285                default:                      pCur->enmReturnType = DBGFRETURNTYPE_NEAR32; break; /// @todo 64-bit guests
    284286            }
     
    405407     * Get the CPUM context pointer and pass it on the specified EMT.
    406408     */
    407     PCCPUMCTXCORE   pCtxCore = (enmCodeType == DBGFCODETYPE_GUEST)
    408                              ? CPUMGetGuestCtxCore(VMMGetCpuById(pVM, idCpu))
    409                              : CPUMGetHyperCtxCore(VMMGetCpuById(pVM, idCpu));
    410     PVMREQ          pReq;
     409    PCCPUMCTXCORE   pCtxCore;
     410    switch (enmCodeType)
     411    {
     412    case DBGFCODETYPE_GUEST:
     413        pCtxCore = CPUMGetGuestCtxCore(VMMGetCpuById(pVM, idCpu));
     414        break;
     415    case DBGFCODETYPE_HYPER:
     416        pCtxCore = CPUMGetHyperCtxCore(VMMGetCpuById(pVM, idCpu));
     417        break;
     418    case DBGFCODETYPE_RING0:
     419        pCtxCore = NULL;    /* No valid context present. */
     420        break;
     421    }
     422    PVMREQ pReq;
    411423    int rc = VMR3ReqCall(pVM, idCpu, &pReq, RT_INDEFINITE_WAIT,
    412424                         (PFNRT)dbgfR3StackWalkCtxFull, 9,
     
    441453 * @param   ppFirstFrame    Where to return the pointer to the first info frame.
    442454 */
    443 VMMR3DECL(int) DBGFR3StackWalkBegintEx(PVM pVM,
    444                                        VMCPUID idCpu,
    445                                        DBGFCODETYPE enmCodeType,
    446                                        PCDBGFADDRESS pAddrFrame,
    447                                        PCDBGFADDRESS pAddrStack,
    448                                        PCDBGFADDRESS pAddrPC,
    449                                        DBGFRETURNTYPE enmReturnType,
    450                                        PCDBGFSTACKFRAME *ppFirstFrame)
     455VMMR3DECL(int) DBGFR3StackWalkBeginEx(PVM pVM,
     456                                      VMCPUID idCpu,
     457                                      DBGFCODETYPE enmCodeType,
     458                                      PCDBGFADDRESS pAddrFrame,
     459                                      PCDBGFADDRESS pAddrStack,
     460                                      PCDBGFADDRESS pAddrPC,
     461                                      DBGFRETURNTYPE enmReturnType,
     462                                      PCDBGFSTACKFRAME *ppFirstFrame)
    451463{
    452464    return dbgfR3StackWalkBeginCommon(pVM, idCpu, enmCodeType, pAddrFrame, pAddrStack, pAddrPC, enmReturnType, ppFirstFrame);
  • trunk/src/VBox/VMM/VMM.cpp

    r19539 r19575  
    12821282
    12831283/**
     1284 * Read from the ring 0 jump buffer stack
     1285 *
     1286 * @returns VBox status code.
     1287 *
     1288 * @param   pVM             Pointer to the shared VM structure.
     1289 * @param   idCpu           The ID of the source CPU context (for the address).
     1290 * @param   pAddress        Where to start reading.
     1291 * @param   pvBuf           Where to store the data we've read.
     1292 * @param   cbRead          The number of bytes to read.
     1293 */
     1294VMMR3DECL(int) VMMR3ReadR0Stack(PVM pVM, VMCPUID idCpu, RTHCUINTPTR pAddress, void *pvBuf, size_t cbRead)
     1295{
     1296    PVMCPU  pVCpu   = VMMGetCpuById(pVM, idCpu);
     1297    AssertReturn(pVCpu, VERR_INVALID_PARAMETER);
     1298
     1299    RTHCUINTPTR offset = pAddress - pVCpu->vmm.s.CallHostR0JmpBuf.SpCheck;
     1300    if (offset >= pVCpu->vmm.s.CallHostR0JmpBuf.cbSavedStack)
     1301        return VERR_INVALID_POINTER;
     1302
     1303    memcpy(pvBuf, pVCpu->vmm.s.pbEMTStackR3 + offset, cbRead);
     1304    return VINF_SUCCESS;
     1305}
     1306
     1307
     1308/**
    12841309 * Calls a RC function.
    12851310 *
  • trunk/src/VBox/VMM/VMMGuruMeditation.cpp

    r19572 r19575  
    291291                /* Callstack. */
    292292                PCDBGFSTACKFRAME pFirstFrame;
    293                 rc2 = DBGFR3StackWalkBegin(pVM, pVCpu->idCpu, DBGFCODETYPE_RING0, &pFirstFrame);
     293                DBGFADDRESS eip, ebp, esp;
     294
     295                eip.fFlags   = DBGFADDRESS_FLAGS_RING0;
     296#if HC_ARCH_BITS == 64
     297                eip.FlatPtr = pVCpu->vmm.s.CallHostR0JmpBuf.rip;
     298#else
     299                eip.FlatPtr = pVCpu->vmm.s.CallHostR0JmpBuf.eip;
     300#endif
     301                ebp.fFlags   = DBGFADDRESS_FLAGS_RING0;
     302                ebp.FlatPtr = pVCpu->vmm.s.CallHostR0JmpBuf.SavedEbp;
     303                esp.fFlags   = DBGFADDRESS_FLAGS_RING0;
     304                esp.FlatPtr = pVCpu->vmm.s.CallHostR0JmpBuf.SavedEsp;
     305
     306                rc2 = DBGFR3StackWalkBeginEx(pVM, pVCpu->idCpu, DBGFCODETYPE_RING0, &ebp, &esp, &eip,
     307                                             DBGFRETURNTYPE_INVALID, &pFirstFrame);
    294308                if (RT_SUCCESS(rc2))
    295309                {
  • trunk/src/VBox/VMM/VMMInternal.h

    r19529 r19575  
    157157    /** The esp we should resume execution with after the restore. */
    158158    RTHCUINTREG                 SpResume;
     159    /** ESP/RSP at the time of the jump to ring 3. */
     160    RTHCUINTREG                 SavedEsp;
     161    /** EBP/RBP at the time of the jump to ring 3. */
     162    RTHCUINTREG                 SavedEbp;
    159163} VMMR0JMPBUF;
    160164/** Pointer to a ring-0 jump buffer. */
  • trunk/src/VBox/VMM/VMMInternal.mac

    r8155 r19575  
    6161    .SpCheck        resq 1
    6262    .SpResume       resq 1
     63    .SavedEsp       resq 1
     64    .SavedEbp       resq 1
    6365%endif
    6466endstruc
  • trunk/src/VBox/VMM/VMMR0/VMMR0A.asm

    r18849 r19575  
    408408%endif ; !VMM_R0_SWITCH_STACK
    409409
     410    ; Save ESP & EBP to enable stack dumps
     411    mov     ecx, ebp
     412    mov     [edx + VMMR0JMPBUF.SavedEbp], ecx
     413    sub     ecx, 4
     414    mov     [edx + VMMR0JMPBUF.SavedEsp], ecx
     415
    410416    ; store the last pieces of info.
    411417    mov     ecx, [edx + VMMR0JMPBUF.esp]
     
    506512 %endif ; !VMM_R0_SWITCH_STACK
    507513
     514    ; Save RSP & RBP to enable stack dumps
     515    mov     rcx, rbp
     516    mov     [rdx + VMMR0JMPBUF.SavedEbp], rcx
     517    sub     rcx, 8
     518    mov     [rdx + VMMR0JMPBUF.SavedEsp], rcx
     519
    508520    ; store the last pieces of info.
    509521    mov     rcx, [rdx + VMMR0JMPBUF.rsp]
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