Index: /trunk/src/VBox/VMM/VMMAll/DBGFAllTracer.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/DBGFAllTracer.cpp	(revision 84493)
+++ /trunk/src/VBox/VMM/VMMAll/DBGFAllTracer.cpp	(revision 84494)
@@ -154,4 +154,27 @@
 }
 
+
+#ifdef IN_RING3
+/**
+ * Posts a single event descriptor to the ring buffer of the given tracer instance - R3 only variant
+ * (used for the register/deregister event source events currently).
+ *
+ * @returns VBox status code.
+ * @param   pVM                     The current context VM instance data.
+ * @param   pThisCC                 The event tracer instance current context data.
+ * @param   hEvtSrc                 The event source for the posted event.
+ * @param   enmTraceEvt             The trace event type posted.
+ * @param   pvEvtDesc               The event descriptor to copy after the header.
+ * @param   cbEvtDesc               Event descriptor size in bytes.
+ * @param   pidEvt                  Where to store the assigned event ID, optional.
+ */
+DECLHIDDEN(int) dbgfTracerR3EvtPostSingle(PVMCC pVM, PDBGFTRACERINSCC pThisCC, DBGFTRACEREVTSRC hEvtSrc,
+                                          DBGFTRACEREVT enmTraceEvt, const void *pvEvtDesc, size_t cbEvtDesc,
+                                          uint64_t *pidEvt)
+{
+    return dbgfTracerEvtPostEx(pVM, pThisCC, hEvtSrc, enmTraceEvt, DBGF_TRACER_EVT_HDR_ID_INVALID,
+                               pvEvtDesc, cbEvtDesc, pidEvt);
+}
+#endif
 
 /**
Index: /trunk/src/VBox/VMM/VMMR3/DBGFR3Tracer.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/DBGFR3Tracer.cpp	(revision 84493)
+++ /trunk/src/VBox/VMM/VMMR3/DBGFR3Tracer.cpp	(revision 84494)
@@ -55,4 +55,24 @@
 /** The event descriptors written to the trace log. */
 
+static const RTTRACELOGEVTDESC g_EvtSrcRegisterEvtDesc =
+{
+    "EvtSrc.Register",
+    "An event soruce was registered",
+    RTTRACELOGEVTSEVERITY_DEBUG,
+    0,
+    NULL
+};
+
+
+static const RTTRACELOGEVTDESC g_EvtSrcDeregisterEvtDesc =
+{
+    "EvtSrc.Deregister",
+    "An event soruce was de-registered",
+    RTTRACELOGEVTSEVERITY_DEBUG,
+    0,
+    NULL
+};
+
+
 static const RTTRACELOGEVTITEMDESC g_DevMmioMapEvtItems[] =
 {
@@ -444,9 +464,21 @@
     switch (pEvtHdr->enmEvt)
     {
+        case DBGFTRACEREVT_SRC_REGISTER:
+        {
+            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_EvtSrcRegisterEvtDesc, RTTRACELOG_WR_ADD_EVT_F_GRP_START,
+                                     pEvtHdr->hEvtSrc, 0 /*uParentGrpId*/);
+            break;
+        }
+        case DBGFTRACEREVT_SRC_DEREGISTER:
+        {
+            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_EvtSrcDeregisterEvtDesc, RTTRACELOG_WR_ADD_EVT_F_GRP_FINISH,
+                                     pEvtHdr->hEvtSrc, 0 /*uParentGrpId*/);
+            break;
+        }
         case DBGFTRACEREVT_MMIO_MAP:
         {
             PCDBGFTRACEREVTMMIOMAP pEvtMmioMap = (PCDBGFTRACEREVTMMIOMAP)(pEvtHdr + 1);
 
-            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_DevMmioMapEvtDesc, RTTRACELOG_WR_ADD_EVT_F_GRP_START | RTTRACELOG_WR_ADD_EVT_F_GRP_FINISH,
+            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_DevMmioMapEvtDesc, 0 /*fFlags*/,
                                      pEvtHdr->idEvt, pEvtHdr->hEvtSrc, pEvtMmioMap->hMmioRegion, pEvtMmioMap->GCPhysMmioBase);
             break;
