1 | /* $Id: DBGFCpu.cpp 24061 2009-10-25 23:54:32Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DBGF - Debugger Facility, CPU State Accessors.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 |
|
---|
23 | /*******************************************************************************
|
---|
24 | * Header Files *
|
---|
25 | *******************************************************************************/
|
---|
26 | #define LOG_GROUP LOG_GROUP_DBGF
|
---|
27 | #include <VBox/dbgf.h>
|
---|
28 | #include <VBox/cpum.h>
|
---|
29 | #include "DBGFInternal.h"
|
---|
30 | #include <VBox/vm.h>
|
---|
31 | #include <VBox/err.h>
|
---|
32 | #include <VBox/log.h>
|
---|
33 | #include <VBox/param.h>
|
---|
34 | #include <iprt/assert.h>
|
---|
35 |
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Wrapper around CPUMGetGuestMode.
|
---|
39 | *
|
---|
40 | * @returns VINF_SUCCESS.
|
---|
41 | * @param pVM The VM handle.
|
---|
42 | * @param idCpu The current CPU ID.
|
---|
43 | * @param penmMode Where to return the mode.
|
---|
44 | */
|
---|
45 | static DECLCALLBACK(int) dbgfR3CpuGetMode(PVM pVM, VMCPUID idCpu, CPUMMODE *penmMode)
|
---|
46 | {
|
---|
47 | Assert(idCpu == VMMGetCpuId(pVM));
|
---|
48 | PVMCPU pVCpu = VMMGetCpuById(pVM, idCpu);
|
---|
49 | *penmMode = CPUMGetGuestMode(pVCpu);
|
---|
50 | return VINF_SUCCESS;
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Get the current CPU mode.
|
---|
56 | *
|
---|
57 | * @returns The CPU mode on success, CPUMMODE_INVALID on failure.
|
---|
58 | * @param pVM The VM handle.
|
---|
59 | * @param idCpu The target CPU ID.
|
---|
60 | */
|
---|
61 | VMMR3DECL(CPUMMODE) DBGFR3CpuGetMode(PVM pVM, VMCPUID idCpu)
|
---|
62 | {
|
---|
63 | VM_ASSERT_VALID_EXT_RETURN(pVM, CPUMMODE_INVALID);
|
---|
64 | AssertReturn(idCpu < pVM->cCpus, CPUMMODE_INVALID);
|
---|
65 |
|
---|
66 | CPUMMODE enmMode;
|
---|
67 | int rc = VMR3ReqCallWait(pVM, idCpu, (PFNRT)dbgfR3CpuGetMode, 3, pVM, idCpu, &enmMode);
|
---|
68 | if (RT_FAILURE(rc))
|
---|
69 | return CPUMMODE_INVALID;
|
---|
70 | return enmMode;
|
---|
71 | }
|
---|
72 |
|
---|