Index: trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp
===================================================================
--- trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp	(revision 46164)
+++ trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp	(revision 46165)
@@ -1183,5 +1183,5 @@
      */
     bool        fFirst = 1;
-    DBGFLINE    LinePrev = { 0, 0, "" };
+    RTDBGLINE   LinePrev = { 0, 0, 0, 0, 0, "" };
     int         iRangeLeft = (int)pDbgc->SourcePos.u64Range;
     if (iRangeLeft == 0)                /* kludge for 'r'. */
@@ -1192,7 +1192,11 @@
          * Get line info.
          */
-        DBGFLINE    Line;
+        RTDBGLINE   Line;
         RTGCINTPTR  off;
-        int rc = DBGFR3LineByAddr(pUVM, pDbgc->SourcePos.u.GCFlat, &off, &Line);
+        DBGFADDRESS SourcePosAddr;
+        int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &pDbgc->SourcePos, &SourcePosAddr);
+        if (RT_FAILURE(rc))
+            return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,%Dv)", &pDbgc->SourcePos);
+        rc = DBGFR3AsLineByAddr(pUVM, pDbgc->hDbgAs, &SourcePosAddr, &off, &Line, NULL);
         if (RT_FAILURE(rc))
             return VINF_SUCCESS;
Index: trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp
===================================================================
--- trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp	(revision 46164)
+++ trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp	(revision 46165)
@@ -114,8 +114,4 @@
     return true;
 }
-VMMR3DECL(int) DBGFR3LineByAddr(PUVM pUVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFLINE pLine)
-{
-    return VERR_INTERNAL_ERROR;
-}
 VMMR3DECL(int) DBGFR3LogModifyDestinations(PUVM pUVM, const char *pszDestSettings)
 {
@@ -149,4 +145,9 @@
 {
     return NIL_RTDBGAS;
+}
+VMMR3DECL(int) DBGFR3AsLineByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
+                                  PRTGCINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod)
+{
+    return VERR_DBG_LINE_NOT_FOUND;
 }
 VMMR3DECL(int) DBGFR3Resume(PUVM pUVM)
Index: trunk/src/VBox/Runtime/common/dbg/dbgas.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/dbg/dbgas.cpp	(revision 46164)
+++ trunk/src/VBox/Runtime/common/dbg/dbgas.cpp	(revision 46165)
@@ -1696,18 +1696,5 @@
 
 
-/**
- * Query a line number by address.
- *
- * @returns IPRT status code. See RTDbgModSymbolAddrA for more specific ones.
- * @retval  VERR_INVALID_HANDLE if hDbgAs is invalid.
- * @retval  VERR_NOT_FOUND if the address couldn't be mapped to a module.
- *
- * @param   hDbgAs          The address space handle.
- * @param   Addr            The address which closest symbol is requested.
- * @param   poffDisp        Where to return the distance between the line
- *                          number and address.
- * @param   pLine           Where to return the line number information.
- */
-RTDECL(int) RTDbgAsLineByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE pLine)
+RTDECL(int) RTDbgAsLineByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod)
 {
     /*
@@ -1729,6 +1716,13 @@
     int rc = RTDbgModLineByAddr(hMod, iSeg, offSeg, poffDisp, pLine);
     if (RT_SUCCESS(rc))
+    {
         rtDbgAsAdjustLineAddress(pLine, hMod, MapAddr, iSeg);
-    RTDbgModRelease(hMod);
+        if (phMod)
+            *phMod = hMod;
+        else
+            RTDbgModRelease(hMod);
+    }
+    else
+        RTDbgModRelease(hMod);
     return rc;
 }
@@ -1736,19 +1730,5 @@
 
 
-/**
- * Query a line number by address.
- *
- * @returns IPRT status code. See RTDbgModSymbolAddrA for more specific ones.
- * @retval  VERR_INVALID_HANDLE if hDbgAs is invalid.
- * @retval  VERR_NOT_FOUND if the address couldn't be mapped to a module.
- *
- * @param   hDbgAs          The address space handle.
- * @param   Addr            The address which closest symbol is requested.
- * @param   poffDisp        Where to return the distance between the line
- *                          number and address.
- * @param   ppLine          Where to return the pointer to the allocated line
- *                          number info. Always set. Free with RTDbgLineFree.
- */
-RTDECL(int) RTDbgAsLineByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE *ppLine)
+RTDECL(int) RTDbgAsLineByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE *ppLine, PRTDBGMOD phMod)
 {
     /*
@@ -1770,6 +1750,13 @@
     int rc = RTDbgModLineByAddrA(hMod, iSeg, offSeg, poffDisp, ppLine);
     if (RT_SUCCESS(rc))
+    {
         rtDbgAsAdjustLineAddress(*ppLine, hMod, MapAddr, iSeg);
-    RTDbgModRelease(hMod);
+        if (phMod)
+            *phMod = hMod;
+        else
+            RTDbgModRelease(hMod);
+    }
+    else
+        RTDbgModRelease(hMod);
     return rc;
 }
Index: trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp	(revision 46164)
+++ trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp	(revision 46165)
@@ -486,5 +486,6 @@
                 return VINF_SUCCESS;
             }
-            pDbgMod->pDbgVt    = NULL;
+
+            pDbgMod->pDbgVt = NULL;
             Assert(pDbgMod->pvDbgPriv == NULL);
         }
@@ -530,11 +531,12 @@
                 return VINF_CALLBACK_RETURN;
             }
-            pDbgMod->pDbgVt    = NULL;
+
+            pDbgMod->pDbgVt = NULL;
             Assert(pDbgMod->pvDbgPriv == NULL);
         }
+        RTSemRWReleaseRead(g_hDbgModRWSem);
     }
 
     /* No joy. */
-    RTSemRWReleaseRead(g_hDbgModRWSem);
     RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszDbgFile);
     pDbgMod->pszDbgFile = NULL;
@@ -843,4 +845,10 @@
                             if (RT_SUCCESS(rc))
                             {
+                                /*
+                                 * We're done!
+                                 */
+                                ASMAtomicIncU32(&pImg->cUsers);
+                                RTSemRWReleaseRead(g_hDbgModRWSem);
+
                                 *phDbgMod = pDbgMod;
                                 return VINF_SUCCESS;
Index: trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp	(revision 46164)
+++ trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp	(revision 46165)
@@ -3696,5 +3696,5 @@
                                                        pSubProgram->PcRange.uHighAddress - pSubProgram->PcRange.uLowAddress,
                                                        0 /*fFlags*/, NULL /*piOrdinal*/);
-                                AssertRC(rc);
+                                AssertMsg(RT_SUCCESS(rc) || rc == VERR_DBG_DUPLICATE_SYMBOL, ("%Rrc\n", rc));
                             }
                             else
