1 | /* $Id: VBoxDbgBase.cpp 12183 2008-09-07 02:35:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Debugger GUI - Base class.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 |
|
---|
23 | /*******************************************************************************
|
---|
24 | * Header Files *
|
---|
25 | *******************************************************************************/
|
---|
26 | #include <VBox/err.h>
|
---|
27 | #include <iprt/assert.h>
|
---|
28 | #include "VBoxDbgBase.h"
|
---|
29 |
|
---|
30 |
|
---|
31 |
|
---|
32 | VBoxDbgBase::VBoxDbgBase(PVM pVM) : m_pVM(pVM), m_hGUIThread(RTThreadNativeSelf())
|
---|
33 | {
|
---|
34 | /*
|
---|
35 | * Register
|
---|
36 | */
|
---|
37 | int rc = VMR3AtStateRegister(pVM, atStateChange, this);
|
---|
38 | AssertRC(rc);
|
---|
39 | }
|
---|
40 |
|
---|
41 | VBoxDbgBase::~VBoxDbgBase()
|
---|
42 | {
|
---|
43 | /*
|
---|
44 | * If the VM is still around.
|
---|
45 | */
|
---|
46 | if (m_pVM)
|
---|
47 | {
|
---|
48 | int rc = VMR3AtStateDeregister(m_pVM, atStateChange, this);
|
---|
49 | AssertRC(rc);
|
---|
50 | m_pVM = NULL;
|
---|
51 | }
|
---|
52 | }
|
---|
53 |
|
---|
54 | int VBoxDbgBase::stamReset(const QString &rPat)
|
---|
55 | {
|
---|
56 | #ifdef VBOXDBG_USE_QT4
|
---|
57 | QByteArray Utf8Array = rPat.toUtf8();
|
---|
58 | const char *pszPat = !rPat.isEmpty() ? Utf8Array.constData() : NULL;
|
---|
59 | #else
|
---|
60 | const char *pszPat = !rPat.isEmpty() ? rPat : NULL;
|
---|
61 | #endif
|
---|
62 | if (m_pVM)
|
---|
63 | return STAMR3Reset(m_pVM, pszPat);
|
---|
64 | return VERR_INVALID_HANDLE;
|
---|
65 | }
|
---|
66 |
|
---|
67 | int VBoxDbgBase::stamEnum(const QString &rPat, PFNSTAMR3ENUM pfnEnum, void *pvUser)
|
---|
68 | {
|
---|
69 | #ifdef VBOXDBG_USE_QT4
|
---|
70 | QByteArray Utf8Array = rPat.toUtf8();
|
---|
71 | const char *pszPat = !rPat.isEmpty() ? Utf8Array.constData() : NULL;
|
---|
72 | #else
|
---|
73 | const char *pszPat = !rPat.isEmpty() ? rPat : NULL;
|
---|
74 | #endif
|
---|
75 | if (m_pVM)
|
---|
76 | return STAMR3Enum(m_pVM, pszPat, pfnEnum, pvUser);
|
---|
77 | return VERR_INVALID_HANDLE;
|
---|
78 | }
|
---|
79 |
|
---|
80 | int VBoxDbgBase::dbgcCreate(PDBGCBACK pBack, unsigned fFlags)
|
---|
81 | {
|
---|
82 | if (m_pVM)
|
---|
83 | return DBGCCreate(m_pVM, pBack, fFlags);
|
---|
84 | return VERR_INVALID_HANDLE;
|
---|
85 | }
|
---|
86 |
|
---|
87 | /*static*/ DECLCALLBACK(void) VBoxDbgBase::atStateChange(PVM /*pVM*/, VMSTATE enmState, VMSTATE /*enmOldState*/, void *pvUser)
|
---|
88 | {
|
---|
89 | VBoxDbgBase *pThis = (VBoxDbgBase *)pvUser;
|
---|
90 | switch (enmState)
|
---|
91 | {
|
---|
92 | case VMSTATE_TERMINATED:
|
---|
93 | pThis->sigTerminated();
|
---|
94 | pThis->m_pVM = NULL;
|
---|
95 | break;
|
---|
96 |
|
---|
97 | default:
|
---|
98 | break;
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 | void VBoxDbgBase::sigTerminated()
|
---|
103 | {
|
---|
104 | }
|
---|
105 |
|
---|