@@ -456,5 +488,5 @@
             PCDBGFTRACEREVTMMIOUNMAP pEvtMmioUnmap = (PCDBGFTRACEREVTMMIOUNMAP)(pEvtHdr + 1);
 
-            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_DevMmioUnmapEvtDesc, RTTRACELOG_WR_ADD_EVT_F_GRP_START | RTTRACELOG_WR_ADD_EVT_F_GRP_FINISH,
+            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_DevMmioUnmapEvtDesc, 0 /*fFlags*/,
                                      pEvtHdr->idEvt, pEvtHdr->hEvtSrc, pEvtMmioUnmap->hMmioRegion);
             break;
@@ -469,5 +501,5 @@
                                      ? &g_DevMmioReadEvtDesc
                                      : &g_DevMmioWriteEvtDesc,
-                                     RTTRACELOG_WR_ADD_EVT_F_GRP_START | RTTRACELOG_WR_ADD_EVT_F_GRP_FINISH,
+                                     0 /*fFlags*/,
                                      pEvtHdr->idEvt, pEvtHdr->hEvtSrc, pEvtMmioRw->hMmioRegion, pEvtMmioRw->offMmio,
                                      pEvtMmioRw->cbXfer, pEvtMmioRw->u64Val);
@@ -478,6 +510,5 @@
             PCDBGFTRACEREVTMMIOFILL pEvtMmioFill = (PCDBGFTRACEREVTMMIOFILL)(pEvtHdr + 1);
 
-            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_DevMmioFillEvtDesc,
-                                     RTTRACELOG_WR_ADD_EVT_F_GRP_START | RTTRACELOG_WR_ADD_EVT_F_GRP_FINISH,
+            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_DevMmioFillEvtDesc, 0 /*fFlags*/,
                                      pEvtHdr->idEvt, pEvtHdr->hEvtSrc, pEvtMmioFill->hMmioRegion, pEvtMmioFill->offMmio,
                                      pEvtMmioFill->cbItem, pEvtMmioFill->cItems, pEvtMmioFill->u32Item);
@@ -488,5 +519,5 @@
             PCDBGFTRACEREVTIOPORTMAP pEvtIoPortMap = (PCDBGFTRACEREVTIOPORTMAP)(pEvtHdr + 1);
 
-            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_DevIoPortMapEvtDesc, RTTRACELOG_WR_ADD_EVT_F_GRP_START | RTTRACELOG_WR_ADD_EVT_F_GRP_FINISH,
+            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_DevIoPortMapEvtDesc, 0 /*fFlags*/,
                                      pEvtHdr->idEvt, pEvtHdr->hEvtSrc, pEvtIoPortMap->hIoPorts, pEvtIoPortMap->IoPortBase);
             break;
@@ -496,5 +527,5 @@
             PCDBGFTRACEREVTIOPORTUNMAP pEvtIoPortUnmap = (PCDBGFTRACEREVTIOPORTUNMAP)(pEvtHdr + 1);
 
-            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_DevIoPortUnmapEvtDesc, RTTRACELOG_WR_ADD_EVT_F_GRP_START | RTTRACELOG_WR_ADD_EVT_F_GRP_FINISH,
+            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_DevIoPortUnmapEvtDesc, 0 /*fFlags*/,
                                      pEvtHdr->idEvt, pEvtHdr->hEvtSrc, pEvtIoPortUnmap->hIoPorts);
             break;
@@ -509,5 +540,5 @@
                                      ? &g_DevIoPortReadEvtDesc
                                      : &g_DevIoPortWriteEvtDesc,
-                                     RTTRACELOG_WR_ADD_EVT_F_GRP_START | RTTRACELOG_WR_ADD_EVT_F_GRP_FINISH,
+                                     0 /*fFlags*/,
                                      pEvtHdr->idEvt, pEvtHdr->hEvtSrc, pEvtIoPortRw->hIoPorts, pEvtIoPortRw->offPort,
                                      pEvtIoPortRw->cbXfer, pEvtIoPortRw->u32Val);
@@ -518,7 +549,5 @@
             PCDBGFTRACEREVTIRQ pEvtIrq = (PCDBGFTRACEREVTIRQ)(pEvtHdr + 1);
 