Index: trunk/src/VBox/Runtime/common/ldr/ldrkStuff.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/ldr/ldrkStuff.cpp	(revision 46164)
+++ trunk/src/VBox/Runtime/common/ldr/ldrkStuff.cpp	(revision 46165)
@@ -812,4 +812,13 @@
 
 
+/** @copydoc RTLDROPS::pfnReadDbgInfo. */
+static DECLCALLBACK(int) rtkldr_ReadDbgInfo(PRTLDRMODINTERNAL pMod, uint32_t iDbgInfo, RTFOFF off, size_t cb, void *pvBuf)
+{
+    PRTLDRMODKLDR   pThis = (PRTLDRMODKLDR)pMod;
+    /** @todo May have to apply fixups here. */
+    return pThis->Core.pReader->pfnRead(pThis->Core.pReader, pvBuf, cb, off);
+}
+
+
 /**
  * Operations for a kLdr module.
@@ -833,5 +842,5 @@
     rtkldr_SegOffsetToRva,
     rtkldr_RvaToSegOffset,
-    NULL,
+    rtkldr_ReadDbgInfo,
     42
 };
Index: trunk/src/VBox/Runtime/tools/RTLdrFlt.cpp
===================================================================
--- trunk/src/VBox/Runtime/tools/RTLdrFlt.cpp	(revision 46164)
+++ trunk/src/VBox/Runtime/tools/RTLdrFlt.cpp	(revision 46165)
@@ -388,5 +388,5 @@
                     RTDBGLINE   Line;
                     RTINTPTR    offLine;
-                    rc = RTDbgAsLineByAddr(hDbgAs, u64Address, &offLine, &Line);
+                    rc = RTDbgAsLineByAddr(hDbgAs, u64Address, &offLine, &Line, NULL);
                     if (RT_SUCCESS(rc))
                         RTStrmPrintf(pOutput, " %Rbn(%u)", Line.szFilename, Line.uLineNo);
Index: trunk/src/VBox/VMM/Makefile.kmk
===================================================================
--- trunk/src/VBox/VMM/Makefile.kmk	(revision 46164)
+++ trunk/src/VBox/VMM/Makefile.kmk	(revision 46165)
@@ -683,4 +683,5 @@
 endif
 
+ifneq ($(USERNAME),bird) # Not opts for me atm.
 #
 # Always optimize the interpreter.
@@ -697,5 +698,5 @@
  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?)
 endif
-
+endif # No optimizations for me atm.
 
 include $(FILE_KBUILD_SUB_FOOTER)
Index: trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp	(revision 46164)
+++ trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp	(revision 46165)
@@ -2458,4 +2458,5 @@
 
 #ifdef VBOX_WITH_RAW_MODE_NOT_R0
+
 /**
  *
@@ -2468,6 +2469,191 @@
     return pVCpu->cpum.s.fRawEntered;
 }
-#endif
-
+
+/**
+ * Transforms the guest CPU state to raw-ring mode.
+ *
+ * This function will change the any of the cs and ss register with DPL=0 to DPL=1.
+ *
+ * @returns VBox status. (recompiler failure)
+ * @param   pVCpu       Pointer to the VMCPU.
+ * @param   pCtxCore    The context core (for trap usage).
+ * @see     @ref pg_raw
+ */
+VMM_INT_DECL(int) CPUMRawEnter(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore)
+{
+    PVM pVM = pVCpu->CTX_SUFF(pVM);
+
+    Assert(!pVCpu->cpum.s.fRawEntered);
+    Assert(!pVCpu->cpum.s.fRemEntered);
+    if (!pCtxCore)
+        pCtxCore = CPUMCTX2CORE(&pVCpu->cpum.s.Guest);
+
+    /*
+     * Are we in Ring-0?
+     */
+    if (    pCtxCore->ss.Sel
+        &&  (pCtxCore->ss.Sel & X86_SEL_RPL) == 0
+        &&  !pCtxCore->eflags.Bits.u1VM)
+    {
+        /*
+         * Enter execution mode.
+         */
+        PATMRawEnter(pVM, pCtxCore);
+
+        /*
+         * Set CPL to Ring-1.
+         */
+        pCtxCore->ss.Sel |= 1;
+        if (    pCtxCore->cs.Sel
+            &&  (pCtxCore->cs.Sel & X86_SEL_RPL) == 0)
+            pCtxCore->cs.Sel |= 1;
+    }
+    else
+    {
+# ifdef VBOX_WITH_RAW_RING1
+        if (    EMIsRawRing1Enabled(pVM)
+            &&  !pCtxCore->eflags.Bits.u1VM
+            &&  (pCtxCore->ss.Sel & X86_SEL_RPL) == 1)
+        {
+            /* Set CPL to Ring-2. */
+            pCtxCore->ss.Sel = (pCtxCore->ss.Sel & ~X86_SEL_RPL) | 2;
+            if (pCtxCore->cs.Sel && (pCtxCore->cs.Sel & X86_SEL_RPL) == 1)
+                pCtxCore->cs.Sel = (pCtxCore->cs.Sel & ~X86_SEL_RPL) | 2;
+        }
+# else
+        AssertMsg((pCtxCore->ss.Sel & X86_SEL_RPL) >= 2 || pCtxCore->eflags.Bits.u1VM,
+                  ("ring-1 code not supported\n"));
+# endif
+        /*
+         * PATM takes care of IOPL and IF flags for Ring-3 and Ring-2 code as well.
+         */
+        PATMRawEnter(pVM, pCtxCore);
+    }
+
+    /*
+     * Assert sanity.
+     */
+    AssertMsg((pCtxCore->eflags.u32 & X86_EFL_IF), ("X86_EFL_IF is clear\n"));
+    AssertReleaseMsg(pCtxCore->eflags.Bits.u2IOPL == 0,
+                     ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss.Sel & X86_SEL_RPL));
+    Assert((pVCpu->cpum.s.Guest.cr0 & (X86_CR0_PG | X86_CR0_WP | X86_CR0_PE)) == (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP));
+
+    pCtxCore->eflags.u32        |= X86_EFL_IF; /* paranoia */
+
+    pVCpu->cpum.s.fRawEntered = true;
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * Transforms the guest CPU state from raw-ring mode to correct values.
+ *
+ * This function will change any selector registers with DPL=1 to DPL=0.
+ *
+ * @returns Adjusted rc.
+ * @param   pVCpu       Pointer to the VMCPU.
+ * @param   rc          Raw mode return code
+ * @param   pCtxCore    The context core (for trap usage).
+ * @see     @ref pg_raw
+ */
+VMM_INT_DECL(int) CPUMRawLeave(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, int rc)
+{
+    PVM pVM = pVCpu->CTX_SUFF(pVM);
+
+    /*
+     * Don't leave if we've already left (in RC).
+     */
+    Assert(!pVCpu->cpum.s.fRemEntered);
+    if (!pVCpu->cpum.s.fRawEntered)
+        return rc;
+    pVCpu->cpum.s.fRawEntered = false;
+
+    PCPUMCTX pCtx = &pVCpu->cpum.s.Guest;
+    if (!pCtxCore)
+        pCtxCore = CPUMCTX2CORE(pCtx);
+    Assert(pCtxCore->eflags.Bits.u1VM || (pCtxCore->ss.Sel & X86_SEL_RPL));
+    AssertMsg(pCtxCore->eflags.Bits.u1VM || pCtxCore->eflags.Bits.u2IOPL < (unsigned)(pCtxCore->ss.Sel & X86_SEL_RPL),
+              ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss.Sel & X86_SEL_RPL));
+
+    /*
+     * Are we executing in raw ring-1?
+     */
+    if (    (pCtxCore->ss.Sel & X86_SEL_RPL) == 1
+        &&  !pCtxCore->eflags.Bits.u1VM)
+    {
+        /*
+         * Leave execution mode.
+         */
+        PATMRawLeave(pVM, pCtxCore, rc);
+        /* Not quite sure if this is really required, but shouldn't harm (too much anyways). */
+        /** @todo See what happens if we remove this. */
+        if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 1)
+            pCtxCore->ds.Sel &= ~X86_SEL_RPL;
+        if ((pCtxCore->es.Sel & X86_SEL_RPL) == 1)
+            pCtxCore->es.Sel &= ~X86_SEL_RPL;
+        if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 1)
+            pCtxCore->fs.Sel &= ~X86_SEL_RPL;
+        if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 1)
+            pCtxCore->gs.Sel &= ~X86_SEL_RPL;
+
+        /*
+         * Ring-1 selector => Ring-0.
+         */
+        pCtxCore->ss.Sel &= ~X86_SEL_RPL;
+        if ((pCtxCore->cs.Sel & X86_SEL_RPL) == 1)
+            pCtxCore->cs.Sel &= ~X86_SEL_RPL;
+    }
+    else
+    {
+        /*
+         * PATM is taking care of the IOPL and IF flags for us.
+         */
+        PATMRawLeave(pVM, pCtxCore, rc);
+        if (!pCtxCore->eflags.Bits.u1VM)
+        {
+# ifdef VBOX_WITH_RAW_RING1
+            if (    EMIsRawRing1Enabled(pVM)
+                &&  (pCtxCore->ss.Sel & X86_SEL_RPL) == 2)
+            {
+                /* Not quite sure if this is really required, but shouldn't harm (too much anyways). */
+                /** @todo See what happens if we remove this. */
+                if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 2)
+                    pCtxCore->ds.Sel = (pCtxCore->ds.Sel & ~X86_SEL_RPL) | 1;
+                if ((pCtxCore->es.Sel & X86_SEL_RPL) == 2)
+                    pCtxCore->es.Sel = (pCtxCore->es.Sel & ~X86_SEL_RPL) | 1;
+                if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 2)
+                    pCtxCore->fs.Sel = (pCtxCore->fs.Sel & ~X86_SEL_RPL) | 1;
+                if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 2)
+                    pCtxCore->gs.Sel = (pCtxCore->gs.Sel & ~X86_SEL_RPL) | 1;
+
+                /*
+                 * Ring-2 selector => Ring-1.
+                 */
+                pCtxCore->ss.Sel = (pCtxCore->ss.Sel & ~X86_SEL_RPL) | 1;
+                if ((pCtxCore->cs.Sel & X86_SEL_RPL) == 2)
+                    pCtxCore->cs.Sel = (pCtxCore->cs.Sel & ~X86_SEL_RPL) | 1;
+            }
+            else
+            {
+# endif
+                /** @todo See what happens if we remove this. */
+                if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 1)
+                    pCtxCore->ds.Sel &= ~X86_SEL_RPL;
+                if ((pCtxCore->es.Sel & X86_SEL_RPL) == 1)
+                    pCtxCore->es.Sel &= ~X86_SEL_RPL;
+                if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 1)
+                    pCtxCore->fs.Sel &= ~X86_SEL_RPL;
+                if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 1)
+                    pCtxCore->gs.Sel &= ~X86_SEL_RPL;
+# ifdef VBOX_WITH_RAW_RING1
+            }
+# endif
+        }
+    }
+
+    return rc;
+}
+
+#endif /* VBOX_WITH_RAW_MODE_NOT_R0 */
 
 /**
Index: trunk/src/VBox/VMM/VMMAll/IEMAll.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMAll/IEMAll.cpp	(revision 46164)
+++ trunk/src/VBox/VMM/VMMAll/IEMAll.cpp	(revision 46165)
@@ -8491,4 +8491,8 @@
     AssertReturn(CPUMCTX2CORE(pCtx) == pCtxCore, VERR_IEM_IPE_3);
 
+#ifdef IN_RC
+    CPUMRawLeave(pVCpu, pCtxCore, VINF_SUCCESS);
+#endif
+
     iemInitDecoder(pIemCpu, true);
     uint32_t const cbOldWritten = pIemCpu->cbWritten;
@@ -8501,4 +8505,8 @@
             *pcbWritten = pIemCpu->cbWritten - cbOldWritten;
     }
+
+#ifdef IN_RC
+    CPUMRawEnter(pVCpu, pCtxCore);
+#endif
     return rcStrict;
 }
@@ -8511,4 +8519,8 @@
     PCPUMCTX pCtx    = pVCpu->iem.s.CTX_SUFF(pCtx);
     AssertReturn(CPUMCTX2CORE(pCtx) == pCtxCore, VERR_IEM_IPE_3);
+
+#ifdef IN_RC
+    CPUMRawLeave(pVCpu, pCtxCore, VINF_SUCCESS);
+#endif
 
     VBOXSTRICTRC rcStrict;
@@ -8525,4 +8537,8 @@
     if (rcStrict == VINF_SUCCESS)
         rcStrict = iemExecOneInner(pVCpu, pIemCpu, false);
+
+#ifdef IN_RC
+    CPUMRawEnter(pVCpu, pCtxCore);
+#endif
     return rcStrict;
 }
Index: trunk/src/VBox/VMM/VMMAll/PATMAll.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMAll/PATMAll.cpp	(revision 46164)
+++ trunk/src/VBox/VMM/VMMAll/PATMAll.cpp	(revision 46165)
@@ -50,5 +50,4 @@
 VMM_INT_DECL(void) PATMRawEnter(PVM pVM, PCPUMCTXCORE pCtxCore)
 {
-    bool fPatchCode = PATMIsPatchGCAddr(pVM, pCtxCore->eip);
     Assert(!HMIsEnabled(pVM));
 
@@ -57,9 +56,14 @@
      * For all cases where it isn't, IOPL will be safe and IF will be set.
      */
