diff options
Diffstat (limited to 'src/VBox/VMM/VMMR3/DBGFOS.cpp')
| -rw-r--r-- | src/VBox/VMM/VMMR3/DBGFOS.cpp | 168 |
1 files changed, 85 insertions, 83 deletions
diff --git a/src/VBox/VMM/VMMR3/DBGFOS.cpp b/src/VBox/VMM/VMMR3/DBGFOS.cpp index 0cc90a6a..902432e4 100644 --- a/src/VBox/VMM/VMMR3/DBGFOS.cpp +++ b/src/VBox/VMM/VMMR3/DBGFOS.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2008 Oracle Corporation + * 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; @@ -23,7 +23,7 @@ #include <VBox/vmm/dbgf.h> #include <VBox/vmm/mm.h> #include "DBGFInternal.h" -#include <VBox/vmm/vm.h> +#include <VBox/vmm/uvm.h> #include <VBox/err.h> #include <VBox/log.h> @@ -35,38 +35,38 @@ /******************************************************************************* * Defined Constants And Macros * *******************************************************************************/ -#define DBGF_OS_READ_LOCK(pVM) do { } while (0) -#define DBGF_OS_READ_UNLOCK(pVM) do { } while (0) +#define DBGF_OS_READ_LOCK(pUVM) do { } while (0) +#define DBGF_OS_READ_UNLOCK(pUVM) do { } while (0) -#define DBGF_OS_WRITE_LOCK(pVM) do { } while (0) -#define DBGF_OS_WRITE_UNLOCK(pVM) do { } while (0) +#define DBGF_OS_WRITE_LOCK(pUVM) do { } while (0) +#define DBGF_OS_WRITE_UNLOCK(pUVM) do { } while (0) /** * Internal cleanup routine called by DBGFR3Term(). * - * @param pVM Pointer to the VM. + * @param pUVM The user mode VM handle. */ -void dbgfR3OSTerm(PVM pVM) +void dbgfR3OSTerm(PUVM pUVM) { /* * Terminate the current one. */ - if (pVM->dbgf.s.pCurOS) + if (pUVM->dbgf.s.pCurOS) { - pVM->dbgf.s.pCurOS->pReg->pfnTerm(pVM, pVM->dbgf.s.pCurOS->abData); - pVM->dbgf.s.pCurOS = NULL; + pUVM->dbgf.s.pCurOS->pReg->pfnTerm(pUVM, pUVM->dbgf.s.pCurOS->abData); + pUVM->dbgf.s.pCurOS = NULL; } /* * Destroy all the instances. */ - while (pVM->dbgf.s.pOSHead) + while (pUVM->dbgf.s.pOSHead) { - PDBGFOS pOS = pVM->dbgf.s.pOSHead; - pVM->dbgf.s.pOSHead = pOS->pNext; + PDBGFOS pOS = pUVM->dbgf.s.pOSHead; + pUVM->dbgf.s.pOSHead = pOS->pNext; if (pOS->pReg->pfnDestruct) - pOS->pReg->pfnDestruct(pVM, pOS->abData); + pOS->pReg->pfnDestruct(pUVM, pOS->abData); MMR3HeapFree(pOS); } } @@ -76,18 +76,18 @@ void dbgfR3OSTerm(PVM pVM) * EMT worker function for DBGFR3OSRegister. * * @returns VBox status code. - * @param pVM Pointer to the VM. + * @param pUVM The user mode VM handle. * @param pReg The registration structure. */ -static DECLCALLBACK(int) dbgfR3OSRegister(PVM pVM, PDBGFOSREG pReg) +static DECLCALLBACK(int) dbgfR3OSRegister(PUVM pUVM, PDBGFOSREG pReg) { /* more validations. */ - DBGF_OS_READ_LOCK(pVM); + DBGF_OS_READ_LOCK(pUVM); PDBGFOS pOS; - for (pOS = pVM->dbgf.s.pOSHead; pOS; pOS = pOS->pNext) + for (pOS = pUVM->dbgf.s.pOSHead; pOS; pOS = pOS->pNext) if (!strcmp(pOS->pReg->szName, pReg->szName)) { - DBGF_OS_READ_UNLOCK(pVM); + DBGF_OS_READ_UNLOCK(pUVM); Log(("dbgfR3OSRegister: %s -> VERR_ALREADY_LOADED\n", pReg->szName)); return VERR_ALREADY_LOADED; } @@ -95,22 +95,22 @@ static DECLCALLBACK(int) dbgfR3OSRegister(PVM pVM, PDBGFOSREG pReg) /* * Allocate a new structure, call the constructor and link it into the list. */ - pOS = (PDBGFOS)MMR3HeapAllocZ(pVM, MM_TAG_DBGF_OS, RT_OFFSETOF(DBGFOS, abData[pReg->cbData])); + pOS = (PDBGFOS)MMR3HeapAllocZU(pUVM, MM_TAG_DBGF_OS, RT_OFFSETOF(DBGFOS, abData[pReg->cbData])); AssertReturn(pOS, VERR_NO_MEMORY); pOS->pReg = pReg; - int rc = pOS->pReg->pfnConstruct(pVM, pOS->abData); + int rc = pOS->pReg->pfnConstruct(pUVM, pOS->abData); if (RT_SUCCESS(rc)) { - DBGF_OS_WRITE_LOCK(pVM); - pOS->pNext = pVM->dbgf.s.pOSHead; - pVM->dbgf.s.pOSHead = pOS; - DBGF_OS_WRITE_UNLOCK(pVM); + DBGF_OS_WRITE_LOCK(pUVM); + pOS->pNext = pUVM->dbgf.s.pOSHead; + pUVM->dbgf.s.pOSHead = pOS; + DBGF_OS_WRITE_UNLOCK(pUVM); } else { if (pOS->pReg->pfnDestruct) - pOS->pReg->pfnDestruct(pVM, pOS->abData); + pOS->pReg->pfnDestruct(pUVM, pOS->abData); MMR3HeapFree(pOS); } @@ -125,16 +125,16 @@ static DECLCALLBACK(int) dbgfR3OSRegister(PVM pVM, PDBGFOSREG pReg) * to the list for us in the next call to DBGFR3OSDetect(). * * @returns VBox status code. - * @param pVM Pointer to the VM. + * @param pUVM The user mode VM handle. * @param pReg The registration structure. * @thread Any. */ -VMMR3DECL(int) DBGFR3OSRegister(PVM pVM, PCDBGFOSREG pReg) +VMMR3DECL(int) DBGFR3OSRegister(PUVM pUVM, PCDBGFOSREG pReg) { /* * Validate intput. */ - VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE); + UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE); AssertPtrReturn(pReg, VERR_INVALID_POINTER); AssertReturn(pReg->u32Magic == DBGFOSREG_MAGIC, VERR_INVALID_MAGIC); @@ -155,7 +155,7 @@ VMMR3DECL(int) DBGFR3OSRegister(PVM pVM, PCDBGFOSREG pReg) /* * Pass it on to EMT(0). */ - return VMR3ReqPriorityCallWait(pVM, 0 /*idDstCpu*/, (PFNRT)dbgfR3OSRegister, 2, pVM, pReg); + return VMR3ReqPriorityCallWaitU(pUVM, 0 /*idDstCpu*/, (PFNRT)dbgfR3OSRegister, 2, pUVM, pReg); } @@ -163,10 +163,10 @@ VMMR3DECL(int) DBGFR3OSRegister(PVM pVM, PCDBGFOSREG pReg) * EMT worker function for DBGFR3OSDeregister. * * @returns VBox status code. - * @param pVM Pointer to the VM. + * @param pUVM The user mode VM handle. * @param pReg The registration structure. */ -static DECLCALLBACK(int) dbgfR3OSDeregister(PVM pVM, PDBGFOSREG pReg) +static DECLCALLBACK(int) dbgfR3OSDeregister(PUVM pUVM, PDBGFOSREG pReg) { /* * Unlink it. @@ -174,22 +174,22 @@ static DECLCALLBACK(int) dbgfR3OSDeregister(PVM pVM, PDBGFOSREG pReg) bool fWasCurOS = false; PDBGFOS pOSPrev = NULL; PDBGFOS pOS; - DBGF_OS_WRITE_LOCK(pVM); - for (pOS = pVM->dbgf.s.pOSHead; pOS; pOSPrev = pOS, pOS = pOS->pNext) + DBGF_OS_WRITE_LOCK(pUVM); + for (pOS = pUVM->dbgf.s.pOSHead; pOS; pOSPrev = pOS, pOS = pOS->pNext) if (pOS->pReg == pReg) { if (pOSPrev) pOSPrev->pNext = pOS->pNext; else - pVM->dbgf.s.pOSHead = pOS->pNext; - if (pVM->dbgf.s.pCurOS == pOS) + pUVM->dbgf.s.pOSHead = pOS->pNext; + if (pUVM->dbgf.s.pCurOS == pOS) { - pVM->dbgf.s.pCurOS = NULL; + pUVM->dbgf.s.pCurOS = NULL; fWasCurOS = true; } break; } - DBGF_OS_WRITE_UNLOCK(pVM); + DBGF_OS_WRITE_UNLOCK(pUVM); if (!pOS) { Log(("DBGFR3OSDeregister: %s -> VERR_NOT_FOUND\n", pReg->szName)); @@ -201,9 +201,9 @@ static DECLCALLBACK(int) dbgfR3OSDeregister(PVM pVM, PDBGFOSREG pReg) * destructor and clean up. */ if (fWasCurOS) - pOS->pReg->pfnTerm(pVM, pOS->abData); + pOS->pReg->pfnTerm(pUVM, pOS->abData); if (pOS->pReg->pfnDestruct) - pOS->pReg->pfnDestruct(pVM, pOS->abData); + pOS->pReg->pfnDestruct(pUVM, pOS->abData); MMR3HeapFree(pOS); return VINF_SUCCESS; @@ -215,27 +215,27 @@ static DECLCALLBACK(int) dbgfR3OSDeregister(PVM pVM, PDBGFOSREG pReg) * * @returns VBox status code. * - * @param pVM Pointer to the VM. + * @param pUVM The user mode VM handle. * @param pReg The registration structure. * @thread Any. */ -VMMR3DECL(int) DBGFR3OSDeregister(PVM pVM, PCDBGFOSREG pReg) +VMMR3DECL(int) DBGFR3OSDeregister(PUVM pUVM, PCDBGFOSREG pReg) { /* * Validate input. */ - VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE); + UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE); AssertPtrReturn(pReg, VERR_INVALID_POINTER); AssertReturn(pReg->u32Magic == DBGFOSREG_MAGIC, VERR_INVALID_MAGIC); AssertReturn(pReg->u32EndMagic == DBGFOSREG_MAGIC, VERR_INVALID_MAGIC); AssertReturn(RTStrEnd(&pReg->szName[0], sizeof(pReg->szName)), VERR_INVALID_NAME); - DBGF_OS_READ_LOCK(pVM); + DBGF_OS_READ_LOCK(pUVM); PDBGFOS pOS; - for (pOS = pVM->dbgf.s.pOSHead; pOS; pOS = pOS->pNext) + for (pOS = pUVM->dbgf.s.pOSHead; pOS; pOS = pOS->pNext) if (pOS->pReg == pReg) break; - DBGF_OS_READ_LOCK(pVM); + DBGF_OS_READ_LOCK(pUVM); if (!pOS) { @@ -246,7 +246,7 @@ VMMR3DECL(int) DBGFR3OSDeregister(PVM pVM, PCDBGFOSREG pReg) /* * Pass it on to EMT(0). */ - return VMR3ReqPriorityCallWait(pVM, 0 /*idDstCpu*/, (PFNRT)dbgfR3OSDeregister, 2, pVM, pReg); + return VMR3ReqPriorityCallWaitU(pUVM, 0 /*idDstCpu*/, (PFNRT)dbgfR3OSDeregister, 2, pUVM, pReg); } @@ -257,30 +257,30 @@ VMMR3DECL(int) DBGFR3OSDeregister(PVM pVM, PCDBGFOSREG pReg) * @retval VINF_SUCCESS if successfully detected. * @retval VINF_DBGF_OS_NOT_DETCTED if we cannot figure it out. * - * @param pVM Pointer to the VM. + * @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. */ -static DECLCALLBACK(int) dbgfR3OSDetect(PVM pVM, char *pszName, size_t cchName) +static DECLCALLBACK(int) dbgfR3OSDetect(PUVM pUVM, char *pszName, size_t cchName) { /* * Cycle thru the detection routines. */ - PDBGFOS const pOldOS = pVM->dbgf.s.pCurOS; - pVM->dbgf.s.pCurOS = NULL; + PDBGFOS const pOldOS = pUVM->dbgf.s.pCurOS; + pUVM->dbgf.s.pCurOS = NULL; - for (PDBGFOS pNewOS = pVM->dbgf.s.pOSHead; pNewOS; pNewOS = pNewOS->pNext) - if (pNewOS->pReg->pfnProbe(pVM, pNewOS->abData)) + for (PDBGFOS pNewOS = pUVM->dbgf.s.pOSHead; pNewOS; pNewOS = pNewOS->pNext) + if (pNewOS->pReg->pfnProbe(pUVM, pNewOS->abData)) { int rc; - pVM->dbgf.s.pCurOS = pNewOS; + pUVM->dbgf.s.pCurOS = pNewOS; if (pOldOS == pNewOS) - rc = pNewOS->pReg->pfnRefresh(pVM, pNewOS->abData); + rc = pNewOS->pReg->pfnRefresh(pUVM, pNewOS->abData); else { if (pOldOS) - pOldOS->pReg->pfnTerm(pVM, pNewOS->abData); - rc = pNewOS->pReg->pfnInit(pVM, pNewOS->abData); + pOldOS->pReg->pfnTerm(pUVM, pNewOS->abData); + rc = pNewOS->pReg->pfnInit(pUVM, pNewOS->abData); } if (pszName && cchName) strncat(pszName, pNewOS->pReg->szName, cchName); @@ -289,7 +289,7 @@ static DECLCALLBACK(int) dbgfR3OSDetect(PVM pVM, char *pszName, size_t cchName) /* not found */ if (pOldOS) - pOldOS->pReg->pfnTerm(pVM, pOldOS->abData); + pOldOS->pReg->pfnTerm(pUVM, pOldOS->abData); return VINF_DBGF_OS_NOT_DETCTED; } @@ -304,21 +304,22 @@ static DECLCALLBACK(int) dbgfR3OSDetect(PVM pVM, char *pszName, size_t cchName) * @retval VINF_SUCCESS if successfully detected. * @retval VINF_DBGF_OS_NOT_DETCTED if we cannot figure it out. * - * @param pVM Pointer to the VM. + * @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. */ -VMMR3DECL(int) DBGFR3OSDetect(PVM pVM, char *pszName, size_t cchName) +VMMR3DECL(int) DBGFR3OSDetect(PUVM pUVM, char *pszName, size_t cchName) { AssertPtrNullReturn(pszName, VERR_INVALID_POINTER); if (pszName && cchName) *pszName = '\0'; + UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE); /* * Pass it on to EMT(0). */ - return VMR3ReqPriorityCallWait(pVM, 0 /*idDstCpu*/, (PFNRT)dbgfR3OSDetect, 3, pVM, pszName, cchName); + return VMR3ReqPriorityCallWaitU(pUVM, 0 /*idDstCpu*/, (PFNRT)dbgfR3OSDetect, 3, pUVM, pszName, cchName); } @@ -326,28 +327,28 @@ VMMR3DECL(int) DBGFR3OSDetect(PVM pVM, char *pszName, size_t cchName) * EMT worker function for DBGFR3OSQueryNameAndVersion * * @returns VBox status code. - * @param pVM Pointer to the VM. + * @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(PVM pVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion) +static DECLCALLBACK(int) dbgfR3OSQueryNameAndVersion(PUVM pUVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion) { /* * Any known OS? */ - if (pVM->dbgf.s.pCurOS) + if (pUVM->dbgf.s.pCurOS) { int rc = VINF_SUCCESS; if (pszName && cchName) { - size_t cch = strlen(pVM->dbgf.s.pCurOS->pReg->szName); + size_t cch = strlen(pUVM->dbgf.s.pCurOS->pReg->szName); if (cchName > cch) - memcpy(pszName, pVM->dbgf.s.pCurOS->pReg->szName, cch + 1); + memcpy(pszName, pUVM->dbgf.s.pCurOS->pReg->szName, cch + 1); else { - memcpy(pszName, pVM->dbgf.s.pCurOS->pReg->szName, cchName - 1); + memcpy(pszName, pUVM->dbgf.s.pCurOS->pReg->szName, cchName - 1); pszName[cchName - 1] = '\0'; rc = VINF_BUFFER_OVERFLOW; } @@ -355,7 +356,7 @@ static DECLCALLBACK(int) dbgfR3OSQueryNameAndVersion(PVM pVM, char *pszName, siz if (pszVersion && cchVersion) { - int rc2 = pVM->dbgf.s.pCurOS->pReg->pfnQueryVersion(pVM, pVM->dbgf.s.pCurOS->abData, pszVersion, cchVersion); + int rc2 = pUVM->dbgf.s.pCurOS->pReg->pfnQueryVersion(pUVM, pUVM->dbgf.s.pCurOS->abData, pszVersion, cchVersion); if (RT_FAILURE(rc2) || rc == VINF_SUCCESS) rc = rc2; } @@ -373,15 +374,16 @@ static DECLCALLBACK(int) dbgfR3OSQueryNameAndVersion(PVM pVM, char *pszName, siz * guest OS digger and not additions or user configuration. * * @returns VBox status code. - * @param pVM Pointer to the VM. + * @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(PVM pVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion) +VMMR3DECL(int) DBGFR3OSQueryNameAndVersion(PUVM pUVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion) { + UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE); AssertPtrNullReturn(pszName, VERR_INVALID_POINTER); AssertPtrNullReturn(pszVersion, VERR_INVALID_POINTER); @@ -396,23 +398,23 @@ VMMR3DECL(int) DBGFR3OSQueryNameAndVersion(PVM pVM, char *pszName, size_t cchNam /* * Pass it on to EMT(0). */ - return VMR3ReqPriorityCallWait(pVM, 0 /*idDstCpu*/, - (PFNRT)dbgfR3OSQueryNameAndVersion, 5, pVM, pszName, cchName, pszVersion, cchVersion); + return VMR3ReqPriorityCallWaitU(pUVM, 0 /*idDstCpu*/, + (PFNRT)dbgfR3OSQueryNameAndVersion, 5, pUVM, pszName, cchName, pszVersion, cchVersion); } /** * EMT worker for DBGFR3OSQueryInterface. * - * @param pVM Pointer to the VM. - * @param enmIf The interface identifier. - * @param ppvIf Where to store the interface pointer on success. + * @param pUVM The user mode VM handle. + * @param enmIf The interface identifier. + * @param ppvIf Where to store the interface pointer on success. */ -static DECLCALLBACK(void) dbgfR3OSQueryInterface(PVM pVM, DBGFOSINTERFACE enmIf, void **ppvIf) +static DECLCALLBACK(void) dbgfR3OSQueryInterface(PUVM pUVM, DBGFOSINTERFACE enmIf, void **ppvIf) { - if (pVM->dbgf.s.pCurOS) + if (pUVM->dbgf.s.pCurOS) { - *ppvIf = pVM->dbgf.s.pCurOS->pReg->pfnQueryInterface(pVM, pVM->dbgf.s.pCurOS->abData, enmIf); + *ppvIf = pUVM->dbgf.s.pCurOS->pReg->pfnQueryInterface(pUVM, pUVM->dbgf.s.pCurOS->abData, enmIf); if (*ppvIf) { /** @todo Create EMT wrapper for the returned interface once we've defined one... @@ -429,11 +431,11 @@ static DECLCALLBACK(void) dbgfR3OSQueryInterface(PVM pVM, DBGFOSINTERFACE enmIf, * * @returns Pointer to the digger interface on success, NULL if the interfaces isn't * available or no active guest OS digger. - * @param pVM Pointer to the VM. - * @param enmIf The interface identifier. + * @param pUVM The user mode VM handle. + * @param enmIf The interface identifier. * @thread Any. */ -VMMR3DECL(void *) DBGFR3OSQueryInterface(PVM pVM, DBGFOSINTERFACE enmIf) +VMMR3DECL(void *) DBGFR3OSQueryInterface(PUVM pUVM, DBGFOSINTERFACE enmIf) { AssertMsgReturn(enmIf > DBGFOSINTERFACE_INVALID && enmIf < DBGFOSINTERFACE_END, ("%d\n", enmIf), NULL); @@ -441,7 +443,7 @@ VMMR3DECL(void *) DBGFR3OSQueryInterface(PVM pVM, DBGFOSINTERFACE enmIf) * Pass it on to an EMT. */ void *pvIf = NULL; - VMR3ReqPriorityCallVoidWait(pVM, VMCPUID_ANY, (PFNRT)dbgfR3OSQueryInterface, 3, pVM, enmIf, &pvIf); + VMR3ReqPriorityCallVoidWaitU(pUVM, VMCPUID_ANY, (PFNRT)dbgfR3OSQueryInterface, 3, pUVM, enmIf, &pvIf); return pvIf; } |
