DBGFInfo.cpp revision dc7e0f093e66df3ea06a27af17713dea87186b9c
/* $Id$ */
/** @file
* DBGF - Debugger Facility, Info.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_DBGF_INFO
#include "DBGFInternal.h"
#include <iprt/semaphore.h>
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
static DECLCALLBACK(void) dbgfR3InfoLog_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args);
static DECLCALLBACK(void) dbgfR3InfoLogRel_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args);
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** Logger output. */
static const DBGFINFOHLP g_dbgfR3InfoLogHlp =
{
};
/** Release logger output. */
static const DBGFINFOHLP g_dbgfR3InfoLogRelHlp =
{
};
/**
* Initialize the info handlers.
*
* @returns VBox status code.
* @param pVM VM handle.
*/
{
/*
* Make sure we already didn't initialized in the lazy manner.
*/
return VINF_SUCCESS;
/*
* Initialize the crit sect.
*/
/*
* Register the 'info help' item.
*/
return VINF_SUCCESS;
}
/**
* Terminate the info handlers.
*
* @returns VBox status code.
* @param pVM VM handle.
*/
{
/*
* Delete the crit sect.
*/
return rc;
}
/** Logger output.
* @copydoc DBGFINFOHLP::pfnPrintf */
{
}
/** Logger output.
* @copydoc DBGFINFOHLP::pfnPrintfV */
static DECLCALLBACK(void) dbgfR3InfoLog_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args)
{
}
/**
* Gets the logger info helper.
* The returned info helper will unconditionally write all output to the log.
*
* @returns Pointer to the logger info helper.
*/
{
return &g_dbgfR3InfoLogHlp;
}
/** Release logger output.
* @copydoc DBGFINFOHLP::pfnPrintf */
{
}
/** Release logger output.
* @copydoc DBGFINFOHLP::pfnPrintfV */
static DECLCALLBACK(void) dbgfR3InfoLogRel_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args)
{
}
/**
* Gets the release logger info helper.
* The returned info helper will unconditionally write all output to the release log.
*
* @returns Pointer to the release logger info helper.
*/
{
return &g_dbgfR3InfoLogRelHlp;
}
/**
* Handle registration worker.
* This allocates the structure, initalizes the common fields and inserts into the list.
* Upon successful return the we're inside the crit sect and the caller must leave it.
*
* @returns VBox status code.
* @param pVM VM handle.
* @param pszName The identifier of the info.
* @param pszDesc The description of the info and any arguments the handler may take.
* @param fFlags The flags.
* @param ppInfo Where to store the created
*/
static int dbgfR3InfoRegister(PVM pVM, const char *pszName, const char *pszDesc, uint32_t fFlags, PDBGFINFO *ppInfo)
{
/*
* Validate.
*/
AssertMsgReturn(!(fFlags & ~(DBGFINFO_FLAGS_RUN_ON_EMT)), ("fFlags=%#x\n", fFlags), VERR_INVALID_PARAMETER);
/*
* Allocate and initialize.
*/
int rc;
PDBGFINFO pInfo = (PDBGFINFO)MMR3HeapAlloc(pVM, MM_TAG_DBGF_INFO, RT_OFFSETOF(DBGFINFO, szName[cchName]));
if (pInfo)
{
/* lazy init */
rc = VINF_SUCCESS;
if (VBOX_SUCCESS(rc))
{
/*
* Insert in alphabetical order.
*/
break;
if (pPrev)
else
return VINF_SUCCESS;
}
}
else
rc = VERR_NO_MEMORY;
return rc;
}
/**
* Register a info handler owned by a device.
*
* @returns VBox status code.
* @param pVM VM handle.
* @param pszName The identifier of the info.
* @param pszDesc The description of the info and any arguments the handler may take.
* @param pfnHandler The handler function to be called to display the info.
* @param pDevIns The device instance owning the info.
*/
VMMR3DECL(int) DBGFR3InfoRegisterDevice(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler, PPDMDEVINS pDevIns)
{
LogFlow(("DBGFR3InfoRegisterDevice: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p pDevIns=%p\n",
/*
* Validate the specific stuff.
*/
if (!pfnHandler)
{
AssertMsgFailed(("No handler\n"));
return VERR_INVALID_PARAMETER;
}
if (!pDevIns)
{
AssertMsgFailed(("No pDevIns\n"));
return VERR_INVALID_PARAMETER;
}
/*
* Register
*/
if (VBOX_SUCCESS(rc))
{
}
return rc;
}
/**
* Register a info handler owned by a driver.
*
* @returns VBox status code.
* @param pVM VM handle.
* @param pszName The identifier of the info.
* @param pszDesc The description of the info and any arguments the handler may take.
* @param pfnHandler The handler function to be called to display the info.
* @param pDrvIns The driver instance owning the info.
*/
VMMR3DECL(int) DBGFR3InfoRegisterDriver(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler, PPDMDRVINS pDrvIns)
{
LogFlow(("DBGFR3InfoRegisterDriver: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p pDrvIns=%p\n",
/*
* Validate the specific stuff.
*/
if (!pfnHandler)
{
AssertMsgFailed(("No handler\n"));
return VERR_INVALID_PARAMETER;
}
if (!pDrvIns)
{
AssertMsgFailed(("No pDrvIns\n"));
return VERR_INVALID_PARAMETER;
}
/*
* Register
*/
if (VBOX_SUCCESS(rc))
{
}
return rc;
}
/**
* Register a info handler owned by an internal component.
*
* @returns VBox status code.
* @param pVM VM handle.
* @param pszName The identifier of the info.
* @param pszDesc The description of the info and any arguments the handler may take.
* @param pfnHandler The handler function to be called to display the info.
*/
VMMR3DECL(int) DBGFR3InfoRegisterInternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler)
{
}
/**
* Register a info handler owned by an internal component.
*
* @returns VBox status code.
* @param pVM VM handle.
* @param pszName The identifier of the info.
* @param pszDesc The description of the info and any arguments the handler may take.
* @param pfnHandler The handler function to be called to display the info.
* @param fFlags Flags, see the DBGFINFO_FLAGS_*.
*/
VMMR3DECL(int) DBGFR3InfoRegisterInternalEx(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler, uint32_t fFlags)
{
LogFlow(("DBGFR3InfoRegisterInternal: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p fFlags=%x\n",
/*
* Validate the specific stuff.
*/
if (!pfnHandler)
{
AssertMsgFailed(("No handler\n"));
return VERR_INVALID_PARAMETER;
}
/*
* Register
*/
if (VBOX_SUCCESS(rc))
{
}
return rc;
}
/**
* Register a info handler owned by an external component.
*
* @returns VBox status code.
* @param pVM VM handle.
* @param pszName The identifier of the info.
* @param pszDesc The description of the info and any arguments the handler may take.
* @param pfnHandler The handler function to be called to display the info.
* @param pvUser User argument to be passed to the handler.
*/
VMMR3DECL(int) DBGFR3InfoRegisterExternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLEREXT pfnHandler, void *pvUser)
{
LogFlow(("DBGFR3InfoRegisterExternal: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p pvUser=%p\n",
/*
* Validate the specific stuff.
*/
if (!pfnHandler)
{
AssertMsgFailed(("No handler\n"));
return VERR_INVALID_PARAMETER;
}
/*
* Register
*/
if (VBOX_SUCCESS(rc))
{
}
return rc;
}
/**
* Deregister one(/all) info handler(s) owned by a device.
*
* @returns VBox status code.
* @param pVM VM Handle.
* @param pDevIns Device instance.
* @param pszName The identifier of the info. If NULL all owned by the device.
*/
{
/*
* Validate input.
*/
if (!pDevIns)
{
AssertMsgFailed(("!pDevIns\n"));
return VERR_INVALID_PARAMETER;
}
/*
* Enumerate the info handlers and free the requested entries.
*/
if (pszName)
{
/*
* Free a specific one.
*/
{
if (pPrev)
else
rc = VINF_SUCCESS;
break;
}
}
else
{
/*
* Free all owned by the driver.
*/
{
if (pPrev)
else
}
rc = VINF_SUCCESS;
}
return rc;
}
/**
* Deregister one(/all) info handler(s) owned by a driver.
*
* @returns VBox status code.
* @param pVM VM Handle.
* @param pDrvIns Driver instance.
* @param pszName The identifier of the info. If NULL all owned by the driver.
*/
{
/*
* Validate input.
*/
if (!pDrvIns)
{
AssertMsgFailed(("!pDrvIns\n"));
return VERR_INVALID_PARAMETER;
}
/*
* Enumerate the info handlers and free the requested entries.
*/
if (pszName)
{
/*
* Free a specific one.
*/
{
if (pPrev)
else
rc = VINF_SUCCESS;
break;
}
}
else
{
/*
* Free all owned by the driver.
*/
{
if (pPrev)
else
}
rc = VINF_SUCCESS;
}
return rc;
}
/**
* Internal deregistration helper.
*
* @returns VBox status code.
* @param pVM VM Handle.
* @param pszName The identifier of the info.
* @param enmType The info owner type.
*/
{
/*
* Validate input.
*/
if (!pszName)
{
AssertMsgFailed(("!pszName\n"));
return VERR_INVALID_PARAMETER;
}
/*
* Find the info handler.
*/
{
if (pPrev)
else
rc = VINF_SUCCESS;
break;
}
return rc;
}
/**
* Deregister a info handler owned by an internal component.
*
* @returns VBox status code.
* @param pVM VM Handle.
* @param pszName The identifier of the info. If NULL all owned by the device.
*/
{
}
/**
* Deregister a info handler owned by an external component.
*
* @returns VBox status code.
* @param pVM VM Handle.
* @param pszName The identifier of the info. If NULL all owned by the device.
*/
{
}
/**
* Display a piece of info writing to the supplied handler.
*
* @returns VBox status code.
* @param pVM VM handle.
* @param pszName The identifier of the info to display.
* @param pszArgs Arguments to the info handler.
* @param pHlp The output helper functions. If NULL the logger will be used.
*/
{
/*
* Validate input.
*/
if (!pszName)
{
AssertMsgFailed(("!pszName\n"));
return VERR_INVALID_PARAMETER;
}
if (pHlp)
{
|| !pHlp->pfnPrintfV)
{
AssertMsgFailed(("A pHlp member is missing!\n"));
return VERR_INVALID_PARAMETER;
}
}
else
/*
* Find the info handler.
*/
break;
if (pInfo)
{
/*
* Found it.
* Make a copy of it on the stack so we can leave the crit sect.
* Switch on the type and invoke the handler.
*/
rc = VINF_SUCCESS;
{
case DBGFINFOTYPE_DEV:
rc = VMR3ReqCallVoid(pVM, VMREQDEST_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)Info.u.Dev.pfnHandler, 3, Info.u.Dev.pDevIns, pHlp, pszArgs);
else
break;
case DBGFINFOTYPE_DRV:
rc = VMR3ReqCallVoid(pVM, VMREQDEST_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)Info.u.Drv.pfnHandler, 3, Info.u.Drv.pDrvIns, pHlp, pszArgs);
else
break;
case DBGFINFOTYPE_INT:
rc = VMR3ReqCallVoid(pVM, VMREQDEST_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)Info.u.Int.pfnHandler, 3, pVM, pHlp, pszArgs);
else
break;
case DBGFINFOTYPE_EXT:
rc = VMR3ReqCallVoid(pVM, VMREQDEST_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)Info.u.Ext.pfnHandler, 3, Info.u.Ext.pvUser, pHlp, pszArgs);
else
break;
default:
break;
}
}
else
{
}
return rc;
}
/**
* Enumerate all the register info handlers.
*
* @returns VBox status code.
* @param pVM VM handle.
* @param pfnCallback Pointer to callback function.
* @param pvUser User argument to pass to the callback.
*/
{
/*
* Validate input.
*/
if (!pfnCallback)
{
AssertMsgFailed(("!pfnCallback\n"));
return VERR_INVALID_PARAMETER;
}
/*
* Enter and enumerate.
*/
rc = VINF_SUCCESS;
/*
* Leave and exit.
*/
return rc;
}
/**
* Info handler, internal version.
*
* @param pVM The VM handle.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
{
/*
* Enter and enumerate.
*/
{
{
if ( psz
}
}
else
{
}
/*
* Leave and exit.
*/
}