-    register uint32_t efl = pCtxCore->eflags.u32;
+    uint32_t efl = pCtxCore->eflags.u32;
     CTXSUFF(pVM->patm.s.pGCState)->uVMFlags = efl & PATM_VIRTUAL_FLAGS_MASK;
-    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));
-
-    AssertReleaseMsg(CTXSUFF(pVM->patm.s.pGCState)->fPIF || fPatchCode, ("fPIF=%d eip=%RRv\n", CTXSUFF(pVM->patm.s.pGCState)->fPIF, pCtxCore->eip));
+
+    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));
+
+    AssertReleaseMsg(CTXSUFF(pVM->patm.s.pGCState)->fPIF || PATMIsPatchGCAddr(pVM, pCtxCore->eip),
+                     ("fPIF=%d eip=%RRv\n", pVM->patm.s.CTXSUFF(pGCState)->fPIF, pCtxCore->eip));
 
     efl &= ~PATM_VIRTUAL_FLAGS_MASK;
@@ -68,5 +72,5 @@
 
 #ifdef IN_RING3
-#ifdef PATM_EMULATE_SYSENTER
+# ifdef PATM_EMULATE_SYSENTER
     PCPUMCTX pCtx;
 
@@ -103,5 +107,5 @@
         pVM->patm.s.pfnSysEnterGC = 0;
     }
