SUPDrvTracer.cpp revision e1320ad829c6bbbb197d1b8003e7a074ed24e73c
6f85213423b2b1e219dee0ea476215ad9e1a8e08theAdib * VBoxDrv - The VirtualBox Support Driver - Tracer Interface.
6f85213423b2b1e219dee0ea476215ad9e1a8e08theAdib * Copyright (C) 2012 Oracle Corporation
0fde093b44fe27a8e17be34eb453e0246482a2e5Kris * This file is part of VirtualBox Open Source Edition (OSE), as
6f85213423b2b1e219dee0ea476215ad9e1a8e08theAdib * available from http://www.virtualbox.org. This file is free software;
6f85213423b2b1e219dee0ea476215ad9e1a8e08theAdib * you can redistribute it and/or modify it under the terms of the GNU
6f85213423b2b1e219dee0ea476215ad9e1a8e08theAdib * General Public License (GPL) as published by the Free Software
c978f17cd54294ccf4a3714c0bbda5924ecd6958JazzyNico * Foundation, in version 2 as it comes in the "COPYING" file of the
6f85213423b2b1e219dee0ea476215ad9e1a8e08theAdib * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
6f85213423b2b1e219dee0ea476215ad9e1a8e08theAdib * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#define SUPDRV_AGNOSTIC
#include "SUPDrvInternal.h"
typedef struct SUPDRVTPPROVIDER
bool fZombie;
bool fRegistered;
#ifdef DEBUG_bird
if (!ch)
return VINF_SUCCESS;
return VERR_SUPDRV_VTG_BAD_STRING;
return VERR_SUPDRV_VTG_STRING_TOO_LONG;
static int supdrvVtgValidate(PVTGOBJHDR pVtgHdr, size_t cbVtgObj, const uint8_t *pbImage, size_t cbImage)
uintptr_t i;
int rc;
cbImage = 0;
if (pbImage) \
return (rc); \
else if (!RT_VALID_PTR(p)) \
return (rc); \
return VERR_SUPDRV_VTG_STRTAB_OFF; \
return rc; \
if ((Attr).u8Code <= (uint8_t)kVTGStability_Invalid || (Attr).u8Code >= (uint8_t)kVTGStability_End) \
return VERR_SUPDRV_VTG_BAD_ATTR; \
if ((Attr).u8Data <= (uint8_t)kVTGStability_Invalid || (Attr).u8Data >= (uint8_t)kVTGStability_End) \
return VERR_SUPDRV_VTG_BAD_ATTR; \
return VERR_SUPDRV_VTG_BAD_ATTR; \
return VERR_SUPDRV_VTG_MAGIC;
return VERR_SUPDRV_VTG_BITS;
return VERR_SUPDRV_VTG_BAD_HDR;
MY_VALIDATE_PTR(pVtgHdr->paProviders, pVtgHdr->cbProviders, 1, 16, sizeof(VTGDESCPROVIDER), VERR_SUPDRV_VTG_BAD_HDR);
MY_VALIDATE_PTR(pVtgHdr->paProbes, pVtgHdr->cbProbes, 1, _32K, sizeof(VTGDESCPROBE), VERR_SUPDRV_VTG_BAD_HDR);
MY_VALIDATE_PTR(pVtgHdr->pafProbeEnabled, pVtgHdr->cbProbeEnabled, 1, _32K, sizeof(bool), VERR_SUPDRV_VTG_BAD_HDR);
MY_VALIDATE_PTR(pVtgHdr->pachStrTab, pVtgHdr->cbStrTab, 4, _1M, sizeof(char), VERR_SUPDRV_VTG_BAD_HDR);
MY_VALIDATE_PTR(pVtgHdr->paArgLists, pVtgHdr->cbArgLists, 1, _32K, sizeof(uint32_t), VERR_SUPDRV_VTG_BAD_HDR);
return VERR_SUPDRV_VTG_BAD_HDR_PTR;
return VERR_SUPDRV_VTG_BAD_HDR_TOO_FEW;
return VERR_SUPDRV_VTG_BAD_HDR_TOO_MUCH;
return VERR_SUPDRV_VTG_BAD_HDR;
return VERR_SUPDRV_VTG_BAD_PROVIDER;
if (pVtgHdr->paProviders[i].iFirstProbe + pVtgHdr->paProviders[i].cProbes > pVtgHdr->cbProbeEnabled)
return VERR_SUPDRV_VTG_BAD_PROVIDER;
return VERR_SUPDRV_VTG_BAD_PROVIDER;
unsigned iArg;
return VERR_SUPDRV_VTG_BAD_PROBE;
return VERR_SUPDRV_VTG_BAD_PROBE;
return VERR_SUPDRV_VTG_BAD_PROBE;
return VERR_SUPDRV_VTG_BAD_PROBE;
return VERR_SUPDRV_VTG_BAD_PROBE;
return VERR_SUPDRV_VTG_BAD_PROBE;
return VERR_SUPDRV_VTG_BAD_ARGLIST;
return VERR_SUPDRV_VTG_BAD_ARGLIST;
while (iArg-- > 0)
return VERR_SUPDRV_VTG_BAD_PROBE_LOC;
return VERR_SUPDRV_VTG_BAD_PROBE_LOC;
return VERR_SUPDRV_VTG_BAD_PROBE_LOC;
return VERR_SUPDRV_VTG_BAD_PROBE_LOC;
return VERR_SUPDRV_VTG_BAD_PROBE_LOC;
return VINF_SUCCESS;
LOG_TRACER(("Freeing tracepoint provider '%s' / %p\n", pProv->szName, pProv->Core.TracerData.DTrace.idProvider));
int rc;
RTListForEachSafe(&pDevExt->TracerProviderZombieList, pProv, pProvNext, SUPDRVTPPROVIDER, ListEntry)
uint32_t i;
bool fEmpty;
RTListForEachSafe(&pDevExt->TracerProviderZombieList, pProv, pProvNext, SUPDRVTPPROVIDER, ListEntry)
int rc;
if (!rc)
fEmpty = false;
if (fEmpty)
static int supdrvTracerRegisterVtgObj(PSUPDRVDEVEXT pDevExt, PVTGOBJHDR pVtgHdr, size_t cbVtgObj, PSUPDRVLDRIMAGE pImage,
int rc;
uintptr_t i;
if (pImage)
return rc;
return rc;
return rc;
if (pProv)
RTListForEachReverseSafe(&pDevExt->TracerProviderList, pProv, pProvNext, SUPDRVTPPROVIDER, ListEntry)
return rc;
return VINF_SUCCESS;
SUPR0DECL(int) SUPR0TracerRegisterDrv(PSUPDRVSESSION pSession, PVTGOBJHDR pVtgHdr, const char *pszName)
int rc;
rc = supdrvTracerRegisterVtgObj(pSession->pDevExt, pVtgHdr, _1M, NULL /*pImage*/, pSession, pszName);
return rc;
int rc;
return rc;
SUPR0DECL(int) SUPR0TracerRegisterImpl(void *hMod, PSUPDRVSESSION pSession, PCSUPDRVTRACERREG pReg, PCSUPDRVTRACERHLP *ppHlp)
int rc;
if (pImage)
return rc;
uint32_t i;
int rc;
cZombies++;
RTListForEachSafe(&pDevExt->TracerProviderZombieList, pProv, pProvNext, SUPDRVTPPROVIDER, ListEntry)
int rc;
cZombies++;
cZombies++;
if (cZombies == 0)
int rc;
if (pImage)
if ( pImage
return rc;
# if defined(RT_ARCH_AMD64)
int VBOXCALL supdrvIOCtl_TracerOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, uint32_t uCookie, uintptr_t uArg)
int rc;
rc = pDevExt->pTracerOps->pfnTracerOpen(pDevExt->pTracerOps, pSession, uCookie, uArg, &pSession->uTracerData);
return rc;
int rc;
return rc;
int VBOXCALL supdrvIOCtl_TracerIOCtl(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, uintptr_t uCmd, uintptr_t uArg, int32_t *piRetVal)
int rc;
rc = pDevExt->pTracerOps->pfnTracerIoCtl(pDevExt->pTracerOps, pSession, uTracerData, uCmd, uArg, piRetVal);
return rc;
#ifdef VBOX_WITH_DTRACE_R0DRV
rc = supdrvTracerRegisterVtgObj(pDevExt, &g_VTGObjHeader, _1M, NULL /*pImage*/, NULL /*pSession*/, "vboxdrv");
return rc;
return rc;