SUPDrvTracer.cpp revision 6fc72851657c09a173d3129c84d99e907af5e01f
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * VBoxDrv - The VirtualBox Support Driver - Tracer Interface.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * Copyright (C) 2012 Oracle Corporation
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * This file is part of VirtualBox Open Source Edition (OSE), as
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * available from http://www.virtualbox.org. This file is free software;
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * you can redistribute it and/or modify it under the terms of the GNU
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * General Public License (GPL) as published by the Free Software
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * Foundation, in version 2 as it comes in the "COPYING" file of the
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * The contents of this file may alternatively be used under the terms
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * of the Common Development and Distribution License Version 1.0
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * VirtualBox OSE distribution, in which case the provisions of the
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * CDDL are applicable instead of those of the GPL.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * You may elect to license modified versions of this file under the
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * terms and conditions of either the GPL or the CDDL or both.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe/*******************************************************************************
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe* Header Files *
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe*******************************************************************************/
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe/*******************************************************************************
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe* Structures and Typedefs *
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe*******************************************************************************/
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * Data for a tracepoint provider.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe /** The entry in the provider list for this image. */
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe /** The core structure. */
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe /** Pointer to the image this provider resides in. NULL if it's a
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * driver. */
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe /** The session this provider is associated with if registered via
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * SUPR0VtgRegisterDrv. NULL if pImage is set. */
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe /** Set when the module is unloaded or the driver deregisters its probes. */
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe /** Set if the provider has been successfully registered with the
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * tracer. */
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe /** The provider name (for logging purposes). */
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe/** Pointer to the data for a tracepoint provider. */
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe/*******************************************************************************
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe* Defined Constants And Macros *
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe*******************************************************************************/
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe/*******************************************************************************
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe* Global Variables *
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe*******************************************************************************/
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe/** The address of the current probe fire routine for kernel mode. */
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe/*PFNRT g_pfnSupdrvProbeFireKernel = supdrvTracerProbeFireStub;*/
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * Validates a VTG string against length and characterset limitations.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * @returns VINF_SUCCESS, VERR_SUPDRV_VTG_BAD_STRING or
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * VERR_SUPDRV_VTG_STRING_TOO_LONG.
4edb61f8b0f8ce9f62d803c706612376498672b4al_xipe * @param psz The string.
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 DTrace 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)
if (fEmpty)
static int supdrvTracerRegisterVtgObj(PSUPDRVDEVEXT pDevExt, PVTGOBJHDR pVtgHdr, size_t cbVtgObj, PSUPDRVLDRIMAGE pImage,
int rc;
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;
int rc;
if (pImage)
if ( pImage
return rc;
# if defined(RT_ARCH_AMD64)
SUPR0DECL(void) SUPR0TracerFireProbe(uint32_t idProbe, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2,
#ifdef VBOX_WITH_DTRACE_R0DRV
rc = supdrvTracerRegisterVtgObj(pDevExt, &g_VTGObjHeader, _1M, NULL /*pImage*/, NULL /*pSession*/, "vboxdrv");
return rc;
return rc;