-#endif
+# endif /* PATM_EMULATE_SYSENTER */
 #endif
 }
@@ -124,8 +128,9 @@
     Assert(!HMIsEnabled(pVM));
     bool fPatchCode = PATMIsPatchGCAddr(pVM, pCtxCore->eip);
+
     /*
      * We will only be called if PATMRawEnter was previously called.
      */
-    register uint32_t efl = pCtxCore->eflags.u32;
+    uint32_t efl = pCtxCore->eflags.u32;
     efl = (efl & ~PATM_VIRTUAL_FLAGS_MASK) | (CTXSUFF(pVM->patm.s.pGCState)->uVMFlags & PATM_VIRTUAL_FLAGS_MASK);
     pCtxCore->eflags.u32 = efl;
@@ -136,10 +141,9 @@
 
 #ifdef IN_RING3
-    if (    (efl & X86_EFL_IF)
-        &&  fPatchCode
-       )
-    {
-        if (    rawRC < VINF_PATM_LEAVE_RC_FIRST
-            ||  rawRC > VINF_PATM_LEAVE_RC_LAST)
+    if (   (efl & X86_EFL_IF)
+        && fPatchCode)
+    {
+        if (   rawRC < VINF_PATM_LEAVE_RC_FIRST
+            || rawRC > VINF_PATM_LEAVE_RC_LAST)
         {
             /*
@@ -182,7 +186,11 @@
         }
     }
-#else /* !IN_RING3 */
-    AssertMsgFailed(("!IN_RING3"));
-#endif  /* !IN_RING3 */
+#else  /* !IN_RING3 */
+    /*
+     * When leaving raw-mode state while IN_RC, it's generally for interpreting
+     * a single original guest instruction.
+     */
+    AssertMsg(!fPatchCode, ("eip=%RRv\n", pCtxCore->eip));
+#endif /* !IN_RING3 */
 
     if (!fPatchCode)
Index: trunk/src/VBox/VMM/VMMR3/CPUM.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/CPUM.cpp	(revision 46164)
+++ trunk/src/VBox/VMM/VMMR3/CPUM.cpp	(revision 46165)
@@ -4194,194 +4194,4 @@
 }
 
-#ifdef VBOX_WITH_RAW_MODE
-
-/**
- * Transforms the guest CPU state to raw-ring mode.
- *
- * This function will change the any of the cs and ss register with DPL=0 to DPL=1.
- *
- * @returns VBox status. (recompiler failure)
- * @param   pVCpu       Pointer to the VMCPU.
- * @param   pCtxCore    The context core (for trap usage).
- * @see     @ref pg_raw
- */
-VMMR3DECL(int) CPUMR3RawEnter(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore)
-{
-    PVM pVM = pVCpu->CTX_SUFF(pVM);
-
-    Assert(!pVCpu->cpum.s.fRawEntered);
-    Assert(!pVCpu->cpum.s.fRemEntered);
-    if (!pCtxCore)
-        pCtxCore = CPUMCTX2CORE(&pVCpu->cpum.s.Guest);
-
-    /*
-     * Are we in Ring-0?
-     */
-    if (    pCtxCore->ss.Sel
-        &&  (pCtxCore->ss.Sel & X86_SEL_RPL) == 0
-        &&  !pCtxCore->eflags.Bits.u1VM)
-    {
-        /*
-         * Enter execution mode.
-         */
-        PATMRawEnter(pVM, pCtxCore);
-
-        /*
-         * Set CPL to Ring-1.
-         */
-        pCtxCore->ss.Sel |= 1;
-        if (    pCtxCore->cs.Sel
-            &&  (pCtxCore->cs.Sel & X86_SEL_RPL) == 0)
-            pCtxCore->cs.Sel |= 1;
-    }
-    else
-    {
-#ifdef VBOX_WITH_RAW_RING1
-        if (    EMIsRawRing1Enabled(pVM)
-            &&  !pCtxCore->eflags.Bits.u1VM
-            &&  (pCtxCore->ss.Sel & X86_SEL_RPL) == 1)
-        {
-            /* Set CPL to Ring-2. */
-            pCtxCore->ss.Sel = (pCtxCore->ss.Sel & ~X86_SEL_RPL) | 2;
-            if (pCtxCore->cs.Sel && (pCtxCore->cs.Sel & X86_SEL_RPL) == 1)
-                pCtxCore->cs.Sel = (pCtxCore->cs.Sel & ~X86_SEL_RPL) | 2;
-        }
-#else
-        AssertMsg((pCtxCore->ss.Sel & X86_SEL_RPL) >= 2 || pCtxCore->eflags.Bits.u1VM,
-                  ("ring-1 code not supported\n"));
-#endif
-        /*
-         * PATM takes care of IOPL and IF flags for Ring-3 and Ring-2 code as well.
-         */
-        PATMRawEnter(pVM, pCtxCore);
-    }
-
-    /*
-     * Assert sanity.
-     */
-    AssertMsg((pCtxCore->eflags.u32 & X86_EFL_IF), ("X86_EFL_IF is clear\n"));
-    AssertReleaseMsg(pCtxCore->eflags.Bits.u2IOPL == 0,
-                     ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss.Sel & X86_SEL_RPL));
-    Assert((pVCpu->cpum.s.Guest.cr0 & (X86_CR0_PG | X86_CR0_WP | X86_CR0_PE)) == (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP));
-
-    pCtxCore->eflags.u32        |= X86_EFL_IF; /* paranoia */
-
-    pVCpu->cpum.s.fRawEntered = true;
-    return VINF_SUCCESS;
-}
-
-
-/**
- * Transforms the guest CPU state from raw-ring mode to correct values.
- *
- * This function will change any selector registers with DPL=1 to DPL=0.
- *
- * @returns Adjusted rc.
- * @param   pVCpu       Pointer to the VMCPU.
- * @param   rc          Raw mode return code
- * @param   pCtxCore    The context core (for trap usage).
- * @see     @ref pg_raw
- */
-VMMR3DECL(int) CPUMR3RawLeave(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, int rc)
-{
-    PVM pVM = pVCpu->CTX_SUFF(pVM);
-
-    /*
-     * Don't leave if we've already left (in GC).
-     */
-    Assert(pVCpu->cpum.s.fRawEntered);
-    Assert(!pVCpu->cpum.s.fRemEntered);
-    if (!pVCpu->cpum.s.fRawEntered)
-        return rc;
-    pVCpu->cpum.s.fRawEntered = false;
-
-    PCPUMCTX pCtx = &pVCpu->cpum.s.Guest;
-    if (!pCtxCore)
-        pCtxCore = CPUMCTX2CORE(pCtx);
-    Assert(pCtxCore->eflags.Bits.u1VM || (pCtxCore->ss.Sel & X86_SEL_RPL));
-    AssertMsg(pCtxCore->eflags.Bits.u1VM || pCtxCore->eflags.Bits.u2IOPL < (unsigned)(pCtxCore->ss.Sel & X86_SEL_RPL),
-              ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss.Sel & X86_SEL_RPL));
-
-    /*
-     * Are we executing in raw ring-1?
-     */
-    if (    (pCtxCore->ss.Sel & X86_SEL_RPL) == 1
-        &&  !pCtxCore->eflags.Bits.u1VM)
-    {
-        /*
-         * Leave execution mode.
-         */
-        PATMRawLeave(pVM, pCtxCore, rc);
-        /* Not quite sure if this is really required, but shouldn't harm (too much anyways). */
-        /** @todo See what happens if we remove this. */
-        if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 1)
-            pCtxCore->ds.Sel &= ~X86_SEL_RPL;
-        if ((pCtxCore->es.Sel & X86_SEL_RPL) == 1)
-            pCtxCore->es.Sel &= ~X86_SEL_RPL;
-        if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 1)
-            pCtxCore->fs.Sel &= ~X86_SEL_RPL;
-        if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 1)
-            pCtxCore->gs.Sel &= ~X86_SEL_RPL;
-
-        /*
-         * Ring-1 selector => Ring-0.
-         */
-        pCtxCore->ss.Sel &= ~X86_SEL_RPL;
-        if ((pCtxCore->cs.Sel & X86_SEL_RPL) == 1)
-            pCtxCore->cs.Sel &= ~X86_SEL_RPL;
-    }
-    else
-    {
-        /*
-         * PATM is taking care of the IOPL and IF flags for us.
-         */
-        PATMRawLeave(pVM, pCtxCore, rc);
-        if (!pCtxCore->eflags.Bits.u1VM)
-        {
-# ifdef VBOX_WITH_RAW_RING1
-            if (    EMIsRawRing1Enabled(pVM)
-                &&  (pCtxCore->ss.Sel & X86_SEL_RPL) == 2)
-            {
-                /* Not quite sure if this is really required, but shouldn't harm (too much anyways). */
-                /** @todo See what happens if we remove this. */
-                if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 2)
-                    pCtxCore->ds.Sel = (pCtxCore->ds.Sel & ~X86_SEL_RPL) | 1;
-                if ((pCtxCore->es.Sel & X86_SEL_RPL) == 2)
-                    pCtxCore->es.Sel = (pCtxCore->es.Sel & ~X86_SEL_RPL) | 1;
-                if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 2)
-                    pCtxCore->fs.Sel = (pCtxCore->fs.Sel & ~X86_SEL_RPL) | 1;
-                if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 2)
-                    pCtxCore->gs.Sel = (pCtxCore->gs.Sel & ~X86_SEL_RPL) | 1;
-
-                /*
-                 * Ring-2 selector => Ring-1.
-                 */
-                pCtxCore->ss.Sel = (pCtxCore->ss.Sel & ~X86_SEL_RPL) | 1;
-                if ((pCtxCore->cs.Sel & X86_SEL_RPL) == 2)
-                    pCtxCore->cs.Sel = (pCtxCore->cs.Sel & ~X86_SEL_RPL) | 1;
-            }
-            else
-            {
-# endif
-                /** @todo See what happens if we remove this. */
-                if ((pCtxCore->ds.Sel & X86_SEL_RPL) == 1)
-                    pCtxCore->ds.Sel &= ~X86_SEL_RPL;
-                if ((pCtxCore->es.Sel & X86_SEL_RPL) == 1)
-                    pCtxCore->es.Sel &= ~X86_SEL_RPL;
-                if ((pCtxCore->fs.Sel & X86_SEL_RPL) == 1)
-                    pCtxCore->fs.Sel &= ~X86_SEL_RPL;
-                if ((pCtxCore->gs.Sel & X86_SEL_RPL) == 1)
-                    pCtxCore->gs.Sel &= ~X86_SEL_RPL;
-# ifdef VBOX_WITH_RAW_RING1
-            }
-# endif
-        }
-    }
-
-    return rc;
-}
-
-#endif /* VBOX_WITH_RAW_MODE */
-
 
 /**
Index: trunk/src/VBox/VMM/VMMR3/DBGFAddrSpace.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/DBGFAddrSpace.cpp	(revision 46164)
+++ trunk/src/VBox/VMM/VMMR3/DBGFAddrSpace.cpp	(revision 46165)
@@ -1272,2 +1272,50 @@
 }
 
+
+VMMR3DECL(int)          DBGFR3AsLineByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
+                                           PRTGCINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod)
+{
+    /*
+     * Implement the special address space aliases the lazy way.
+     */
+    if (hDbgAs == DBGF_AS_RC_AND_GC_GLOBAL)
+    {
+        int rc = DBGFR3AsLineByAddr(pUVM, DBGF_AS_RC, pAddress, poffDisp, pLine, phMod);
+        if (RT_FAILURE(rc))
+            rc = DBGFR3AsLineByAddr(pUVM, DBGF_AS_GLOBAL, pAddress, poffDisp, pLine, phMod);
+        return rc;
+    }
+
+    /*
+     * Input validation.
+     */
+    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
+    AssertReturn(DBGFR3AddrIsValid(pUVM, pAddress), VERR_INVALID_PARAMETER);
+    AssertPtrNullReturn(poffDisp, VERR_INVALID_POINTER);
+    AssertPtrReturn(pLine, VERR_INVALID_POINTER);
+    AssertPtrNullReturn(phMod, VERR_INVALID_POINTER);
+    if (poffDisp)
+        *poffDisp = 0;
+    if (phMod)
+        *phMod = NIL_RTDBGMOD;
+    RTDBGAS hRealAS = DBGFR3AsResolveAndRetain(pUVM, hDbgAs);
+    if (hRealAS == NIL_RTDBGAS)
+        return VERR_INVALID_HANDLE;
+
+    /*
+     * Do the lookup.
+     */
+    return RTDbgAsLineByAddr(hRealAS, pAddress->FlatPtr, poffDisp, pLine, phMod);
+}
+
+
+VMMR3DECL(PRTDBGLINE)   DBGFR3AsLineByAddrA(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
+                                            PRTGCINTPTR poffDisp, PRTDBGMOD phMod)
+{
+    RTDBGLINE Line;
+    int rc = DBGFR3AsLineByAddr(pUVM, hDbgAs, pAddress, poffDisp, &Line, phMod);
+    if (RT_SUCCESS(rc))
+        return RTDbgLineDup(&Line);
+    return NULL;
+}
+
Index: trunk/src/VBox/VMM/VMMR3/DBGFStack.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/DBGFStack.cpp	(revision 46164)
+++ trunk/src/VBox/VMM/VMMR3/DBGFStack.cpp	(revision 46165)
@@ -158,6 +158,6 @@
         {
             pFrame->pSymPC  = DBGFR3AsSymbolByAddrA(pUVM, hAs, &pFrame->AddrPC, RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL,
-                                                    NULL /*offDisp*/, NULL /*phMod*/);
-            pFrame->pLinePC = DBGFR3LineByAddrAlloc(pUVM, pFrame->AddrPC.FlatPtr, NULL);
+                                                    NULL /*poffDisp*/, NULL /*phMod*/);
+            pFrame->pLinePC = DBGFR3AsLineByAddrA(pUVM, hAs, &pFrame->AddrPC, NULL /*poffDisp*/, NULL /*phMod*/);
         }
     }
@@ -255,6 +255,6 @@
 
     pFrame->pSymReturnPC  = DBGFR3AsSymbolByAddrA(pUVM, hAs, &pFrame->AddrReturnPC, RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL,
-                                                  NULL /*offDisp*/, NULL /*phMod*/);
-    pFrame->pLineReturnPC = DBGFR3LineByAddrAlloc(pUVM, pFrame->AddrReturnPC.FlatPtr, NULL);
+                                                  NULL /*poffDisp*/, NULL /*phMod*/);
+    pFrame->pLineReturnPC = DBGFR3AsLineByAddrA(pUVM, hAs, &pFrame->AddrPC, NULL /*poffDisp*/, NULL /*phMod*/);
 
     /*
@@ -584,6 +584,6 @@
         RTDbgSymbolFree(pCur->pSymPC);
         RTDbgSymbolFree(pCur->pSymReturnPC);
-        DBGFR3LineFree(pCur->pLinePC);
-        DBGFR3LineFree(pCur->pLineReturnPC);
+        RTDbgLineFree(pCur->pLinePC);
+        RTDbgLineFree(pCur->pLineReturnPC);
 
         pCur->pNextInternal = NULL;
Index: trunk/src/VBox/VMM/VMMR3/DBGFSym.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/DBGFSym.cpp	(revision 46164)
+++ trunk/src/VBox/VMM/VMMR3/DBGFSym.cpp	(revision 46165)
@@ -2,4 +2,7 @@
 /** @file
  * DBGF - Debugger Facility, Symbol Management.
+ *
+ * This is obsolete code that's only sticking around till we've moved the linux map
+ * file reader into IPRT.
  */
 
