Index: trunk/src/VBox/Debugger/VBoxDbg.cpp
===================================================================
--- trunk/src/VBox/Debugger/VBoxDbg.cpp	(revision 12461)
+++ trunk/src/VBox/Debugger/VBoxDbg.cpp	(revision 12462)
@@ -68,16 +68,18 @@
 
 
-
-/**
- * Creates the debugger GUI.
- *
- * @returns VBox status code.
- * @param   pSession    The Virtual Box session.
- * @param   ppGui       Where to store the pointer to the debugger instance.
- * @param   ppGuiVT     Where to store the virtual method table pointer.
- *                      Optional.
- */
-DBGDECL(int) DBGGuiCreate(ISession *pSession, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT)
-{
+/**
+ * Internal worker for DBGGuiCreate and DBGGuiCreateForVM.
+ *
+ * @returns VBox status code.
+ * @param   pSession    The ISession interface. (DBGGuiCreate)
+ * @param   pVM         The VM handle. (DBGGuiCreateForVM)
+ * @param   ppGui       See DBGGuiCreate.
+ * @param   ppGuiVT     See DBGGuiCreate.
+ */
+static int dbgGuiCreate(ISession *pSession, PVM pVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT)
+{
+    /*
+     * Allocate and initialize the Debugger GUI handle.
+     */
     PDBGGUI pGui = (PDBGGUI)RTMemAlloc(sizeof(*pGui));
     if (!pGui)
@@ -86,7 +88,14 @@
     pGui->pVBoxDbgGui = new VBoxDbgGui();
 
-    int rc = pGui->pVBoxDbgGui->init(pSession);
+    int rc;
+    if (pSession)
+        rc = pGui->pVBoxDbgGui->init(pSession);
+    else
+        rc = pGui->pVBoxDbgGui->init(pVM);
     if (VBOX_SUCCESS(rc))
     {
+        /*
+         * Successfully initialized.
+         */
         *ppGui = pGui;
         if (ppGuiVT)
@@ -95,4 +104,7 @@
     }
 
+    /*
+     * Failed, cleanup.
+     */
     delete pGui->pVBoxDbgGui;
     RTMemFree(pGui);
@@ -105,4 +117,36 @@
 
 /**
+ * Creates the debugger GUI.
+ *
+ * @returns VBox status code.
+ * @param   pSession    The Virtual Box session.
+ * @param   ppGui       Where to store the pointer to the debugger instance.
+ * @param   ppGuiVT     Where to store the virtual method table pointer.
+ *                      Optional.
+ */
+DBGDECL(int) DBGGuiCreate(ISession *pSession, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT)
+{
+    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
+    return dbgGuiCreate(pSession, NULL, ppGui, ppGuiVT);
+}
+
+
+/**
+ * Creates the debugger GUI given a VM handle.
+ *
+ * @returns VBox status code.
+ * @param   pVM         The VM handle.
+ * @param   ppGui       Where to store the pointer to the debugger instance.
+ * @param   ppGuiVT     Where to store the virtual method table pointer.
+ *                      Optional.
+ */
+DBGDECL(int) DBGGuiCreateForVM(PVM pVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT)
+{
+    AssertPtrReturn(pVM, VERR_INVALID_POINTER);
+    return dbgGuiCreate(NULL, pVM, ppGui, ppGuiVT);
+}
+
+
+/**
  * Destroys the debugger GUI.
  *
Index: trunk/src/VBox/Debugger/VBoxDbgGui.cpp
===================================================================
--- trunk/src/VBox/Debugger/VBoxDbgGui.cpp	(revision 12461)
+++ trunk/src/VBox/Debugger/VBoxDbgGui.cpp	(revision 12462)
@@ -33,5 +33,5 @@
 # include <qdesktopwidget.h>
 # include <qapplication.h>
-#endif 
+#endif
 
 
@@ -45,10 +45,19 @@
 
 
+int VBoxDbgGui::init(PVM pVM)
+{
+    /*
+     * Set the VM handle and update the desktop size.
+     */
+    m_pVM = pVM;
+    updateDesktopSize();
+
+    return VINF_SUCCESS;
+}
+
+
 int VBoxDbgGui::init(ISession *pSession)
 {
-    /*
-     * Update the desktop size first.
-     */
-    updateDesktopSize();
+    int rc = VERR_GENERAL_FAILURE;
 
     /*
@@ -74,6 +83,7 @@
                 if (SUCCEEDED(hrc))
                 {
-                    m_pVM = (PVM)(uintptr_t)ullVM;
-                    return VINF_SUCCESS;
+                    rc = init((PVM)(uintptr_t)ullVM);
+                    if (RT_SUCCESS(rc))
+                        return rc;
                 }
 
@@ -86,5 +96,5 @@
     }
 
-    return VERR_GENERAL_FAILURE;
+    return rc;
 }
 
@@ -143,5 +153,5 @@
 #else
         m_pDbgStats = new VBoxDbgStats(m_pVM);
-#endif 
+#endif
         connect(m_pDbgStats, SIGNAL(destroyed(QObject *)), this, SLOT(notifyChildDestroyed(QObject *)));
         repositionStatistics();
@@ -185,5 +195,5 @@
         if (fResize)
             /* Resize it to cover the space down to the bottom of the desktop. */
-            resizeWidget(m_pDbgConsole, m_cx, m_cyDesktop - m_cy - m_y + m_yDesktop);
+            resizeWidget(m_pDbgConsole, RT_MAX(m_cx, 32), m_cyDesktop - m_cy - m_y + m_yDesktop);
     }
 }
