Index: trunk/src/VBox/Frontends/VBoxBFE/MachineDebuggerImpl.cpp
===================================================================
--- trunk/src/VBox/Frontends/VBoxBFE/MachineDebuggerImpl.cpp	(revision 38318)
+++ trunk/src/VBox/Frontends/VBoxBFE/MachineDebuggerImpl.cpp	(revision 38324)
@@ -128,16 +128,9 @@
     }
     if (!gpVM)
-    {
         return E_FAIL;
-    }
-
-    EMRAWMODE rawModeFlag = enable ? EMRAW_RING3_DISABLE : EMRAW_RING3_ENABLE;
-    int rcVBox = VMR3ReqCallWait(gpVM, VMCPUID_ANY, (PFNRT)EMR3RawSetMode, 2, gpVM, rawModeFlag);
-    if (RT_SUCCESS(rcVBox))
-        return S_OK;
-
-    AssertMsgFailed(("Could not set raw mode flags to %d, rcVBox = %Rrc\n",
-                     rawModeFlag, rcVBox));
-    return E_FAIL;
+
+    int rcVBox = EMR3SetExecutionPolicy(gpVM, EMEXECPOLICY_RECOMPILE_RING3, enable);
+    AssertRCReturn(rcVBox, E_FAIL);
+    return S_OK;
 }
 
@@ -180,16 +173,9 @@
     }
     if (!gpVM)
-    {
         return E_FAIL;
-    }
-
-    EMRAWMODE rawModeFlag = enable ? EMRAW_RING0_DISABLE : EMRAW_RING0_ENABLE;
-    int rcVBox = VMR3ReqCallWait(gpVM, VMCPUID_ANY, (PFNRT)EMR3RawSetMode, 2, gpVM, rawModeFlag);
-    if (RT_SUCCESS(rcVBox))
-        return S_OK;
-
-    AssertMsgFailed(("Could not set raw mode flags to %d, rcVBox = %Rrc\n",
-                     rawModeFlag, rcVBox));
-    return E_FAIL;
+
+    int rcVBox = EMR3SetExecutionPolicy(gpVM, EMEXECPOLICY_RECOMPILE_RING0, enable);
+    AssertRCReturn(rcVBox, E_FAIL);
+    return S_OK;
 }
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 38318)
+++ trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 38324)
@@ -277,4 +277,8 @@
     , mMediaEnumThread (NULL)
     , mIsKWinManaged (false)
+    , mDisablePatm(false)
+    , mDisableCsam(false)
+    , mRecompileSupervisor(false)
+    , mRecompileUser(false)
     , mVerString ("1.0")
 {
@@ -5124,9 +5128,17 @@
             mShowStartVMErrors = false;
         }
+        else if (!::strcmp(arg, "--disable-patm"))
+            mDisablePatm = true;
+        else if (!::strcmp(arg, "--disable-csam"))
+            mDisableCsam = true;
+        else if (!::strcmp(arg, "--recompile-supervisor"))
+            mRecompileSupervisor = true;
+        else if (!::strcmp(arg, "--recompile-user"))
+            mRecompileUser = true;
+        else if (!::strcmp(arg, "--recompile-all"))
+            mDisablePatm = mDisableCsam = mRecompileSupervisor = mRecompileUser = true;
 #ifdef VBOX_WITH_DEBUGGER_GUI
         else if (!::strcmp (arg, "-dbg") || !::strcmp (arg, "--dbg"))
-        {
             setDebuggerVar(&mDbgEnabled, true);
-        }
         else if (!::strcmp( arg, "-debug") || !::strcmp (arg, "--debug"))
         {
@@ -5160,11 +5172,7 @@
         /* Not quite debug options, but they're only useful with the debugger bits. */
         else if (!::strcmp (arg, "--start-paused"))
-        {
             mStartPaused = true;
-        }
         else if (!::strcmp (arg, "--start-running"))
-        {
             mStartPaused = false;
-        }
 #endif
         /** @todo add an else { msgbox(syntax error); exit(1); } here, pretty please... */
Index: trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 38318)
+++ trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 38324)
@@ -178,4 +178,9 @@
     const QRect availableGeometry(int iScreen = 0) const;
 
+    bool isPatmDisabled() const { return mDisablePatm; }
+    bool isCsamDisabled() const { return mDisableCsam; }
+    bool isSupervisorCodeExecedRecompiled() const { return mRecompileSupervisor; }
+    bool isUserCodeExecedRecompiled()       const { return mRecompileUser; }
+
 #ifdef VBOX_WITH_DEBUGGER_GUI
     bool isDebuggerEnabled(CMachine &aMachine);
@@ -821,4 +826,13 @@
     bool mIsKWinManaged;
 
+    /** The --disable-patm option. */
+    bool mDisablePatm;
+    /** The --disable-csam option. */
+    bool mDisableCsam;
+    /** The --recompile-supervisor option. */
+    bool mRecompileSupervisor;
+    /** The --recompile-user option. */
+    bool mRecompileUser;
+
 #ifdef VBOX_WITH_DEBUGGER_GUI
     /** Whether the debugger should be accessible or not.
Index: trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/main.cpp	(revision 38318)
+++ trunk/src/VBox/Frontends/VirtualBox/src/main.cpp	(revision 38324)
@@ -170,6 +170,6 @@
     char szInfo[64];
     int rc = RTSystemQueryOSInfo (RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo));
-    if (RT_SUCCESS (rc) &&
-        szInfo[0] == '1') /* higher than 1x.x.x */
+    if (   RT_SUCCESS (rc)
+        && szInfo[0] == '1') /* higher than 1x.x.x */
     {
         /*
@@ -272,4 +272,15 @@
             "  --start-running            start the VM running (for overriding --debug*)\n"
             "\n"
+# endif
+            "Expert options:\n"
+            "  --disable-patm             disable code patching (ignored by AMD-V/VT-x)\n"
+            "  --disable-csam             disable code scanning (ignored by AMD-V/VT-x)\n"
+            "  --recompile-supervisor     recompiled execution of supervisor code (*)\n"
+            "  --recompile-user           recompiled execution of user code (*)\n"
+            "  --recompile-all            recompiled execution of all code, with disabled\n"
+            "                             code patching and scanning\n"
+            "  (*) For AMD-V/VT-x setups the effect is --recompile-all.\n"
+            "\n"
+# ifdef VBOX_WITH_DEBUGGER_GUI
             "The following environment variables are evaluated:\n"
             "  VBOX_GUI_DBG_ENABLED       enable the GUI debug menu if set\n"
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp	(revision 38318)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp	(revision 38324)
@@ -203,4 +203,18 @@
     CConsole console = session().GetConsole();
 
+    /* Apply debug settings from the command line. */
+    CMachineDebugger debugger = console.GetDebugger();
+    if (debugger.isOk())
+    {
+        if (vboxGlobal().isPatmDisabled())
+            debugger.SetPATMEnabled(false);
+        if (vboxGlobal().isCsamDisabled())
+            debugger.SetCSAMEnabled(false);
+        if (vboxGlobal().isSupervisorCodeExecedRecompiled())
+            debugger.SetRecompileSupervisor(true);
+        if (vboxGlobal().isUserCodeExecedRecompiled())
+            debugger.SetRecompileUser(true);
+    }
+
     /* Power UP machine: */
     CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled(machine) ?
@@ -290,6 +304,6 @@
             return;
         }
-        else
-            setPause(false);
+
+        setPause(false);
     }
 