@@ -20,12 +23,4 @@
 *   Header Files                                                               *
 *******************************************************************************/
-#define LOG_GROUP LOG_GROUP_DBGF
-#if defined(RT_OS_WINDOWS) && 0 //defined(DEBUG_bird) // enabled this is you want to debug win32 guests, the hypervisor of EFI.
-# include <Windows.h>
-# define _IMAGEHLP64
-# include <DbgHelp.h>
-# define HAVE_DBGHELP /* if doing guest stuff, this can be nice. */
-#endif
-/** @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)! */
 #include <VBox/vmm/dbgf.h>
 #include <VBox/vmm/mm.h>
@@ -43,21 +38,9 @@
 #include <iprt/env.h>
 #include <iprt/param.h>
-#ifndef HAVE_DBGHELP
-# include <iprt/avl.h>
-# include <iprt/string.h>
-#endif
+#include <iprt/avl.h>
+#include <iprt/string.h>
 
 #include <stdio.h> /* for fopen(). */ /** @todo use iprt/stream.h! */
 #include <stdlib.h>
-
-
-/*******************************************************************************
-*   Internal Functions                                                         *
-*******************************************************************************/
-#ifdef HAVE_DBGHELP
-static DECLCALLBACK(int) dbgfR3EnumModules(PVM pVM, const char *pszFilename, const char *pszName,
-                                           RTUINTPTR ImageBase, size_t cbImage, bool fRC, void *pvArg);
-static int win32Error(PVM pVM);
-#endif
 
 
@@ -65,5 +48,4 @@
 *   Structures and Typedefs                                                    *
 *******************************************************************************/
-#ifndef HAVE_DBGHELP
 /* later */
 typedef struct DBGFMOD *PDBGFMOD;
@@ -96,5 +78,4 @@
 } DBGFSYMSPACE, *PDBGFSYMSPACE;
 
-#endif
 
 
@@ -103,6 +84,4 @@
 *   Internal Functions                                                         *
 *******************************************************************************/
-#ifndef HAVE_DBGHELP
-
 /**
  * Initializes the symbol tree.
@@ -220,6 +199,4 @@
 }
 
-#endif
-
 
 /**
@@ -256,5 +233,4 @@
     AssertReturn(pVM->dbgf.s.pSymbolSpace, VERR_NO_MEMORY);
 
-#ifndef HAVE_DBGHELP
     /* modules & lines later */
     rc = dbgfR3SymbolInit(pVM);
@@ -262,5 +238,4 @@
         return rc;
     pVM->dbgf.s.fSymInited = true;
-#endif
 
     /** @todo symbol search path setup. */
@@ -404,51 +379,6 @@
     if (pVM->dbgf.s.fSymInited)
         return VINF_SUCCESS;
-#ifdef HAVE_DBGHELP
-    if (SymInitialize(pVM, NULL, FALSE))
-    {
-        pVM->dbgf.s.fSymInited = true;
-        SymSetOptions(SYMOPT_LOAD_LINES | SYMOPT_AUTO_PUBLICS | SYMOPT_ALLOW_ABSOLUTE_SYMBOLS);
-
-        /*
-         * Enumerate all modules loaded by PDM and add them to the symbol database.
-         */
-        PDMR3LdrEnumModules(pVM, dbgfR3EnumModules, NULL);
-        return VINF_SUCCESS;
-    }
-    return win32Error(pVM);
-#else
     return VINF_SUCCESS;
-#endif
-}
-
-
-#ifdef HAVE_DBGHELP
-/**
- * Module enumeration callback function.
- *
- * @returns VBox status.
- *          Failure will stop the search and return the return code.
- *          Warnings will be ignored and not returned.
- * @param   pVM             Pointer to the VM.
- * @param   pszFilename     Module filename.
- * @param   pszName         Module name. (short and unique)
- * @param   ImageBase       Address where to executable image is loaded.
- * @param   cbImage         Size of the executable image.
- * @param   fRC             Set if guest context, clear if host context.
- * @param   pvArg           User argument.
- */
-static DECLCALLBACK(int) dbgfR3EnumModules(PVM pVM, const char *pszFilename, const char *pszName,
-                                           RTUINTPTR ImageBase, size_t cbImage, bool fRC, void *pvArg)
-{
-    DWORD64 LoadedImageBase = SymLoadModule64(pVM, NULL, (char *)(void *)pszFilename,
-                                                (char *)(void *)pszName, ImageBase, (DWORD)cbImage);
-    if (!LoadedImageBase)
-        Log(("SymLoadModule64(,,%s,,) -> lasterr=%d\n", pszFilename, GetLastError()));
-    else
-        Log(("Loaded debuginfo for %s - %s %llx\n", pszName, pszFilename, LoadedImageBase));
-
-    return VINF_SUCCESS;
-}
-#endif
+}
 
 
@@ -461,14 +391,7 @@
 int dbgfR3SymTerm(PVM pVM)
 {
-#ifdef HAVE_DBGHELP
-    if (pVM->dbgf.s.fSymInited)
-        SymCleanup(pVM);
-    pVM->dbgf.s.fSymInited = false;
-    return VINF_SUCCESS;
-#else
     pVM->dbgf.s.SymbolTree = 0; /* MM cleans up allocations */
     pVM->dbgf.s.fSymInited = false;
     return VINF_SUCCESS;
-#endif
 }
 
