DBGFR3Trace.cpp revision 5c4d7e2aae42bbf39793dfa686925f076a56b4d5
/* $Id$ */
/** @file
* DBGF - Debugger Facility, Tracing.
*/
/*
* Copyright (C) 2011-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_DBGF
#include "DBGFInternal.h"
#include "VMMTracing.h"
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/**
* VMM trace point group translation table.
*/
static const struct
{
/** The group name. */
const char *pszName;
/** The name length. */
/** The mask. */
} g_aVmmTpGroups[] =
{
};
/**
* Initializes the tracing.
*
* @returns VBox status code
* @param pVM The VM handle.
*/
{
/*
* Don't enable it twice.
*/
return VERR_ALREADY_EXISTS;
/*
* Resolve default parameter values.
*/
int rc;
if (!cbEntry)
{
rc = CFGMR3QueryU32Def(CFGMR3GetChild(CFGMR3GetRoot(pVM), "DBGF"), "TraceBufEntrySize", &cbEntry, 128);
}
if (!cEntries)
{
rc = CFGMR3QueryU32Def(CFGMR3GetChild(CFGMR3GetRoot(pVM), "DBGF"), "TraceBufEntries", &cEntries, 4096);
}
/*
* Figure the required size.
*/
if (rc != VERR_BUFFER_OVERFLOW)
{
return rc;
}
/*
* Allocate a hyper heap block and carve a trace buffer out of it.
*
* Note! We ASSUME that the returned trace buffer handle has the same value
* as the heap block.
*/
void *pvBlock;
if (RT_FAILURE(rc))
return rc;
return VINF_SUCCESS;
}
/**
* Initializes the tracing.
*
* @returns VBox status code
* @param pVM The VM handle.
*/
{
/*
* Initialize the trace buffer handles.
*/
/*
* Check the config and enable tracing if requested.
*/
#if defined(DEBUG) || defined(RTTRACE_ENABLED)
bool const fDefault = true;
const char * const pszConfigDefault = "all";
#else
bool const fDefault = false;
const char * const pszConfigDefault = "";
#endif
bool fTracingEnabled;
if (fTracingEnabled)
{
if (RT_SUCCESS(rc))
{
char *pszTracingConfig;
if (RT_SUCCESS(rc))
{
if (RT_FAILURE(rc))
}
}
}
/*
* Register a debug info item that will dump the trace buffer content.
*/
if (RT_SUCCESS(rc))
rc = DBGFR3InfoRegisterInternal(pVM, "tracebuf", "Display the trace buffer content. No arguments.", dbgfR3TraceInfo);
return rc;
}
/**
* Terminates the tracing.
*
* @param pVM The VM handle.
*/
{
/* nothing to do */
}
/**
* Relocates the trace buffer handle in RC.
*
* @param pVM The VM handle.
*/
{
}
/**
* Change the traceing configuration of the VM.
*
* @returns VBox status code.
* @retval VINF_SUCCESS
* @retval VERR_NOT_FOUND if any of the trace point groups mentioned in the
* config string cannot be found. (Or if the string cannot be made
* sense of.) No change made.
* @retval VERR_INVALID_VM_HANDLE
* @retval VERR_INVALID_POINTER
*
* @param pVM The VM handle.
* @param pszConfig The configuration change specification.
*
* Trace point group names, optionally prefixed by a '-' to
* indicate that the group is being disabled. A special
* group 'all' can be used to enable or disable all trace
* points.
*
* Drivers, devices and USB devices each have their own
* trace point group which can be accessed by prefixing
* their official PDM name by 'drv', 'dev' or 'usb'
* respectively.
*/
{
return VERR_DBGF_NO_TRACE_BUFFER;
/*
* We do this in two passes, the first pass just validates the input string
* and the second applies the changes.
*/
{
char ch;
{
if (RT_C_IS_SPACE(ch))
continue;
/*
* Operation prefix.
*/
bool fNo = false;
do
{
{
pszConfig++;
}
else if (ch == '+')
fNo = false;
else
break;
if (ch == '\0')
break;
/*
* Extract the name.
*/
while ( ch != '\0'
&& !RT_C_IS_SPACE(ch)
&& !RT_C_IS_PUNCT(ch))
/*
* 'all' - special group that enables or disables all trace points.
*/
{
if (uPass != 0)
{
if (!fNo)
while (iCpu-- > 0)
else
while (iCpu-- > 0)
}
}
else
{
/*
* A specific group, try the VMM first then PDM.
*/
while (i-- > 0)
{
if (uPass != 0)
{
if (!fNo)
while (iCpu-- > 0)
else
while (iCpu-- > 0)
}
break;
}
if (i == UINT32_MAX)
{
if (RT_FAILURE(rc))
return rc;
}
}
}
}
return VINF_SUCCESS;
}
/**
* Query the trace configuration specification string.
*
* @returns VBox status code.
* @retval VINF_SUCCESS
* @retval VERR_INVALID_VM_HANDLE
* @retval VERR_INVALID_POINTER
* @retval VERR_BUFFER_OVERFLOW if the buffer is too small. Buffer will be
* empty.
* @param pVM The VM handle.
* @param pszConfig Pointer to the output buffer.
* @param cbConfig The size of the output buffer.
*/
{
if (cbConfig < 1)
return VERR_BUFFER_OVERFLOW;
*pszConfig = '\0';
return VERR_DBGF_NO_TRACE_BUFFER;
int rc = VINF_SUCCESS;
if ( fTraceGroups == UINT32_MAX
else if ( fTraceGroups == 0
else
{
while (i-- > 0)
{
{
break;
}
{
*pszDst = ' ';
}
else
}
if (RT_SUCCESS(rc))
}
if (RT_FAILURE(rc))
*pszConfig = '\0';
return rc;
}
/**
* @callback_method_impl{FNRTTRACEBUFCALLBACK}
*/
static DECLCALLBACK(int)
dbgfR3TraceInfoDumpEntry(RTTRACEBUF hTraceBuf, uint32_t iEntry, uint64_t NanoTS, RTCPUID idCpu, const char *pszMsg, void *pvUser)
{
return VINF_SUCCESS;
}
/**
* @callback_method_impl{FNDBGFHANDLERINT, Info handler for displaying the trace buffer content.}
*/
{
if (hTraceBuf == NIL_RTTRACEBUF)
else
{
}
}