-            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog,
-                                     &g_DevIrqEvtDesc,
-                                     RTTRACELOG_WR_ADD_EVT_F_GRP_START | RTTRACELOG_WR_ADD_EVT_F_GRP_FINISH,
+            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_DevIrqEvtDesc, 0 /*fFlags*/,
                                      pEvtHdr->idEvt, pEvtHdr->hEvtSrc, pEvtIrq->iIrq, pEvtIrq->fIrqLvl);
             break;
@@ -528,7 +557,5 @@
             PCDBGFTRACEREVTIOAPICMSI pEvtIoApicMsi = (PCDBGFTRACEREVTIOAPICMSI)(pEvtHdr + 1);
 
-            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog,
-                                     &g_DevIrqEvtDesc,
-                                     RTTRACELOG_WR_ADD_EVT_F_GRP_START | RTTRACELOG_WR_ADD_EVT_F_GRP_FINISH,
+            rc = RTTraceLogWrEvtAddL(pThis->hTraceLog, &g_DevIrqEvtDesc, 0 /*fFlags*/,
                                      pEvtHdr->idEvt, pEvtHdr->hEvtSrc, pEvtIoApicMsi->GCPhys, pEvtIoApicMsi->u32Val);
             break;
@@ -893,6 +920,12 @@
     PDBGFTRACERINSR3 pThis = pUVM->dbgf.s.pTracerR3;
 
-    *phEvtSrc = pThis->hEvtSrcNext++;
-    return VINF_SUCCESS;
+    DBGFTRACEREVTSRC hEvtSrc = ASMAtomicIncU64((volatile uint64_t *)&pThis->hEvtSrcNext) - 1;
+
+    int rc = dbgfTracerR3EvtPostSingle(pVM, pThis, hEvtSrc, DBGFTRACEREVT_SRC_REGISTER,
+                                       NULL /*pvEvtDesc*/, 0 /*cbEvtDesc*/, NULL /*pidEvt*/);
+    if (RT_SUCCESS(rc))
+        *phEvtSrc = hEvtSrc;
+
+    return rc;
 }
 
@@ -910,6 +943,8 @@
     AssertReturn(hEvtSrc != NIL_DBGFTRACEREVTSRC, VERR_INVALID_HANDLE);
 
-    /** @todo Leave an event that the source deregistered. */
-    return VINF_SUCCESS;
-}
-
+    PUVM pUVM = pVM->pUVM;
+    PDBGFTRACERINSR3 pThis = pUVM->dbgf.s.pTracerR3;
+    return dbgfTracerR3EvtPostSingle(pVM, pThis, hEvtSrc, DBGFTRACEREVT_SRC_DEREGISTER,
+                                     NULL /*pvEvtDesc*/, 0 /*cbEvtDesc*/, NULL /*pidEvt*/);
+}
+
Index: /trunk/src/VBox/VMM/include/DBGFInternal.h
===================================================================
--- /trunk/src/VBox/VMM/include/DBGFInternal.h	(revision 84493)
+++ /trunk/src/VBox/VMM/include/DBGFInternal.h	(revision 84494)
@@ -67,4 +67,8 @@
     /** Invalid type. */
     DBGFTRACEREVT_INVALID = 0,
+    /** Register event source event. */
+    DBGFTRACEREVT_SRC_REGISTER,
+    /** Deregister event source event. */
+    DBGFTRACEREVT_SRC_DEREGISTER,
     /** MMIO map region event. */
     DBGFTRACEREVT_MMIO_MAP,
@@ -471,4 +475,10 @@
 } DBGFTRACERINSRC;
 
+
+#ifdef IN_RING3
+DECLHIDDEN(int) dbgfTracerR3EvtPostSingle(PVMCC pVM, PDBGFTRACERINSCC pThisCC, DBGFTRACEREVTSRC hEvtSrc,
+                                          DBGFTRACEREVT enmTraceEvt, const void *pvEvtDesc, size_t cbEvtDesc,
+                                          uint64_t *pidEvt);
+#endif
 
 /** VMM Debugger Command. */
