Index: /trunk/include/VBox/HostServices/GuestPropertySvc.h
===================================================================
--- /trunk/include/VBox/HostServices/GuestPropertySvc.h	(revision 75494)
+++ /trunk/include/VBox/HostServices/GuestPropertySvc.h	(revision 75495)
@@ -243,7 +243,4 @@
  * parameter for the flags. */
 #define GUEST_PROP_FN_HOST_SET_GLOBAL_FLAGS 7
-/** Return the pointer to a debug info function enumerating all guest
- * properties. */
-#define GUEST_PROP_FN_HOST_GET_DBGF_INFO    8
 /** @} */
 
Index: /trunk/include/VBox/hgcmsvc.h
===================================================================
--- /trunk/include/VBox/hgcmsvc.h	(revision 75494)
+++ /trunk/include/VBox/hgcmsvc.h	(revision 75495)
@@ -28,8 +28,11 @@
 
 #include <iprt/assert.h>
+#include <iprt/stdarg.h>
 #include <iprt/string.h>
 #include <VBox/cdefs.h>
 #include <VBox/types.h>
 #include <VBox/err.h>
+#include <VBox/vmm/stam.h>
+#include <VBox/vmm/dbgf.h>
 #ifdef VBOX_TEST_HGCM_PARMS
 # include <iprt/test.h>
@@ -91,7 +94,75 @@
     DECLR3CALLBACKMEMBER(bool, pfnIsCallRestored, (VBOXHGCMCALLHANDLE callHandle));
 
+    /** Access to STAMR3RegisterV. */
+    DECLR3CALLBACKMEMBER(int, pfnStamRegisterV,(void *pvInstance, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
+                                                STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list va)
+                                                RT_IPRT_FORMAT_ATTR(7, 0));
+    /** Access to STAMR3DeregisterV. */
+    DECLR3CALLBACKMEMBER(int, pfnStamDeregisterV,(void *pvInstance, const char *pszPatFmt, va_list va) RT_IPRT_FORMAT_ATTR(2, 0));
+
+    /** Access to DBGFR3InfoRegisterExternal. */
+    DECLR3CALLBACKMEMBER(int, pfnInfoRegister,(void *pvInstance, const char *pszName, const char *pszDesc,
+                                               PFNDBGFHANDLEREXT pfnHandler, void *pvUser));
+    /** Access to DBGFR3InfoDeregisterExternal. */
+    DECLR3CALLBACKMEMBER(int, pfnInfoDeregister,(void *pvInstance, const char *pszName));
+
 } VBOXHGCMSVCHELPERS;
 
 typedef VBOXHGCMSVCHELPERS *PVBOXHGCMSVCHELPERS;
