summaryrefslogtreecommitdiff
path: root/src/VBox/Debugger/VBoxDbgBase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Debugger/VBoxDbgBase.cpp')
-rw-r--r--src/VBox/Debugger/VBoxDbgBase.cpp60
1 files changed, 35 insertions, 25 deletions
diff --git a/src/VBox/Debugger/VBoxDbgBase.cpp b/src/VBox/Debugger/VBoxDbgBase.cpp
index dd08ef33..b7038c9a 100644
--- a/src/VBox/Debugger/VBoxDbgBase.cpp
+++ b/src/VBox/Debugger/VBoxDbgBase.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -32,16 +32,17 @@
VBoxDbgBase::VBoxDbgBase(VBoxDbgGui *a_pDbgGui)
- : m_pDbgGui(a_pDbgGui), m_pVM(NULL), m_hGUIThread(RTThreadNativeSelf())
+ : m_pDbgGui(a_pDbgGui), m_pUVM(NULL), m_hGUIThread(RTThreadNativeSelf())
{
/*
* Register
*/
- PVM pVM = a_pDbgGui->getVMHandle();
- if (pVM)
+ m_pUVM = a_pDbgGui->getUvmHandle();
+ if (m_pUVM)
{
- m_pVM = pVM;
- int rc = VMR3AtStateRegister(pVM, atStateChange, this);
+ VMR3RetainUVM(m_pUVM);
+
+ int rc = VMR3AtStateRegister(m_pUVM, atStateChange, this);
AssertRC(rc);
}
}
@@ -53,11 +54,13 @@ VBoxDbgBase::~VBoxDbgBase()
* If the VM is still around.
*/
/** @todo need to do some locking here? */
- PVM pVM = ASMAtomicXchgPtrT(&m_pVM, NULL, PVM);
- if (pVM)
+ PUVM pUVM = ASMAtomicXchgPtrT(&m_pUVM, NULL, PUVM);
+ if (pUVM)
{
- int rc = VMR3AtStateDeregister(pVM, atStateChange, this);
+ int rc = VMR3AtStateDeregister(pUVM, atStateChange, this);
AssertRC(rc);
+
+ VMR3ReleaseUVM(pUVM);
}
}
@@ -67,10 +70,10 @@ VBoxDbgBase::stamReset(const QString &rPat)
{
QByteArray Utf8Array = rPat.toUtf8();
const char *pszPat = !rPat.isEmpty() ? Utf8Array.constData() : NULL;
- PVM pVM = m_pVM;
- if ( pVM
- && VMR3GetState(pVM) < VMSTATE_DESTROYING)
- return STAMR3Reset(pVM, pszPat);
+ PUVM pUVM = m_pUVM;
+ if ( pUVM
+ && VMR3GetStateU(pUVM) < VMSTATE_DESTROYING)
+ return STAMR3Reset(pUVM, pszPat);
return VERR_INVALID_HANDLE;
}
@@ -80,10 +83,10 @@ VBoxDbgBase::stamEnum(const QString &rPat, PFNSTAMR3ENUM pfnEnum, void *pvUser)
{
QByteArray Utf8Array = rPat.toUtf8();
const char *pszPat = !rPat.isEmpty() ? Utf8Array.constData() : NULL;
- PVM pVM = m_pVM;
- if ( pVM
- && VMR3GetState(pVM) < VMSTATE_DESTROYING)
- return STAMR3Enum(pVM, pszPat, pfnEnum, pvUser);
+ PUVM pUVM = m_pUVM;
+ if ( pUVM
+ && VMR3GetStateU(pUVM) < VMSTATE_DESTROYING)
+ return STAMR3Enum(pUVM, pszPat, pfnEnum, pvUser);
return VERR_INVALID_HANDLE;
}
@@ -91,25 +94,32 @@ VBoxDbgBase::stamEnum(const QString &rPat, PFNSTAMR3ENUM pfnEnum, void *pvUser)
int
VBoxDbgBase::dbgcCreate(PDBGCBACK pBack, unsigned fFlags)
{
- PVM pVM = m_pVM;
- if ( pVM
- && VMR3GetState(pVM) < VMSTATE_DESTROYING)
- return DBGCCreate(pVM, pBack, fFlags);
+ PUVM pUVM = m_pUVM;
+ if ( pUVM
+ && VMR3GetStateU(pUVM) < VMSTATE_DESTROYING)
+ return DBGCCreate(pUVM, pBack, fFlags);
return VERR_INVALID_HANDLE;
}
/*static*/ DECLCALLBACK(void)
-VBoxDbgBase::atStateChange(PVM pVM, VMSTATE enmState, VMSTATE /*enmOldState*/, void *pvUser)
+VBoxDbgBase::atStateChange(PUVM pUVM, VMSTATE enmState, VMSTATE /*enmOldState*/, void *pvUser)
{
- VBoxDbgBase *pThis = (VBoxDbgBase *)pvUser;
+ VBoxDbgBase *pThis = (VBoxDbgBase *)pvUser; NOREF(pUVM);
switch (enmState)
{
case VMSTATE_TERMINATED:
+ {
/** @todo need to do some locking here? */
- if (ASMAtomicCmpXchgPtr(&pThis->m_pVM, NULL, pVM))
+ PUVM pUVM2 = ASMAtomicXchgPtrT(&pThis->m_pUVM, NULL, PUVM);
+ if (pUVM2)
+ {
+ Assert(pUVM2 == pUVM);
pThis->sigTerminated();
+ VMR3ReleaseUVM(pUVM2);
+ }
break;
+ }
case VMSTATE_DESTROYING:
pThis->sigDestroying();
@@ -150,7 +160,7 @@ unsigned VBoxDbgBaseWindow::m_cyBorder = 0;
VBoxDbgBaseWindow::VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent)
- : QWidget(a_pParent, Qt::Window), VBoxDbgBase(a_pDbgGui), m_fPolished(false),
+ : QWidget(a_pParent, Qt::Window), VBoxDbgBase(a_pDbgGui), m_fPolished(false),
m_x(INT_MAX), m_y(INT_MAX), m_cx(0), m_cy(0)
{
}