Index: /trunk/include/VBox/vmm/pdmdrv.h
===================================================================
--- /trunk/include/VBox/vmm/pdmdrv.h	(revision 88304)
+++ /trunk/include/VBox/vmm/pdmdrv.h	(revision 88305)
@@ -1038,5 +1038,7 @@
      * @param   enmType     Sample type. This indicates what pvSample is pointing at.
      * @param   pszName     Sample name. The name is on this form "/<component>/<sample>".
-     *                      Further nesting is possible.
+     *                      Further nesting is possible.  If this does not start
+     *                      with a '/', the default prefix will be prepended,
+     *                      otherwise it will be used as-is.
      * @param   enmUnit     Sample unit.
      * @param   pszDesc     Sample description.
@@ -1055,5 +1057,7 @@
      * @param   enmUnit     Sample unit.
      * @param   pszDesc     Sample description.
-     * @param   pszName     The sample name format string.
+     * @param   pszName     The sample name format string.  If this does not start
+     *                      with a '/', the default prefix will be prepended,
+     *                      otherwise it will be used as-is.
      * @param   ...         Arguments to the format string.
      */
@@ -1072,5 +1076,7 @@
      * @param   enmUnit         Sample unit.
      * @param   pszDesc         Sample description.
-     * @param   pszName         The sample name format string.
+     * @param   pszName         The sample name format string.  If this does not
+     *                          start with a '/', the default prefix will be prepended,
+     *                          otherwise it will be used as-is.
      * @param   args            Arguments to the format string.
      */
Index: /trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp	(revision 88304)
+++ /trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp	(revision 88305)
@@ -1442,10 +1442,46 @@
 {
     PDMDRV_ASSERT_DRVINS(pDrvIns);
-    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
-
-    STAM_REG(pDrvIns->Internal.s.pVMR3, pvSample, enmType, pszName, enmUnit, pszDesc);
-    RT_NOREF6(pDrvIns, pvSample, enmType, pszName, enmUnit, pszDesc);
-    /** @todo track the samples so they can be dumped & deregistered when the driver instance is destroyed.
-     * For now we just have to be careful not to use this call for drivers which can be unloaded. */
+    PVM pVM = pDrvIns->Internal.s.pVMR3;
+    VM_ASSERT_EMT(pVM);
+
+#ifdef VBOX_WITH_STATISTICS /** @todo rework this to always be compiled in */
+    if (*pszName == '/')
+        STAM_REG(pDrvIns->Internal.s.pVMR3, pvSample, enmType, pszName, enmUnit, pszDesc);
+    else
+        STAMR3RegisterF(pVM, pvSample, enmType, STAMVISIBILITY_ALWAYS, enmUnit, pszDesc,
+                        "/Drivers/%s-%u/%s", pDrvIns->pReg->szName, pDrvIns->iInstance, pszName);
+#else
+    RT_NOREF(pDrvIns, pvSample, enmType, pszName, enmUnit, pszDesc, pVM);
+#endif
+}
+
+
+/** @interface_method_impl{PDMDRVHLPR3,pfnSTAMRegisterV} */
+static DECLCALLBACK(void) pdmR3DrvHlp_STAMRegisterV(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
+                                                    STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args)
+{
+    PDMDRV_ASSERT_DRVINS(pDrvIns);
+    PVM pVM = pDrvIns->Internal.s.pVMR3;
+    VM_ASSERT_EMT(pVM);
+
+    int rc;
+    if (*pszName == '/')
+        rc = STAMR3RegisterV(pVM, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
+    else
+    {
+        /* We need to format it to check whether it starts with a
+           slash or not (will rework this later). */
+        char szFormatted[2048];
+        ssize_t cchBase = RTStrPrintf2(szFormatted, sizeof(szFormatted) - 1024, "/Drivers/%s-%u/",
+                                       pDrvIns->pReg->szName, pDrvIns->iInstance);
+        AssertReturnVoid(cchBase > 0);
+
+        ssize_t cch2 = RTStrPrintf2V(&szFormatted[cchBase], sizeof(szFormatted) - cchBase, pszName, args);
+        AssertReturnVoid(cch2 > 0);
+
+        rc = STAMR3Register(pVM, pvSample, enmType, enmVisibility,
+                            &szFormatted[szFormatted[cchBase] == '/' ? cchBase : 0], enmUnit, pszDesc);
+    }
+    AssertRC(rc);
 }
 
@@ -1455,24 +1491,8 @@
                                                     STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...)
 {
-    PDMDRV_ASSERT_DRVINS(pDrvIns);
-    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
-
-    va_list args;
-    va_start(args, pszName);
-    int rc = STAMR3RegisterV(pDrvIns->Internal.s.pVMR3, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
-    va_end(args);
-    AssertRC(rc);
-}
-
-
-/** @interface_method_impl{PDMDRVHLPR3,pfnSTAMRegisterV} */
-static DECLCALLBACK(void) pdmR3DrvHlp_STAMRegisterV(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
-                                                    STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args)
-{
-    PDMDRV_ASSERT_DRVINS(pDrvIns);
-    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
-
-    int rc = STAMR3RegisterV(pDrvIns->Internal.s.pVMR3, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
-    AssertRC(rc);
+    va_list va;
+    va_start(va, pszName);
+    pdmR3DrvHlp_STAMRegisterV(pDrvIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
+    va_end(va);
 }
 