+
+#if defined(IN_RING3) || defined(IN_SLICKEDIT)
+
+/** Wrapper around STAMR3RegisterF. */
+DECLINLINE(int) RT_IPRT_FORMAT_ATTR(7, 8)
+HGCMSvcHlpStamRegister(PVBOXHGCMSVCHELPERS pHlp, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
+                       STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...)
+{
+    int rc;
+    va_list va;
+    va_start(va, pszName);
+    rc = pHlp->pfnStamRegisterV(pHlp->pvInstance, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
+    va_end(va);
+    return rc;
+}
+
+/** Wrapper around STAMR3RegisterV. */
+DECLINLINE(int) RT_IPRT_FORMAT_ATTR(7, 0)
+HGCMSvcHlpStamRegisterV(PVBOXHGCMSVCHELPERS pHlp, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
+                        STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list va)
+{
+    return pHlp->pfnStamRegisterV(pHlp->pvInstance, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
+}
+
+/** Wrapper around STAMR3DeregisterF. */
+DECLINLINE(int) RT_IPRT_FORMAT_ATTR(2, 3) HGCMSvcHlpStamDeregister(PVBOXHGCMSVCHELPERS pHlp, const char *pszPatFmt, ...)
+{
+    int rc;
+    va_list va;
+    va_start(va, pszPatFmt);
+    rc = pHlp->pfnStamDeregisterV(pHlp->pvInstance, pszPatFmt, va);
+    va_end(va);
+    return rc;
+}
+
+/** Wrapper around STAMR3DeregisterV. */
+DECLINLINE(int) RT_IPRT_FORMAT_ATTR(2, 0) HGCMSvcHlpStamDeregisterV(PVBOXHGCMSVCHELPERS pHlp, const char *pszPatFmt, va_list va)
+{
+    return pHlp->pfnStamDeregisterV(pHlp->pvInstance, pszPatFmt, va);
+}
+
+/** Wrapper around DBGFR3InfoRegisterExternal. */
+DECLINLINE(int) HGCMSvcHlpInfoRegister(PVBOXHGCMSVCHELPERS pHlp, const char *pszName, const char *pszDesc,
+                                       PFNDBGFHANDLEREXT pfnHandler, void *pvUser)
+{
+    return pHlp->pfnInfoRegister(pHlp->pvInstance, pszName, pszDesc, pfnHandler, pvUser);
+}
+
+/** Wrapper around DBGFR3InfoDeregisterExternal. */
+DECLINLINE(int) HGCMSvcHlpInfoDeregister(PVBOXHGCMSVCHELPERS pHlp, const char *pszName)
+{
+    return pHlp->pfnInfoDeregister(pHlp->pvInstance, pszName);
+}
+
+#endif /* IN_RING3 */
 
 
Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp	(revision 75494)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp	(revision 75495)
@@ -20,4 +20,5 @@
 *   Header Files                                                                                                                 *
 *********************************************************************************************************************************/
+# define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
 #include "VBoxTray.h"
 #include "VBoxHelpers.h"
@@ -29,8 +30,4 @@
 #include <strsafe.h>
 
-#ifdef DEBUG /** @todo r=bird: these are all default values. sigh. */
-# define LOG_ENABLED
-# define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
-#endif
 #include <VBox/log.h>
 
Index: /trunk/src/VBox/Main/include/ConsoleImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 75494)
+++ /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 75495)
@@ -735,5 +735,5 @@
                         bool fAttachDetach, bool fIgnoreConnectFailure);
     int i_configSerialPort(PCFGMNODE pInst, PortMode_T ePortMode, const char *pszPath, bool fServer);
-    static DECLCALLBACK(int) i_configGuestProperties(void *pvConsole, PUVM pUVM);
+    static DECLCALLBACK(int) i_configGuestProperties(void *pvConsole);
     static DECLCALLBACK(int) i_configGuestControl(void *pvConsole);
     static DECLCALLBACK(void) i_vmstateChangeCallback(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
Index: /trunk/src/VBox/Main/include/HGCM.h
===================================================================
--- /trunk/src/VBox/Main/include/HGCM.h	(revision 75494)
+++ /trunk/src/VBox/Main/include/HGCM.h	(revision 75495)
@@ -39,5 +39,5 @@
 int HGCMHostReset (void);
 
-int HGCMHostLoad (const char *pszServiceLibrary, const char *pszServiceName);
+int HGCMHostLoad (const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM);
 
 int HGCMHostRegisterServiceExtension (HGCMSVCEXTHANDLE *pHandle, const char *pszServiceName, PFNHGCMSVCEXT pfnExtension, void *pvExtension);
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 75494)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 75495)
@@ -8218,5 +8218,4 @@
         alock.release();
 
-        DBGFR3InfoDeregisterExternal(pUVM, "guestprops"); /* will crash in unloaded code if we guru later */
         m_pVMMDev->hgcmShutdown();
 
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 75494)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 75495)
@@ -3192,6 +3192,6 @@
          * Guest property service.
          */
-        rc = i_configGuestProperties(this, pUVM);
-#endif /* VBOX_WITH_GUEST_PROPS defined */
+        rc = i_configGuestProperties(this);
+#endif
 
 #ifdef VBOX_WITH_GUEST_CONTROL
@@ -3200,5 +3200,5 @@
          */
         rc = i_configGuestControl(this);
-#endif /* VBOX_WITH_GUEST_CONTROL defined */
+#endif
 
         /*
@@ -6091,5 +6091,5 @@
  * the machine XML and set a couple of initial properties.
  */
-/* static */ int Console::i_configGuestProperties(void *pvConsole, PUVM pUVM)
+/* static */ int Console::i_configGuestProperties(void *pvConsole)
 {
 #ifdef VBOX_WITH_GUEST_PROPS
@@ -6115,15 +6115,4 @@
          * change.
          */
-
-        {
-            VBOXHGCMSVCPARM Params[2];
-            int rc2 = pConsole->m_pVMMDev->hgcmHostCall("VBoxGuestPropSvc", GUEST_PROP_FN_HOST_GET_DBGF_INFO, 2, &Params[0]);
-            if (RT_SUCCESS(rc2))
-            {
-                PFNDBGFHANDLEREXT pfnHandler = (PFNDBGFHANDLEREXT)(uintptr_t)Params[0].u.pointer.addr;
-                void *pvService = Params[1].u.pointer.addr;
-                DBGFR3InfoRegisterExternal(pUVM, "guestprops", "Display the guest properties", pfnHandler, pvService);
-            }
-        }
 
         /* Sysprep execution by VBoxService. */
Index: /trunk/src/VBox/Main/src-client/HGCM.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/HGCM.cpp	(revision 75494)
+++ /trunk/src/VBox/Main/src-client/HGCM.cpp	(revision 75495)
@@ -25,4 +25,5 @@
 #include <VBox/hgcmsvc.h>
 #include <VBox/vmm/ssm.h>
+#include <VBox/vmm/stam.h>
 #include <VBox/sup.h>
 
@@ -115,4 +116,11 @@
         HGCMSVCEXTHANDLE m_hExtension;
 
+        PUVM m_pUVM;
+
+        /** @name Statistics
+         * @{ */
+        STAMPROFILE m_StatHandleMsg;
+        /** @} */
+
         int loadServiceDLL(void);
         void unloadServiceDLL(void);
@@ -121,5 +129,5 @@
          * Main HGCM thread methods.
          */
-        int instanceCreate(const char *pszServiceLibrary, const char *pszServiceName);
+        int instanceCreate(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM);
         void instanceDestroy(void);
 
@@ -133,4 +141,11 @@
         static DECLCALLBACK(void) svcHlpDisconnectClient(void *pvInstance, uint32_t u32ClientId);
         static DECLCALLBACK(bool) svcHlpIsCallRestored(VBOXHGCMCALLHANDLE callHandle);
+        static DECLCALLBACK(int)  svcHlpStamRegisterV(void *pvInstance, void *pvSample, STAMTYPE enmType,
+                                                      STAMVISIBILITY enmVisibility, STAMUNIT enmUnit, const char *pszDesc,
+                                                      const char *pszName, va_list va);
+        static DECLCALLBACK(int)  svcHlpStamDeregisterV(void *pvInstance, const char *pszPatFmt, va_list va);
+        static DECLCALLBACK(int)  svcHlpInfoRegister(void *pvInstance, const char *pszName, const char *pszDesc,
+                                                     PFNDBGFHANDLEREXT pfnHandler, void *pvUser);
+        static DECLCALLBACK(int)  svcHlpInfoDeregister(void *pvInstance, const char *pszName);
 
     public:
@@ -139,5 +154,5 @@
          * Main HGCM thread methods.
          */
-        static int LoadService(const char *pszServiceLibrary, const char *pszServiceName);
+        static int LoadService(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM);
         void UnloadService(void);
 
@@ -243,5 +258,6 @@
     m_cHandleAcquires (0),
 #endif
-    m_hExtension (NULL)
+    m_hExtension (NULL),
+    m_pUVM       (NULL)
 {
     RT_ZERO(m_fntable);
@@ -380,4 +396,9 @@
 class HGCMMsgSvcLoad: public HGCMMsgCore
 {
+    public:
+        HGCMMsgSvcLoad() : HGCMMsgCore(), pUVM() {}
+
+        /** The user mode VM handle (for statistics and such). */
+        PUVM pUVM;
 };
 
@@ -525,4 +546,6 @@
         }
 
+        STAM_REL_PROFILE_START(&pSvc->m_StatHandleMsg, a);
+
         /* Cache required information to avoid unnecessary pMsgCore access. */
         uint32_t u32MsgId = pMsgCore->MsgId();
@@ -753,4 +776,5 @@
             hgcmMsgComplete (pMsgCore, rc);
         }
+        STAM_REL_PROFILE_STOP(&pSvc->m_StatHandleMsg, a);
     }
 }
@@ -807,4 +831,52 @@
 }
 
