VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxBFE/MachineDebuggerImpl.cpp@ 2397

Last change on this file since 2397 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/** @file
2 *
3 * VBox frontends: Basic Frontend (BFE):
4 * Implementation of MachineDebugger class
5 */
6
7/*
8 * Copyright (C) 2006 InnoTek Systemberatung GmbH
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License as published by the Free Software Foundation,
14 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15 * distribution. VirtualBox OSE is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * If you received this file as part of a commercial VirtualBox
19 * distribution, then only the terms of your commercial VirtualBox
20 * license agreement apply instead of the previous paragraph.
21 */
22
23#ifdef VBOXBFE_WITHOUT_COM
24# include "COMDefs.h"
25#else
26# include <VBox/com/defs.h>
27#endif
28#include <VBox/em.h>
29#include <VBox/patm.h>
30#include <VBox/csam.h>
31#include <VBox/vm.h>
32#include <VBox/err.h>
33#include <VBox/log.h>
34#include <iprt/semaphore.h>
35#include <iprt/assert.h>
36
37#include "VBoxBFE.h"
38#include "MachineDebuggerImpl.h"
39
40//
41// defines
42//
43
44
45//
46// globals
47//
48
49
50//
51// public methods
52//
53
54/**
55 * Initializes the machine debugger object.
56 *
57 * @returns COM result indicator
58 * @param parent handle of our parent object
59 */
60MachineDebugger::MachineDebugger()
61{
62 singlestepQueued = ~0;
63 recompileUserQueued = ~0;
64 recompileSupervisorQueued = ~0;
65 patmEnabledQueued = ~0;
66 csamEnabledQueued = ~0;
67 fFlushMode = false;
68}
69
70/**
71 * Returns the current singlestepping flag.
72 *
73 * @returns COM status code
74 * @param enabled address of result variable
75 */
76STDMETHODIMP MachineDebugger::COMGETTER(Singlestep)(BOOL *enabled)
77{
78 if (!enabled)
79 return E_POINTER;
80 /** @todo */
81 return E_NOTIMPL;
82}
83
84/**
85 * Sets the singlestepping flag.
86 *
87 * @returns COM status code
88 * @param enable new singlestepping flag
89 */
90STDMETHODIMP MachineDebugger::COMSETTER(Singlestep)(BOOL enable)
91{
92 /** @todo */
93 return E_NOTIMPL;
94}
95
96/**
97 * Returns the current recompile user mode code flag.
98 *
99 * @returns COM status code
100 * @param enabled address of result variable
101 */
102STDMETHODIMP MachineDebugger::COMGETTER(RecompileUser)(BOOL *enabled)
103{
104 if (!enabled)
105 return E_POINTER;
106 if (pVM)
107 *enabled = !EMIsRawRing3Enabled(pVM);
108 else
109 *enabled = false;
110 return S_OK;
111}
112
113/**
114 * Sets the recompile user mode code flag.
115 *
116 * @returns COM status
117 * @param enable new user mode code recompile flag.
118 */
119STDMETHODIMP MachineDebugger::COMSETTER(RecompileUser)(BOOL enable)
120{
121 LogFlow(("MachineDebugger:: set user mode recompiler to %d\n", enable));
122
123 if (!fFlushMode)
124 {
125 // check if the machine is running
126 if (machineState != VMSTATE_RUNNING)
127 {
128 // queue the request
129 recompileUserQueued = enable;
130 return S_OK;
131 }
132 }
133 if (!pVM)
134 {
135 return E_FAIL;
136 }
137
138 PVMREQ pReq;
139 EMRAWMODE rawModeFlag = enable ? EMRAW_RING3_DISABLE : EMRAW_RING3_ENABLE;
140 int rcVBox = VMR3ReqCall(pVM, &pReq, RT_INDEFINITE_WAIT,
141 (PFNRT)EMR3RawSetMode, 2, pVM, rawModeFlag);
142 if (VBOX_SUCCESS(rcVBox))
143 {
144 rcVBox = pReq->iStatus;
145 VMR3ReqFree(pReq);
146 }
147
148 if (VBOX_SUCCESS(rcVBox))
149 return S_OK;
150
151 AssertMsgFailed(("Could not set raw mode flags to %d, rcVBox = %Vrc\n",
152 rawModeFlag, rcVBox));
153 return E_FAIL;
154}
155
156/**
157 * Returns the current recompile supervisor code flag.
158 *
159 * @returns COM status code
160 * @param enabled address of result variable
161 */
162STDMETHODIMP MachineDebugger::COMGETTER(RecompileSupervisor)(BOOL *enabled)
163{
164 if (!enabled)
165 return E_POINTER;
166 if (pVM)
167 *enabled = !EMIsRawRing0Enabled(pVM);
168 else
169 *enabled = false;
170 return S_OK;
171}
172
173/**
174 * Sets the new recompile supervisor code flag.
175 *
176 * @returns COM status code
177 * @param enable new recompile supervisor code flag
178 */
179STDMETHODIMP MachineDebugger::COMSETTER(RecompileSupervisor)(BOOL enable)
180{
181 LogFlow(("MachineDebugger:: set supervisor mode recompiler to %d\n", enable));
182
183 if (!fFlushMode)
184 {
185 // check if the machine is running
186 if (machineState != VMSTATE_RUNNING)
187 {
188 // queue the request
189 recompileSupervisorQueued = enable;
190 return S_OK;
191 }
192 }
193 if (!pVM)
194 {
195 return E_FAIL;
196 }
197
198 PVMREQ pReq;
199 EMRAWMODE rawModeFlag = enable ? EMRAW_RING0_DISABLE : EMRAW_RING0_ENABLE;
200 int rcVBox = VMR3ReqCall(pVM, &pReq, RT_INDEFINITE_WAIT,
201 (PFNRT)EMR3RawSetMode, 2, pVM, rawModeFlag);
202 if (VBOX_SUCCESS(rcVBox))
203 {
204 rcVBox = pReq->iStatus;
205 VMR3ReqFree(pReq);
206 }
207
208 if (VBOX_SUCCESS(rcVBox))
209 return S_OK;
210
211 AssertMsgFailed(("Could not set raw mode flags to %d, rcVBox = %Vrc\n",
212 rawModeFlag, rcVBox));
213 return E_FAIL;
214}
215
216/**
217 * Returns the current patch manager enabled flag.
218 *
219 * @returns COM status code
220 * @param enabled address of result variable
221 */
222STDMETHODIMP MachineDebugger::COMGETTER(PATMEnabled)(BOOL *enabled)
223{
224 if (!enabled)
225 return E_POINTER;
226 if (pVM)
227 *enabled = PATMIsEnabled(pVM);
228 else
229 *enabled = false;
230 return S_OK;
231}
232
233/**
234 * Set the new patch manager enabled flag.
235 *
236 * @returns COM status code
237 * @param new patch manager enabled flag
238 */
239STDMETHODIMP MachineDebugger::COMSETTER(PATMEnabled)(BOOL enable)
240{
241 LogFlow(("MachineDebugger::SetPATMEnabled: %d\n", enable));
242
243 if (!fFlushMode)
244 {
245 // check if the machine is running
246 if (machineState != VMSTATE_RUNNING)
247 {
248 // queue the request
249 patmEnabledQueued = enable;
250 return S_OK;
251 }
252 }
253
254 if (!pVM)
255 return E_FAIL;
256
257 PATMR3AllowPatching(pVM, enable);
258 return E_NOTIMPL;
259}
260
261/**
262 * Returns the current code scanner enabled flag.
263 *
264 * @returns COM status code
265 * @param enabled address of result variable
266 */
267STDMETHODIMP MachineDebugger::COMGETTER(CSAMEnabled)(BOOL *enabled)
268{
269 if (!enabled)
270 return E_POINTER;
271 if (pVM)
272 *enabled = CSAMIsEnabled(pVM);
273 else
274 *enabled = false;
275 return S_OK;
276}
277
278/**
279 * Sets the new code scanner enabled flag.
280 *
281 * @returns COM status code
282 * @param enable new code scanner enabled flag
283 */
284STDMETHODIMP MachineDebugger::COMSETTER(CSAMEnabled)(BOOL enable)
285{
286 LogFlow(("MachineDebugger:SetCSAMEnabled: %d\n", enable));
287
288 if (!fFlushMode)
289 {
290 // check if the machine is running
291 if (machineState != VMSTATE_RUNNING)
292 {
293 // queue the request
294 csamEnabledQueued = enable;
295 return S_OK;
296 }
297 }
298
299 if (!pVM)
300 return E_FAIL;
301
302 if (enable)
303 CSAMEnableScanning(pVM);
304 else
305 CSAMDisableScanning(pVM);
306 return E_NOTIMPL;
307}
308
309//
310// "public-private" methods
311//
312void MachineDebugger::flushQueuedSettings()
313{
314 fFlushMode = true;
315 if (singlestepQueued != ~0)
316 {
317 COMSETTER(Singlestep)(singlestepQueued);
318 singlestepQueued = ~0;
319 }
320 if (recompileUserQueued != ~0)
321 {
322 COMSETTER(RecompileUser)(recompileUserQueued);
323 recompileUserQueued = ~0;
324 }
325 if (recompileSupervisorQueued != ~0)
326 {
327 COMSETTER(RecompileSupervisor)(recompileSupervisorQueued);
328 recompileSupervisorQueued = ~0;
329 }
330 if (patmEnabledQueued != ~0)
331 {
332 COMSETTER(PATMEnabled)(patmEnabledQueued);
333 patmEnabledQueued = ~0;
334 }
335 if (csamEnabledQueued != ~0)
336 {
337 COMSETTER(CSAMEnabled)(csamEnabledQueued);
338 csamEnabledQueued = ~0;
339 }
340 fFlushMode = false;
341}
342
343//
344// private methods
345//
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette