1 | /* $Id: MachineDebuggerImpl.cpp 27607 2010-03-22 18:13:07Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | *
|
---|
19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
20 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
21 | * additional information or have any questions.
|
---|
22 | */
|
---|
23 |
|
---|
24 | #include "MachineDebuggerImpl.h"
|
---|
25 |
|
---|
26 | #include "Global.h"
|
---|
27 | #include "ConsoleImpl.h"
|
---|
28 |
|
---|
29 | #include "AutoCaller.h"
|
---|
30 | #include "Logging.h"
|
---|
31 |
|
---|
32 | #include <VBox/em.h>
|
---|
33 | #include <VBox/patm.h>
|
---|
34 | #include <VBox/csam.h>
|
---|
35 | #include <VBox/vm.h>
|
---|
36 | #include <VBox/tm.h>
|
---|
37 | #include <VBox/err.h>
|
---|
38 | #include <VBox/hwaccm.h>
|
---|
39 |
|
---|
40 | // defines
|
---|
41 | /////////////////////////////////////////////////////////////////////////////
|
---|
42 |
|
---|
43 |
|
---|
44 | // globals
|
---|
45 | /////////////////////////////////////////////////////////////////////////////
|
---|
46 |
|
---|
47 |
|
---|
48 | // constructor / destructor
|
---|
49 | /////////////////////////////////////////////////////////////////////////////
|
---|
50 |
|
---|
51 | MachineDebugger::MachineDebugger()
|
---|
52 | : mParent(NULL)
|
---|
53 | {
|
---|
54 | }
|
---|
55 |
|
---|
56 | MachineDebugger::~MachineDebugger()
|
---|
57 | {
|
---|
58 | }
|
---|
59 |
|
---|
60 | HRESULT MachineDebugger::FinalConstruct()
|
---|
61 | {
|
---|
62 | unconst(mParent) = NULL;
|
---|
63 | return S_OK;
|
---|
64 | }
|
---|
65 |
|
---|
66 | void MachineDebugger::FinalRelease()
|
---|
67 | {
|
---|
68 | uninit();
|
---|
69 | }
|
---|
70 |
|
---|
71 | // public initializer/uninitializer for internal purposes only
|
---|
72 | /////////////////////////////////////////////////////////////////////////////
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * Initializes the machine debugger object.
|
---|
76 | *
|
---|
77 | * @returns COM result indicator
|
---|
78 | * @param aParent handle of our parent object
|
---|
79 | */
|
---|
80 | HRESULT MachineDebugger::init (Console *aParent)
|
---|
81 | {
|
---|
82 | LogFlowThisFunc(("aParent=%p\n", aParent));
|
---|
83 |
|
---|
84 | ComAssertRet(aParent, E_INVALIDARG);
|
---|
85 |
|
---|
86 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
87 | AutoInitSpan autoInitSpan(this);
|
---|
88 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
89 |
|
---|
90 | unconst(mParent) = aParent;
|
---|
91 |
|
---|
92 | mSinglestepQueued = ~0;
|
---|
93 | mRecompileUserQueued = ~0;
|
---|
94 | mRecompileSupervisorQueued = ~0;
|
---|
95 | mPatmEnabledQueued = ~0;
|
---|
96 | mCsamEnabledQueued = ~0;
|
---|
97 | mLogEnabledQueued = ~0;
|
---|
98 | mVirtualTimeRateQueued = ~0;
|
---|
99 | mFlushMode = false;
|
---|
100 |
|
---|
101 | /* Confirm a successful initialization */
|
---|
102 | autoInitSpan.setSucceeded();
|
---|
103 |
|
---|
104 | return S_OK;
|
---|
105 | }
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
109 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
110 | */
|
---|
111 | void MachineDebugger::uninit()
|
---|
112 | {
|
---|
113 | LogFlowThisFunc(("\n"));
|
---|
114 |
|
---|
115 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
116 | AutoUninitSpan autoUninitSpan(this);
|
---|
117 | if (autoUninitSpan.uninitDone())
|
---|
118 | return;
|
---|
119 |
|
---|
120 | unconst(mParent) = NULL;
|
---|
121 | mFlushMode = false;
|
---|
122 | }
|
---|
123 |
|
---|
124 | // IMachineDebugger properties
|
---|
125 | /////////////////////////////////////////////////////////////////////////////
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * Returns the current singlestepping flag.
|
---|
129 | *
|
---|
130 | * @returns COM status code
|
---|
131 | * @param aEnabled address of result variable
|
---|
132 | */
|
---|
133 | STDMETHODIMP MachineDebugger::COMGETTER(Singlestep) (BOOL *aEnabled)
|
---|
134 | {
|
---|
135 | CheckComArgOutPointerValid(aEnabled);
|
---|
136 |
|
---|
137 | AutoCaller autoCaller(this);
|
---|
138 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
139 |
|
---|
140 | /** @todo */
|
---|
141 | ReturnComNotImplemented();
|
---|
142 | }
|
---|
143 |
|
---|
144 | /**
|
---|
145 | * Sets the singlestepping flag.
|
---|
146 | *
|
---|
147 | * @returns COM status code
|
---|
148 | * @param aEnable new singlestepping flag
|
---|
149 | */
|
---|
150 | STDMETHODIMP MachineDebugger::COMSETTER(Singlestep) (BOOL aEnable)
|
---|
151 | {
|
---|
152 | AutoCaller autoCaller(this);
|
---|
153 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
154 |
|
---|
155 | /** @todo */
|
---|
156 | ReturnComNotImplemented();
|
---|
157 | }
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * Returns the current recompile user mode code flag.
|
---|
161 | *
|
---|
162 | * @returns COM status code
|
---|
163 | * @param aEnabled address of result variable
|
---|
164 | */
|
---|
165 | STDMETHODIMP MachineDebugger::COMGETTER(RecompileUser) (BOOL *aEnabled)
|
---|
166 | {
|
---|
167 | CheckComArgOutPointerValid(aEnabled);
|
---|
168 |
|
---|
169 | AutoCaller autoCaller(this);
|
---|
170 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
171 |
|
---|
172 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
173 |
|
---|
174 | Console::SafeVMPtrQuiet pVM (mParent);
|
---|
175 |
|
---|
176 | if (pVM.isOk())
|
---|
177 | *aEnabled = !EMIsRawRing3Enabled (pVM.raw());
|
---|
178 | else
|
---|
179 | *aEnabled = false;
|
---|
180 |
|
---|
181 | return S_OK;
|
---|
182 | }
|
---|
183 |
|
---|
184 | /**
|
---|
185 | * Sets the recompile user mode code flag.
|
---|
186 | *
|
---|
187 | * @returns COM status
|
---|
188 | * @param aEnable new user mode code recompile flag.
|
---|
189 | */
|
---|
190 | STDMETHODIMP MachineDebugger::COMSETTER(RecompileUser) (BOOL aEnable)
|
---|
191 | {
|
---|
192 | LogFlowThisFunc(("enable=%d\n", aEnable));
|
---|
193 |
|
---|
194 | AutoCaller autoCaller(this);
|
---|
195 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
196 |
|
---|
197 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
198 |
|
---|
199 | if (queueSettings())
|
---|
200 | {
|
---|
201 | // queue the request
|
---|
202 | mRecompileUserQueued = aEnable;
|
---|
203 | return S_OK;
|
---|
204 | }
|
---|
205 |
|
---|
206 | Console::SafeVMPtr pVM (mParent);
|
---|
207 | if (FAILED(pVM.rc())) return pVM.rc();
|
---|
208 |
|
---|
209 | EMRAWMODE rawModeFlag = aEnable ? EMRAW_RING3_DISABLE : EMRAW_RING3_ENABLE;
|
---|
210 | int rcVBox = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)EMR3RawSetMode, 2, pVM.raw(), rawModeFlag);
|
---|
211 | if (RT_SUCCESS(rcVBox))
|
---|
212 | return S_OK;
|
---|
213 |
|
---|
214 | AssertMsgFailed (("Could not set raw mode flags to %d, rcVBox = %Rrc\n",
|
---|
215 | rawModeFlag, rcVBox));
|
---|
216 | return E_FAIL;
|
---|
217 | }
|
---|
218 |
|
---|
219 | /**
|
---|
220 | * Returns the current recompile supervisor code flag.
|
---|
221 | *
|
---|
222 | * @returns COM status code
|
---|
223 | * @param aEnabled address of result variable
|
---|
224 | */
|
---|
225 | STDMETHODIMP MachineDebugger::COMGETTER(RecompileSupervisor) (BOOL *aEnabled)
|
---|
226 | {
|
---|
227 | CheckComArgOutPointerValid(aEnabled);
|
---|
228 |
|
---|
229 | AutoCaller autoCaller(this);
|
---|
230 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
231 |
|
---|
232 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
233 |
|
---|
234 | Console::SafeVMPtrQuiet pVM (mParent);
|
---|
235 |
|
---|
236 | if (pVM.isOk())
|
---|
237 | *aEnabled = !EMIsRawRing0Enabled (pVM.raw());
|
---|
238 | else
|
---|
239 | *aEnabled = false;
|
---|
240 |
|
---|
241 | return S_OK;
|
---|
242 | }
|
---|
243 |
|
---|
244 | /**
|
---|
245 | * Sets the new recompile supervisor code flag.
|
---|
246 | *
|
---|
247 | * @returns COM status code
|
---|
248 | * @param aEnable new recompile supervisor code flag
|
---|
249 | */
|
---|
250 | STDMETHODIMP MachineDebugger::COMSETTER(RecompileSupervisor) (BOOL aEnable)
|
---|
251 | {
|
---|
252 | LogFlowThisFunc(("enable=%d\n", aEnable));
|
---|
253 |
|
---|
254 | AutoCaller autoCaller(this);
|
---|
255 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
256 |
|
---|
257 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
258 |
|
---|
259 | if (queueSettings())
|
---|
260 | {
|
---|
261 | // queue the request
|
---|
262 | mRecompileSupervisorQueued = aEnable;
|
---|
263 | return S_OK;
|
---|
264 | }
|
---|
265 |
|
---|
266 | Console::SafeVMPtr pVM (mParent);
|
---|
267 | if (FAILED(pVM.rc())) return pVM.rc();
|
---|
268 |
|
---|
269 | EMRAWMODE rawModeFlag = aEnable ? EMRAW_RING0_DISABLE : EMRAW_RING0_ENABLE;
|
---|
270 | int rcVBox = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)EMR3RawSetMode, 2, pVM.raw(), rawModeFlag);
|
---|
271 | if (RT_SUCCESS(rcVBox))
|
---|
272 | return S_OK;
|
---|
273 |
|
---|
274 | AssertMsgFailed (("Could not set raw mode flags to %d, rcVBox = %Rrc\n",
|
---|
275 | rawModeFlag, rcVBox));
|
---|
276 | return E_FAIL;
|
---|
277 | }
|
---|
278 |
|
---|
279 | /**
|
---|
280 | * Returns the current patch manager enabled flag.
|
---|
281 | *
|
---|
282 | * @returns COM status code
|
---|
283 | * @param aEnabled address of result variable
|
---|
284 | */
|
---|
285 | STDMETHODIMP MachineDebugger::COMGETTER(PATMEnabled) (BOOL *aEnabled)
|
---|
286 | {
|
---|
287 | CheckComArgOutPointerValid(aEnabled);
|
---|
288 |
|
---|
289 | AutoCaller autoCaller(this);
|
---|
290 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
291 |
|
---|
292 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
293 |
|
---|
294 | Console::SafeVMPtrQuiet pVM (mParent);
|
---|
295 |
|
---|
296 | if (pVM.isOk())
|
---|
297 | *aEnabled = PATMIsEnabled (pVM.raw());
|
---|
298 | else
|
---|
299 | *aEnabled = false;
|
---|
300 |
|
---|
301 | return S_OK;
|
---|
302 | }
|
---|
303 |
|
---|
304 | /**
|
---|
305 | * Set the new patch manager enabled flag.
|
---|
306 | *
|
---|
307 | * @returns COM status code
|
---|
308 | * @param aEnable new patch manager enabled flag
|
---|
309 | */
|
---|
310 | STDMETHODIMP MachineDebugger::COMSETTER(PATMEnabled) (BOOL aEnable)
|
---|
311 | {
|
---|
312 | LogFlowThisFunc(("enable=%d\n", aEnable));
|
---|
313 |
|
---|
314 | AutoCaller autoCaller(this);
|
---|
315 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
316 |
|
---|
317 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
318 |
|
---|
319 | if (queueSettings())
|
---|
320 | {
|
---|
321 | // queue the request
|
---|
322 | mPatmEnabledQueued = aEnable;
|
---|
323 | return S_OK;
|
---|
324 | }
|
---|
325 |
|
---|
326 | Console::SafeVMPtr pVM(mParent);
|
---|
327 | if (FAILED(pVM.rc())) return pVM.rc();
|
---|
328 |
|
---|
329 | PATMR3AllowPatching (pVM, aEnable);
|
---|
330 |
|
---|
331 | return S_OK;
|
---|
332 | }
|
---|
333 |
|
---|
334 | /**
|
---|
335 | * Returns the current code scanner enabled flag.
|
---|
336 | *
|
---|
337 | * @returns COM status code
|
---|
338 | * @param aEnabled address of result variable
|
---|
339 | */
|
---|
340 | STDMETHODIMP MachineDebugger::COMGETTER(CSAMEnabled) (BOOL *aEnabled)
|
---|
341 | {
|
---|
342 | CheckComArgOutPointerValid(aEnabled);
|
---|
343 |
|
---|
344 | AutoCaller autoCaller(this);
|
---|
345 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
346 |
|
---|
347 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
348 |
|
---|
349 | Console::SafeVMPtrQuiet pVM (mParent);
|
---|
350 |
|
---|
351 | if (pVM.isOk())
|
---|
352 | *aEnabled = CSAMIsEnabled (pVM.raw());
|
---|
353 | else
|
---|
354 | *aEnabled = false;
|
---|
355 |
|
---|
356 | return S_OK;
|
---|
357 | }
|
---|
358 |
|
---|
359 | /**
|
---|
360 | * Sets the new code scanner enabled flag.
|
---|
361 | *
|
---|
362 | * @returns COM status code
|
---|
363 | * @param aEnable new code scanner enabled flag
|
---|
364 | */
|
---|
365 | STDMETHODIMP MachineDebugger::COMSETTER(CSAMEnabled) (BOOL aEnable)
|
---|
366 | {
|
---|
367 | LogFlowThisFunc(("enable=%d\n", aEnable));
|
---|
368 |
|
---|
369 | AutoCaller autoCaller(this);
|
---|
370 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
371 |
|
---|
372 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
373 |
|
---|
374 | if (queueSettings())
|
---|
375 | {
|
---|
376 | // queue the request
|
---|
377 | mCsamEnabledQueued = aEnable;
|
---|
378 | return S_OK;
|
---|
379 | }
|
---|
380 |
|
---|
381 | Console::SafeVMPtr pVM(mParent);
|
---|
382 | if (FAILED(pVM.rc())) return pVM.rc();
|
---|
383 |
|
---|
384 | int vrc;
|
---|
385 | if (aEnable)
|
---|
386 | vrc = CSAMEnableScanning (pVM);
|
---|
387 | else
|
---|
388 | vrc = CSAMDisableScanning (pVM);
|
---|
389 |
|
---|
390 | if (RT_FAILURE(vrc))
|
---|
391 | {
|
---|
392 | /** @todo handle error case */
|
---|
393 | }
|
---|
394 |
|
---|
395 | return S_OK;
|
---|
396 | }
|
---|
397 |
|
---|
398 | /**
|
---|
399 | * Returns the log enabled / disabled status.
|
---|
400 | *
|
---|
401 | * @returns COM status code
|
---|
402 | * @param aEnabled address of result variable
|
---|
403 | */
|
---|
404 | STDMETHODIMP MachineDebugger::COMGETTER(LogEnabled) (BOOL *aEnabled)
|
---|
405 | {
|
---|
406 | CheckComArgOutPointerValid(aEnabled);
|
---|
407 |
|
---|
408 | AutoCaller autoCaller(this);
|
---|
409 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
410 |
|
---|
411 | #ifdef LOG_ENABLED
|
---|
412 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
413 |
|
---|
414 | const PRTLOGGER pLogInstance = RTLogDefaultInstance();
|
---|
415 | *aEnabled = pLogInstance && !(pLogInstance->fFlags & RTLOGFLAGS_DISABLED);
|
---|
416 | #else
|
---|
417 | *aEnabled = false;
|
---|
418 | #endif
|
---|
419 |
|
---|
420 | return S_OK;
|
---|
421 | }
|
---|
422 |
|
---|
423 | /**
|
---|
424 | * Enables or disables logging.
|
---|
425 | *
|
---|
426 | * @returns COM status code
|
---|
427 | * @param aEnabled The new code log state.
|
---|
428 | */
|
---|
429 | STDMETHODIMP MachineDebugger::COMSETTER(LogEnabled) (BOOL aEnabled)
|
---|
430 | {
|
---|
431 | LogFlowThisFunc(("aEnabled=%d\n", aEnabled));
|
---|
432 |
|
---|
433 | AutoCaller autoCaller(this);
|
---|
434 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
435 |
|
---|
436 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
437 |
|
---|
438 | if (queueSettings())
|
---|
439 | {
|
---|
440 | // queue the request
|
---|
441 | mLogEnabledQueued = aEnabled;
|
---|
442 | return S_OK;
|
---|
443 | }
|
---|
444 |
|
---|
445 | Console::SafeVMPtr pVM(mParent);
|
---|
446 | if (FAILED(pVM.rc())) return pVM.rc();
|
---|
447 |
|
---|
448 | #ifdef LOG_ENABLED
|
---|
449 | int vrc = DBGFR3LogModifyFlags (pVM, aEnabled ? "enabled" : "disabled");
|
---|
450 | if (RT_FAILURE(vrc))
|
---|
451 | {
|
---|
452 | /** @todo handle error code. */
|
---|
453 | }
|
---|
454 | #endif
|
---|
455 |
|
---|
456 | return S_OK;
|
---|
457 | }
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Returns the current hardware virtualization flag.
|
---|
461 | *
|
---|
462 | * @returns COM status code
|
---|
463 | * @param aEnabled address of result variable
|
---|
464 | */
|
---|
465 | STDMETHODIMP MachineDebugger::COMGETTER(HWVirtExEnabled) (BOOL *aEnabled)
|
---|
466 | {
|
---|
467 | CheckComArgOutPointerValid(aEnabled);
|
---|
468 |
|
---|
469 | AutoCaller autoCaller(this);
|
---|
470 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
471 |
|
---|
472 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
473 |
|
---|
474 | Console::SafeVMPtrQuiet pVM (mParent);
|
---|
475 |
|
---|
476 | if (pVM.isOk())
|
---|
477 | *aEnabled = HWACCMIsEnabled (pVM.raw());
|
---|
478 | else
|
---|
479 | *aEnabled = false;
|
---|
480 |
|
---|
481 | return S_OK;
|
---|
482 | }
|
---|
483 |
|
---|
484 | /**
|
---|
485 | * Returns the current nested paging flag.
|
---|
486 | *
|
---|
487 | * @returns COM status code
|
---|
488 | * @param aEnabled address of result variable
|
---|
489 | */
|
---|
490 | STDMETHODIMP MachineDebugger::COMGETTER(HWVirtExNestedPagingEnabled) (BOOL *aEnabled)
|
---|
491 | {
|
---|
492 | CheckComArgOutPointerValid(aEnabled);
|
---|
493 |
|
---|
494 | AutoCaller autoCaller(this);
|
---|
495 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
496 |
|
---|
497 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
498 |
|
---|
499 | Console::SafeVMPtrQuiet pVM (mParent);
|
---|
500 |
|
---|
501 | if (pVM.isOk())
|
---|
502 | *aEnabled = HWACCMR3IsNestedPagingActive (pVM.raw());
|
---|
503 | else
|
---|
504 | *aEnabled = false;
|
---|
505 |
|
---|
506 | return S_OK;
|
---|
507 | }
|
---|
508 |
|
---|
509 | /**
|
---|
510 | * Returns the current VPID flag.
|
---|
511 | *
|
---|
512 | * @returns COM status code
|
---|
513 | * @param aEnabled address of result variable
|
---|
514 | */
|
---|
515 | STDMETHODIMP MachineDebugger::COMGETTER(HWVirtExVPIDEnabled) (BOOL *aEnabled)
|
---|
516 | {
|
---|
517 | CheckComArgOutPointerValid(aEnabled);
|
---|
518 |
|
---|
519 | AutoCaller autoCaller(this);
|
---|
520 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
521 |
|
---|
522 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
523 |
|
---|
524 | Console::SafeVMPtrQuiet pVM (mParent);
|
---|
525 |
|
---|
526 | if (pVM.isOk())
|
---|
527 | *aEnabled = HWACCMR3IsVPIDActive (pVM.raw());
|
---|
528 | else
|
---|
529 | *aEnabled = false;
|
---|
530 |
|
---|
531 | return S_OK;
|
---|
532 | }
|
---|
533 |
|
---|
534 | /**
|
---|
535 | * Returns the current PAE flag.
|
---|
536 | *
|
---|
537 | * @returns COM status code
|
---|
538 | * @param aEnabled address of result variable
|
---|
539 | */
|
---|
540 | STDMETHODIMP MachineDebugger::COMGETTER(PAEEnabled) (BOOL *aEnabled)
|
---|
541 | {
|
---|
542 | CheckComArgOutPointerValid(aEnabled);
|
---|
543 |
|
---|
544 | AutoCaller autoCaller(this);
|
---|
545 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
546 |
|
---|
547 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
548 |
|
---|
549 | Console::SafeVMPtrQuiet pVM (mParent);
|
---|
550 |
|
---|
551 | if (pVM.isOk())
|
---|
552 | {
|
---|
553 | uint64_t cr4 = CPUMGetGuestCR4 (VMMGetCpu0(pVM.raw()));
|
---|
554 | *aEnabled = !!(cr4 & X86_CR4_PAE);
|
---|
555 | }
|
---|
556 | else
|
---|
557 | *aEnabled = false;
|
---|
558 |
|
---|
559 | return S_OK;
|
---|
560 | }
|
---|
561 |
|
---|
562 | /**
|
---|
563 | * Returns the current virtual time rate.
|
---|
564 | *
|
---|
565 | * @returns COM status code.
|
---|
566 | * @param aPct Where to store the rate.
|
---|
567 | */
|
---|
568 | STDMETHODIMP MachineDebugger::COMGETTER(VirtualTimeRate) (ULONG *aPct)
|
---|
569 | {
|
---|
570 | CheckComArgOutPointerValid(aPct);
|
---|
571 |
|
---|
572 | AutoCaller autoCaller(this);
|
---|
573 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
574 |
|
---|
575 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
576 |
|
---|
577 | Console::SafeVMPtrQuiet pVM (mParent);
|
---|
578 |
|
---|
579 | if (pVM.isOk())
|
---|
580 | *aPct = TMGetWarpDrive (pVM);
|
---|
581 | else
|
---|
582 | *aPct = 100;
|
---|
583 |
|
---|
584 | return S_OK;
|
---|
585 | }
|
---|
586 |
|
---|
587 | /**
|
---|
588 | * Returns the current virtual time rate.
|
---|
589 | *
|
---|
590 | * @returns COM status code.
|
---|
591 | * @param aPct Where to store the rate.
|
---|
592 | */
|
---|
593 | STDMETHODIMP MachineDebugger::COMSETTER(VirtualTimeRate) (ULONG aPct)
|
---|
594 | {
|
---|
595 | if (aPct < 2 || aPct > 20000)
|
---|
596 | return E_INVALIDARG;
|
---|
597 |
|
---|
598 | AutoCaller autoCaller(this);
|
---|
599 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
600 |
|
---|
601 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
602 |
|
---|
603 | if (queueSettings())
|
---|
604 | {
|
---|
605 | // queue the request
|
---|
606 | mVirtualTimeRateQueued = aPct;
|
---|
607 | return S_OK;
|
---|
608 | }
|
---|
609 |
|
---|
610 | Console::SafeVMPtr pVM(mParent);
|
---|
611 | if (FAILED(pVM.rc())) return pVM.rc();
|
---|
612 |
|
---|
613 | int vrc = TMR3SetWarpDrive (pVM, aPct);
|
---|
614 | if (RT_FAILURE(vrc))
|
---|
615 | {
|
---|
616 | /** @todo handle error code. */
|
---|
617 | }
|
---|
618 |
|
---|
619 | return S_OK;
|
---|
620 | }
|
---|
621 |
|
---|
622 | /**
|
---|
623 | * Hack for getting the VM handle.
|
---|
624 | * This is only temporary (promise) while prototyping the debugger.
|
---|
625 | *
|
---|
626 | * @returns COM status code
|
---|
627 | * @param aVm Where to store the vm handle.
|
---|
628 | * Since there is no uintptr_t in COM, we're using the max integer.
|
---|
629 | * (No, ULONG is not pointer sized!)
|
---|
630 | */
|
---|
631 | STDMETHODIMP MachineDebugger::COMGETTER(VM) (ULONG64 *aVm)
|
---|
632 | {
|
---|
633 | CheckComArgOutPointerValid(aVm);
|
---|
634 |
|
---|
635 | AutoCaller autoCaller(this);
|
---|
636 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
637 |
|
---|
638 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
639 |
|
---|
640 | Console::SafeVMPtr pVM(mParent);
|
---|
641 | if (FAILED(pVM.rc())) return pVM.rc();
|
---|
642 |
|
---|
643 | *aVm = (uintptr_t)pVM.raw();
|
---|
644 |
|
---|
645 | /*
|
---|
646 | * Note: pVM protection provided by SafeVMPtr is no more effective
|
---|
647 | * after we return from this method.
|
---|
648 | */
|
---|
649 |
|
---|
650 | return S_OK;
|
---|
651 | }
|
---|
652 |
|
---|
653 | // IMachineDebugger methods
|
---|
654 | /////////////////////////////////////////////////////////////////////////////
|
---|
655 |
|
---|
656 | /**
|
---|
657 | * Resets VM statistics.
|
---|
658 | *
|
---|
659 | * @returns COM status code.
|
---|
660 | * @param aPattern The selection pattern. A bit similar to filename globbing.
|
---|
661 | */
|
---|
662 | STDMETHODIMP MachineDebugger::ResetStats (IN_BSTR aPattern)
|
---|
663 | {
|
---|
664 | Console::SafeVMPtrQuiet pVM (mParent);
|
---|
665 |
|
---|
666 | if (!pVM.isOk())
|
---|
667 | return setError(VBOX_E_INVALID_VM_STATE, "Machine is not running");
|
---|
668 |
|
---|
669 | STAMR3Reset (pVM, Utf8Str (aPattern).raw());
|
---|
670 |
|
---|
671 | return S_OK;
|
---|
672 | }
|
---|
673 |
|
---|
674 | /**
|
---|
675 | * Dumps VM statistics to the log.
|
---|
676 | *
|
---|
677 | * @returns COM status code.
|
---|
678 | * @param aPattern The selection pattern. A bit similar to filename globbing.
|
---|
679 | */
|
---|
680 | STDMETHODIMP MachineDebugger::DumpStats (IN_BSTR aPattern)
|
---|
681 | {
|
---|
682 | Console::SafeVMPtrQuiet pVM (mParent);
|
---|
683 |
|
---|
684 | if (!pVM.isOk())
|
---|
685 | return setError(VBOX_E_INVALID_VM_STATE, "Machine is not running");
|
---|
686 |
|
---|
687 | STAMR3Dump (pVM, Utf8Str (aPattern).raw());
|
---|
688 |
|
---|
689 | return S_OK;
|
---|
690 | }
|
---|
691 |
|
---|
692 | /**
|
---|
693 | * Get the VM statistics in an XML format.
|
---|
694 | *
|
---|
695 | * @returns COM status code.
|
---|
696 | * @param aPattern The selection pattern. A bit similar to filename globbing.
|
---|
697 | * @param aWithDescriptions Whether to include the descriptions.
|
---|
698 | * @param aStats The XML document containing the statistics.
|
---|
699 | */
|
---|
700 | STDMETHODIMP MachineDebugger::GetStats (IN_BSTR aPattern, BOOL aWithDescriptions, BSTR *aStats)
|
---|
701 | {
|
---|
702 | Console::SafeVMPtrQuiet pVM (mParent);
|
---|
703 |
|
---|
704 | if (!pVM.isOk())
|
---|
705 | return setError(VBOX_E_INVALID_VM_STATE, "Machine is not running");
|
---|
706 |
|
---|
707 | char *pszSnapshot;
|
---|
708 | int vrc = STAMR3Snapshot (pVM, Utf8Str (aPattern).raw(), &pszSnapshot, NULL,
|
---|
709 | !!aWithDescriptions);
|
---|
710 | if (RT_FAILURE(vrc))
|
---|
711 | return vrc == VERR_NO_MEMORY ? E_OUTOFMEMORY : E_FAIL;
|
---|
712 |
|
---|
713 | /** @todo this is horribly inefficient! And it's kinda difficult to tell whether it failed...
|
---|
714 | * Must use UTF-8 or ASCII here and completely avoid these two extra copy operations.
|
---|
715 | * Until that's done, this method is kind of useless for debugger statistics GUI because
|
---|
716 | * of the amount statistics in a debug build. */
|
---|
717 | Bstr (pszSnapshot).cloneTo(aStats);
|
---|
718 |
|
---|
719 | return S_OK;
|
---|
720 | }
|
---|
721 |
|
---|
722 | /**
|
---|
723 | * Set the new patch manager enabled flag.
|
---|
724 | *
|
---|
725 | * @returns COM status code
|
---|
726 | * @param new patch manager enabled flag
|
---|
727 | */
|
---|
728 | STDMETHODIMP MachineDebugger::InjectNMI()
|
---|
729 | {
|
---|
730 | LogFlowThisFunc(("\n"));
|
---|
731 |
|
---|
732 | AutoCaller autoCaller(this);
|
---|
733 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
734 |
|
---|
735 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
736 |
|
---|
737 | Console::SafeVMPtr pVM(mParent);
|
---|
738 | if (FAILED(pVM.rc())) return pVM.rc();
|
---|
739 |
|
---|
740 | HWACCMR3InjectNMI(pVM);
|
---|
741 |
|
---|
742 | return S_OK;
|
---|
743 | }
|
---|
744 |
|
---|
745 |
|
---|
746 | // public methods only for internal purposes
|
---|
747 | /////////////////////////////////////////////////////////////////////////////
|
---|
748 |
|
---|
749 | void MachineDebugger::flushQueuedSettings()
|
---|
750 | {
|
---|
751 | mFlushMode = true;
|
---|
752 | if (mSinglestepQueued != ~0)
|
---|
753 | {
|
---|
754 | COMSETTER(Singlestep) (mSinglestepQueued);
|
---|
755 | mSinglestepQueued = ~0;
|
---|
756 | }
|
---|
757 | if (mRecompileUserQueued != ~0)
|
---|
758 | {
|
---|
759 | COMSETTER(RecompileUser) (mRecompileUserQueued);
|
---|
760 | mRecompileUserQueued = ~0;
|
---|
761 | }
|
---|
762 | if (mRecompileSupervisorQueued != ~0)
|
---|
763 | {
|
---|
764 | COMSETTER(RecompileSupervisor) (mRecompileSupervisorQueued);
|
---|
765 | mRecompileSupervisorQueued = ~0;
|
---|
766 | }
|
---|
767 | if (mPatmEnabledQueued != ~0)
|
---|
768 | {
|
---|
769 | COMSETTER(PATMEnabled) (mPatmEnabledQueued);
|
---|
770 | mPatmEnabledQueued = ~0;
|
---|
771 | }
|
---|
772 | if (mCsamEnabledQueued != ~0)
|
---|
773 | {
|
---|
774 | COMSETTER(CSAMEnabled) (mCsamEnabledQueued);
|
---|
775 | mCsamEnabledQueued = ~0;
|
---|
776 | }
|
---|
777 | if (mLogEnabledQueued != ~0)
|
---|
778 | {
|
---|
779 | COMSETTER(LogEnabled) (mLogEnabledQueued);
|
---|
780 | mLogEnabledQueued = ~0;
|
---|
781 | }
|
---|
782 | if (mVirtualTimeRateQueued != ~(uint32_t)0)
|
---|
783 | {
|
---|
784 | COMSETTER(VirtualTimeRate) (mVirtualTimeRateQueued);
|
---|
785 | mVirtualTimeRateQueued = ~0;
|
---|
786 | }
|
---|
787 | mFlushMode = false;
|
---|
788 | }
|
---|
789 |
|
---|
790 | // private methods
|
---|
791 | /////////////////////////////////////////////////////////////////////////////
|
---|
792 |
|
---|
793 | bool MachineDebugger::queueSettings() const
|
---|
794 | {
|
---|
795 | if (!mFlushMode)
|
---|
796 | {
|
---|
797 | // check if the machine is running
|
---|
798 | MachineState_T machineState;
|
---|
799 | mParent->COMGETTER(State) (&machineState);
|
---|
800 | switch (machineState)
|
---|
801 | {
|
---|
802 | // queue the request
|
---|
803 | default:
|
---|
804 | return true;
|
---|
805 |
|
---|
806 | case MachineState_Running:
|
---|
807 | case MachineState_Paused:
|
---|
808 | case MachineState_Stuck:
|
---|
809 | case MachineState_LiveSnapshotting:
|
---|
810 | case MachineState_Teleporting:
|
---|
811 | break;
|
---|
812 | }
|
---|
813 | }
|
---|
814 | return false;
|
---|
815 | }
|
---|
816 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|