+/**
+ * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnStamRegisterV}
+ */
+/* static */ DECLCALLBACK(int)
+HGCMService::svcHlpStamRegisterV(void *pvInstance, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
+                                 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list va)
+{
+     HGCMService *pService = static_cast <HGCMService *>(pvInstance);
+     AssertPtrReturn(pService, VERR_INVALID_PARAMETER);
+
+     return STAMR3RegisterVU(pService->m_pUVM, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
+}
+
+/**
+ * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnStamDeregisterV}
+ */
+/* static */ DECLCALLBACK(int) HGCMService::svcHlpStamDeregisterV(void *pvInstance, const char *pszPatFmt, va_list va)
+{
+     HGCMService *pService = static_cast <HGCMService *>(pvInstance);
+     AssertPtrReturn(pService, VERR_INVALID_PARAMETER);
+
+     return STAMR3DeregisterV(pService->m_pUVM, pszPatFmt, va);
+}
+
+/**
+ * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnInfoRegister}
+ */
+/* static */ DECLCALLBACK(int) HGCMService::svcHlpInfoRegister(void *pvInstance, const char *pszName, const char *pszDesc,
+                                                               PFNDBGFHANDLEREXT pfnHandler, void *pvUser)
+{
+     HGCMService *pService = static_cast <HGCMService *>(pvInstance);
+     AssertPtrReturn(pService, VERR_INVALID_PARAMETER);
+
+     return DBGFR3InfoRegisterExternal(pService->m_pUVM, pszName, pszDesc, pfnHandler, pvUser);
+}
+
+/**
+ * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnInfoDeregister}
+ */
+/* static */ DECLCALLBACK(int) HGCMService::svcHlpInfoDeregister(void *pvInstance, const char *pszName)
+{
+     HGCMService *pService = static_cast <HGCMService *>(pvInstance);
+     AssertPtrReturn(pService, VERR_INVALID_PARAMETER);
+
+     return DBGFR3InfoDeregisterExternal(pService->m_pUVM, pszName);
+}
+
+
 static DECLCALLBACK(void) hgcmMsgCompletionCallback(int32_t result, HGCMMsgCore *pMsgCore)
 {
@@ -824,8 +896,7 @@
  */
 
-int HGCMService::instanceCreate(const char *pszServiceLibrary, const char *pszServiceName)
+int HGCMService::instanceCreate(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM)
 {
     LogFlowFunc(("name %s, lib %s\n", pszServiceName, pszServiceLibrary));
-
     /* The maximum length of the thread name, allowed by the RT is 15. */
     char szThreadName[16];
@@ -856,4 +927,9 @@
         else
         {
+            /* Register statistics: */
+            m_pUVM = pUVM;
+            STAMR3RegisterFU(pUVM, &m_StatHandleMsg, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,
+                             "Message handling", "/HGCM/%s/Msg", pszServiceName);
+
             /* Initialize service helpers table. */
             m_svcHelpers.pfnCallComplete     = svcHlpCallComplete;
@@ -861,4 +937,8 @@
             m_svcHelpers.pfnDisconnectClient = svcHlpDisconnectClient;
             m_svcHelpers.pfnIsCallRestored   = svcHlpIsCallRestored;
+            m_svcHelpers.pfnStamRegisterV    = svcHlpStamRegisterV;
+            m_svcHelpers.pfnStamDeregisterV  = svcHlpStamDeregisterV;
+            m_svcHelpers.pfnInfoRegister     = svcHlpInfoRegister;
+            m_svcHelpers.pfnInfoDeregister   = svcHlpInfoDeregister;
 
             /* Execute the load request on the service thread. */
@@ -868,4 +948,9 @@
             if (RT_SUCCESS(rc))
             {
+                HGCMMsgSvcLoad *pMsg = (HGCMMsgSvcLoad *)hgcmObjReference(hMsg, HGCMOBJ_MSG);
+                AssertRelease(pMsg);
+                pMsg->pUVM = pUVM;
+                hgcmObjDereference(pMsg);
+
                 rc = hgcmMsgSend(hMsg);
             }
@@ -899,4 +984,8 @@
     }
 
+    if (m_pszSvcName)
+        STAMR3DeregisterF(m_pUVM, "/HGCM/%s/*", m_pszSvcName);
+    m_pUVM = NULL;
+
     RTStrFree(m_pszSvcLibrary);
     m_pszSvcLibrary = NULL;
@@ -960,10 +1049,11 @@
  * @param pszServiceLibrary  The library to be loaded.
  * @param pszServiceName     The name of the service.
+ * @param pUVM               The user mode VM handle (for statistics and such).
  * @return VBox rc.
  * @thread main HGCM
  */
-/* static */ int HGCMService::LoadService(const char *pszServiceLibrary, const char *pszServiceName)
-{
-    LogFlowFunc(("lib %s, name = %s\n", pszServiceLibrary, pszServiceName));
+/* static */ int HGCMService::LoadService(const char *pszServiceLibrary, const char *pszServiceName, PUVM pUVM)
+{
+    LogFlowFunc(("lib %s, name = %s, pUVM = %p\n", pszServiceLibrary, pszServiceName, pUVM));
 
     /* Look at already loaded services to avoid double loading. */
@@ -981,5 +1071,5 @@
     {
         /* Create the new service. */
-        pSvc = new HGCMService();
+        pSvc = new (std::nothrow) HGCMService();
 
         if (!pSvc)
@@ -990,5 +1080,5 @@
         {
             /* Load the library and call the initialization entry point. */
-            rc = pSvc->instanceCreate(pszServiceLibrary, pszServiceName);
+            rc = pSvc->instanceCreate(pszServiceLibrary, pszServiceName, pUVM);
 
             if (RT_SUCCESS(rc))
@@ -1744,4 +1834,6 @@
         /* Name to be assigned to the service. */
         const char *pszServiceName;
+        /** The user mode VM handle (for statistics and such). */
+        PUVM pUVM;
 };
 
@@ -1916,8 +2008,8 @@
                 HGCMMsgMainLoad *pMsg = (HGCMMsgMainLoad *)pMsgCore;
 
-                LogFlowFunc(("HGCM_MSG_LOAD pszServiceName = %s, pMsg->pszServiceLibrary = %s\n",
-                             pMsg->pszServiceName, pMsg->pszServiceLibrary));
-
-                rc = HGCMService::LoadService(pMsg->pszServiceLibrary, pMsg->pszServiceName);
+                LogFlowFunc(("HGCM_MSG_LOAD pszServiceName = %s, pMsg->pszServiceLibrary = %s, pMsg->pUVM = %p\n",
+                             pMsg->pszServiceName, pMsg->pszServiceLibrary, pMsg->pUVM));
+
+                rc = HGCMService::LoadService(pMsg->pszServiceLibrary, pMsg->pszServiceName, pMsg->pUVM);
             } break;
 
@@ -2109,8 +2201,10 @@
  * @param pszServiceLibrary  The library to be loaded.
  * @param pszServiceName     The name to be assigned to the service.
+ * @param pUVM               The user mode VM handle (for statistics and such).
  * @return VBox rc.
  */
 int HGCMHostLoad(const char *pszServiceLibrary,
-                 const char *pszServiceName)
+                 const char *pszServiceName,
+                 PUVM pUVM)
 {
     LogFlowFunc(("lib = %s, name = %s\n", pszServiceLibrary, pszServiceName));
@@ -2134,4 +2228,5 @@
         pMsg->pszServiceLibrary = pszServiceLibrary;
         pMsg->pszServiceName    = pszServiceName;
+        pMsg->pUVM              = pUVM;
 
         hgcmObjDereference(pMsg);
Index: /trunk/src/VBox/Main/src-client/VMMDevInterface.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/VMMDevInterface.cpp	(revision 75494)
+++ /trunk/src/VBox/Main/src-client/VMMDevInterface.cpp	(revision 75495)
@@ -98,10 +98,4 @@
     {
         ASMAtomicWriteBool(&m_fHGCMActive, false);
-        if (mParent)
-        {
-            Console::SafeVMPtrQuiet ptrVM(mParent);
-            if (ptrVM.rawUVM())
-                DBGFR3InfoDeregisterExternal(ptrVM.rawUVM(), "guestprops"); /* will crash in unloaded code if we guru later */
-        }
         HGCMHostShutdown();
     }
@@ -701,5 +695,6 @@
         return VERR_INVALID_STATE;
 
-    return HGCMHostLoad(pszServiceLibrary, pszServiceName);
+    Console::SafeVMPtrQuiet ptrVM(mParent);
+    return HGCMHostLoad(pszServiceLibrary, pszServiceName, ptrVM.rawUVM());
 }
 
Index: /trunk/src/VBox/VMM/VMMR3/VMMR3.def
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/VMMR3.def	(revision 75494)
+++ /trunk/src/VBox/VMM/VMMR3/VMMR3.def	(revision 75495)
@@ -361,4 +361,8 @@
     STAMR3SnapshotFree
     STAMR3GetUnit
+    STAMR3RegisterFU
+    STAMR3RegisterVU
+    STAMR3DeregisterF
+    STAMR3DeregisterV
 
     TMR3TimerSetCritSect
