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