/* $Id$ */
/** @file
* DBGF - Debugger Facility, Guest OS Diggers.
*/
/*
* Copyright (C) 2008-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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "DBGFInternal.h"
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* EMT interface wrappers.
*
* The diggers expects to be called on an EMT. To avoid the debugger+Main having
*
*/
typedef struct DBGFOSEMTWRAPPER
{
/** Pointer to the next list entry. */
/** The interface type. */
/** The digger interface pointer. */
union
{
/** Generic void pointer. */
void *pv;
/** DBGFOSINTERFACE_DMESG.*/
} uDigger;
/** The user mode VM handle. */
/** The wrapper interface union (consult enmIf). */
union
{
/** DBGFOSINTERFACE_DMESG.*/
} uWrapper;
/** Pointer to an EMT interface wrapper. */
/**
* Internal init routine called by DBGFR3Init().
*
* @returns VBox status code.
* @param pUVM The user mode VM handle.
*/
{
}
/**
* Internal cleanup routine called by DBGFR3Term().
*
* @param pUVM The user mode VM handle.
*/
{
/*
* Terminate the current one.
*/
{
}
/*
* Destroy all the instances.
*/
{
{
}
}
}
/**
* EMT worker function for DBGFR3OSRegister.
*
* @returns VBox status code.
* @param pUVM The user mode VM handle.
* @param pReg The registration structure.
*/
{
/* more validations. */
{
return VERR_ALREADY_LOADED;
}
/*
* Allocate a new structure, call the constructor and link it into the list.
*/
if (RT_SUCCESS(rc))
{
}
else
{
}
return VINF_SUCCESS;
}
/**
* Registers a guest OS digger.
*
* This will instantiate an instance of the digger and add it
* to the list for us in the next call to DBGFR3OSDetect().
*
* @returns VBox status code.
* @param pUVM The user mode VM handle.
* @param pReg The registration structure.
* @thread Any.
*/
{
/*
* Validate intput.
*/
/*
* Pass it on to EMT(0).
*/
}
/**
* EMT worker function for DBGFR3OSDeregister.
*
* @returns VBox status code.
* @param pUVM The user mode VM handle.
* @param pReg The registration structure.
*/
{
/*
* Unlink it.
*/
bool fWasCurOS = false;
{
if (pOSPrev)
else
{
fWasCurOS = true;
}
break;
}
if (!pOS)
{
return VERR_NOT_FOUND;
}
/*
* Terminate it if it was the current OS, then invoke the
* destructor and clean up.
*/
if (fWasCurOS)
{
}
return VINF_SUCCESS;
}
/**
* Deregisters a guest OS digger previously registered by DBGFR3OSRegister.
*
* @returns VBox status code.
*
* @param pUVM The user mode VM handle.
* @param pReg The registration structure.
* @thread Any.
*/
{
/*
* Validate input.
*/
break;
if (!pOS)
{
return VERR_NOT_FOUND;
}
/*
* Pass it on to EMT(0).
*/
}
/**
* EMT worker function for DBGFR3OSDetect.
*
* @returns VBox status code.
* @retval VINF_SUCCESS if successfully detected.
* @retval VINF_DBGF_OS_NOT_DETCTED if we cannot figure it out.
*
* @param pUVM The user mode VM handle.
* @param pszName Where to store the OS name. Empty string if not detected.
* @param cchName Size of the buffer.
*/
{
/*
* Cycle thru the detection routines.
*/
{
int rc;
else
{
if (pOldOS)
}
return rc;
}
/* not found */
if (pOldOS)
return VINF_DBGF_OS_NOT_DETCTED;
}
/**
* Detects the guest OS and try dig out symbols and useful stuff.
*
* When called the 2nd time, symbols will be updated that if the OS
* is the same.
*
* @returns VBox status code.
* @retval VINF_SUCCESS if successfully detected.
* @retval VINF_DBGF_OS_NOT_DETCTED if we cannot figure it out.
*
* @param pUVM The user mode VM handle.
* @param pszName Where to store the OS name. Empty string if not detected.
* @param cchName Size of the buffer.
* @thread Any.
*/
{
*pszName = '\0';
/*
* Pass it on to EMT(0).
*/
return VMR3ReqPriorityCallWaitU(pUVM, 0 /*idDstCpu*/, (PFNRT)dbgfR3OSDetect, 3, pUVM, pszName, cchName);
}
/**
* EMT worker function for DBGFR3OSQueryNameAndVersion
*
* @returns VBox status code.
* @param pUVM The user mode VM handle.
* @param pszName Where to store the OS name. Optional.
* @param cchName The size of the name buffer.
* @param pszVersion Where to store the version string. Optional.
* @param cchVersion The size of the version buffer.
*/
static DECLCALLBACK(int) dbgfR3OSQueryNameAndVersion(PUVM pUVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion)
{
/*
* Any known OS?
*/
{
{
else
{
}
}
if (pszVersion && cchVersion)
{
int rc2 = pUVM->dbgf.s.pCurOS->pReg->pfnQueryVersion(pUVM, pUVM->dbgf.s.pCurOS->abData, pszVersion, cchVersion);
}
return rc;
}
return VERR_DBGF_OS_NOT_DETCTED;
}
/**
*
* It goes without saying that this querying is done using the current
* guest OS digger and not additions or user configuration.
*
* @returns VBox status code.
* @param pUVM The user mode VM handle.
* @param pszName Where to store the OS name. Optional.
* @param cchName The size of the name buffer.
* @param pszVersion Where to store the version string. Optional.
* @param cchVersion The size of the version buffer.
* @thread Any.
*/
VMMR3DECL(int) DBGFR3OSQueryNameAndVersion(PUVM pUVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion)
{
/*
* Initialize the output up front.
*/
*pszName = '\0';
if (pszVersion && cchVersion)
*pszVersion = '\0';
/*
* Pass it on to EMT(0).
*/
}
/**
* @interface_method_impl{DBGFOSIDMESG,pfnQueryKernelLog, Generic EMT wrapper.}
*/
static DECLCALLBACK(int) dbgfR3OSEmtIDmesg_QueryKernelLog(PDBGFOSIDMESG pThis, PUVM pUVM, uint32_t fFlags, uint32_t cMessages,
{
if (cbBuf)
}
/**
* EMT worker for DBGFR3OSQueryInterface.
*
* @param pUVM The user mode VM handle.
* @param enmIf The interface identifier.
* @param ppvIf Where to store the interface pointer on success.
*/
{
/*
* Forward the query to the current OS.
*/
if (pOS)
{
void *pvDiggerIf;
if (pvDiggerIf)
{
/*
* Do we have an EMT wrapper for this interface already?
*
* We ASSUME the interfaces are static and not dynamically allocated
* for each QueryInterface call.
*/
if (pWrapper)
{
return;
}
/*
* Create a wrapper.
*/
if (RT_FAILURE(rc))
return;
switch (enmIf)
{
case DBGFOSINTERFACE_DMESG:
break;
default:
AssertFailed();
return;
}
{
}
else
{
}
return;
}
}
}
/**
* Query an optional digger interface.
*
* @returns Pointer to the digger interface on success, NULL if the interfaces isn't
* available or no active guest OS digger.
* @param pUVM The user mode VM handle.
* @param enmIf The interface identifier.
* @thread Any.
*/
{
AssertMsgReturn(enmIf > DBGFOSINTERFACE_INVALID && enmIf < DBGFOSINTERFACE_END, ("%d\n", enmIf), NULL);
/*
* Pass it on to an EMT.
*/
VMR3ReqPriorityCallVoidWaitU(pUVM, VMCPUID_ANY, (PFNRT)dbgfR3OSQueryInterface, 3, pUVM, enmIf, &pvIf);
return pvIf;
}