summaryrefslogtreecommitdiff
path: root/src/VBox/VMM/VMMR3/DBGFCpu.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-03-26 19:21:20 +0000
committer <>2014-05-08 15:03:54 +0000
commitfb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch)
treec2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/VMM/VMMR3/DBGFCpu.cpp
parent58ed4748338f9466599adfc8a9171280ed99e23f (diff)
downloadVirtualBox-master.tar.gz
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/VMM/VMMR3/DBGFCpu.cpp')
-rw-r--r--src/VBox/VMM/VMMR3/DBGFCpu.cpp73
1 files changed, 63 insertions, 10 deletions
diff --git a/src/VBox/VMM/VMMR3/DBGFCpu.cpp b/src/VBox/VMM/VMMR3/DBGFCpu.cpp
index 0aff3100..afb58430 100644
--- a/src/VBox/VMM/VMMR3/DBGFCpu.cpp
+++ b/src/VBox/VMM/VMMR3/DBGFCpu.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-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;
@@ -24,6 +24,7 @@
#include <VBox/vmm/cpum.h>
#include "DBGFInternal.h"
#include <VBox/vmm/vm.h>
+#include <VBox/vmm/uvm.h>
#include <VBox/err.h>
#include <VBox/log.h>
#include <VBox/param.h>
@@ -34,9 +35,9 @@
* Wrapper around CPUMGetGuestMode.
*
* @returns VINF_SUCCESS.
- * @param pVM Pointer to the VM.
- * @param idCpu The current CPU ID.
- * @param penmMode Where to return the mode.
+ * @param pVM Pointer to the VM.
+ * @param idCpu The current CPU ID.
+ * @param penmMode Where to return the mode.
*/
static DECLCALLBACK(int) dbgfR3CpuGetMode(PVM pVM, VMCPUID idCpu, CPUMMODE *penmMode)
{
@@ -51,18 +52,70 @@ static DECLCALLBACK(int) dbgfR3CpuGetMode(PVM pVM, VMCPUID idCpu, CPUMMODE *penm
* Get the current CPU mode.
*
* @returns The CPU mode on success, CPUMMODE_INVALID on failure.
- * @param pVM Pointer to the VM.
- * @param idCpu The target CPU ID.
+ * @param pUVM The user mode VM handle.
+ * @param idCpu The target CPU ID.
*/
-VMMR3DECL(CPUMMODE) DBGFR3CpuGetMode(PVM pVM, VMCPUID idCpu)
+VMMR3DECL(CPUMMODE) DBGFR3CpuGetMode(PUVM pUVM, VMCPUID idCpu)
{
- VM_ASSERT_VALID_EXT_RETURN(pVM, CPUMMODE_INVALID);
- AssertReturn(idCpu < pVM->cCpus, CPUMMODE_INVALID);
+ UVM_ASSERT_VALID_EXT_RETURN(pUVM, CPUMMODE_INVALID);
+ VM_ASSERT_VALID_EXT_RETURN(pUVM->pVM, CPUMMODE_INVALID);
+ AssertReturn(idCpu < pUVM->pVM->cCpus, CPUMMODE_INVALID);
CPUMMODE enmMode;
- int rc = VMR3ReqPriorityCallWait(pVM, idCpu, (PFNRT)dbgfR3CpuGetMode, 3, pVM, idCpu, &enmMode);
+ int rc = VMR3ReqPriorityCallWaitU(pUVM, idCpu, (PFNRT)dbgfR3CpuGetMode, 3, pUVM->pVM, idCpu, &enmMode);
if (RT_FAILURE(rc))
return CPUMMODE_INVALID;
return enmMode;
}
+
+/**
+ * Wrapper around CPUMIsGuestIn64BitCode.
+ *
+ * @returns VINF_SUCCESS.
+ * @param pVM Pointer to the VM.
+ * @param idCpu The current CPU ID.
+ * @param pfIn64BitCode Where to return the result.
+ */
+static DECLCALLBACK(int) dbgfR3CpuIn64BitCode(PVM pVM, VMCPUID idCpu, bool *pfIn64BitCode)
+{
+ Assert(idCpu == VMMGetCpuId(pVM));
+ PVMCPU pVCpu = VMMGetCpuById(pVM, idCpu);
+ *pfIn64BitCode = CPUMIsGuestIn64BitCode(pVCpu);
+ return VINF_SUCCESS;
+}
+
+
+/**
+ * Checks if the given CPU is executing 64-bit code or not.
+ *
+ * @returns true / false accordingly.
+ * @param pUVM The user mode VM handle.
+ * @param idCpu The target CPU ID.
+ */
+VMMR3DECL(bool) DBGFR3CpuIsIn64BitCode(PUVM pUVM, VMCPUID idCpu)
+{
+ UVM_ASSERT_VALID_EXT_RETURN(pUVM, false);
+ VM_ASSERT_VALID_EXT_RETURN(pUVM->pVM, false);
+ AssertReturn(idCpu < pUVM->pVM->cCpus, false);
+
+ bool fIn64BitCode;
+ int rc = VMR3ReqPriorityCallWaitU(pUVM, idCpu, (PFNRT)dbgfR3CpuIn64BitCode, 3, pUVM->pVM, idCpu, &fIn64BitCode);
+ if (RT_FAILURE(rc))
+ return false;
+ return fIn64BitCode;
+}
+
+
+/**
+ * Get the number of CPUs (or threads if you insist).
+ *
+ * @returns The number of CPUs
+ * @param pUVM The user mode VM handle.
+ */
+VMMR3DECL(VMCPUID) DBGFR3CpuGetCount(PUVM pUVM)
+{
+ UVM_ASSERT_VALID_EXT_RETURN(pUVM, 1);
+ return pUVM->cCpus;
+}
+