MachineDebuggerImpl.cpp revision 7cdbdf820361f32367c876c319a25a163734a53f
/* $Id$ */
/** @file
*
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2008 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "MachineDebuggerImpl.h"
#include "Global.h"
#include "ConsoleImpl.h"
#include "AutoCaller.h"
#include "Logging.h"
// defines
/////////////////////////////////////////////////////////////////////////////
// globals
/////////////////////////////////////////////////////////////////////////////
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
{
}
{
}
{
return S_OK;
}
void MachineDebugger::FinalRelease()
{
uninit();
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
/**
* Initializes the machine debugger object.
*
* @returns COM result indicator
* @param aParent handle of our parent object
*/
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan(this);
mSinglestepQueued = ~0;
mRecompileUserQueued = ~0;
mPatmEnabledQueued = ~0;
mCsamEnabledQueued = ~0;
mLogEnabledQueued = ~0;
mVirtualTimeRateQueued = ~0;
mFlushMode = false;
/* Confirm a successful initialization */
return S_OK;
}
/**
* Uninitializes the instance and sets the ready flag to FALSE.
* Called either from FinalRelease() or by the parent when it gets destroyed.
*/
void MachineDebugger::uninit()
{
LogFlowThisFunc(("\n"));
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan(this);
if (autoUninitSpan.uninitDone())
return;
mFlushMode = false;
}
// IMachineDebugger properties
/////////////////////////////////////////////////////////////////////////////
/**
* Returns the current singlestepping flag.
*
* @returns COM status code
* @param aEnabled address of result variable
*/
{
AutoCaller autoCaller(this);
/** @todo */
}
/**
* Sets the singlestepping flag.
*
* @returns COM status code
* @param aEnable new singlestepping flag
*/
{
AutoCaller autoCaller(this);
/** @todo */
}
/**
* Returns the current recompile user mode code flag.
*
* @returns COM status code
* @param aEnabled address of result variable
*/
{
AutoCaller autoCaller(this);
else
*aEnabled = false;
return S_OK;
}
/**
* Sets the recompile user mode code flag.
*
* @returns COM status
* @param aEnable new user mode code recompile flag.
*/
{
AutoCaller autoCaller(this);
if (queueSettings())
{
// queue the request
return S_OK;
}
if (RT_SUCCESS(rcVBox))
return S_OK;
AssertMsgFailed (("Could not set raw mode flags to %d, rcVBox = %Rrc\n",
rawModeFlag, rcVBox));
return E_FAIL;
}
/**
* Returns the current recompile supervisor code flag.
*
* @returns COM status code
* @param aEnabled address of result variable
*/
{
AutoCaller autoCaller(this);
else
*aEnabled = false;
return S_OK;
}
/**
* Sets the new recompile supervisor code flag.
*
* @returns COM status code
* @param aEnable new recompile supervisor code flag
*/
{
AutoCaller autoCaller(this);
if (queueSettings())
{
// queue the request
return S_OK;
}
if (RT_SUCCESS(rcVBox))
return S_OK;
AssertMsgFailed (("Could not set raw mode flags to %d, rcVBox = %Rrc\n",
rawModeFlag, rcVBox));
return E_FAIL;
}
/**
* Returns the current patch manager enabled flag.
*
* @returns COM status code
* @param aEnabled address of result variable
*/
{
AutoCaller autoCaller(this);
else
*aEnabled = false;
return S_OK;
}
/**
* Set the new patch manager enabled flag.
*
* @returns COM status code
* @param aEnable new patch manager enabled flag
*/
{
AutoCaller autoCaller(this);
if (queueSettings())
{
// queue the request
return S_OK;
}
return S_OK;
}
/**
* Returns the current code scanner enabled flag.
*
* @returns COM status code
* @param aEnabled address of result variable
*/
{
AutoCaller autoCaller(this);
else
*aEnabled = false;
return S_OK;
}
/**
* Sets the new code scanner enabled flag.
*
* @returns COM status code
* @param aEnable new code scanner enabled flag
*/
{
AutoCaller autoCaller(this);
if (queueSettings())
{
// queue the request
return S_OK;
}
int vrc;
if (aEnable)
else
if (RT_FAILURE(vrc))
{
/** @todo handle error case */
}
return S_OK;
}
/**
* Returns the log enabled / disabled status.
*
* @returns COM status code
* @param aEnabled address of result variable
*/
{
AutoCaller autoCaller(this);
#ifdef LOG_ENABLED
#else
*aEnabled = false;
#endif
return S_OK;
}
/**
* Enables or disables logging.
*
* @returns COM status code
* @param aEnabled The new code log state.
*/
{
AutoCaller autoCaller(this);
if (queueSettings())
{
// queue the request
return S_OK;
}
#ifdef LOG_ENABLED
if (RT_FAILURE(vrc))
{
/** @todo handle error code. */
}
#endif
return S_OK;
}
{
}
{
}
{
}
/**
* Returns the current hardware virtualization flag.
*
* @returns COM status code
* @param aEnabled address of result variable
*/
{
AutoCaller autoCaller(this);
else
*aEnabled = false;
return S_OK;
}
/**
* Returns the current nested paging flag.
*
* @returns COM status code
* @param aEnabled address of result variable
*/
{
AutoCaller autoCaller(this);
else
*aEnabled = false;
return S_OK;
}
/**
* Returns the current VPID flag.
*
* @returns COM status code
* @param aEnabled address of result variable
*/
{
AutoCaller autoCaller(this);
else
*aEnabled = false;
return S_OK;
}
{
}
{
}
/**
* Returns the current PAE flag.
*
* @returns COM status code
* @param aEnabled address of result variable
*/
{
AutoCaller autoCaller(this);
{
}
else
*aEnabled = false;
return S_OK;
}
/**
* Returns the current virtual time rate.
*
* @returns COM status code.
* @param aPct Where to store the rate.
*/
{
AutoCaller autoCaller(this);
else
*aPct = 100;
return S_OK;
}
/**
* Returns the current virtual time rate.
*
* @returns COM status code.
* @param aPct Where to store the rate.
*/
{
return E_INVALIDARG;
AutoCaller autoCaller(this);
if (queueSettings())
{
// queue the request
return S_OK;
}
if (RT_FAILURE(vrc))
{
/** @todo handle error code. */
}
return S_OK;
}
/**
* Hack for getting the VM handle.
* This is only temporary (promise) while prototyping the debugger.
*
* @returns COM status code
* @param aVm Where to store the vm handle.
* Since there is no uintptr_t in COM, we're using the max integer.
* (No, ULONG is not pointer sized!)
*/
{
AutoCaller autoCaller(this);
/*
* Note: pVM protection provided by SafeVMPtr is no more effective
* after we return from this method.
*/
return S_OK;
}
// IMachineDebugger methods
/////////////////////////////////////////////////////////////////////////////
{
if (a_bstrCompression && *a_bstrCompression)
AutoCaller autoCaller(this);
{
{
if (RT_SUCCESS(vrc))
else
}
}
return hrc;
}
STDMETHODIMP MachineDebugger::DumpHostProcessCore(IN_BSTR a_bstrFilename, IN_BSTR a_bstrCompression)
{
}
{
}
{
LogFlowThisFunc(("\n"));
AutoCaller autoCaller(this);
{
{
if (RT_SUCCESS(vrc))
else
}
}
return hrc;
}
{
}
{
}
{
}
STDMETHODIMP MachineDebugger::ReadPhysicalMemory(LONG64 a_Address, ULONG a_cbRead, ComSafeArrayOut(BYTE, a_abData))
{
}
STDMETHODIMP MachineDebugger::WritePhysicalMemory(LONG64 a_Address, ULONG a_cbRead, ComSafeArrayIn(BYTE, a_abData))
{
}
STDMETHODIMP MachineDebugger::ReadVirtualMemory(ULONG a_idCpu, LONG64 a_Address, ULONG a_cbRead, ComSafeArrayOut(BYTE, a_abData))
{
}
STDMETHODIMP MachineDebugger::WriteVirtualMemory(ULONG a_idCpu, LONG64 a_Address, ULONG a_cbRead, ComSafeArrayIn(BYTE, a_abData))
{
}
{
}
{
}
STDMETHODIMP MachineDebugger::GetRegisters(ULONG a_idCpu, ComSafeArrayOut(BSTR, a_bstrNames), ComSafeArrayOut(BSTR, a_bstrValues))
{
}
{
}
STDMETHODIMP MachineDebugger::SetRegisters(ULONG a_idCpu, ComSafeArrayIn(IN_BSTR, a_bstrNames), ComSafeArrayIn(IN_BSTR, a_bstrValues))
{
}
{
}
/**
* Resets VM statistics.
*
* @returns COM status code.
* @param aPattern The selection pattern. A bit similar to filename globbing.
*/
{
return S_OK;
}
/**
* Dumps VM statistics to the log.
*
* @returns COM status code.
* @param aPattern The selection pattern. A bit similar to filename globbing.
*/
{
return S_OK;
}
/**
* Get the VM statistics in an XML format.
*
* @returns COM status code.
* @param aPattern The selection pattern. A bit similar to filename globbing.
* @param aWithDescriptions Whether to include the descriptions.
* @param aStats The XML document containing the statistics.
*/
{
char *pszSnapshot;
if (RT_FAILURE(vrc))
/** @todo this is horribly inefficient! And it's kinda difficult to tell whether it failed...
* Must use UTF-8 or ASCII here and completely avoid these two extra copy operations.
* Until that's done, this method is kind of useless for debugger statistics GUI because
* of the amount statistics in a debug build. */
return S_OK;
}
// public methods only for internal purposes
/////////////////////////////////////////////////////////////////////////////
void MachineDebugger::flushQueuedSettings()
{
mFlushMode = true;
if (mSinglestepQueued != ~0)
{
mSinglestepQueued = ~0;
}
if (mRecompileUserQueued != ~0)
{
mRecompileUserQueued = ~0;
}
if (mRecompileSupervisorQueued != ~0)
{
}
if (mPatmEnabledQueued != ~0)
{
mPatmEnabledQueued = ~0;
}
if (mCsamEnabledQueued != ~0)
{
mCsamEnabledQueued = ~0;
}
if (mLogEnabledQueued != ~0)
{
mLogEnabledQueued = ~0;
}
if (mVirtualTimeRateQueued != ~(uint32_t)0)
{
mVirtualTimeRateQueued = ~0;
}
mFlushMode = false;
}
// private methods
/////////////////////////////////////////////////////////////////////////////
bool MachineDebugger::queueSettings() const
{
if (!mFlushMode)
{
// check if the machine is running
switch (machineState)
{
// queue the request
default:
return true;
case MachineState_Running:
case MachineState_Paused:
case MachineState_Stuck:
case MachineState_Teleporting:
break;
}
}
return false;
}
/* vi: set tabstop=4 shiftwidth=4 expandtab: */