VirtualBox

Ignore:
Timestamp:
May 22, 2020 12:55:07 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
138166
Message:

VMM/PDM: DBGF even tracing integration, bugref:9210

Integrates the new DBGF event tracing framework into PDM
devices. The new CFGM key "TracingEnabled" for a device
instance enables tracing using DBGF. A special tracing variant
of the PDM device helper is provided.

Disabled by default for now, enable with VBOX_WITH_DBGF_TRACING

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/PDMDevice.cpp

    r82968 r84459  
    308308        }
    309309
     310#ifdef VBOX_WITH_DBGF_TRACING
     311        DBGFTRACEREVTSRC hDbgfTraceEvtSrc = NIL_DBGFTRACEREVTSRC;
     312        bool fTracingEnabled = false;
     313        bool fGCPhysRwAll = false;
     314        rc = CFGMR3QueryBoolDef(paDevs[i].pNode, "TracingEnabled", &fTracingEnabled,
     315                                false);
     316        AssertLogRelRCReturn(rc, rc);
     317        if (fTracingEnabled)
     318        {
     319            rc = CFGMR3QueryBoolDef(paDevs[i].pNode, "TraceAllGstMemRw", &fGCPhysRwAll,
     320                                    false);
     321            AssertLogRelRCReturn(rc, rc);
     322
     323            /* Traced devices need to be trusted for now. */
     324            if (fTrusted)
     325            {
     326                rc = DBGFR3TracerRegisterEvtSrc(pVM, pReg->szName, &hDbgfTraceEvtSrc);
     327                AssertLogRelRCReturn(rc, rc);
     328            }
     329            else
     330                AssertMsgFailedReturn(("configuration error: Device tracing needs a trusted device\n"), VERR_INCOMPATIBLE_CONFIG);
     331        }
     332#endif
     333
    310334        /* config node */
    311335        PCFGMNODE pConfigNode = CFGMR3GetChild(paDevs[i].pNode, "Config");
     
    338362
    339363            PDMDEVICECREATEREQ Req;
    340             Req.Hdr.u32Magic     = SUPVMMR0REQHDR_MAGIC;
    341             Req.Hdr.cbReq        = sizeof(Req);
    342             Req.pDevInsR3        = NULL;
    343             Req.fFlags           = pReg->fFlags;
    344             Req.fClass           = pReg->fClass;
    345             Req.cMaxInstances    = pReg->cMaxInstances;
    346             Req.uSharedVersion   = pReg->uSharedVersion;
    347             Req.cbInstanceShared = pReg->cbInstanceShared;
    348             Req.cbInstanceR3     = pReg->cbInstanceCC;
    349             Req.cbInstanceRC     = pReg->cbInstanceRC;
    350             Req.cMaxPciDevices   = pReg->cMaxPciDevices;
    351             Req.cMaxMsixVectors  = pReg->cMaxMsixVectors;
    352             Req.iInstance        = paDevs[i].iInstance;
    353             Req.fRCEnabled       = fRCEnabled;
    354             Req.afReserved[0]    = false;
    355             Req.afReserved[1]    = false;
    356             Req.afReserved[2]    = false;
     364            Req.Hdr.u32Magic      = SUPVMMR0REQHDR_MAGIC;
     365            Req.Hdr.cbReq         = sizeof(Req);
     366            Req.pDevInsR3         = NULL;
     367            /** @todo Add tracer id in request so R0 can set up DEVINSR0 properly. */
     368            Req.fFlags            = pReg->fFlags;
     369            Req.fClass            = pReg->fClass;
     370            Req.cMaxInstances     = pReg->cMaxInstances;
     371            Req.uSharedVersion    = pReg->uSharedVersion;
     372            Req.cbInstanceShared  = pReg->cbInstanceShared;
     373            Req.cbInstanceR3      = pReg->cbInstanceCC;
     374            Req.cbInstanceRC      = pReg->cbInstanceRC;
     375            Req.cMaxPciDevices    = pReg->cMaxPciDevices;
     376            Req.cMaxMsixVectors   = pReg->cMaxMsixVectors;
     377            Req.iInstance         = paDevs[i].iInstance;
     378            Req.fRCEnabled        = fRCEnabled;
     379            Req.afReserved[0]     = false;
     380            Req.afReserved[1]     = false;
     381            Req.afReserved[2]     = false;
     382#ifdef VBOX_WITH_DBGF_TRACING
     383            Req.hDbgfTracerEvtSrc = hDbgfTraceEvtSrc;
     384#else
     385            Req.hDbgfTracerEvtSrc = NIL_DBGFTRACEREVTSRC;
     386#endif
    357387            rc = RTStrCopy(Req.szDevName, sizeof(Req.szDevName), pReg->szName);
    358388            AssertLogRelRCReturn(rc, rc);
     
    429459        pDevIns->Internal.s.pCfgHandle          = paDevs[i].pNode;
    430460        pDevIns->Internal.s.pVMR3               = pVM;
     461#ifdef VBOX_WITH_DBGF_TRACING
     462        pDevIns->Internal.s.hDbgfTraceEvtSrc    = hDbgfTraceEvtSrc;
     463#else
     464        pDevIns->Internal.s.hDbgfTraceEvtSrc    = NIL_DBGFTRACEREVTSRC;
     465#endif
    431466        //pDevIns->Internal.s.pHeadPciDevR3       = NULL;
    432467        pDevIns->Internal.s.fIntFlags          |= PDMDEVINSINT_FLAGS_SUSPENDED;
     
    479514            return rc == VERR_VERSION_MISMATCH ? VERR_PDM_DEVICE_VERSION_MISMATCH : rc;
    480515        }
     516
     517#ifdef VBOX_WITH_DBGF_TRACING
     518        /*
     519         * Allocate memory for the MMIO/IO port registration tracking if DBGF tracing is enabled.
     520         */
     521        if (hDbgfTraceEvtSrc != NIL_DBGFTRACEREVTSRC)
     522        {
     523            pDevIns->Internal.s.paDbgfTraceTrack = (PPDMDEVINSDBGFTRACK)RTMemAllocZ(PDM_MAX_DEVICE_DBGF_TRACING_TRACK);
     524            if (!pDevIns->Internal.s.paDbgfTraceTrack)
     525            {
     526                LogRel(("PDM: Failed to construct '%s'/%d! %Rra\n", pDevIns->pReg->szName, pDevIns->iInstance, VERR_NO_MEMORY));
     527                if (VMR3GetErrorCount(pVM->pUVM) == 0)
     528                    VMSetError(pVM, rc, RT_SRC_POS, "Failed to construct device '%s' instance #%u",
     529                               pDevIns->pReg->szName, pDevIns->iInstance);
     530                paDevs[i].pDev->cInstances--;
     531                return VERR_NO_MEMORY;
     532            }
     533
     534            pDevIns->Internal.s.idxDbgfTraceTrackNext = 0;
     535            pDevIns->Internal.s.cDbgfTraceTrackMax = PDM_MAX_DEVICE_DBGF_TRACING_TRACK / sizeof(PDMDEVINSDBGFTRACK);
     536            pDevIns->pHlpR3 = &g_pdmR3DevHlpTracing;
     537        }
     538#endif
    481539
    482540        /*
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette