Changeset 46165 in vbox for trunk/src/VBox
- Timestamp:
- May 19, 2013 7:07:50 PM (12 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp
r46159 r46165 1183 1183 */ 1184 1184 bool fFirst = 1; 1185 DBGFLINE LinePrev = {0, 0, "" };1185 RTDBGLINE LinePrev = { 0, 0, 0, 0, 0, "" }; 1186 1186 int iRangeLeft = (int)pDbgc->SourcePos.u64Range; 1187 1187 if (iRangeLeft == 0) /* kludge for 'r'. */ … … 1192 1192 * Get line info. 1193 1193 */ 1194 DBGFLINELine;1194 RTDBGLINE Line; 1195 1195 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); 1197 1201 if (RT_FAILURE(rc)) 1198 1202 return VINF_SUCCESS; -
trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp
r46156 r46165 114 114 return true; 115 115 } 116 VMMR3DECL(int) DBGFR3LineByAddr(PUVM pUVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFLINE pLine)117 {118 return VERR_INTERNAL_ERROR;119 }120 116 VMMR3DECL(int) DBGFR3LogModifyDestinations(PUVM pUVM, const char *pszDestSettings) 121 117 { … … 149 145 { 150 146 return NIL_RTDBGAS; 147 } 148 VMMR3DECL(int) DBGFR3AsLineByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, 149 PRTGCINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod) 150 { 151 return VERR_DBG_LINE_NOT_FOUND; 151 152 } 152 153 VMMR3DECL(int) DBGFR3Resume(PUVM pUVM) -
trunk/src/VBox/Runtime/common/dbg/dbgas.cpp
r46134 r46165 1696 1696 1697 1697 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) 1698 RTDECL(int) RTDbgAsLineByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod) 1712 1699 { 1713 1700 /* … … 1729 1716 int rc = RTDbgModLineByAddr(hMod, iSeg, offSeg, poffDisp, pLine); 1730 1717 if (RT_SUCCESS(rc)) 1718 { 1731 1719 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); 1733 1727 return rc; 1734 1728 } … … 1736 1730 1737 1731 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) 1732 RTDECL(int) RTDbgAsLineByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE *ppLine, PRTDBGMOD phMod) 1753 1733 { 1754 1734 /* … … 1770 1750 int rc = RTDbgModLineByAddrA(hMod, iSeg, offSeg, poffDisp, ppLine); 1771 1751 if (RT_SUCCESS(rc)) 1752 { 1772 1753 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); 1774 1761 return rc; 1775 1762 } -
trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp
r46164 r46165 486 486 return VINF_SUCCESS; 487 487 } 488 pDbgMod->pDbgVt = NULL; 488 489 pDbgMod->pDbgVt = NULL; 489 490 Assert(pDbgMod->pvDbgPriv == NULL); 490 491 } … … 530 531 return VINF_CALLBACK_RETURN; 531 532 } 532 pDbgMod->pDbgVt = NULL; 533 534 pDbgMod->pDbgVt = NULL; 533 535 Assert(pDbgMod->pvDbgPriv == NULL); 534 536 } 537 RTSemRWReleaseRead(g_hDbgModRWSem); 535 538 } 536 539 537 540 /* No joy. */ 538 RTSemRWReleaseRead(g_hDbgModRWSem);539 541 RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszDbgFile); 540 542 pDbgMod->pszDbgFile = NULL; … … 843 845 if (RT_SUCCESS(rc)) 844 846 { 847 /* 848 * We're done! 849 */ 850 ASMAtomicIncU32(&pImg->cUsers); 851 RTSemRWReleaseRead(g_hDbgModRWSem); 852 845 853 *phDbgMod = pDbgMod; 846 854 return VINF_SUCCESS; -
trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp
r46164 r46165 3696 3696 pSubProgram->PcRange.uHighAddress - pSubProgram->PcRange.uLowAddress, 3697 3697 0 /*fFlags*/, NULL /*piOrdinal*/); 3698 Assert RC(rc);3698 AssertMsg(RT_SUCCESS(rc) || rc == VERR_DBG_DUPLICATE_SYMBOL, ("%Rrc\n", rc)); 3699 3699 } 3700 3700 else -
trunk/src/VBox/Runtime/common/ldr/ldrkStuff.cpp
r46164 r46165 812 812 813 813 814 /** @copydoc RTLDROPS::pfnReadDbgInfo. */ 815 static 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 814 823 /** 815 824 * Operations for a kLdr module. … … 833 842 rtkldr_SegOffsetToRva, 834 843 rtkldr_RvaToSegOffset, 835 NULL,844 rtkldr_ReadDbgInfo, 836 845 42 837 846 }; -
trunk/src/VBox/Runtime/tools/RTLdrFlt.cpp
r46161 r46165 388 388 RTDBGLINE Line; 389 389 RTINTPTR offLine; 390 rc = RTDbgAsLineByAddr(hDbgAs, u64Address, &offLine, &Line );390 rc = RTDbgAsLineByAddr(hDbgAs, u64Address, &offLine, &Line, NULL); 391 391 if (RT_SUCCESS(rc)) 392 392 RTStrmPrintf(pOutput, " %Rbn(%u)", Line.szFilename, Line.uLineNo); -
trunk/src/VBox/VMM/Makefile.kmk
r46137 r46165 683 683 endif 684 684 685 ifneq ($(USERNAME),bird) # Not opts for me atm. 685 686 # 686 687 # Always optimize the interpreter. … … 697 698 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?) 698 699 endif 699 700 endif # No optimizations for me atm. 700 701 701 702 include $(FILE_KBUILD_SUB_FOOTER) -
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r45965 r46165 2458 2458 2459 2459 #ifdef VBOX_WITH_RAW_MODE_NOT_R0 2460 2460 2461 /** 2461 2462 * … … 2468 2469 return pVCpu->cpum.s.fRawEntered; 2469 2470 } 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 */ 2482 VMM_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 */ 2559 VMM_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 */ 2472 2658 2473 2659 /** -
trunk/src/VBox/VMM/VMMAll/IEMAll.cpp
r45701 r46165 8491 8491 AssertReturn(CPUMCTX2CORE(pCtx) == pCtxCore, VERR_IEM_IPE_3); 8492 8492 8493 #ifdef IN_RC 8494 CPUMRawLeave(pVCpu, pCtxCore, VINF_SUCCESS); 8495 #endif 8496 8493 8497 iemInitDecoder(pIemCpu, true); 8494 8498 uint32_t const cbOldWritten = pIemCpu->cbWritten; … … 8501 8505 *pcbWritten = pIemCpu->cbWritten - cbOldWritten; 8502 8506 } 8507 8508 #ifdef IN_RC 8509 CPUMRawEnter(pVCpu, pCtxCore); 8510 #endif 8503 8511 return rcStrict; 8504 8512 } … … 8511 8519 PCPUMCTX pCtx = pVCpu->iem.s.CTX_SUFF(pCtx); 8512 8520 AssertReturn(CPUMCTX2CORE(pCtx) == pCtxCore, VERR_IEM_IPE_3); 8521 8522 #ifdef IN_RC 8523 CPUMRawLeave(pVCpu, pCtxCore, VINF_SUCCESS); 8524 #endif 8513 8525 8514 8526 VBOXSTRICTRC rcStrict; … … 8525 8537 if (rcStrict == VINF_SUCCESS) 8526 8538 rcStrict = iemExecOneInner(pVCpu, pIemCpu, false); 8539 8540 #ifdef IN_RC 8541 CPUMRawEnter(pVCpu, pCtxCore); 8542 #endif 8527 8543 return rcStrict; 8528 8544 } -
trunk/src/VBox/VMM/VMMAll/PATMAll.cpp
r45628 r46165 50 50 VMM_INT_DECL(void) PATMRawEnter(PVM pVM, PCPUMCTXCORE pCtxCore) 51 51 { 52 bool fPatchCode = PATMIsPatchGCAddr(pVM, pCtxCore->eip);53 52 Assert(!HMIsEnabled(pVM)); 54 53 … … 57 56 * For all cases where it isn't, IOPL will be safe and IF will be set. 58 57 */ 59 registeruint32_t efl = pCtxCore->eflags.u32;58 uint32_t efl = pCtxCore->eflags.u32; 60 59 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)); 64 68 65 69 efl &= ~PATM_VIRTUAL_FLAGS_MASK; … … 68 72 69 73 #ifdef IN_RING3 70 # ifdef PATM_EMULATE_SYSENTER74 # ifdef PATM_EMULATE_SYSENTER 71 75 PCPUMCTX pCtx; 72 76 … … 103 107 pVM->patm.s.pfnSysEnterGC = 0; 104 108 } 105 # endif109 # endif /* PATM_EMULATE_SYSENTER */ 106 110 #endif 107 111 } … … 124 128 Assert(!HMIsEnabled(pVM)); 125 129 bool fPatchCode = PATMIsPatchGCAddr(pVM, pCtxCore->eip); 130 126 131 /* 127 132 * We will only be called if PATMRawEnter was previously called. 128 133 */ 129 registeruint32_t efl = pCtxCore->eflags.u32;134 uint32_t efl = pCtxCore->eflags.u32; 130 135 efl = (efl & ~PATM_VIRTUAL_FLAGS_MASK) | (CTXSUFF(pVM->patm.s.pGCState)->uVMFlags & PATM_VIRTUAL_FLAGS_MASK); 131 136 pCtxCore->eflags.u32 = efl; … … 136 141 137 142 #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) 144 148 { 145 149 /* … … 182 186 } 183 187 } 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 */ 187 195 188 196 if (!fPatchCode) -
trunk/src/VBox/VMM/VMMR3/CPUM.cpp
r46142 r46165 4194 4194 } 4195 4195 4196 #ifdef VBOX_WITH_RAW_MODE4197 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_raw4207 */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.Sel4221 && (pCtxCore->ss.Sel & X86_SEL_RPL) == 04222 && !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.Sel4234 && (pCtxCore->cs.Sel & X86_SEL_RPL) == 0)4235 pCtxCore->cs.Sel |= 1;4236 }4237 else4238 {4239 #ifdef VBOX_WITH_RAW_RING14240 if ( EMIsRawRing1Enabled(pVM)4241 && !pCtxCore->eflags.Bits.u1VM4242 && (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 #else4250 AssertMsg((pCtxCore->ss.Sel & X86_SEL_RPL) >= 2 || pCtxCore->eflags.Bits.u1VM,4251 ("ring-1 code not supported\n"));4252 #endif4253 /*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 code4282 * @param pCtxCore The context core (for trap usage).4283 * @see @ref pg_raw4284 */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) == 14309 && !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 else4334 {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_RING14342 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 else4364 {4365 # endif4366 /** @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_RING14376 }4377 # endif4378 }4379 }4380 4381 return rc;4382 }4383 4384 #endif /* VBOX_WITH_RAW_MODE */4385 4386 4196 4387 4197 /** -
trunk/src/VBox/VMM/VMMR3/DBGFAddrSpace.cpp
r46161 r46165 1272 1272 } 1273 1273 1274 1275 VMMR3DECL(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 1312 VMMR3DECL(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 158 158 { 159 159 pFrame->pSymPC = DBGFR3AsSymbolByAddrA(pUVM, hAs, &pFrame->AddrPC, RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, 160 NULL /* offDisp*/, NULL /*phMod*/);161 pFrame->pLinePC = DBGFR3 LineByAddrAlloc(pUVM, pFrame->AddrPC.FlatPtr, NULL);160 NULL /*poffDisp*/, NULL /*phMod*/); 161 pFrame->pLinePC = DBGFR3AsLineByAddrA(pUVM, hAs, &pFrame->AddrPC, NULL /*poffDisp*/, NULL /*phMod*/); 162 162 } 163 163 } … … 255 255 256 256 pFrame->pSymReturnPC = DBGFR3AsSymbolByAddrA(pUVM, hAs, &pFrame->AddrReturnPC, RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, 257 NULL /* offDisp*/, NULL /*phMod*/);258 pFrame->pLineReturnPC = DBGFR3 LineByAddrAlloc(pUVM, pFrame->AddrReturnPC.FlatPtr, NULL);257 NULL /*poffDisp*/, NULL /*phMod*/); 258 pFrame->pLineReturnPC = DBGFR3AsLineByAddrA(pUVM, hAs, &pFrame->AddrPC, NULL /*poffDisp*/, NULL /*phMod*/); 259 259 260 260 /* … … 584 584 RTDbgSymbolFree(pCur->pSymPC); 585 585 RTDbgSymbolFree(pCur->pSymReturnPC); 586 DBGFR3LineFree(pCur->pLinePC);587 DBGFR3LineFree(pCur->pLineReturnPC);586 RTDbgLineFree(pCur->pLinePC); 587 RTDbgLineFree(pCur->pLineReturnPC); 588 588 589 589 pCur->pNextInternal = NULL; -
trunk/src/VBox/VMM/VMMR3/DBGFSym.cpp
r45753 r46165 2 2 /** @file 3 3 * 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. 4 7 */ 5 8 … … 20 23 * Header Files * 21 24 *******************************************************************************/ 22 #define LOG_GROUP LOG_GROUP_DBGF23 #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 _IMAGEHLP6426 # include <DbgHelp.h>27 # define HAVE_DBGHELP /* if doing guest stuff, this can be nice. */28 #endif29 /** @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)! */30 25 #include <VBox/vmm/dbgf.h> 31 26 #include <VBox/vmm/mm.h> … … 43 38 #include <iprt/env.h> 44 39 #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> 49 42 50 43 #include <stdio.h> /* for fopen(). */ /** @todo use iprt/stream.h! */ 51 44 #include <stdlib.h> 52 53 54 /*******************************************************************************55 * Internal Functions *56 *******************************************************************************/57 #ifdef HAVE_DBGHELP58 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 #endif62 45 63 46 … … 65 48 * Structures and Typedefs * 66 49 *******************************************************************************/ 67 #ifndef HAVE_DBGHELP68 50 /* later */ 69 51 typedef struct DBGFMOD *PDBGFMOD; … … 96 78 } DBGFSYMSPACE, *PDBGFSYMSPACE; 97 79 98 #endif99 80 100 81 … … 103 84 * Internal Functions * 104 85 *******************************************************************************/ 105 #ifndef HAVE_DBGHELP106 107 86 /** 108 87 * Initializes the symbol tree. … … 220 199 } 221 200 222 #endif223 224 201 225 202 /** … … 256 233 AssertReturn(pVM->dbgf.s.pSymbolSpace, VERR_NO_MEMORY); 257 234 258 #ifndef HAVE_DBGHELP259 235 /* modules & lines later */ 260 236 rc = dbgfR3SymbolInit(pVM); … … 262 238 return rc; 263 239 pVM->dbgf.s.fSymInited = true; 264 #endif265 240 266 241 /** @todo symbol search path setup. */ … … 404 379 if (pVM->dbgf.s.fSymInited) 405 380 return VINF_SUCCESS; 406 #ifdef HAVE_DBGHELP407 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 #else420 381 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 } 453 383 454 384 … … 461 391 int dbgfR3SymTerm(PVM pVM) 462 392 { 463 #ifdef HAVE_DBGHELP464 if (pVM->dbgf.s.fSymInited)465 SymCleanup(pVM);466 pVM->dbgf.s.fSymInited = false;467 return VINF_SUCCESS;468 #else469 393 pVM->dbgf.s.SymbolTree = 0; /* MM cleans up allocations */ 470 394 pVM->dbgf.s.fSymInited = false; 471 395 return VINF_SUCCESS; 472 #endif473 396 } 474 397 … … 739 662 if (pszName) 740 663 { 741 #ifdef HAVE_DBGHELP742 /** @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 else752 rc = win32Error(pVM);753 #else754 664 rc = VERR_NOT_IMPLEMENTED; 755 #endif756 665 } 757 666 if (RT_SUCCESS(rc)) … … 775 684 case SYMFILETYPE_DBG: 776 685 case SYMFILETYPE_MZ: 777 #ifdef HAVE_DBGHELP778 /* done it all above! */779 break;780 #endif781 686 case SYMFILETYPE_LD_MAP: 782 687 case SYMFILETYPE_MS_MAP: … … 803 708 804 709 /** 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_DBGHELP818 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 else828 Log(("Reloaded debuginfo for %s - %s %llx\n", pszName, pszFilename, LoadedImageBase));829 }830 #else831 NOREF(pVM); NOREF(OldImageBase); NOREF(NewImageBase); NOREF(cbImage); NOREF(pszFilename); NOREF(pszName);832 #endif833 }834 835 836 /**837 710 * Adds a symbol to the debug info manager. 838 711 * … … 866 739 } 867 740 868 #ifdef HAVE_DBGHELP869 if (SymAddSymbol(pVM, ModuleAddress, (char *)(void *)pszSymbol, SymbolAddress, cbSymbol, 0))870 return VINF_SUCCESS;871 return win32Error(pVM);872 #else873 741 NOREF(ModuleAddress); /** @todo module lookup. */ 874 742 return dbgfR3SymbolInsert(pVM, pszSymbol, SymbolAddress, cbSymbol, NULL); 875 #endif876 743 } 877 744 … … 901 768 * Look it up. 902 769 */ 903 #ifdef HAVE_DBGHELP904 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 #else920 921 770 PDBGFSYM pSym = dbgfR3SymbolGetAddr(pVM, Address); 922 771 if (pSym) … … 931 780 return VINF_SUCCESS; 932 781 } 933 934 #endif935 782 936 783 /* … … 990 837 * Look it up. 991 838 */ 992 #ifdef HAVE_DBGHELP993 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 #else1008 1009 839 PDBGFSYM pSym = dbgfR3SymbolGetName(pVM, pszSymbol); 1010 840 if (pSym) … … 1019 849 1020 850 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 127 127 * Resume execution. 128 128 */ 129 CPUMR 3RawEnter(pVCpu, NULL);129 CPUMRawEnter(pVCpu, NULL); 130 130 CPUMSetHyperEFlags(pVCpu, CPUMGetHyperEFlags(pVCpu) | X86_EFL_RF); 131 131 rc = VMMR3ResumeHyper(pVM, pVCpu); 132 132 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 = CPUMR 3RawLeave(pVCpu, NULL, rc);133 rc = CPUMRawLeave(pVCpu, NULL, rc); 134 134 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK); 135 135 … … 189 189 * We do not start time or anything, if anything we should just do a few nanoseconds. 190 190 */ 191 CPUMR 3RawEnter(pVCpu, NULL);191 CPUMRawEnter(pVCpu, NULL); 192 192 do 193 193 { … … 202 202 } while ( rc == VINF_SUCCESS 203 203 || rc == VINF_EM_RAW_INTERRUPT); 204 rc = CPUMR 3RawLeave(pVCpu, NULL, rc);204 rc = CPUMRawLeave(pVCpu, NULL, rc); 205 205 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK); 206 206 … … 1393 1393 * and perhaps EIP) needs to be stored with PATM. 1394 1394 */ 1395 rc = CPUMR 3RawEnter(pVCpu, NULL);1395 rc = CPUMRawEnter(pVCpu, NULL); 1396 1396 if (rc != VINF_SUCCESS) 1397 1397 { … … 1417 1417 if (rc != VINF_SUCCESS) 1418 1418 { 1419 rc = CPUMR 3RawLeave(pVCpu, NULL, rc);1419 rc = CPUMRawLeave(pVCpu, NULL, rc); 1420 1420 break; 1421 1421 } … … 1477 1477 * execution FFs before doing anything else. 1478 1478 */ 1479 rc = CPUMR 3RawLeave(pVCpu, NULL, rc);1479 rc = CPUMRawLeave(pVCpu, NULL, rc); 1480 1480 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK); 1481 1481 if ( VM_FF_ISPENDING(pVM, VM_FF_HIGH_PRIORITY_POST_MASK) -
trunk/src/VBox/VMM/VMMR3/PDMLdr.cpp
r45830 r46165 216 216 pdmR3GetImportRC, &Args); 217 217 AssertFatalMsgRC(rc, ("RTLdrRelocate failed, rc=%d\n", rc)); 218 DBGFR3ModuleRelocate(pUVM->pVM, pCur->OldImageBase, pCur->ImageBase, RTLdrSize(pCur->hLdrMod),219 pCur->szFilename, pCur->szName);220 218 } 221 219 }
Note:
See TracChangeset
for help on using the changeset viewer.