STAM.cpp revision 2a2b85a6544fc8728b466dc9e8bace50d3fa5185
/* $Id$ */
/** @file
* STAM - The Statistics Manager.
*/
/*
* Copyright (C) 2006-2013 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.
*/
/** @page pg_stam STAM - The Statistics Manager
*
* The purpose for the statistics manager is to present the rest of the system
* with a somewhat uniform way of accessing VMM statistics. STAM sports a
* couple of different APIs for accessing them: STAMR3EnumU, STAMR3SnapshotU,
* STAMR3DumpU, STAMR3DumpToReleaseLogU and the debugger. Main is exposing the
* XML based one, STAMR3SnapshotU.
*
* The rest of the VMM together with the devices and drivers registers their
* statistics with STAM giving them a name. The name is hierarchical, the
* components separated by slashes ('/') and must start with a slash.
*
* Each item registered with STAM - also, half incorrectly, called a sample -
* has a type, unit, visibility, data pointer and description associated with it
* in addition to the name (described above). The type tells STAM what kind of
* structure the pointer is pointing to. The visibility allows unused
* statistics from cluttering the output or showing up in the GUI. All the bits
* together makes STAM able to present the items in a sensible way to the user.
* Some types also allows STAM to reset the data, which is very convenient when
* digging into specific operations and such.
*
* PS. The VirtualBox Debugger GUI has a viewer for inspecting the statistics
* STAM provides. You will also find statistics in the release and debug logs.
* And as mentioned in the introduction, the debugger console features a couple
* of command: .stats and .statsreset.
*
* @see grp_stam
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
/*#define USE_PDMCRITSECTRW - testing, not for production. */
#define LOG_GROUP LOG_GROUP_STAM
#include "STAMInternal.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Argument structure for stamR3PrintOne().
*/
typedef struct STAMR3PRINTONEARGS
{
void *pvArg;
/**
* Argument structure to stamR3EnumOne().
*/
typedef struct STAMR3ENUMONEARGS
{
void *pvUser;
/**
* The snapshot status structure.
* Argument package passed to stamR3SnapshotOne, stamR3SnapshotPrintf and stamR3SnapshotOutput.
*/
typedef struct STAMR3SNAPSHOTONE
{
/** Pointer to the buffer start. */
char *pszStart;
/** Pointer to the buffer end. */
char *pszEnd;
/** Pointer to the current buffer position. */
char *psz;
/** Pointer to the VM. */
/** The number of bytes allocated. */
/** The status code. */
int rc;
/** Whether to include the description strings. */
bool fWithDesc;
/**
* Init record for a ring-0 statistic sample.
*/
typedef struct STAMR0SAMPLE
{
/** The GVMMSTATS structure offset of the variable. */
unsigned offVar;
/** The type. */
/** The unit. */
/** The name. */
const char *pszName;
/** The description. */
const char *pszDesc;
} STAMR0SAMPLE;
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
static int stamR3RegisterU(PUVM pUVM, void *pvSample, PFNSTAMR3CALLBACKRESET pfnReset, PFNSTAMR3CALLBACKPRINT pfnPrint,
STAMTYPE enmType, STAMVISIBILITY enmVisibility, const char *pszName, STAMUNIT enmUnit, const char *pszDesc);
static DECLCALLBACK(void) stamR3EnumLogPrintf(PSTAMR3PRINTONEARGS pvArg, const char *pszFormat, ...);
static DECLCALLBACK(void) stamR3EnumRelLogPrintf(PSTAMR3PRINTONEARGS pvArg, const char *pszFormat, ...);
static bool stamR3MultiMatch(const char * const *papszExpressions, unsigned cExpressions, unsigned *piExpression, const char *pszName);
static int stamR3EnumU(PUVM pUVM, const char *pszPat, bool fUpdateRing0, int (pfnCallback)(PSTAMDESC pDesc, void *pvArg), void *pvArg);
static void stamR3Ring0StatsUpdateMultiU(PUVM pUVM, const char * const *papszExpressions, unsigned cExpressions);
#ifdef VBOX_WITH_DEBUGGER
static FNDBGCCMD stamR3CmdStats;
static DECLCALLBACK(void) stamR3EnumDbgfPrintf(PSTAMR3PRINTONEARGS pArgs, const char *pszFormat, ...);
static FNDBGCCMD stamR3CmdStatsReset;
#endif
/*******************************************************************************
* Global Variables *
*******************************************************************************/
#ifdef VBOX_WITH_DEBUGGER
/** Pattern argument. */
static const DBGCVARDESC g_aArgPat[] =
{
/* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
{ 0, 1, DBGCVAR_CAT_STRING, 0, "pattern", "Which samples the command shall be applied to. Use '*' as wildcard. Use ';' to separate expression." }
};
/** Command descriptors. */
{
/* pszCmd, cArgsMin, cArgsMax, paArgDesc, cArgDescs, fFlags, pfnHandler pszSyntax, ....pszDescription */
{ "stats", 0, 1, &g_aArgPat[0], RT_ELEMENTS(g_aArgPat), 0, stamR3CmdStats, "[pattern]", "Display statistics." },
{ "statsreset", 0, 1, &g_aArgPat[0], RT_ELEMENTS(g_aArgPat), 0, stamR3CmdStatsReset,"[pattern]", "Resets statistics." }
};
#endif
/**
* The GVMM mapping records - sans the host cpus.
*/
static const STAMR0SAMPLE g_aGVMMStats[] =
{
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cHaltCalls), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/HaltCalls", "The number of calls to GVMMR0SchedHalt." },
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cHaltBlocking), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/HaltBlocking", "The number of times we did go to sleep in GVMMR0SchedHalt." },
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cHaltTimeouts), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/HaltTimeouts", "The number of times we timed out in GVMMR0SchedHalt." },
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cHaltNotBlocking), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/HaltNotBlocking", "The number of times we didn't go to sleep in GVMMR0SchedHalt." },
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cHaltWakeUps), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/HaltWakeUps", "The number of wake ups done during GVMMR0SchedHalt." },
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cWakeUpCalls), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/WakeUpCalls", "The number of calls to GVMMR0WakeUp." },
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cWakeUpNotHalted), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/WakeUpNotHalted", "The number of times the EMT thread wasn't actually halted when GVMMR0WakeUp was called." },
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cWakeUpWakeUps), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/WakeUpWakeUps", "The number of wake ups done during GVMMR0WakeUp (not counting the explicit one)." },
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cPokeCalls), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/PokeCalls", "The number of calls to GVMMR0Poke." },
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cPokeNotBusy), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/PokeNotBusy", "The number of times the EMT thread wasn't actually busy when GVMMR0Poke was called." },
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cPollCalls), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/PollCalls", "The number of calls to GVMMR0SchedPoll." },
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cPollHalts), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/PollHalts", "The number of times the EMT has halted in a GVMMR0SchedPoll call." },
{ RT_UOFFSETOF(GVMMSTATS, SchedVM.cPollWakeUps), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/VM/PollWakeUps", "The number of wake ups done during GVMMR0SchedPoll." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cHaltCalls), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/HaltCalls", "The number of calls to GVMMR0SchedHalt." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cHaltBlocking), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/HaltBlocking", "The number of times we did go to sleep in GVMMR0SchedHalt." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cHaltTimeouts), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/HaltTimeouts", "The number of times we timed out in GVMMR0SchedHalt." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cHaltNotBlocking), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/HaltNotBlocking", "The number of times we didn't go to sleep in GVMMR0SchedHalt." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cHaltWakeUps), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/HaltWakeUps", "The number of wake ups done during GVMMR0SchedHalt." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cWakeUpCalls), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/WakeUpCalls", "The number of calls to GVMMR0WakeUp." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cWakeUpNotHalted), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/WakeUpNotHalted", "The number of times the EMT thread wasn't actually halted when GVMMR0WakeUp was called." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cWakeUpWakeUps), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/WakeUpWakeUps", "The number of wake ups done during GVMMR0WakeUp (not counting the explicit one)." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cPokeCalls), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/PokeCalls", "The number of calls to GVMMR0Poke." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cPokeNotBusy), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/PokeNotBusy", "The number of times the EMT thread wasn't actually busy when GVMMR0Poke was called." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cPollCalls), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/PollCalls", "The number of calls to GVMMR0SchedPoll." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cPollHalts), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/PollHalts", "The number of times the EMT has halted in a GVMMR0SchedPoll call." },
{ RT_UOFFSETOF(GVMMSTATS, SchedSum.cPollWakeUps), STAMTYPE_U64_RESET, STAMUNIT_CALLS, "/GVMM/Sum/PollWakeUps", "The number of wake ups done during GVMMR0SchedPoll." },
{ RT_UOFFSETOF(GVMMSTATS, cVMs), STAMTYPE_U32, STAMUNIT_CALLS, "/GVMM/VMs", "The number of VMs accessible to the caller." },
{ RT_UOFFSETOF(GVMMSTATS, cEMTs), STAMTYPE_U32, STAMUNIT_CALLS, "/GVMM/EMTs", "The number of emulation threads." },
{ RT_UOFFSETOF(GVMMSTATS, cHostCpus), STAMTYPE_U32, STAMUNIT_CALLS, "/GVMM/HostCPUs", "The number of host CPUs." },
};
/**
* The GMM mapping records.
*/
static const STAMR0SAMPLE g_aGMMStats[] =
{
{ RT_UOFFSETOF(GMMSTATS, cMaxPages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/cMaxPages", "The maximum number of pages GMM is allowed to allocate." },
{ RT_UOFFSETOF(GMMSTATS, cReservedPages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/cReservedPages", "The number of pages that has been reserved." },
{ RT_UOFFSETOF(GMMSTATS, cOverCommittedPages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/cOverCommittedPages", "The number of pages that we have over-committed in reservations." },
{ RT_UOFFSETOF(GMMSTATS, cAllocatedPages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/cAllocatedPages", "The number of actually allocated (committed if you like) pages." },
{ RT_UOFFSETOF(GMMSTATS, cSharedPages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/cSharedPages", "The number of pages that are shared. A subset of cAllocatedPages." },
{ RT_UOFFSETOF(GMMSTATS, cDuplicatePages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/cDuplicatePages", "The number of pages that are actually shared between VMs." },
{ RT_UOFFSETOF(GMMSTATS, cLeftBehindSharedPages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/cLeftBehindSharedPages", "The number of pages that are shared that has been left behind by VMs not doing proper cleanups." },
{ RT_UOFFSETOF(GMMSTATS, cBalloonedPages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/cBalloonedPages", "The number of current ballooned pages." },
{ RT_UOFFSETOF(GMMSTATS, cChunks), STAMTYPE_U32, STAMUNIT_COUNT, "/GMM/cChunks", "The number of allocation chunks." },
{ RT_UOFFSETOF(GMMSTATS, cFreedChunks), STAMTYPE_U32, STAMUNIT_COUNT, "/GMM/cFreedChunks", "The number of freed chunks ever." },
{ RT_UOFFSETOF(GMMSTATS, cShareableModules), STAMTYPE_U32, STAMUNIT_COUNT, "/GMM/cShareableModules", "The number of shareable modules." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.Reserved.cBasePages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/VM/Reserved/cBasePages", "The amount of base memory (RAM, ROM, ++) reserved by the VM." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.Reserved.cShadowPages), STAMTYPE_U32, STAMUNIT_PAGES, "/GMM/VM/Reserved/cShadowPages", "The amount of memory reserved for shadow/nested page tables." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.Reserved.cFixedPages), STAMTYPE_U32, STAMUNIT_PAGES, "/GMM/VM/Reserved/cFixedPages", "The amount of memory reserved for fixed allocations like MMIO2 and the hyper heap." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.Allocated.cBasePages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/VM/Allocated/cBasePages", "The amount of base memory (RAM, ROM, ++) allocated by the VM." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.Allocated.cShadowPages), STAMTYPE_U32, STAMUNIT_PAGES, "/GMM/VM/Allocated/cShadowPages", "The amount of memory allocated for shadow/nested page tables." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.Allocated.cFixedPages), STAMTYPE_U32, STAMUNIT_PAGES, "/GMM/VM/Allocated/cFixedPages", "The amount of memory allocated for fixed allocations like MMIO2 and the hyper heap." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.cPrivatePages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/VM/cPrivatePages", "The current number of private pages." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.cSharedPages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/VM/cSharedPages", "The current number of shared pages." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.cBalloonedPages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/VM/cBalloonedPages", "The current number of ballooned pages." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.cMaxBalloonedPages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/VM/cMaxBalloonedPages", "The max number of pages that can be ballooned." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.cReqBalloonedPages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/VM/cReqBalloonedPages", "The number of pages we've currently requested the guest to give us." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.cReqActuallyBalloonedPages),STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/VM/cReqActuallyBalloonedPages","The number of pages the guest has given us in response to the request." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.cReqDeflatePages), STAMTYPE_U64, STAMUNIT_PAGES, "/GMM/VM/cReqDeflatePages", "The number of pages we've currently requested the guest to take back." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.cShareableModules), STAMTYPE_U32, STAMUNIT_COUNT, "/GMM/VM/cShareableModules", "The number of shareable modules traced by the VM." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.enmPolicy), STAMTYPE_U32, STAMUNIT_NONE, "/GMM/VM/enmPolicy", "The current over-commit policy." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.enmPriority), STAMTYPE_U32, STAMUNIT_NONE, "/GMM/VM/enmPriority", "The VM priority for arbitrating VMs in low and out of memory situation." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.fBallooningEnabled), STAMTYPE_BOOL, STAMUNIT_NONE, "/GMM/VM/fBallooningEnabled", "Whether ballooning is enabled or not." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.fBallooningEnabled), STAMTYPE_BOOL, STAMUNIT_NONE, "/GMM/VM/fSharedPagingEnabled", "Whether shared paging is enabled or not." },
{ RT_UOFFSETOF(GMMSTATS, VMStats.fBallooningEnabled), STAMTYPE_BOOL, STAMUNIT_NONE, "/GMM/VM/fMayAllocate", "Whether the VM is allowed to allocate memory or not." },
};
/**
* Initializes the STAM.
*
* @returns VBox status code.
* @param pVM Pointer to the VM.
*/
{
int rc;
LogFlow(("STAMR3Init\n"));
/*
* Assert alignment and sizes.
*/
/*
*/
#ifndef USE_PDMCRITSECTRW
#endif
/*
*/
#ifdef VBOX_WITH_DEBUGGER
/*
* Register debugger commands.
*/
static bool fRegisteredCmds = false;
if (!fRegisteredCmds)
{
if (RT_SUCCESS(rc))
fRegisteredCmds = true;
}
#endif
return VINF_SUCCESS;
}
/**
* Terminates the STAM.
*
* @param pUVM Pointer to the user mode VM structure.
*/
{
/*
* Free used memory and the RWLock.
*/
while (pCur)
{
}
#ifndef USE_PDMCRITSECTRW
#endif
}
/**
* Registers a sample with the statistics manager.
*
* Statistics are maintained on a per VM basis and is normally registered
* during the VM init stage, but there is nothing preventing you from
* register them at runtime.
*
* Use STAMR3Deregister() to deregister statistics at runtime, however do
* not bother calling at termination time.
*
* It is not possible to register the same sample twice.
*
* @returns VBox status.
* @param pUVM Pointer to the user mode VM structure.
* @param pvSample Pointer to the sample.
* @param enmType Sample type. This indicates what pvSample is pointing at.
* @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
* @param pszName Sample name. The name is on this form "/<component>/<sample>".
* Further nesting is possible.
* @param enmUnit Sample unit.
* @param pszDesc Sample description.
*/
VMMR3DECL(int) STAMR3RegisterU(PUVM pUVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
{
return stamR3RegisterU(pUVM, pvSample, NULL, NULL, enmType, enmVisibility, pszName, enmUnit, pszDesc);
}
/**
* Registers a sample with the statistics manager.
*
* Statistics are maintained on a per VM basis and is normally registered
* during the VM init stage, but there is nothing preventing you from
* register them at runtime.
*
* Use STAMR3Deregister() to deregister statistics at runtime, however do
* not bother calling at termination time.
*
* It is not possible to register the same sample twice.
*
* @returns VBox status.
* @param pVM Pointer to the VM.
* @param pvSample Pointer to the sample.
* @param enmType Sample type. This indicates what pvSample is pointing at.
* @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
* @param pszName Sample name. The name is on this form "/<component>/<sample>".
* Further nesting is possible.
* @param enmUnit Sample unit.
* @param pszDesc Sample description.
*/
VMMR3DECL(int) STAMR3Register(PVM pVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
{
return stamR3RegisterU(pVM->pUVM, pvSample, NULL, NULL, enmType, enmVisibility, pszName, enmUnit, pszDesc);
}
/**
* Same as STAMR3RegisterU except that the name is specified in a
* RTStrPrintf like fashion.
*
* @returns VBox status.
* @param pUVM Pointer to the user mode VM structure.
* @param pvSample Pointer to the sample.
* @param enmType Sample type. This indicates what pvSample is pointing at.
* @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
* @param enmUnit Sample unit.
* @param pszDesc Sample description.
* @param pszName The sample name format string.
* @param ... Arguments to the format string.
*/
VMMR3DECL(int) STAMR3RegisterFU(PUVM pUVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
{
return rc;
}
/**
* Same as STAMR3Register except that the name is specified in a
* RTStrPrintf like fashion.
*
* @returns VBox status.
* @param pVM Pointer to the VM.
* @param pvSample Pointer to the sample.
* @param enmType Sample type. This indicates what pvSample is pointing at.
* @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
* @param enmUnit Sample unit.
* @param pszDesc Sample description.
* @param pszName The sample name format string.
* @param ... Arguments to the format string.
*/
VMMR3DECL(int) STAMR3RegisterF(PVM pVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
{
int rc = STAMR3RegisterVU(pVM->pUVM, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
return rc;
}
/**
* Same as STAMR3Register except that the name is specified in a
* RTStrPrintfV like fashion.
*
* @returns VBox status.
* @param pVM Pointer to the VM.
* @param pvSample Pointer to the sample.
* @param enmType Sample type. This indicates what pvSample is pointing at.
* @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
* @param enmUnit Sample unit.
* @param pszDesc Sample description.
* @param pszName The sample name format string.
* @param args Arguments to the format string.
*/
VMMR3DECL(int) STAMR3RegisterVU(PUVM pUVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
{
char *pszFormattedName;
if (!pszFormattedName)
return VERR_NO_MEMORY;
int rc = STAMR3RegisterU(pUVM, pvSample, enmType, enmVisibility, pszFormattedName, enmUnit, pszDesc);
return rc;
}
/**
* Same as STAMR3Register except that the name is specified in a
* RTStrPrintfV like fashion.
*
* @returns VBox status.
* @param pVM Pointer to the VM.
* @param pvSample Pointer to the sample.
* @param enmType Sample type. This indicates what pvSample is pointing at.
* @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
* @param enmUnit Sample unit.
* @param pszDesc Sample description.
* @param pszName The sample name format string.
* @param args Arguments to the format string.
*/
VMMR3DECL(int) STAMR3RegisterV(PVM pVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
{
return STAMR3RegisterVU(pVM->pUVM, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
}
/**
* Similar to STAMR3Register except for the two callbacks, the implied type (STAMTYPE_CALLBACK),
* and name given in an RTStrPrintf like fashion.
*
* @returns VBox status.
* @param pVM Pointer to the VM.
* @param pvSample Pointer to the sample.
* @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
* @param enmUnit Sample unit.
* @param pfnReset Callback for resetting the sample. NULL should be used if the sample can't be reset.
* @param pfnPrint Print the sample.
* @param pszDesc Sample description.
* @param pszName The sample name format string.
* @param ... Arguments to the format string.
* @remark There is currently no device or driver variant of this API. Add one if it should become necessary!
*/
VMMR3DECL(int) STAMR3RegisterCallback(PVM pVM, void *pvSample, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
{
int rc = STAMR3RegisterCallbackV(pVM, pvSample, enmVisibility, enmUnit, pfnReset, pfnPrint, pszDesc, pszName, args);
return rc;
}
/**
* Same as STAMR3RegisterCallback() except for the ellipsis which is a va_list here.
*
* @returns VBox status.
* @param pVM Pointer to the VM.
* @param pvSample Pointer to the sample.
* @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
* @param enmUnit Sample unit.
* @param pfnReset Callback for resetting the sample. NULL should be used if the sample can't be reset.
* @param pfnPrint Print the sample.
* @param pszDesc Sample description.
* @param pszName The sample name format string.
* @param args Arguments to the format string.
* @remark There is currently no device or driver variant of this API. Add one if it should become necessary!
*/
VMMR3DECL(int) STAMR3RegisterCallbackV(PVM pVM, void *pvSample, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
{
char *pszFormattedName;
if (!pszFormattedName)
return VERR_NO_MEMORY;
int rc = stamR3RegisterU(pVM->pUVM, pvSample, pfnReset, pfnPrint, STAMTYPE_CALLBACK, enmVisibility, pszFormattedName, enmUnit, pszDesc);
return rc;
}
#ifdef VBOX_STRICT
/**
* Divide the strings into sub-strings using '/' as delimiter
* and then compare them in strcmp fashion.
*
* @returns Difference.
* @retval 0 if equal.
* @retval < 0 if psz1 is less than psz2.
* @retval > 0 if psz1 greater than psz2.
*
* @param psz1 The first string.
* @param psz2 The second string.
*/
{
for (;;)
{
{
/* slash is end-of-sub-string, so it trumps everything but '\0'. */
if (ch1 == '/')
if (ch2 == '/')
}
/* done? */
if (ch1 == '\0')
return 0;
}
}
#endif /* VBOX_STRICT */
/**
* Internal worker for the different register calls.
*
* @returns VBox status.
* @param pUVM Pointer to the user mode VM structure.
* @param pvSample Pointer to the sample.
* @param pfnReset Callback for resetting the sample. NULL should be used if the sample can't be reset.
* @param pfnPrint Print the sample.
* @param enmType Sample type. This indicates what pvSample is pointing at.
* @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
* @param enmUnit Sample unit.
* @param pszDesc Sample description.
* @param pszName The sample name format string.
* @param args Arguments to the format string.
* @remark There is currently no device or driver variant of this API. Add one if it should become necessary!
*/
static int stamR3RegisterU(PUVM pUVM, void *pvSample, PFNSTAMR3CALLBACKRESET pfnReset, PFNSTAMR3CALLBACKPRINT pfnPrint,
STAMTYPE enmType, STAMVISIBILITY enmVisibility, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
{
/*
* Check if exists.
*/
{
}
while (pCur)
{
/* passed it */
if (iDiff > 0)
break;
/* found it. */
if (!iDiff)
{
return VERR_ALREADY_EXISTS;
}
/* next */
}
/*
* Check that the name doesn't screw up sorting order when taking
* slashes into account. The QT4 GUI makes some assumptions.
* Problematic chars are: !"#$%&'()*+,-.
*/
if (pPrev)
if (pCur)
#ifdef VBOX_STRICT
/*
* Check alignment requirements.
*/
switch (enmType)
{
/* 8 byte / 64-bit */
case STAMTYPE_U64:
case STAMTYPE_U64_RESET:
case STAMTYPE_X64:
case STAMTYPE_X64_RESET:
case STAMTYPE_COUNTER:
case STAMTYPE_PROFILE:
case STAMTYPE_PROFILE_ADV:
break;
/* 4 byte / 32-bit */
case STAMTYPE_RATIO_U32:
case STAMTYPE_RATIO_U32_RESET:
case STAMTYPE_U32:
case STAMTYPE_U32_RESET:
case STAMTYPE_X32:
case STAMTYPE_X32_RESET:
break;
/* 2 byte / 32-bit */
case STAMTYPE_U16:
case STAMTYPE_U16_RESET:
case STAMTYPE_X16:
case STAMTYPE_X16_RESET:
break;
/* 1 byte / 8-bit / unaligned */
case STAMTYPE_U8:
case STAMTYPE_U8_RESET:
case STAMTYPE_X8:
case STAMTYPE_X8_RESET:
case STAMTYPE_BOOL:
case STAMTYPE_BOOL_RESET:
case STAMTYPE_CALLBACK:
break;
default:
break;
}
#endif /* VBOX_STRICT */
/*
* Create a new node and insert it at the current location.
*/
int rc;
if (pNew)
{
if (enmType != STAMTYPE_CALLBACK)
else
{
}
if (pszDesc)
if (pPrev)
else
rc = VINF_SUCCESS;
}
else
rc = VERR_NO_MEMORY;
return rc;
}
/**
* Deregisters a sample previously registered by STAR3Register().
*
* This is intended used for devices which can be unplugged and for
* temporary samples.
*
* @returns VBox status.
* @param pUVM Pointer to the user mode VM structure.
* @param pvSample Pointer to the sample registered with STAMR3Register().
*/
{
/*
* Search for it.
*/
int rc = VERR_INVALID_HANDLE;
while (pCur)
{
{
if (pPrev)
else
rc = VINF_SUCCESS;
continue;
}
/* next */
}
return rc;
}
/**
* Deregisters a sample previously registered by STAR3Register().
*
* This is intended used for devices which can be unplugged and for
* temporary samples.
*
* @returns VBox status.
* @param pVM Pointer to the VM.
* @param pvSample Pointer to the sample registered with STAMR3Register().
*/
{
}
/**
* Resets statistics for the specified VM.
* It's possible to select a subset of the samples.
*
* @returns VBox status. (Basically, it cannot fail.)
* @param pUVM The user mode VM handle.
* @param pszPat The name matching pattern. See somewhere_where_this_is_described_in_detail.
* If NULL all samples are reset.
* @remarks Don't confuse this with the other 'XYZR3Reset' methods, it's not called at VM reset.
*/
{
int rc = VINF_SUCCESS;
/* ring-0 */
bool fGMMMatched = fGVMMMatched;
if (fGVMMMatched)
{
}
else
{
char *pszCopy;
unsigned cExpressions;
if (!papszExpressions)
return VERR_NO_MEMORY;
/* GVMM */
for (unsigned i = 0; i < RT_ELEMENTS(g_aGVMMStats); i++)
{
fGVMMMatched = true;
}
if (!fGVMMMatched)
{
/** @todo match cpu leaves some rainy day. */
}
/* GMM */
for (unsigned i = 0; i < RT_ELEMENTS(g_aGMMStats); i++)
{
fGMMMatched = true;
}
}
if (fGVMMMatched)
{
}
if (fGMMMatched)
{
}
/* and the reset */
return rc;
}
/**
* Resets one statistics sample.
* Callback for stamR3EnumU().
*
* @returns VINF_SUCCESS
* @param pDesc Pointer to the current descriptor.
* @param pvArg User argument - Pointer to the VM.
*/
{
{
case STAMTYPE_COUNTER:
break;
case STAMTYPE_PROFILE:
case STAMTYPE_PROFILE_ADV:
break;
case STAMTYPE_RATIO_U32_RESET:
break;
case STAMTYPE_CALLBACK:
break;
case STAMTYPE_U8_RESET:
case STAMTYPE_X8_RESET:
break;
case STAMTYPE_U16_RESET:
case STAMTYPE_X16_RESET:
break;
case STAMTYPE_U32_RESET:
case STAMTYPE_X32_RESET:
break;
case STAMTYPE_U64_RESET:
case STAMTYPE_X64_RESET:
break;
case STAMTYPE_BOOL_RESET:
break;
/* These are custom and will not be touched. */
case STAMTYPE_U8:
case STAMTYPE_X8:
case STAMTYPE_U16:
case STAMTYPE_X16:
case STAMTYPE_U32:
case STAMTYPE_X32:
case STAMTYPE_U64:
case STAMTYPE_X64:
case STAMTYPE_RATIO_U32:
case STAMTYPE_BOOL:
break;
default:
break;
}
return VINF_SUCCESS;
}
/**
* Get a snapshot of the statistics.
* It's possible to select a subset of the samples.
*
* @returns VBox status. (Basically, it cannot fail.)
* @param pUVM The user mode VM handle.
* @param pszPat The name matching pattern. See somewhere_where_this_is_described_in_detail.
* If NULL all samples are reset.
* @param fWithDesc Whether to include the descriptions.
* @param ppszSnapshot Where to store the pointer to the snapshot data.
* The format of the snapshot should be XML, but that will have to be discussed
* when this function is implemented.
* The returned pointer must be freed by calling STAMR3SnapshotFree().
* @param pcchSnapshot Where to store the size of the snapshot data. (Excluding the trailing '\0')
*/
VMMR3DECL(int) STAMR3Snapshot(PUVM pUVM, const char *pszPat, char **ppszSnapshot, size_t *pcchSnapshot, bool fWithDesc)
{
/*
* Write the XML header.
*/
/** @todo Make this proper & valid XML. */
/*
* Write the content.
*/
if (RT_SUCCESS(rc))
else
{
State.cbAllocated = 0;
}
/*
* Done.
*/
if (pcchSnapshot)
return rc;
}
/**
* stamR3EnumU callback employed by STAMR3Snapshot.
*
* @returns VBox status code, but it's interpreted as 0 == success / !0 == failure by enmR3Enum.
* @param pDesc The sample.
* @param pvArg The snapshot status structure.
*/
{
{
case STAMTYPE_COUNTER:
return VINF_SUCCESS;
break;
case STAMTYPE_PROFILE:
case STAMTYPE_PROFILE_ADV:
return VINF_SUCCESS;
stamR3SnapshotPrintf(pThis, "<Profile cPeriods=\"%lld\" cTicks=\"%lld\" cTicksMin=\"%lld\" cTicksMax=\"%lld\"",
break;
case STAMTYPE_RATIO_U32:
case STAMTYPE_RATIO_U32_RESET:
if (pDesc->enmVisibility == STAMVISIBILITY_USED && !pDesc->u.pRatioU32->u32A && !pDesc->u.pRatioU32->u32B)
return VINF_SUCCESS;
break;
case STAMTYPE_CALLBACK:
{
char szBuf[512];
break;
}
case STAMTYPE_U8:
case STAMTYPE_U8_RESET:
return VINF_SUCCESS;
break;
case STAMTYPE_X8:
case STAMTYPE_X8_RESET:
return VINF_SUCCESS;
break;
case STAMTYPE_U16:
case STAMTYPE_U16_RESET:
return VINF_SUCCESS;
break;
case STAMTYPE_X16:
case STAMTYPE_X16_RESET:
return VINF_SUCCESS;
break;
case STAMTYPE_U32:
case STAMTYPE_U32_RESET:
return VINF_SUCCESS;
break;
case STAMTYPE_X32:
case STAMTYPE_X32_RESET:
return VINF_SUCCESS;
break;
case STAMTYPE_U64:
case STAMTYPE_U64_RESET:
return VINF_SUCCESS;
break;
case STAMTYPE_X64:
case STAMTYPE_X64_RESET:
return VINF_SUCCESS;
break;
case STAMTYPE_BOOL:
case STAMTYPE_BOOL_RESET:
return VINF_SUCCESS;
break;
default:
return 0;
}
switch (pDesc->enmVisibility)
{
default:
case STAMVISIBILITY_ALWAYS:
break;
case STAMVISIBILITY_USED:
break;
case STAMVISIBILITY_NOT_GUI:
break;
}
{
/*
* The description is a bit tricky as it may include chars that
* xml requires to be escaped.
*/
if (!pszBadChar)
do
{
switch (*pszBadChar)
{
}
} while (pszBadChar);
}
}
/**
* Output callback for stamR3SnapshotPrintf.
*
* @returns number of bytes written.
* @param pvArg The snapshot status structure.
* @param pach Pointer to an array of characters (bytes).
* @param cch The number or chars (bytes) to write from the array.
*/
{
/*
* Make sure we've got space for it.
*/
{
return 0;
cbNewSize *= 2;
else
if (!pszNew)
{
/*
* Free up immediately, out-of-memory is bad news and this
* isn't an important allocations / API.
*/
pThis->cbAllocated = 0;
return 0;
}
}
/*
* Copy the chars to the buffer and terminate it.
*/
return cch;
}
/**
* Wrapper around RTStrFormatV for use by the snapshot API.
*
* @returns VBox status code.
* @param pThis The snapshot status structure.
* @param pszFormat The format string.
* @param ... Optional arguments.
*/
{
}
/**
* Releases a statistics snapshot returned by STAMR3Snapshot().
*
* @returns VBox status.
* @param pUVM The user mode VM handle.
* @param pszSnapshot The snapshot data pointer returned by STAMR3Snapshot().
* NULL is allowed.
*/
{
if (!pszSnapshot)
return VINF_SUCCESS;
}
/**
* Dumps the selected statistics to the log.
*
* @returns VBox status.
* @param pUVM Pointer to the user mode VM structure.
* @param pszPat The name matching pattern. See somewhere_where_this_is_described_in_detail.
* If NULL all samples are written to the log.
*/
{
return VINF_SUCCESS;
}
/**
* Prints to the log.
*
* @param pArgs Pointer to the print one argument structure.
* @param pszFormat Format string.
* @param ... Format arguments.
*/
static DECLCALLBACK(void) stamR3EnumLogPrintf(PSTAMR3PRINTONEARGS pArgs, const char *pszFormat, ...)
{
}
/**
* Dumps the selected statistics to the release log.
*
* @returns VBox status.
* @param pUVM Pointer to the user mode VM structure.
* @param pszPat The name matching pattern. See somewhere_where_this_is_described_in_detail.
* If NULL all samples are written to the log.
*/
{
return VINF_SUCCESS;
}
/**
* Prints to the release log.
*
* @param pArgs Pointer to the print one argument structure.
* @param pszFormat Format string.
* @param ... Format arguments.
*/
static DECLCALLBACK(void) stamR3EnumRelLogPrintf(PSTAMR3PRINTONEARGS pArgs, const char *pszFormat, ...)
{
}
/**
* Prints the selected statistics to standard out.
*
* @returns VBox status.
* @param pUVM The user mode VM handle.
* @param pszPat The name matching pattern. See somewhere_where_this_is_described_in_detail.
* If NULL all samples are reset.
*/
{
return VINF_SUCCESS;
}
/**
* Prints to stdout.
*
* @param pArgs Pointer to the print one argument structure.
* @param pszFormat Format string.
* @param ... Format arguments.
*/
{
}
/**
* Prints one sample.
* Callback for stamR3EnumU().
*
* @returns VINF_SUCCESS
* @param pDesc Pointer to the current descriptor.
* @param pvArg User argument - STAMR3PRINTONEARGS.
*/
{
{
case STAMTYPE_COUNTER:
return VINF_SUCCESS;
pArgs->pfnPrintf(pArgs, "%-32s %8llu %s\n", pDesc->pszName, pDesc->u.pCounter->c, STAMR3GetUnit(pDesc->enmUnit));
break;
case STAMTYPE_PROFILE:
case STAMTYPE_PROFILE_ADV:
{
return VINF_SUCCESS;
pArgs->pfnPrintf(pArgs, "%-32s %8llu %s (%12llu ticks, %7llu times, max %9llu, min %7lld)\n", pDesc->pszName,
pDesc->u.pProfile->cTicks, pDesc->u.pProfile->cPeriods, pDesc->u.pProfile->cTicksMax, pDesc->u.pProfile->cTicksMin);
break;
}
case STAMTYPE_RATIO_U32:
case STAMTYPE_RATIO_U32_RESET:
if (pDesc->enmVisibility == STAMVISIBILITY_USED && !pDesc->u.pRatioU32->u32A && !pDesc->u.pRatioU32->u32B)
return VINF_SUCCESS;
break;
case STAMTYPE_CALLBACK:
{
char szBuf[512];
break;
}
case STAMTYPE_U8:
case STAMTYPE_U8_RESET:
return VINF_SUCCESS;
pArgs->pfnPrintf(pArgs, "%-32s %8u %s\n", pDesc->pszName, *pDesc->u.pu8, STAMR3GetUnit(pDesc->enmUnit));
break;
case STAMTYPE_X8:
case STAMTYPE_X8_RESET:
return VINF_SUCCESS;
pArgs->pfnPrintf(pArgs, "%-32s %8x %s\n", pDesc->pszName, *pDesc->u.pu8, STAMR3GetUnit(pDesc->enmUnit));
break;
case STAMTYPE_U16:
case STAMTYPE_U16_RESET:
return VINF_SUCCESS;
pArgs->pfnPrintf(pArgs, "%-32s %8u %s\n", pDesc->pszName, *pDesc->u.pu16, STAMR3GetUnit(pDesc->enmUnit));
break;
case STAMTYPE_X16:
case STAMTYPE_X16_RESET:
return VINF_SUCCESS;
pArgs->pfnPrintf(pArgs, "%-32s %8x %s\n", pDesc->pszName, *pDesc->u.pu16, STAMR3GetUnit(pDesc->enmUnit));
break;
case STAMTYPE_U32:
case STAMTYPE_U32_RESET:
return VINF_SUCCESS;
pArgs->pfnPrintf(pArgs, "%-32s %8u %s\n", pDesc->pszName, *pDesc->u.pu32, STAMR3GetUnit(pDesc->enmUnit));
break;
case STAMTYPE_X32:
case STAMTYPE_X32_RESET:
return VINF_SUCCESS;
pArgs->pfnPrintf(pArgs, "%-32s %8x %s\n", pDesc->pszName, *pDesc->u.pu32, STAMR3GetUnit(pDesc->enmUnit));
break;
case STAMTYPE_U64:
case STAMTYPE_U64_RESET:
return VINF_SUCCESS;
pArgs->pfnPrintf(pArgs, "%-32s %8llu %s\n", pDesc->pszName, *pDesc->u.pu64, STAMR3GetUnit(pDesc->enmUnit));
break;
case STAMTYPE_X64:
case STAMTYPE_X64_RESET:
return VINF_SUCCESS;
pArgs->pfnPrintf(pArgs, "%-32s %8llx %s\n", pDesc->pszName, *pDesc->u.pu64, STAMR3GetUnit(pDesc->enmUnit));
break;
case STAMTYPE_BOOL:
case STAMTYPE_BOOL_RESET:
return VINF_SUCCESS;
pArgs->pfnPrintf(pArgs, "%-32s %s %s\n", pDesc->pszName, *pDesc->u.pf ? "true " : "false ", STAMR3GetUnit(pDesc->enmUnit));
break;
default:
break;
}
return VINF_SUCCESS;
}
/**
* Enumerate the statistics by the means of a callback function.
*
* @returns Whatever the callback returns.
*
* @param pUVM The user mode VM handle.
* @param pszPat The pattern to match samples.
* @param pfnEnum The callback function.
* @param pvUser The pvUser argument of the callback function.
*/
{
}
/**
* Callback function for STARTR3Enum().
*
* @returns whatever the callback returns.
* @param pDesc Pointer to the current descriptor.
* @param pvArg Points to a STAMR3ENUMONEARGS structure.
*/
{
int rc;
{
/* Give the enumerator something useful. */
char szBuf[512];
}
else
return rc;
}
/**
* Match a name against an array of patterns.
*
* @returns true if it matches, false if it doesn't match.
* @param papszExpressions The array of pattern expressions.
* @param cExpressions The number of array entries.
* @param pszName The name to match.
*/
unsigned *piExpression, const char *pszName)
{
{
const char *pszPat = papszExpressions[i];
{
/* later:
if (piExpression && i > *piExpression)
{
check if we can skip some expressions
}*/
return true;
}
}
return false;
}
/**
* Splits a multi pattern into single ones.
*
* @returns Pointer to an array of single patterns. Free it with RTMemTmpFree.
* @param pszPat The pattern to split.
* @param pcExpressions The number of array elements.
* @param pszCopy The pattern copy to free using RTStrFree.
*/
{
if (!pszCopy)
return NULL;
/* count them & allocate array. */
unsigned cExpressions = 1;
cExpressions++, psz++;
if (!papszExpressions)
{
return NULL;
}
/* split */
for (unsigned i = 0;;)
{
papszExpressions[i] = psz;
if (++i >= cExpressions)
break;
*psz++ = '\0';
}
/* sort the array, putting '*' last. */
/** @todo sort it... */
return papszExpressions;
}
/**
* Enumerates the nodes selected by a pattern or all nodes if no pattern
* is specified.
*
* The call may lock STAM for writing before calling this function, however do
* not lock it for reading as this function may need to write lock STAM.
*
* @returns The rc from the callback.
* @param pUVM Pointer to the user mode VM structure.
* @param pszPat Pattern.
* @param fUpdateRing0 Update the ring-0 .
* @param pfnCallback Callback function which shall be called for matching nodes.
* If it returns anything but VINF_SUCCESS the enumeration is
* terminated and the status code returned to the caller.
* @param pvArg User parameter for the callback.
*/
{
int rc = VINF_SUCCESS;
/*
* All
*/
{
if (fUpdateRing0)
while (pCur)
{
if (rc)
break;
/* next */
}
}
/*
* Single expression pattern.
*/
{
if (fUpdateRing0)
/** @todo This needs to be optimized since the GUI is using this path for the VM info dialog.
* Note that it's doing exact matching. Organizing the samples in a tree would speed up thing
* no end (at least for debug and profile builds). */
{
if (rc)
break;
}
}
/*
* Multi expression pattern.
*/
else
{
/*
* Split up the pattern first.
*/
char *pszCopy;
unsigned cExpressions;
if (!papszExpressions)
return VERR_NO_MEMORY;
/*
* Perform the enumeration.
*/
if (fUpdateRing0)
unsigned iExpression = 0;
{
if (rc)
break;
}
}
return rc;
}
/**
* Registers the ring-0 statistics.
*
* @param pUVM Pointer to the user mode VM structure.
*/
{
/* GVMM */
for (unsigned i = 0; i < RT_ELEMENTS(g_aGVMMStats); i++)
/* GMM */
for (unsigned i = 0; i < RT_ELEMENTS(g_aGMMStats); i++)
}
/**
* Updates the ring-0 statistics (the copy).
*
* @param pUVM Pointer to the user mode VM structure.
* @param pszPat The pattern.
*/
{
}
/**
* Updates the ring-0 statistics.
*
* The ring-0 statistics aren't directly addressable from ring-3 and must be
* copied when needed.
*
* @param pUVM Pointer to the user mode VM structure.
* @param pszPat The pattern (for knowing when to skip).
*/
static void stamR3Ring0StatsUpdateMultiU(PUVM pUVM, const char * const *papszExpressions, unsigned cExpressions)
{
return;
/*
* GVMM
*/
bool fUpdate = false;
for (unsigned i = 0; i < RT_ELEMENTS(g_aGVMMStats); i++)
{
fUpdate = true;
break;
}
if (!fUpdate)
{
/** @todo check the cpu leaves - rainy day. */
}
if (fUpdate)
{
if (RT_SUCCESS(rc))
{
/*
* Check if the number of host CPUs has changed (it will the first
* time around and normally never again).
*/
{
{
{
char szName[120];
}
}
}
}
}
/*
* GMM
*/
fUpdate = false;
for (unsigned i = 0; i < RT_ELEMENTS(g_aGMMStats); i++)
{
fUpdate = true;
break;
}
if (fUpdate)
{
if (RT_SUCCESS(rc))
}
}
/**
* Get the unit string.
*
* @returns Pointer to read only unit string.
* @param enmUnit The unit.
*/
{
switch (enmUnit)
{
case STAMUNIT_NONE: return "";
case STAMUNIT_CALLS: return "calls";
case STAMUNIT_COUNT: return "count";
case STAMUNIT_BYTES: return "bytes";
case STAMUNIT_PAGES: return "pages";
case STAMUNIT_ERRORS: return "errors";
case STAMUNIT_OCCURENCES: return "times";
case STAMUNIT_TICKS: return "ticks";
case STAMUNIT_TICKS_PER_CALL: return "ticks/call";
case STAMUNIT_TICKS_PER_OCCURENCE: return "ticks/time";
case STAMUNIT_GOOD_BAD: return "good:bad";
case STAMUNIT_MEGABYTES: return "megabytes";
case STAMUNIT_KILOBYTES: return "kilobytes";
case STAMUNIT_NS: return "ns";
case STAMUNIT_NS_PER_CALL: return "ns/call";
case STAMUNIT_NS_PER_OCCURENCE: return "ns/time";
case STAMUNIT_PCT: return "%";
case STAMUNIT_HZ: return "Hz";
default:
return "(?unit?)";
}
}
#ifdef VBOX_WITH_DEBUGGER
/**
* @callback_method_impl{FNDBGCCMD, The '.stats' command.}
*/
static DECLCALLBACK(int) stamR3CmdStats(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
{
/*
* Validate input.
*/
/*
* Do the printing.
*/
return stamR3EnumU(pUVM, cArgs ? paArgs[0].u.pszString : NULL, true /* fUpdateRing0 */, stamR3PrintOne, &Args);
}
/**
* Display one sample in the debugger.
*
* @param pArgs Pointer to the print one argument structure.
* @param pszFormat Format string.
* @param ... Format arguments.
*/
static DECLCALLBACK(void) stamR3EnumDbgfPrintf(PSTAMR3PRINTONEARGS pArgs, const char *pszFormat, ...)
{
}
/**
* @callback_method_impl{FNDBGCCMD, The '.statsreset' command.}
*/
static DECLCALLBACK(int) stamR3CmdStatsReset(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
{
/*
* Validate input.
*/
/*
* Execute reset.
*/
if (RT_SUCCESS(rc))
}
#endif /* VBOX_WITH_DEBUGGER */