@@ -739,19 +662,5 @@
             if (pszName)
             {
-                #ifdef HAVE_DBGHELP
-                /** @todo arg! checkout the inserting of modules and then loading them again.... Or just the module representation.... */
-                DWORD64 ImageBase = SymLoadModule64(pVM, NULL, (char *)(void *)szFoundFile, (char *)(void *)pszName, ModuleAddress, cbImage);
-                if (!ImageBase)
-                    ImageBase = SymLoadModule64(pVM, NULL, (char *)(void *)pszName, (char *)(void *)pszName, ModuleAddress, cbImage);
-                if (ImageBase)
-                {
-                    AssertMsg(ModuleAddress == 0 || ModuleAddress == ImageBase, ("ModuleAddres=%RGv ImageBase=%llx\n", ModuleAddress, ImageBase));
-                    ModuleAddress = ImageBase;
-                }
-                else
-                    rc = win32Error(pVM);
-                #else
                 rc = VERR_NOT_IMPLEMENTED;
-                #endif
             }
             if (RT_SUCCESS(rc))
@@ -775,8 +684,4 @@
                     case SYMFILETYPE_DBG:
                     case SYMFILETYPE_MZ:
-                #ifdef HAVE_DBGHELP
-                        /* done it all above! */
-                        break;
-                #endif
                     case SYMFILETYPE_LD_MAP:
                     case SYMFILETYPE_MS_MAP:
@@ -803,36 +708,4 @@
 
 /**
- * Interface used by PDMR3LdrRelocate for telling us that a GC module has been relocated.
- *
- * @param   pVM             Pointer to the VM.
- * @param   OldImageBase    The old image base.
- * @param   NewImageBase    The new image base.
- * @param   cbImage         The image size.
- * @param   pszFilename     The image filename.
- * @param   pszName         The module name.
- */
-VMMR3_INT_DECL(void) DBGFR3ModuleRelocate(PVM pVM, RTGCUINTPTR OldImageBase, RTGCUINTPTR NewImageBase, RTGCUINTPTR cbImage,
-                                          const char *pszFilename, const char *pszName)
-{
-#ifdef HAVE_DBGHELP
-    if (pVM->dbgf.s.fSymInited)
-    {
-        if (!SymUnloadModule64(pVM, OldImageBase))
-            Log(("SymUnloadModule64(,%RGv) failed, lasterr=%d\n", OldImageBase, GetLastError()));
-
-        DWORD ImageSize = (DWORD)cbImage; Assert(ImageSize == cbImage);
-        DWORD64 LoadedImageBase = SymLoadModule64(pVM, NULL, (char *)(void *)pszFilename, (char *)(void *)pszName, NewImageBase, ImageSize);
-        if (!LoadedImageBase)
-            Log(("SymLoadModule64(,,%s,,) -> lasterr=%d (relocate)\n", pszFilename, GetLastError()));
-        else
-            Log(("Reloaded debuginfo for %s - %s %llx\n", pszName, pszFilename, LoadedImageBase));
-    }
-#else
-    NOREF(pVM); NOREF(OldImageBase); NOREF(NewImageBase); NOREF(cbImage); NOREF(pszFilename); NOREF(pszName);
-#endif
-}
-
-
-/**
  * Adds a symbol to the debug info manager.
  *
@@ -866,12 +739,6 @@
     }
 
-#ifdef HAVE_DBGHELP
-    if (SymAddSymbol(pVM, ModuleAddress, (char *)(void *)pszSymbol, SymbolAddress, cbSymbol, 0))
-        return VINF_SUCCESS;
-    return win32Error(pVM);
-#else
     NOREF(ModuleAddress); /** @todo module lookup. */
     return dbgfR3SymbolInsert(pVM, pszSymbol, SymbolAddress, cbSymbol, NULL);
-#endif
 }
 
@@ -901,22 +768,4 @@
      * Look it up.
      */
-#ifdef HAVE_DBGHELP
-    char                achBuffer[sizeof(IMAGEHLP_SYMBOL64) + DBGF_SYMBOL_NAME_LENGTH * sizeof(TCHAR) + sizeof(ULONG64)];
-    PIMAGEHLP_SYMBOL64  pSym = (PIMAGEHLP_SYMBOL64)&achBuffer[0];
-    pSym->SizeOfStruct      = sizeof(IMAGEHLP_SYMBOL64);
-    pSym->MaxNameLength     = DBGF_SYMBOL_NAME_LENGTH;
-
-    if (SymGetSymFromAddr64(pVM, Address, (PDWORD64)poffDisplacement, pSym))
-    {
-        pSymbol->Value  = (RTGCUINTPTR)pSym->Address;
-        pSymbol->cb     = pSym->Size;
-        pSymbol->fFlags = pSym->Flags;
-        strcpy(pSymbol->szName, pSym->Name);
-        return VINF_SUCCESS;
-    }
-    //return win32Error(pVM);
-
-#else
-
     PDBGFSYM pSym = dbgfR3SymbolGetAddr(pVM, Address);
     if (pSym)
@@ -931,6 +780,4 @@
         return VINF_SUCCESS;
     }
-
-#endif
 
     /*
@@ -990,21 +837,4 @@
      * Look it up.
      */
-#ifdef HAVE_DBGHELP
-    char            achBuffer[sizeof(IMAGEHLP_SYMBOL64) + DBGF_SYMBOL_NAME_LENGTH * sizeof(TCHAR) + sizeof(ULONG64)];
-    PIMAGEHLP_SYMBOL64 pSym = (PIMAGEHLP_SYMBOL64)&achBuffer[0];
-    pSym->SizeOfStruct      = sizeof(IMAGEHLP_SYMBOL64);
-    pSym->MaxNameLength     = DBGF_SYMBOL_NAME_LENGTH;
-
-    if (SymGetSymFromName64(pVM, (char *)(void *)pszSymbol, pSym))
-    {
-        pSymbol->Value  = (RTGCUINTPTR)pSym->Address;
-        pSymbol->cb     = pSym->Size;
-        pSymbol->fFlags = pSym->Flags;
-        strcpy(pSymbol->szName, pSym->Name);
-        return VINF_SUCCESS;
-    }
-    return win32Error(pVM);
-#else
-
     PDBGFSYM pSym = dbgfR3SymbolGetName(pVM, pszSymbol);
     if (pSym)
@@ -1019,122 +849,4 @@
 
     return VERR_SYMBOL_NOT_FOUND;
