VirtualBox

Changeset 46165 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 19, 2013 7:07:50 PM (12 years ago)
Author:
vboxsync
Message:

Made dSYM-bundle loading work as well as line numbers in the stack traces (when possible).

Location:
trunk/src/VBox
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp

    r46159 r46165  
    11831183     */
    11841184    bool        fFirst = 1;
    1185     DBGFLINE    LinePrev = { 0, 0, "" };
     1185    RTDBGLINE   LinePrev = { 0, 0, 0, 0, 0, "" };
    11861186    int         iRangeLeft = (int)pDbgc->SourcePos.u64Range;
    11871187    if (iRangeLeft == 0)                /* kludge for 'r'. */
     
    11921192         * Get line info.
    11931193         */
    1194         DBGFLINE    Line;
     1194        RTDBGLINE   Line;
    11951195        RTGCINTPTR  off;
    1196         int rc = DBGFR3LineByAddr(pUVM, pDbgc->SourcePos.u.GCFlat, &off, &Line);
     1196        DBGFADDRESS SourcePosAddr;
     1197        int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &pDbgc->SourcePos, &SourcePosAddr);
     1198        if (RT_FAILURE(rc))
     1199            return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,%Dv)", &pDbgc->SourcePos);
     1200        rc = DBGFR3AsLineByAddr(pUVM, pDbgc->hDbgAs, &SourcePosAddr, &off, &Line, NULL);
    11971201        if (RT_FAILURE(rc))
    11981202            return VINF_SUCCESS;
  • trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp

    r46156 r46165  
    114114    return true;
    115115}
    116 VMMR3DECL(int) DBGFR3LineByAddr(PUVM pUVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFLINE pLine)
    117 {
    118     return VERR_INTERNAL_ERROR;
    119 }
    120116VMMR3DECL(int) DBGFR3LogModifyDestinations(PUVM pUVM, const char *pszDestSettings)
    121117{
     
    149145{
    150146    return NIL_RTDBGAS;
     147}
     148VMMR3DECL(int) DBGFR3AsLineByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
     149                                  PRTGCINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod)
     150{
     151    return VERR_DBG_LINE_NOT_FOUND;
    151152}
    152153VMMR3DECL(int) DBGFR3Resume(PUVM pUVM)
  • trunk/src/VBox/Runtime/common/dbg/dbgas.cpp

    r46134 r46165  
    16961696
    16971697
    1698 /**
    1699  * Query a line number by address.
    1700  *
    1701  * @returns IPRT status code. See RTDbgModSymbolAddrA for more specific ones.
    1702  * @retval  VERR_INVALID_HANDLE if hDbgAs is invalid.
    1703  * @retval  VERR_NOT_FOUND if the address couldn't be mapped to a module.
    1704  *
    1705  * @param   hDbgAs          The address space handle.
    1706  * @param   Addr            The address which closest symbol is requested.
    1707  * @param   poffDisp        Where to return the distance between the line
    1708  *                          number and address.
    1709  * @param   pLine           Where to return the line number information.
    1710  */
    1711 RTDECL(int) RTDbgAsLineByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE pLine)
     1698RTDECL(int) RTDbgAsLineByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod)
    17121699{
    17131700    /*
     
    17291716    int rc = RTDbgModLineByAddr(hMod, iSeg, offSeg, poffDisp, pLine);
    17301717    if (RT_SUCCESS(rc))
     1718    {
    17311719        rtDbgAsAdjustLineAddress(pLine, hMod, MapAddr, iSeg);
    1732     RTDbgModRelease(hMod);
     1720        if (phMod)
     1721            *phMod = hMod;
     1722        else
     1723            RTDbgModRelease(hMod);
     1724    }
     1725    else
     1726        RTDbgModRelease(hMod);
    17331727    return rc;
    17341728}
     
    17361730
    17371731
    1738 /**
    1739  * Query a line number by address.
    1740  *
    1741  * @returns IPRT status code. See RTDbgModSymbolAddrA for more specific ones.
    1742  * @retval  VERR_INVALID_HANDLE if hDbgAs is invalid.
    1743  * @retval  VERR_NOT_FOUND if the address couldn't be mapped to a module.
    1744  *
    1745  * @param   hDbgAs          The address space handle.
    1746  * @param   Addr            The address which closest symbol is requested.
    1747  * @param   poffDisp        Where to return the distance between the line
    1748  *                          number and address.
    1749  * @param   ppLine          Where to return the pointer to the allocated line
    1750  *                          number info. Always set. Free with RTDbgLineFree.
    1751  */
    1752 RTDECL(int) RTDbgAsLineByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE *ppLine)
     1732RTDECL(int) RTDbgAsLineByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE *ppLine, PRTDBGMOD phMod)
    17531733{
    17541734    /*
     
    17701750    int rc = RTDbgModLineByAddrA(hMod, iSeg, offSeg, poffDisp, ppLine);
    17711751    if (RT_SUCCESS(rc))
     1752    {
    17721753        rtDbgAsAdjustLineAddress(*ppLine, hMod, MapAddr, iSeg);
    1773     RTDbgModRelease(hMod);
     1754        if (phMod)
     1755            *phMod = hMod;
     1756        else
     1757            RTDbgModRelease(hMod);
     1758    }
     1759    else
     1760        RTDbgModRelease(hMod);
    17741761    return rc;
    17751762}
  • trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp

    r46164 r46165  
    486486                return VINF_SUCCESS;
    487487            }
    488             pDbgMod->pDbgVt    = NULL;
     488
     489            pDbgMod->pDbgVt = NULL;
    489490            Assert(pDbgMod->pvDbgPriv == NULL);
    490491        }
     
    530531                return VINF_CALLBACK_RETURN;
    531532            }
    532             pDbgMod->pDbgVt    = NULL;
     533
     534            pDbgMod->pDbgVt = NULL;
    533535            Assert(pDbgMod->pvDbgPriv == NULL);
    534536        }
     537        RTSemRWReleaseRead(g_hDbgModRWSem);
    535538    }
    536539
    537540    /* No joy. */
    538     RTSemRWReleaseRead(g_hDbgModRWSem);
    539541    RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszDbgFile);
    540542    pDbgMod->pszDbgFile = NULL;
     
    843845                            if (RT_SUCCESS(rc))
    844846                            {
     847                                /*
     848                                 * We're done!
     849                                 */
     850                                ASMAtomicIncU32(&pImg->cUsers);
     851                                RTSemRWReleaseRead(g_hDbgModRWSem);
     852
    845853                                *phDbgMod = pDbgMod;
    846854                                return VINF_SUCCESS;
  • trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp

    r46164 r46165  
    36963696                                                       pSubProgram->PcRange.uHighAddress - pSubProgram->PcRange.uLowAddress,
    36973697                                                       0 /*fFlags*/, NULL /*piOrdinal*/);
    3698                                 AssertRC(rc);
     3698                                AssertMsg(RT_SUCCESS(rc) || rc == VERR_DBG_DUPLICATE_SYMBOL, ("%Rrc\n", rc));
    36993699                            }
    37003700                            else
  • trunk/src/VBox/Runtime/common/ldr/ldrkStuff.cpp

    r46164 r46165  
    812812
    813813
     814/** @copydoc RTLDROPS::pfnReadDbgInfo. */
     815static DECLCALLBACK(int) rtkldr_ReadDbgInfo(PRTLDRMODINTERNAL pMod, uint32_t iDbgInfo, RTFOFF off, size_t cb, void *pvBuf)
     816{
     817    PRTLDRMODKLDR   pThis = (PRTLDRMODKLDR)pMod;
     818    /** @todo May have to apply fixups here. */
     819    return pThis->Core.pReader->pfnRead(pThis->Core.pReader, pvBuf, cb, off);
     820}
     821
     822
    814823/**
    815824 * Operations for a kLdr module.
     
    833842    rtkldr_SegOffsetToRva,
    834843    rtkldr_RvaToSegOffset,
    835     NULL,
     844    rtkldr_ReadDbgInfo,
    836845    42
    837846};
  • trunk/src/VBox/Runtime/tools/RTLdrFlt.cpp

    r46161 r46165  
    388388                    RTDBGLINE   Line;
    389389                    RTINTPTR    offLine;
    390                     rc = RTDbgAsLineByAddr(hDbgAs, u64Address, &offLine, &Line);
     390                    rc = RTDbgAsLineByAddr(hDbgAs, u64Address, &offLine, &Line, NULL);
    391391                    if (RT_SUCCESS(rc))
    392392                        RTStrmPrintf(pOutput, " %Rbn(%u)", Line.szFilename, Line.uLineNo);
  • trunk/src/VBox/VMM/Makefile.kmk

    r46137 r46165  
    683683endif
    684684
     685ifneq ($(USERNAME),bird) # Not opts for me atm.
    685686#
    686687# Always optimize the interpreter.
     
    697698 VMMAll/IEMAll.cpp_CXXFLAGS += -fomit-frame-pointer # Omitting the frame pointer results in larger code, but it might be worth it. (esp addressing vs ebp?)
    698699endif
    699 
     700endif # No optimizations for me atm.
    700701
    701702include $(FILE_KBUILD_SUB_FOOTER)
  • trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp

    r45965 r46165  
    24582458
    24592459#ifdef VBOX_WITH_RAW_MODE_NOT_R0
     2460
    24602461/**
    24612462 *
     
    24682469    return pVCpu->cpum.s.fRawEntered;
    24692470}
    2470 #endif
    2471 
     2471
     2472/**
     2473 * Transforms the guest CPU state to raw-ring mode.
     2474 *
     2475 * This function will change the any of the cs and ss register with DPL=0 to DPL=1.
     2476 *
     2477 * @returns VBox status. (recompiler failure)
     2478 * @param   pVCpu       Pointer to the VMCPU.
     2479 * @param   pCtxCore    The context core (for trap usage).
     2480 * @see     @ref pg_raw
     2481 */
     2482VMM_INT_DECL(int) CPUMRawEnter(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore)
     2483{
     2484    PVM pVM = pVCpu->CTX_SUFF(pVM);
     2485
     2486    Assert(!pVCpu->cpum.s.fRawEntered);
     2487    Assert(!pVCpu->cpum.s.fRemEntered);
     2488    if (!pCtxCore)
     2489        pCtxCore = CPUMCTX2CORE(&pVCpu->cpum.s.Guest);
     2490
     2491    /*
     2492     * Are we in Ring-0?
     2493     */
     2494    if (    pCtxCore->ss.Sel
     2495        &&  (pCtxCore->ss.Sel & X86_SEL_RPL) == 0
     2496        &&  !pCtxCore->eflags.Bits.u1VM)
     2497    {
     2498        /*
     2499         * Enter execution mode.
     2500         */
     2501        PATMRawEnter(pVM, pCtxCore);
     2502
     2503        /*
     2504         * Set CPL to Ring-1.
     2505         */
     2506        pCtxCore->ss.Sel |= 1;
     2507        if (    pCtxCore->cs.Sel
     2508            &&  (pCtxCore->cs.Sel & X86_SEL_RPL) == 0)
     2509            pCtxCore->cs.Sel |= 1;
     2510    }
     2511    else
     2512    {
     2513# ifdef VBOX_WITH_RAW_RING1
     2514        if (    EMIsRawRing1Enabled(pVM)
     2515            &&  !pCtxCore->eflags.Bits.u1VM
     2516            &&  (pCtxCore->ss.Sel & X86_SEL_RPL) == 1)
     2517        {
     2518            /* Set CPL to Ring-2. */
     2519            pCtxCore->ss.Sel = (pCtxCore->ss.Sel & ~X86_SEL_RPL) | 2;
     2520            if (pCtxCore->cs.Sel && (pCtxCore->cs.Sel & X86_SEL_RPL) == 1)
     2521                pCtxCore->cs.Sel = (pCtxCore->cs.Sel & ~X86_SEL_RPL) | 2;
     2522        }
     2523# else
     2524        AssertMsg((pCtxCore->ss.Sel & X86_SEL_RPL) >= 2 || pCtxCore->eflags.Bits.u1VM,
     2525                  ("ring-1 code not supported\n"));
     2526# endif
     2527        /*
     2528         * PATM takes care of IOPL and IF flags for Ring-3 and Ring-2 code as well.
     2529         */
     2530        PATMRawEnter(pVM, pCtxCore);
     2531    }
     2532
     2533    /*
     2534     * Assert sanity.
     2535     */
     2536    AssertMsg((pCtxCore->eflags.u32 & X86_EFL_IF), ("X86_EFL_IF is clear\n"));
     2537    AssertReleaseMsg(pCtxCore->eflags.Bits.u2IOPL == 0,
     2538                     ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss.Sel & X86_SEL_RPL));
     2539    Assert((pVCpu->cpum.s.Guest.cr0 & (X86_CR0_PG | X86_CR0_WP | X86_CR0_PE)) == (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP));
     2540
     2541    pCtxCore->eflags.u32        |= X86_EFL_IF; /* paranoia */
     2542
     2543    pVCpu->cpum.s.fRawEntered = true;
     2544    return VINF_SUCCESS;
     2545}
     2546
     2547
     2548/**
     2549 * Transforms the guest CPU state from raw-ring mode to correct values.
     2550 *
     2551 * This function will change any selector registers with DPL=1 to DPL=0.
     2552 *
     2553 * @returns Adjusted rc.
     2554 * @param   pVCpu       Pointer to the VMCPU.
     2555 * @param   rc          Raw mode return code
     2556 * @param   pCtxCore    The context core (for trap usage).
     2557 * @see     @ref pg_raw
     2558 */
     2559VMM_INT_DECL(int) CPUMRawLeave(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, int rc)
     2560{
     2561    PVM pVM = pVCpu->CTX_SUFF(pVM);
     2562
     2563    /*
     2564     * Don't leave if we've already left (in RC).
     2565     */
     2566    Assert(!pVCpu->cpum.s.fRemEntered);
     2567    if (!pVCpu->cpum.s.fRawEntered)
     2568        return rc;
     2569    pVCpu->cpum.s.fRawEntered = false;
     2570
     2571    PCPUMCTX pCtx = &pVCpu->cpum.s.Guest;
     2572    if (!pCtxCore)
     2573        pCtxCore = CPUMCTX2CORE(pCtx);
     2574    Assert(pCtxCore->eflags.Bits.u1VM || (pCtxCore->ss.Sel & X86_SEL_RPL));
     2575    AssertMsg(pCtxCore->eflags.Bits.u1VM || pCtxCore->eflags.Bits.u2IOPL < (unsigned)(pCtxCore->ss.Sel & X86_SEL_RPL),
     2576              ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss.Sel & X86_SEL_RPL));
     2577
     2578    /*
     2579     * Are we executing in raw ring-1?
     2580     */
     2581    if (    (pCtxCore->ss.Sel & X86_SEL_RPL) == 1
     2582        &&  !pCtxCore->eflags.Bits.u1VM)
     2583    {
     2584        /*
     2585         * Leave execution mode.
     2586         */
     2587        PATMRawLeave(pVM, pCtxCore, rc);
     2588        /* Not quite sure if this is really required, but shouldn't harm (too much anyways). */
     2589        /** @todo See what happens if we remove this. */
     2590        if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 1)
     2591            pCtxCore->ds.Sel &= ~X86_SEL_RPL;
     2592        if ((pCtxCore->es.Sel & X86_SEL_RPL) == 1)
     2593            pCtxCore->es.Sel &= ~X86_SEL_RPL;
     2594        if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 1)
     2595            pCtxCore->fs.Sel &= ~X86_SEL_RPL;
     2596        if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 1)
     2597            pCtxCore->gs.Sel &= ~X86_SEL_RPL;
     2598
     2599        /*
     2600         * Ring-1 selector => Ring-0.
     2601         */
     2602        pCtxCore->ss.Sel &= ~X86_SEL_RPL;
     2603        if ((pCtxCore->cs.Sel & X86_SEL_RPL) == 1)
     2604            pCtxCore->cs.Sel &= ~X86_SEL_RPL;
     2605    }
     2606    else
     2607    {
     2608        /*
     2609         * PATM is taking care of the IOPL and IF flags for us.
     2610         */
     2611        PATMRawLeave(pVM, pCtxCore, rc);
     2612        if (!pCtxCore->eflags.Bits.u1VM)
     2613        {
     2614# ifdef VBOX_WITH_RAW_RING1
     2615            if (    EMIsRawRing1Enabled(pVM)
     2616                &&  (pCtxCore->ss.Sel & X86_SEL_RPL) == 2)
     2617            {
     2618                /* Not quite sure if this is really required, but shouldn't harm (too much anyways). */
     2619                /** @todo See what happens if we remove this. */
     2620                if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 2)
     2621                    pCtxCore->ds.Sel = (pCtxCore->ds.Sel & ~X86_SEL_RPL) | 1;
     2622                if ((pCtxCore->es.Sel & X86_SEL_RPL) == 2)
     2623                    pCtxCore->es.Sel = (pCtxCore->es.Sel & ~X86_SEL_RPL) | 1;
     2624                if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 2)
     2625                    pCtxCore->fs.Sel = (pCtxCore->fs.Sel & ~X86_SEL_RPL) | 1;
     2626                if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 2)
     2627                    pCtxCore->gs.Sel = (pCtxCore->gs.Sel & ~X86_SEL_RPL) | 1;
     2628
     2629                /*
     2630                 * Ring-2 selector => Ring-1.
     2631                 */
     2632                pCtxCore->ss.Sel = (pCtxCore->ss.Sel & ~X86_SEL_RPL) | 1;
     2633                if ((pCtxCore->cs.Sel & X86_SEL_RPL) == 2)
     2634                    pCtxCore->cs.Sel = (pCtxCore->cs.Sel & ~X86_SEL_RPL) | 1;
     2635            }
     2636            else
     2637            {
     2638# endif
     2639                /** @todo See what happens if we remove this. */
     2640                if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 1)
     2641                    pCtxCore->ds.Sel &= ~X86_SEL_RPL;
     2642                if ((pCtxCore->es.Sel & X86_SEL_RPL) == 1)
     2643                    pCtxCore->es.Sel &= ~X86_SEL_RPL;
     2644                if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 1)
     2645                    pCtxCore->fs.Sel &= ~X86_SEL_RPL;
     2646                if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 1)
     2647                    pCtxCore->gs.Sel &= ~X86_SEL_RPL;
     2648# ifdef VBOX_WITH_RAW_RING1
     2649            }
     2650# endif
     2651        }
     2652    }
     2653
     2654    return rc;
     2655}
     2656
     2657#endif /* VBOX_WITH_RAW_MODE_NOT_R0 */
    24722658
    24732659/**
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r45701 r46165  
    84918491    AssertReturn(CPUMCTX2CORE(pCtx) == pCtxCore, VERR_IEM_IPE_3);
    84928492
     8493#ifdef IN_RC
     8494    CPUMRawLeave(pVCpu, pCtxCore, VINF_SUCCESS);
     8495#endif
     8496
    84938497    iemInitDecoder(pIemCpu, true);
    84948498    uint32_t const cbOldWritten = pIemCpu->cbWritten;
     
    85018505            *pcbWritten = pIemCpu->cbWritten - cbOldWritten;
    85028506    }
     8507
     8508#ifdef IN_RC
     8509    CPUMRawEnter(pVCpu, pCtxCore);
     8510#endif
    85038511    return rcStrict;
    85048512}
     
    85118519    PCPUMCTX pCtx    = pVCpu->iem.s.CTX_SUFF(pCtx);
    85128520    AssertReturn(CPUMCTX2CORE(pCtx) == pCtxCore, VERR_IEM_IPE_3);
     8521
     8522#ifdef IN_RC
     8523    CPUMRawLeave(pVCpu, pCtxCore, VINF_SUCCESS);
     8524#endif
    85138525
    85148526    VBOXSTRICTRC rcStrict;
     
    85258537    if (rcStrict == VINF_SUCCESS)
    85268538        rcStrict = iemExecOneInner(pVCpu, pIemCpu, false);
     8539
     8540#ifdef IN_RC
     8541    CPUMRawEnter(pVCpu, pCtxCore);
     8542#endif
    85278543    return rcStrict;
    85288544}
  • trunk/src/VBox/VMM/VMMAll/PATMAll.cpp

    r45628 r46165  
    5050VMM_INT_DECL(void) PATMRawEnter(PVM pVM, PCPUMCTXCORE pCtxCore)
    5151{
    52     bool fPatchCode = PATMIsPatchGCAddr(pVM, pCtxCore->eip);
    5352    Assert(!HMIsEnabled(pVM));
    5453
     
    5756     * For all cases where it isn't, IOPL will be safe and IF will be set.
    5857     */
    59     register uint32_t efl = pCtxCore->eflags.u32;
     58    uint32_t efl = pCtxCore->eflags.u32;
    6059    CTXSUFF(pVM->patm.s.pGCState)->uVMFlags = efl & PATM_VIRTUAL_FLAGS_MASK;
    61     AssertMsg((efl & X86_EFL_IF) || PATMShouldUseRawMode(pVM, (RTRCPTR)pCtxCore->eip), ("X86_EFL_IF is clear and PATM is disabled! (eip=%RRv eflags=%08x fPATM=%d pPATMGC=%RRv-%RRv\n", pCtxCore->eip, pCtxCore->eflags.u32, PATMIsEnabled(pVM), pVM->patm.s.pPatchMemGC, pVM->patm.s.pPatchMemGC + pVM->patm.s.cbPatchMem));
    62 
    63     AssertReleaseMsg(CTXSUFF(pVM->patm.s.pGCState)->fPIF || fPatchCode, ("fPIF=%d eip=%RRv\n", CTXSUFF(pVM->patm.s.pGCState)->fPIF, pCtxCore->eip));
     60
     61    AssertMsg((efl & X86_EFL_IF) || PATMShouldUseRawMode(pVM, (RTRCPTR)pCtxCore->eip),
     62              ("X86_EFL_IF is clear and PATM is disabled! (eip=%RRv eflags=%08x fPATM=%d pPATMGC=%RRv-%RRv\n",
     63               pCtxCore->eip, pCtxCore->eflags.u32, PATMIsEnabled(pVM), pVM->patm.s.pPatchMemGC,
     64               pVM->patm.s.pPatchMemGC + pVM->patm.s.cbPatchMem));
     65
     66    AssertReleaseMsg(CTXSUFF(pVM->patm.s.pGCState)->fPIF || PATMIsPatchGCAddr(pVM, pCtxCore->eip),
     67                     ("fPIF=%d eip=%RRv\n", pVM->patm.s.CTXSUFF(pGCState)->fPIF, pCtxCore->eip));
    6468
    6569    efl &= ~PATM_VIRTUAL_FLAGS_MASK;
     
    6872
    6973#ifdef IN_RING3
    70 #ifdef PATM_EMULATE_SYSENTER
     74# ifdef PATM_EMULATE_SYSENTER
    7175    PCPUMCTX pCtx;
    7276
     
    103107        pVM->patm.s.pfnSysEnterGC = 0;
    104108    }
    105 #endif
     109# endif /* PATM_EMULATE_SYSENTER */
    106110#endif
    107111}
     
    124128    Assert(!HMIsEnabled(pVM));
    125129    bool fPatchCode = PATMIsPatchGCAddr(pVM, pCtxCore->eip);
     130
    126131    /*
    127132     * We will only be called if PATMRawEnter was previously called.
    128133     */
    129     register uint32_t efl = pCtxCore->eflags.u32;
     134    uint32_t efl = pCtxCore->eflags.u32;
    130135    efl = (efl & ~PATM_VIRTUAL_FLAGS_MASK) | (CTXSUFF(pVM->patm.s.pGCState)->uVMFlags & PATM_VIRTUAL_FLAGS_MASK);
    131136    pCtxCore->eflags.u32 = efl;
     
    136141
    137142#ifdef IN_RING3
    138     if (    (efl & X86_EFL_IF)
    139         &&  fPatchCode
    140        )
    141     {
    142         if (    rawRC < VINF_PATM_LEAVE_RC_FIRST
    143             ||  rawRC > VINF_PATM_LEAVE_RC_LAST)
     143    if (   (efl & X86_EFL_IF)
     144        && fPatchCode)
     145    {
     146        if (   rawRC < VINF_PATM_LEAVE_RC_FIRST
     147            || rawRC > VINF_PATM_LEAVE_RC_LAST)
    144148        {
    145149            /*
     
    182186        }
    183187    }
    184 #else /* !IN_RING3 */
    185     AssertMsgFailed(("!IN_RING3"));
    186 #endif  /* !IN_RING3 */
     188#else  /* !IN_RING3 */
     189    /*
     190     * When leaving raw-mode state while IN_RC, it's generally for interpreting
     191     * a single original guest instruction.
     192     */
     193    AssertMsg(!fPatchCode, ("eip=%RRv\n", pCtxCore->eip));
     194#endif /* !IN_RING3 */
    187195
    188196    if (!fPatchCode)
  • trunk/src/VBox/VMM/VMMR3/CPUM.cpp

    r46142 r46165  
    41944194}
    41954195
    4196 #ifdef VBOX_WITH_RAW_MODE
    4197 
    4198 /**
    4199  * Transforms the guest CPU state to raw-ring mode.
    4200  *
    4201  * This function will change the any of the cs and ss register with DPL=0 to DPL=1.
    4202  *
    4203  * @returns VBox status. (recompiler failure)
    4204  * @param   pVCpu       Pointer to the VMCPU.
    4205  * @param   pCtxCore    The context core (for trap usage).
    4206  * @see     @ref pg_raw
    4207  */
    4208 VMMR3DECL(int) CPUMR3RawEnter(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore)
    4209 {
    4210     PVM pVM = pVCpu->CTX_SUFF(pVM);
    4211 
    4212     Assert(!pVCpu->cpum.s.fRawEntered);
    4213     Assert(!pVCpu->cpum.s.fRemEntered);
    4214     if (!pCtxCore)
    4215         pCtxCore = CPUMCTX2CORE(&pVCpu->cpum.s.Guest);
    4216 
    4217     /*
    4218      * Are we in Ring-0?
    4219      */
    4220     if (    pCtxCore->ss.Sel
    4221         &&  (pCtxCore->ss.Sel & X86_SEL_RPL) == 0
    4222         &&  !pCtxCore->eflags.Bits.u1VM)
    4223     {
    4224         /*
    4225          * Enter execution mode.
    4226          */
    4227         PATMRawEnter(pVM, pCtxCore);
    4228 
    4229         /*
    4230          * Set CPL to Ring-1.
    4231          */
    4232         pCtxCore->ss.Sel |= 1;
    4233         if (    pCtxCore->cs.Sel
    4234             &&  (pCtxCore->cs.Sel & X86_SEL_RPL) == 0)
    4235             pCtxCore->cs.Sel |= 1;
    4236     }
    4237     else
    4238     {
    4239 #ifdef VBOX_WITH_RAW_RING1
    4240         if (    EMIsRawRing1Enabled(pVM)
    4241             &&  !pCtxCore->eflags.Bits.u1VM
    4242             &&  (pCtxCore->ss.Sel & X86_SEL_RPL) == 1)
    4243         {
    4244             /* Set CPL to Ring-2. */
    4245             pCtxCore->ss.Sel = (pCtxCore->ss.Sel & ~X86_SEL_RPL) | 2;
    4246             if (pCtxCore->cs.Sel && (pCtxCore->cs.Sel & X86_SEL_RPL) == 1)
    4247                 pCtxCore->cs.Sel = (pCtxCore->cs.Sel & ~X86_SEL_RPL) | 2;
    4248         }
    4249 #else
    4250         AssertMsg((pCtxCore->ss.Sel & X86_SEL_RPL) >= 2 || pCtxCore->eflags.Bits.u1VM,
    4251                   ("ring-1 code not supported\n"));
    4252 #endif
    4253         /*
    4254          * PATM takes care of IOPL and IF flags for Ring-3 and Ring-2 code as well.
    4255          */
    4256         PATMRawEnter(pVM, pCtxCore);
    4257     }
    4258 
    4259     /*
    4260      * Assert sanity.
    4261      */
    4262     AssertMsg((pCtxCore->eflags.u32 & X86_EFL_IF), ("X86_EFL_IF is clear\n"));
    4263     AssertReleaseMsg(pCtxCore->eflags.Bits.u2IOPL == 0,
    4264                      ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss.Sel & X86_SEL_RPL));
    4265     Assert((pVCpu->cpum.s.Guest.cr0 & (X86_CR0_PG | X86_CR0_WP | X86_CR0_PE)) == (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP));
    4266 
    4267     pCtxCore->eflags.u32        |= X86_EFL_IF; /* paranoia */
    4268 
    4269     pVCpu->cpum.s.fRawEntered = true;
    4270     return VINF_SUCCESS;
    4271 }
    4272 
    4273 
    4274 /**
    4275  * Transforms the guest CPU state from raw-ring mode to correct values.
    4276  *
    4277  * This function will change any selector registers with DPL=1 to DPL=0.
    4278  *
    4279  * @returns Adjusted rc.
    4280  * @param   pVCpu       Pointer to the VMCPU.
    4281  * @param   rc          Raw mode return code
    4282  * @param   pCtxCore    The context core (for trap usage).
    4283  * @see     @ref pg_raw
    4284  */
    4285 VMMR3DECL(int) CPUMR3RawLeave(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, int rc)
    4286 {
    4287     PVM pVM = pVCpu->CTX_SUFF(pVM);
    4288 
    4289     /*
    4290      * Don't leave if we've already left (in GC).
    4291      */
    4292     Assert(pVCpu->cpum.s.fRawEntered);
    4293     Assert(!pVCpu->cpum.s.fRemEntered);
    4294     if (!pVCpu->cpum.s.fRawEntered)
    4295         return rc;
    4296     pVCpu->cpum.s.fRawEntered = false;
    4297 
    4298     PCPUMCTX pCtx = &pVCpu->cpum.s.Guest;
    4299     if (!pCtxCore)
    4300         pCtxCore = CPUMCTX2CORE(pCtx);
    4301     Assert(pCtxCore->eflags.Bits.u1VM || (pCtxCore->ss.Sel & X86_SEL_RPL));
    4302     AssertMsg(pCtxCore->eflags.Bits.u1VM || pCtxCore->eflags.Bits.u2IOPL < (unsigned)(pCtxCore->ss.Sel & X86_SEL_RPL),
    4303               ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss.Sel & X86_SEL_RPL));
    4304 
    4305     /*
    4306      * Are we executing in raw ring-1?
    4307      */
    4308     if (    (pCtxCore->ss.Sel & X86_SEL_RPL) == 1
    4309         &&  !pCtxCore->eflags.Bits.u1VM)
    4310     {
    4311         /*
    4312          * Leave execution mode.
    4313          */
    4314         PATMRawLeave(pVM, pCtxCore, rc);
    4315         /* Not quite sure if this is really required, but shouldn't harm (too much anyways). */
    4316         /** @todo See what happens if we remove this. */
    4317         if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 1)
    4318             pCtxCore->ds.Sel &= ~X86_SEL_RPL;
    4319         if ((pCtxCore->es.Sel & X86_SEL_RPL) == 1)
    4320             pCtxCore->es.Sel &= ~X86_SEL_RPL;
    4321         if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 1)
    4322             pCtxCore->fs.Sel &= ~X86_SEL_RPL;
    4323         if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 1)
    4324             pCtxCore->gs.Sel &= ~X86_SEL_RPL;
    4325 
    4326         /*
    4327          * Ring-1 selector => Ring-0.
    4328          */
    4329         pCtxCore->ss.Sel &= ~X86_SEL_RPL;
    4330         if ((pCtxCore->cs.Sel & X86_SEL_RPL) == 1)
    4331             pCtxCore->cs.Sel &= ~X86_SEL_RPL;
    4332     }
    4333     else
    4334     {
    4335         /*
    4336          * PATM is taking care of the IOPL and IF flags for us.
    4337          */
    4338         PATMRawLeave(pVM, pCtxCore, rc);
    4339         if (!pCtxCore->eflags.Bits.u1VM)
    4340         {
    4341 # ifdef VBOX_WITH_RAW_RING1
    4342             if (    EMIsRawRing1Enabled(pVM)
    4343                 &&  (pCtxCore->ss.Sel & X86_SEL_RPL) == 2)
    4344             {
    4345                 /* Not quite sure if this is really required, but shouldn't harm (too much anyways). */
    4346                 /** @todo See what happens if we remove this. */
    4347                 if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 2)
    4348                     pCtxCore->ds.Sel = (pCtxCore->ds.Sel & ~X86_SEL_RPL) | 1;
    4349                 if ((pCtxCore->es.Sel & X86_SEL_RPL) == 2)
    4350                     pCtxCore->es.Sel = (pCtxCore->es.Sel & ~X86_SEL_RPL) | 1;
    4351                 if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 2)
    4352                     pCtxCore->fs.Sel = (pCtxCore->fs.Sel & ~X86_SEL_RPL) | 1;
    4353                 if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 2)
    4354                     pCtxCore->gs.Sel = (pCtxCore->gs.Sel & ~X86_SEL_RPL) | 1;
    4355 
    4356                 /*
    4357                  * Ring-2 selector => Ring-1.
    4358                  */
    4359                 pCtxCore->ss.Sel = (pCtxCore->ss.Sel & ~X86_SEL_RPL) | 1;
    4360                 if ((pCtxCore->cs.Sel & X86_SEL_RPL) == 2)
    4361                     pCtxCore->cs.Sel = (pCtxCore->cs.Sel & ~X86_SEL_RPL) | 1;
    4362             }
    4363             else
    4364             {
    4365 # endif
    4366                 /** @todo See what happens if we remove this. */
    4367                 if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 1)
    4368                     pCtxCore->ds.Sel &= ~X86_SEL_RPL;
    4369                 if ((pCtxCore->es.Sel & X86_SEL_RPL) == 1)
    4370                     pCtxCore->es.Sel &= ~X86_SEL_RPL;
    4371                 if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 1)
    4372                     pCtxCore->fs.Sel &= ~X86_SEL_RPL;
    4373                 if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 1)
    4374                     pCtxCore->gs.Sel &= ~X86_SEL_RPL;
    4375 # ifdef VBOX_WITH_RAW_RING1
    4376             }
    4377 # endif
    4378         }
    4379     }
    4380 
    4381     return rc;
    4382 }
    4383 
    4384 #endif /* VBOX_WITH_RAW_MODE */
    4385 
    43864196
    43874197/**
  • trunk/src/VBox/VMM/VMMR3/DBGFAddrSpace.cpp

    r46161 r46165  
    12721272}
    12731273
     1274
     1275VMMR3DECL(int)          DBGFR3AsLineByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
     1276                                           PRTGCINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod)
     1277{
     1278    /*
     1279     * Implement the special address space aliases the lazy way.
     1280     */
     1281    if (hDbgAs == DBGF_AS_RC_AND_GC_GLOBAL)
     1282    {
     1283        int rc = DBGFR3AsLineByAddr(pUVM, DBGF_AS_RC, pAddress, poffDisp, pLine, phMod);
     1284        if (RT_FAILURE(rc))
     1285            rc = DBGFR3AsLineByAddr(pUVM, DBGF_AS_GLOBAL, pAddress, poffDisp, pLine, phMod);
     1286        return rc;
     1287    }
     1288
     1289    /*
     1290     * Input validation.
     1291     */
     1292    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     1293    AssertReturn(DBGFR3AddrIsValid(pUVM, pAddress), VERR_INVALID_PARAMETER);
     1294    AssertPtrNullReturn(poffDisp, VERR_INVALID_POINTER);
     1295    AssertPtrReturn(pLine, VERR_INVALID_POINTER);
     1296    AssertPtrNullReturn(phMod, VERR_INVALID_POINTER);
     1297    if (poffDisp)
     1298        *poffDisp = 0;
     1299    if (phMod)
     1300        *phMod = NIL_RTDBGMOD;
     1301    RTDBGAS hRealAS = DBGFR3AsResolveAndRetain(pUVM, hDbgAs);
     1302    if (hRealAS == NIL_RTDBGAS)
     1303        return VERR_INVALID_HANDLE;
     1304
     1305    /*
     1306     * Do the lookup.
     1307     */
     1308    return RTDbgAsLineByAddr(hRealAS, pAddress->FlatPtr, poffDisp, pLine, phMod);
     1309}
     1310
     1311
     1312VMMR3DECL(PRTDBGLINE)   DBGFR3AsLineByAddrA(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
     1313                                            PRTGCINTPTR poffDisp, PRTDBGMOD phMod)
     1314{
     1315    RTDBGLINE Line;
     1316    int rc = DBGFR3AsLineByAddr(pUVM, hDbgAs, pAddress, poffDisp, &Line, phMod);
     1317    if (RT_SUCCESS(rc))
     1318        return RTDbgLineDup(&Line);
     1319    return NULL;
     1320}
     1321
  • trunk/src/VBox/VMM/VMMR3/DBGFStack.cpp

    r46155 r46165  
    158158        {
    159159            pFrame->pSymPC  = DBGFR3AsSymbolByAddrA(pUVM, hAs, &pFrame->AddrPC, RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL,
    160                                                     NULL /*offDisp*/, NULL /*phMod*/);
    161             pFrame->pLinePC = DBGFR3LineByAddrAlloc(pUVM, pFrame->AddrPC.FlatPtr, NULL);
     160                                                    NULL /*poffDisp*/, NULL /*phMod*/);
     161            pFrame->pLinePC = DBGFR3AsLineByAddrA(pUVM, hAs, &pFrame->AddrPC, NULL /*poffDisp*/, NULL /*phMod*/);
    162162        }
    163163    }
     
    255255
    256256    pFrame->pSymReturnPC  = DBGFR3AsSymbolByAddrA(pUVM, hAs, &pFrame->AddrReturnPC, RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL,
    257                                                   NULL /*offDisp*/, NULL /*phMod*/);
    258     pFrame->pLineReturnPC = DBGFR3LineByAddrAlloc(pUVM, pFrame->AddrReturnPC.FlatPtr, NULL);
     257                                                  NULL /*poffDisp*/, NULL /*phMod*/);
     258    pFrame->pLineReturnPC = DBGFR3AsLineByAddrA(pUVM, hAs, &pFrame->AddrPC, NULL /*poffDisp*/, NULL /*phMod*/);
    259259
    260260    /*
     
    584584        RTDbgSymbolFree(pCur->pSymPC);
    585585        RTDbgSymbolFree(pCur->pSymReturnPC);
    586         DBGFR3LineFree(pCur->pLinePC);
    587         DBGFR3LineFree(pCur->pLineReturnPC);
     586        RTDbgLineFree(pCur->pLinePC);
     587        RTDbgLineFree(pCur->pLineReturnPC);
    588588
    589589        pCur->pNextInternal = NULL;
  • trunk/src/VBox/VMM/VMMR3/DBGFSym.cpp

    r45753 r46165  
    22/** @file
    33 * DBGF - Debugger Facility, Symbol Management.
     4 *
     5 * This is obsolete code that's only sticking around till we've moved the linux map
     6 * file reader into IPRT.
    47 */
    58
     
    2023*   Header Files                                                               *
    2124*******************************************************************************/
    22 #define LOG_GROUP LOG_GROUP_DBGF
    23 #if defined(RT_OS_WINDOWS) && 0 //defined(DEBUG_bird) // enabled this is you want to debug win32 guests, the hypervisor of EFI.
    24 # include <Windows.h>
    25 # define _IMAGEHLP64
    26 # include <DbgHelp.h>
    27 # define HAVE_DBGHELP /* if doing guest stuff, this can be nice. */
    28 #endif
    29 /** @todo Only use DBGHELP for reading modules since it doesn't do all we want (relocations), or is way to slow in some cases (add symbol)! */
    3025#include <VBox/vmm/dbgf.h>
    3126#include <VBox/vmm/mm.h>
     
    4338#include <iprt/env.h>
    4439#include <iprt/param.h>
    45 #ifndef HAVE_DBGHELP
    46 # include <iprt/avl.h>
    47 # include <iprt/string.h>
    48 #endif
     40#include <iprt/avl.h>
     41#include <iprt/string.h>
    4942
    5043#include <stdio.h> /* for fopen(). */ /** @todo use iprt/stream.h! */
    5144#include <stdlib.h>
    52 
    53 
    54 /*******************************************************************************
    55 *   Internal Functions                                                         *
    56 *******************************************************************************/
    57 #ifdef HAVE_DBGHELP
    58 static DECLCALLBACK(int) dbgfR3EnumModules(PVM pVM, const char *pszFilename, const char *pszName,
    59                                            RTUINTPTR ImageBase, size_t cbImage, bool fRC, void *pvArg);
    60 static int win32Error(PVM pVM);
    61 #endif
    6245
    6346
     
    6548*   Structures and Typedefs                                                    *
    6649*******************************************************************************/
    67 #ifndef HAVE_DBGHELP
    6850/* later */
    6951typedef struct DBGFMOD *PDBGFMOD;
     
    9678} DBGFSYMSPACE, *PDBGFSYMSPACE;
    9779
    98 #endif
    9980
    10081
     
    10384*   Internal Functions                                                         *
    10485*******************************************************************************/
    105 #ifndef HAVE_DBGHELP
    106 
    10786/**
    10887 * Initializes the symbol tree.
     
    220199}
    221200
    222 #endif
    223 
    224201
    225202/**
     
    256233    AssertReturn(pVM->dbgf.s.pSymbolSpace, VERR_NO_MEMORY);
    257234
    258 #ifndef HAVE_DBGHELP
    259235    /* modules & lines later */
    260236    rc = dbgfR3SymbolInit(pVM);
     
    262238        return rc;
    263239    pVM->dbgf.s.fSymInited = true;
    264 #endif
    265240
    266241    /** @todo symbol search path setup. */
     
    404379    if (pVM->dbgf.s.fSymInited)
    405380        return VINF_SUCCESS;
    406 #ifdef HAVE_DBGHELP
    407     if (SymInitialize(pVM, NULL, FALSE))
    408     {
    409         pVM->dbgf.s.fSymInited = true;
    410         SymSetOptions(SYMOPT_LOAD_LINES | SYMOPT_AUTO_PUBLICS | SYMOPT_ALLOW_ABSOLUTE_SYMBOLS);
    411 
    412         /*
    413          * Enumerate all modules loaded by PDM and add them to the symbol database.
    414          */
    415         PDMR3LdrEnumModules(pVM, dbgfR3EnumModules, NULL);
    416         return VINF_SUCCESS;
    417     }
    418     return win32Error(pVM);
    419 #else
    420381    return VINF_SUCCESS;
    421 #endif
    422 }
    423 
    424 
    425 #ifdef HAVE_DBGHELP
    426 /**
    427  * Module enumeration callback function.
    428  *
    429  * @returns VBox status.
    430  *          Failure will stop the search and return the return code.
    431  *          Warnings will be ignored and not returned.
    432  * @param   pVM             Pointer to the VM.
    433  * @param   pszFilename     Module filename.
    434  * @param   pszName         Module name. (short and unique)
    435  * @param   ImageBase       Address where to executable image is loaded.
    436  * @param   cbImage         Size of the executable image.
    437  * @param   fRC             Set if guest context, clear if host context.
    438  * @param   pvArg           User argument.
    439  */
    440 static DECLCALLBACK(int) dbgfR3EnumModules(PVM pVM, const char *pszFilename, const char *pszName,
    441                                            RTUINTPTR ImageBase, size_t cbImage, bool fRC, void *pvArg)
    442 {
    443     DWORD64 LoadedImageBase = SymLoadModule64(pVM, NULL, (char *)(void *)pszFilename,
    444                                                 (char *)(void *)pszName, ImageBase, (DWORD)cbImage);
    445     if (!LoadedImageBase)
    446         Log(("SymLoadModule64(,,%s,,) -> lasterr=%d\n", pszFilename, GetLastError()));
    447     else
    448         Log(("Loaded debuginfo for %s - %s %llx\n", pszName, pszFilename, LoadedImageBase));
    449 
    450     return VINF_SUCCESS;
    451 }
    452 #endif
     382}
    453383
    454384
     
    461391int dbgfR3SymTerm(PVM pVM)
    462392{
    463 #ifdef HAVE_DBGHELP
    464     if (pVM->dbgf.s.fSymInited)
    465         SymCleanup(pVM);
    466     pVM->dbgf.s.fSymInited = false;
    467     return VINF_SUCCESS;
    468 #else
    469393    pVM->dbgf.s.SymbolTree = 0; /* MM cleans up allocations */
    470394    pVM->dbgf.s.fSymInited = false;
    471395    return VINF_SUCCESS;
    472 #endif
    473396}
    474397
     
    739662            if (pszName)
    740663            {
    741                 #ifdef HAVE_DBGHELP
    742                 /** @todo arg! checkout the inserting of modules and then loading them again.... Or just the module representation.... */
    743                 DWORD64 ImageBase = SymLoadModule64(pVM, NULL, (char *)(void *)szFoundFile, (char *)(void *)pszName, ModuleAddress, cbImage);
    744                 if (!ImageBase)
    745                     ImageBase = SymLoadModule64(pVM, NULL, (char *)(void *)pszName, (char *)(void *)pszName, ModuleAddress, cbImage);
    746                 if (ImageBase)
    747                 {
    748                     AssertMsg(ModuleAddress == 0 || ModuleAddress == ImageBase, ("ModuleAddres=%RGv ImageBase=%llx\n", ModuleAddress, ImageBase));
    749                     ModuleAddress = ImageBase;
    750                 }
    751                 else
    752                     rc = win32Error(pVM);
    753                 #else
    754664                rc = VERR_NOT_IMPLEMENTED;
    755                 #endif
    756665            }
    757666            if (RT_SUCCESS(rc))
     
    775684                    case SYMFILETYPE_DBG:
    776685                    case SYMFILETYPE_MZ:
    777                 #ifdef HAVE_DBGHELP
    778                         /* done it all above! */
    779                         break;
    780                 #endif
    781686                    case SYMFILETYPE_LD_MAP:
    782687                    case SYMFILETYPE_MS_MAP:
     
    803708
    804709/**
    805  * Interface used by PDMR3LdrRelocate for telling us that a GC module has been relocated.
    806  *
    807  * @param   pVM             Pointer to the VM.
    808  * @param   OldImageBase    The old image base.
    809  * @param   NewImageBase    The new image base.
    810  * @param   cbImage         The image size.
    811  * @param   pszFilename     The image filename.
    812  * @param   pszName         The module name.
    813  */
    814 VMMR3_INT_DECL(void) DBGFR3ModuleRelocate(PVM pVM, RTGCUINTPTR OldImageBase, RTGCUINTPTR NewImageBase, RTGCUINTPTR cbImage,
    815                                           const char *pszFilename, const char *pszName)
    816 {
    817 #ifdef HAVE_DBGHELP
    818     if (pVM->dbgf.s.fSymInited)
    819     {
    820         if (!SymUnloadModule64(pVM, OldImageBase))
    821             Log(("SymUnloadModule64(,%RGv) failed, lasterr=%d\n", OldImageBase, GetLastError()));
    822 
    823         DWORD ImageSize = (DWORD)cbImage; Assert(ImageSize == cbImage);
    824         DWORD64 LoadedImageBase = SymLoadModule64(pVM, NULL, (char *)(void *)pszFilename, (char *)(void *)pszName, NewImageBase, ImageSize);
    825         if (!LoadedImageBase)
    826             Log(("SymLoadModule64(,,%s,,) -> lasterr=%d (relocate)\n", pszFilename, GetLastError()));
    827         else
    828             Log(("Reloaded debuginfo for %s - %s %llx\n", pszName, pszFilename, LoadedImageBase));
    829     }
    830 #else
    831     NOREF(pVM); NOREF(OldImageBase); NOREF(NewImageBase); NOREF(cbImage); NOREF(pszFilename); NOREF(pszName);
    832 #endif
    833 }
    834 
    835 
    836 /**
    837710 * Adds a symbol to the debug info manager.
    838711 *
     
    866739    }
    867740
    868 #ifdef HAVE_DBGHELP
    869     if (SymAddSymbol(pVM, ModuleAddress, (char *)(void *)pszSymbol, SymbolAddress, cbSymbol, 0))
    870         return VINF_SUCCESS;
    871     return win32Error(pVM);
    872 #else
    873741    NOREF(ModuleAddress); /** @todo module lookup. */
    874742    return dbgfR3SymbolInsert(pVM, pszSymbol, SymbolAddress, cbSymbol, NULL);
    875 #endif
    876743}
    877744
     
    901768     * Look it up.
    902769     */
    903 #ifdef HAVE_DBGHELP
    904     char                achBuffer[sizeof(IMAGEHLP_SYMBOL64) + DBGF_SYMBOL_NAME_LENGTH * sizeof(TCHAR) + sizeof(ULONG64)];
    905     PIMAGEHLP_SYMBOL64  pSym = (PIMAGEHLP_SYMBOL64)&achBuffer[0];
    906     pSym->SizeOfStruct      = sizeof(IMAGEHLP_SYMBOL64);
    907     pSym->MaxNameLength     = DBGF_SYMBOL_NAME_LENGTH;
    908 
    909     if (SymGetSymFromAddr64(pVM, Address, (PDWORD64)poffDisplacement, pSym))
    910     {
    911         pSymbol->Value  = (RTGCUINTPTR)pSym->Address;
    912         pSymbol->cb     = pSym->Size;
    913         pSymbol->fFlags = pSym->Flags;
    914         strcpy(pSymbol->szName, pSym->Name);
    915         return VINF_SUCCESS;
    916     }
    917     //return win32Error(pVM);
    918 
    919 #else
    920 
    921770    PDBGFSYM pSym = dbgfR3SymbolGetAddr(pVM, Address);
    922771    if (pSym)
     
    931780        return VINF_SUCCESS;
    932781    }
    933 
    934 #endif
    935782
    936783    /*
     
    990837     * Look it up.
    991838     */
    992 #ifdef HAVE_DBGHELP
    993     char            achBuffer[sizeof(IMAGEHLP_SYMBOL64) + DBGF_SYMBOL_NAME_LENGTH * sizeof(TCHAR) + sizeof(ULONG64)];
    994     PIMAGEHLP_SYMBOL64 pSym = (PIMAGEHLP_SYMBOL64)&achBuffer[0];
    995     pSym->SizeOfStruct      = sizeof(IMAGEHLP_SYMBOL64);
    996     pSym->MaxNameLength     = DBGF_SYMBOL_NAME_LENGTH;
    997 
    998     if (SymGetSymFromName64(pVM, (char *)(void *)pszSymbol, pSym))
    999     {
    1000         pSymbol->Value  = (RTGCUINTPTR)pSym->Address;
    1001         pSymbol->cb     = pSym->Size;
    1002         pSymbol->fFlags = pSym->Flags;
    1003         strcpy(pSymbol->szName, pSym->Name);
    1004         return VINF_SUCCESS;
    1005     }
    1006     return win32Error(pVM);
    1007 #else
    1008 
    1009839    PDBGFSYM pSym = dbgfR3SymbolGetName(pVM, pszSymbol);
    1010840    if (pSym)
     
    1019849
    1020850    return VERR_SYMBOL_NOT_FOUND;
    1021 #endif
    1022 }
    1023 
    1024 
    1025 /**
    1026  * Find line by address (nearest).
    1027  *
    1028  * @returns VBox status.
    1029  * @param   pUVM                The user mode VM handle.
    1030  * @param   Address             Address.
    1031  * @param   poffDisplacement    Where to store the line displacement from Address.
    1032  * @param   pLine               Where to store the line info.
    1033  */
    1034 VMMR3DECL(int) DBGFR3LineByAddr(PUVM pUVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFLINE pLine)
    1035 {
    1036     /*
    1037      * Lazy init.
    1038      */
    1039     UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
    1040     PVM pVM = pUVM->pVM;
    1041     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    1042     if (!pVM->dbgf.s.fSymInited)
    1043     {
    1044         int rc = dbgfR3SymLazyInit(pVM);
    1045         if (RT_FAILURE(rc))
    1046             return rc;
    1047     }
    1048 
    1049     /*
    1050      * Look it up.
    1051      */
    1052 #ifdef HAVE_DBGHELP
    1053     IMAGEHLP_LINE64     Line = {0};
    1054     DWORD               off = 0;
    1055     Line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
    1056     if (SymGetLineFromAddr64(pVM, Address, &off, &Line))
    1057     {
    1058         if (poffDisplacement)
    1059             *poffDisplacement = (long)off;
    1060         pLine->Address      = (RTGCUINTPTR)Line.Address;
    1061         pLine->uLineNo      = Line.LineNumber;
    1062         pLine->szFilename[0] = '\0';
    1063         strncat(pLine->szFilename, Line.FileName, sizeof(pLine->szFilename));
    1064         return VINF_SUCCESS;
    1065     }
    1066     return win32Error(pVM);
    1067 #else
    1068     NOREF(pVM); NOREF(Address); NOREF(poffDisplacement); NOREF(pLine);
    1069     return VERR_NOT_IMPLEMENTED;
    1070 #endif
    1071 }
    1072 
    1073 
    1074 /**
    1075  * Duplicates a line.
    1076  *
    1077  * @returns VBox status code.
    1078  * @param   pUVM            The user mode VM handle.
    1079  * @param   pLine           The line to duplicate.
    1080  */
    1081 static PDBGFLINE dbgfR3LineDup(PUVM pUVM, PCDBGFLINE pLine)
    1082 {
    1083     size_t cb = strlen(pLine->szFilename) + RT_OFFSETOF(DBGFLINE, szFilename[1]);
    1084     PDBGFLINE pDup = (PDBGFLINE)MMR3HeapAllocU(pUVM, MM_TAG_DBGF_LINE_DUP, cb);
    1085     if (pDup)
    1086         memcpy(pDup, pLine, cb);
    1087     return pDup;
    1088 }
    1089 
    1090 
    1091 /**
    1092  * Find line by address (nearest), allocate return buffer.
    1093  *
    1094  * @returns Pointer to the line. Must be freed using DBGFR3LineFree().
    1095  * @returns NULL if the line was not found or if we're out of memory.
    1096  * @param   pUVM                The user mode VM handle.
    1097  * @param   Address             Address.
    1098  * @param   poffDisplacement    Where to store the line displacement from Address.
    1099  */
    1100 VMMR3DECL(PDBGFLINE) DBGFR3LineByAddrAlloc(PUVM pUVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement)
    1101 {
    1102     DBGFLINE Line;
    1103     int rc = DBGFR3LineByAddr(pUVM, Address, poffDisplacement, &Line);
    1104     if (RT_FAILURE(rc))
    1105         return NULL;
    1106     return dbgfR3LineDup(pUVM, &Line);
    1107 }
    1108 
    1109 
    1110 /**
    1111  * Frees a line returned by DBGFR3LineByAddressAlloc().
    1112  *
    1113  * @param   pLine           Pointer to the line.
    1114  */
    1115 VMMR3_INT_DECL(void) DBGFR3LineFree(PDBGFLINE pLine)
    1116 {
    1117     if (pLine)
    1118         MMR3HeapFree(pLine);
    1119 }
    1120 
    1121 
    1122 #ifdef HAVE_DBGHELP
    1123 
    1124 //static BOOL CALLBACK win32EnumModulesCallback(PSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext)
    1125 //{
    1126 //    Log(("dbg: module: %08llx %s\n", ModuleName, BaseOfDll));
    1127 //    return TRUE;
    1128 //}
    1129 
    1130 static int win32Error(PVM pVM)
    1131 {
    1132     int rc = GetLastError();
    1133     Log(("Lasterror=%d\n", rc));
    1134 
    1135     //SymEnumerateModules64(pVM, win32EnumModulesCallback, NULL);
    1136 
    1137     return VERR_GENERAL_FAILURE;
    1138 }
    1139 #endif
    1140 
     851}
     852
  • trunk/src/VBox/VMM/VMMR3/EMRaw.cpp

    r45531 r46165  
    127127     * Resume execution.
    128128     */
    129     CPUMR3RawEnter(pVCpu, NULL);
     129    CPUMRawEnter(pVCpu, NULL);
    130130    CPUMSetHyperEFlags(pVCpu, CPUMGetHyperEFlags(pVCpu) | X86_EFL_RF);
    131131    rc = VMMR3ResumeHyper(pVM, pVCpu);
    132132    Log(("emR3RawResumeHyper: cs:eip=%RTsel:%RGr efl=%RGr - returned from GC with rc=%Rrc\n", pCtx->cs.Sel, pCtx->eip, pCtx->eflags, rc));
    133     rc = CPUMR3RawLeave(pVCpu, NULL, rc);
     133    rc = CPUMRawLeave(pVCpu, NULL, rc);
    134134    VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK);
    135135
     
    189189     * We do not start time or anything, if anything we should just do a few nanoseconds.
    190190     */
    191     CPUMR3RawEnter(pVCpu, NULL);
     191    CPUMRawEnter(pVCpu, NULL);
    192192    do
    193193    {
     
    202202    } while (   rc == VINF_SUCCESS
    203203             || rc == VINF_EM_RAW_INTERRUPT);
    204     rc = CPUMR3RawLeave(pVCpu, NULL, rc);
     204    rc = CPUMRawLeave(pVCpu, NULL, rc);
    205205    VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK);
    206206
     
    13931393         * and perhaps EIP) needs to be stored with PATM.
    13941394         */
    1395         rc = CPUMR3RawEnter(pVCpu, NULL);
     1395        rc = CPUMRawEnter(pVCpu, NULL);
    13961396        if (rc != VINF_SUCCESS)
    13971397        {
     
    14171417                if (rc != VINF_SUCCESS)
    14181418                {
    1419                     rc = CPUMR3RawLeave(pVCpu, NULL, rc);
     1419                    rc = CPUMRawLeave(pVCpu, NULL, rc);
    14201420                    break;
    14211421                }
     
    14771477         * execution FFs before doing anything else.
    14781478         */
    1479         rc = CPUMR3RawLeave(pVCpu, NULL, rc);
     1479        rc = CPUMRawLeave(pVCpu, NULL, rc);
    14801480        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK);
    14811481        if (    VM_FF_ISPENDING(pVM, VM_FF_HIGH_PRIORITY_POST_MASK)
  • trunk/src/VBox/VMM/VMMR3/PDMLdr.cpp

    r45830 r46165  
    216216                                       pdmR3GetImportRC, &Args);
    217217                AssertFatalMsgRC(rc, ("RTLdrRelocate failed, rc=%d\n", rc));
    218                 DBGFR3ModuleRelocate(pUVM->pVM, pCur->OldImageBase, pCur->ImageBase, RTLdrSize(pCur->hLdrMod),
    219                                      pCur->szFilename, pCur->szName);
    220218            }
    221219        }
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