Index: trunk/src/VBox/Debugger/VBoxDbgGui.h
===================================================================
--- trunk/src/VBox/Debugger/VBoxDbgGui.h	(revision 12461)
+++ trunk/src/VBox/Debugger/VBoxDbgGui.h	(revision 12462)
@@ -51,5 +51,5 @@
 
     /**
-     * Initializes a VBoxDbgGui object.
+     * Initializes a VBoxDbgGui object by ISession.
      *
      * @returns VBox status code.
@@ -57,4 +57,12 @@
      */
     int init(ISession *pSession);
+
+    /**
+     * Initializes a VBoxDbgGui object by VM handle.
+     *
+     * @returns VBox status code.
+     * @param   pVM         The VM handle.
+     */
+    int init(PVM pVM);
 
     /**
Index: trunk/src/VBox/Debugger/testcase/tstVBoxDbg.cpp
===================================================================
--- trunk/src/VBox/Debugger/testcase/tstVBoxDbg.cpp	(revision 12461)
+++ trunk/src/VBox/Debugger/testcase/tstVBoxDbg.cpp	(revision 12462)
@@ -25,5 +25,5 @@
 *******************************************************************************/
 #include <qapplication.h>
-#include <VBox/dbg.h>
+#include <VBox/dbggui.h>
 #include <VBox/vm.h>
 #include <VBox/err.h>
@@ -57,6 +57,35 @@
          */
         QApplication App(argc, argv);
-//        DBGGuiCreate(pVM, true, NULL);
-        App.exec();
+        PDBGGUI pGui;
+        PCDBGGUIVT pGuiVT;
+        rc = DBGGuiCreateForVM(pVM, &pGui, &pGuiVT);
+        if (RT_SUCCESS(rc))
+        {
+            RTPrintf(TESTCASE ": calling pfnShowCommandLine...\n");
+            rc = pGuiVT->pfnShowCommandLine(pGui);
+            if (RT_FAILURE(rc))
+            {
+                RTPrintf(TESTCASE ": error: pfnShowCommandLine failed! rc=%Rrc\n", rc);
+                cErrors++;
+            }
+
+#if 0
+            RTPrintf(TESTCASE ": calling pfnShowStatistics...\n");
+            pGuiVT->pfnShowStatistics(pGui);
+            if (RT_FAILURE(rc))
+            {
+                RTPrintf(TESTCASE ": error: pfnShowStatistics failed! rc=%Rrc\n", rc);
+                cErrors++;
+            }
+#endif
+
+            RTPrintf(TESTCASE ": calling App.exec()...\n");
+            App.exec();
+        }
+        else
+        {
+            RTPrintf(TESTCASE ": error: DBGGuiCreateForVM failed! rc=%Rrc\n", rc);
+            cErrors++;
+        }
 
         /*
@@ -66,5 +95,5 @@
         if (!VBOX_SUCCESS(rc))
         {
-            RTPrintf(TESTCASE ": error: failed to destroy vm! rc=%d\n", rc);
+            RTPrintf(TESTCASE ": error: failed to destroy vm! rc=%Rrc\n", rc);
             cErrors++;
         }
@@ -72,5 +101,5 @@
     else
     {
-        RTPrintf(TESTCASE ": fatal error: failed to create vm! rc=%d\n", rc);
+        RTPrintf(TESTCASE ": fatal error: failed to create vm! rc=%Rrc\n", rc);
         cErrors++;
     }