-#endif
-}
-
-
-/**
- * Find line by address (nearest).
- *
- * @returns VBox status.
- * @param   pUVM                The user mode VM handle.
- * @param   Address             Address.
- * @param   poffDisplacement    Where to store the line displacement from Address.
- * @param   pLine               Where to store the line info.
- */
-VMMR3DECL(int) DBGFR3LineByAddr(PUVM pUVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFLINE pLine)
-{
-    /*
-     * Lazy init.
-     */
-    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
-    PVM pVM = pUVM->pVM;
-    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
-    if (!pVM->dbgf.s.fSymInited)
-    {
-        int rc = dbgfR3SymLazyInit(pVM);
-        if (RT_FAILURE(rc))
-            return rc;
-    }
-
-    /*
-     * Look it up.
-     */
-#ifdef HAVE_DBGHELP
-    IMAGEHLP_LINE64     Line = {0};
-    DWORD               off = 0;
-    Line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
-    if (SymGetLineFromAddr64(pVM, Address, &off, &Line))
-    {
-        if (poffDisplacement)
-            *poffDisplacement = (long)off;
-        pLine->Address      = (RTGCUINTPTR)Line.Address;
-        pLine->uLineNo      = Line.LineNumber;
-        pLine->szFilename[0] = '\0';
-        strncat(pLine->szFilename, Line.FileName, sizeof(pLine->szFilename));
-        return VINF_SUCCESS;
-    }
-    return win32Error(pVM);
-#else
-    NOREF(pVM); NOREF(Address); NOREF(poffDisplacement); NOREF(pLine);
-    return VERR_NOT_IMPLEMENTED;
-#endif
-}
-
-
-/**
- * Duplicates a line.
- *
- * @returns VBox status code.
- * @param   pUVM            The user mode VM handle.
- * @param   pLine           The line to duplicate.
- */
-static PDBGFLINE dbgfR3LineDup(PUVM pUVM, PCDBGFLINE pLine)
-{
-    size_t cb = strlen(pLine->szFilename) + RT_OFFSETOF(DBGFLINE, szFilename[1]);
-    PDBGFLINE pDup = (PDBGFLINE)MMR3HeapAllocU(pUVM, MM_TAG_DBGF_LINE_DUP, cb);
-    if (pDup)
-        memcpy(pDup, pLine, cb);
-    return pDup;
-}
-
-
-/**
- * Find line by address (nearest), allocate return buffer.
- *
- * @returns Pointer to the line. Must be freed using DBGFR3LineFree().
- * @returns NULL if the line was not found or if we're out of memory.
- * @param   pUVM                The user mode VM handle.
- * @param   Address             Address.
- * @param   poffDisplacement    Where to store the line displacement from Address.
- */
-VMMR3DECL(PDBGFLINE) DBGFR3LineByAddrAlloc(PUVM pUVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement)
-{
-    DBGFLINE Line;
-    int rc = DBGFR3LineByAddr(pUVM, Address, poffDisplacement, &Line);
-    if (RT_FAILURE(rc))
-        return NULL;
-    return dbgfR3LineDup(pUVM, &Line);
-}
-
-
-/**
- * Frees a line returned by DBGFR3LineByAddressAlloc().
- *
- * @param   pLine           Pointer to the line.
- */
-VMMR3_INT_DECL(void) DBGFR3LineFree(PDBGFLINE pLine)
-{
-    if (pLine)
-        MMR3HeapFree(pLine);
-}
-
-
-#ifdef HAVE_DBGHELP
-
-//static BOOL CALLBACK win32EnumModulesCallback(PSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext)
-//{
-//    Log(("dbg: module: %08llx %s\n", ModuleName, BaseOfDll));
-//    return TRUE;
-//}
-
-static int win32Error(PVM pVM)
-{
-    int rc = GetLastError();
-    Log(("Lasterror=%d\n", rc));
-
-    //SymEnumerateModules64(pVM, win32EnumModulesCallback, NULL);
-
-    return VERR_GENERAL_FAILURE;
-}
-#endif
-
+}
+
Index: trunk/src/VBox/VMM/VMMR3/EMRaw.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/EMRaw.cpp	(revision 46164)
+++ trunk/src/VBox/VMM/VMMR3/EMRaw.cpp	(revision 46165)
@@ -127,9 +127,9 @@
      * Resume execution.
      */
-    CPUMR3RawEnter(pVCpu, NULL);
+    CPUMRawEnter(pVCpu, NULL);
     CPUMSetHyperEFlags(pVCpu, CPUMGetHyperEFlags(pVCpu) | X86_EFL_RF);
     rc = VMMR3ResumeHyper(pVM, pVCpu);
     Log(("emR3RawResumeHyper: cs:eip=%RTsel:%RGr efl=%RGr - returned from GC with rc=%Rrc\n", pCtx->cs.Sel, pCtx->eip, pCtx->eflags, rc));
-    rc = CPUMR3RawLeave(pVCpu, NULL, rc);
+    rc = CPUMRawLeave(pVCpu, NULL, rc);
     VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK);
 
@@ -189,5 +189,5 @@
      * We do not start time or anything, if anything we should just do a few nanoseconds.
      */
-    CPUMR3RawEnter(pVCpu, NULL);
+    CPUMRawEnter(pVCpu, NULL);
     do
     {
@@ -202,5 +202,5 @@
     } while (   rc == VINF_SUCCESS
              || rc == VINF_EM_RAW_INTERRUPT);
-    rc = CPUMR3RawLeave(pVCpu, NULL, rc);
+    rc = CPUMRawLeave(pVCpu, NULL, rc);
     VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK);
 
@@ -1393,5 +1393,5 @@
          * and perhaps EIP) needs to be stored with PATM.
          */
-        rc = CPUMR3RawEnter(pVCpu, NULL);
+        rc = CPUMRawEnter(pVCpu, NULL);
         if (rc != VINF_SUCCESS)
         {
@@ -1417,5 +1417,5 @@
                 if (rc != VINF_SUCCESS)
                 {
-                    rc = CPUMR3RawLeave(pVCpu, NULL, rc);
+                    rc = CPUMRawLeave(pVCpu, NULL, rc);
                     break;
                 }
@@ -1477,5 +1477,5 @@
          * execution FFs before doing anything else.
          */
-        rc = CPUMR3RawLeave(pVCpu, NULL, rc);
+        rc = CPUMRawLeave(pVCpu, NULL, rc);
         VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK);
         if (    VM_FF_ISPENDING(pVM, VM_FF_HIGH_PRIORITY_POST_MASK)
Index: trunk/src/VBox/VMM/VMMR3/PDMLdr.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/PDMLdr.cpp	(revision 46164)
+++ trunk/src/VBox/VMM/VMMR3/PDMLdr.cpp	(revision 46165)
@@ -216,6 +216,4 @@
                                        pdmR3GetImportRC, &Args);
                 AssertFatalMsgRC(rc, ("RTLdrRelocate failed, rc=%d\n", rc));
-                DBGFR3ModuleRelocate(pUVM->pVM, pCur->OldImageBase, pCur->ImageBase, RTLdrSize(pCur->hLdrMod),
-                                     pCur->szFilename, pCur->szName);
             }
         }
