1 | /* $Id: VBoxDbgBase.h 93460 2022-01-27 16:50:15Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Debugger GUI - Base classes.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2022 Oracle Corporation
|
---|
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 |
|
---|
18 | #ifndef DEBUGGER_INCLUDED_SRC_VBoxDbgBase_h
|
---|
19 | #define DEBUGGER_INCLUDED_SRC_VBoxDbgBase_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 |
|
---|
25 | #include <VBox/vmm/stam.h>
|
---|
26 | #include <VBox/vmm/vmapi.h>
|
---|
27 | #include <VBox/vmm/vmmr3vtable.h>
|
---|
28 | #include <VBox/dbg.h>
|
---|
29 | #include <iprt/thread.h>
|
---|
30 | #include <QString>
|
---|
31 | #include <QWidget>
|
---|
32 |
|
---|
33 | class VBoxDbgGui;
|
---|
34 |
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * VBox Debugger GUI Base Class.
|
---|
38 | *
|
---|
39 | * The purpose of this class is to hide the VM handle, abstract VM
|
---|
40 | * operations, and finally to make sure the GUI won't crash when
|
---|
41 | * the VM dies.
|
---|
42 | */
|
---|
43 | class VBoxDbgBase
|
---|
44 | {
|
---|
45 | public:
|
---|
46 | /**
|
---|
47 | * Construct the object.
|
---|
48 | *
|
---|
49 | * @param a_pDbgGui Pointer to the debugger gui object.
|
---|
50 | */
|
---|
51 | VBoxDbgBase(VBoxDbgGui *a_pDbgGui);
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Destructor.
|
---|
55 | */
|
---|
56 | virtual ~VBoxDbgBase();
|
---|
57 |
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Checks if the VM is OK for normal operations.
|
---|
61 | * @returns true if ok, false if not.
|
---|
62 | */
|
---|
63 | bool isVMOk() const
|
---|
64 | {
|
---|
65 | return m_pUVM != NULL;
|
---|
66 | }
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * Checks if the current thread is the GUI thread or not.
|
---|
70 | * @return true/false accordingly.
|
---|
71 | */
|
---|
72 | bool isGUIThread() const
|
---|
73 | {
|
---|
74 | return m_hGUIThread == RTThreadNativeSelf();
|
---|
75 | }
|
---|
76 |
|
---|
77 | /** @name Operations
|
---|
78 | * @{ */
|
---|
79 | /**
|
---|
80 | * Wrapper for STAMR3Reset().
|
---|
81 | */
|
---|
82 | int stamReset(const QString &rPat);
|
---|
83 | /**
|
---|
84 | * Wrapper for STAMR3Enum().
|
---|
85 | */
|
---|
86 | int stamEnum(const QString &rPat, PFNSTAMR3ENUM pfnEnum, void *pvUser);
|
---|
87 | /**
|
---|
88 | * Wrapper for DBGCCreate().
|
---|
89 | */
|
---|
90 | int dbgcCreate(PCDBGCIO pIo, unsigned fFlags);
|
---|
91 | /** @} */
|
---|
92 |
|
---|
93 |
|
---|
94 | protected:
|
---|
95 | /** @name Signals
|
---|
96 | * @{ */
|
---|
97 | /**
|
---|
98 | * Called when the VM is being destroyed.
|
---|
99 | */
|
---|
100 | virtual void sigDestroying();
|
---|
101 | /**
|
---|
102 | * Called when the VM has been terminated.
|
---|
103 | */
|
---|
104 | virtual void sigTerminated();
|
---|
105 | /** @} */
|
---|
106 |
|
---|
107 |
|
---|
108 | private:
|
---|
109 | /** @callback_method_impl{FNVMATSTATE} */
|
---|
110 | static DECLCALLBACK(void) atStateChange(PUVM pUVM, PCVMMR3VTABLE pVMM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
|
---|
111 |
|
---|
112 | private:
|
---|
113 | /** Pointer to the debugger GUI object. */
|
---|
114 | VBoxDbgGui *m_pDbgGui;
|
---|
115 | /** The user mode VM handle. */
|
---|
116 | PUVM volatile m_pUVM;
|
---|
117 | /** The handle of the GUI thread. */
|
---|
118 | RTNATIVETHREAD m_hGUIThread;
|
---|
119 | };
|
---|
120 |
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * VBox Debugger GUI Base Window Class.
|
---|
124 | *
|
---|
125 | * This is just a combination of QWidget and VBoxDbgBase with some additional
|
---|
126 | * functionality for window management. This class is not intended for control
|
---|
127 | * widgets, only normal top-level windows.
|
---|
128 | */
|
---|
129 | class VBoxDbgBaseWindow : public QWidget, public VBoxDbgBase
|
---|
130 | {
|
---|
131 | public:
|
---|
132 | /**
|
---|
133 | * Construct the object.
|
---|
134 | *
|
---|
135 | * @param a_pDbgGui Pointer to the debugger gui object.
|
---|
136 | * @param a_pParent Pointer to the parent object.
|
---|
137 | * @param a_pszTitle The window title string (persistent, not copied).
|
---|
138 | */
|
---|
139 | VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent, const char *a_pszTitle);
|
---|
140 |
|
---|
141 | /**
|
---|
142 | * Destructor.
|
---|
143 | */
|
---|
144 | virtual ~VBoxDbgBaseWindow();
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * Shows the window and gives it focus.
|
---|
148 | */
|
---|
149 | void vShow();
|
---|
150 |
|
---|
151 | /**
|
---|
152 | * Repositions the window, taking the frame decoration into account.
|
---|
153 | *
|
---|
154 | * @param a_x The new x coordinate.
|
---|
155 | * @param a_y The new x coordinate.
|
---|
156 | * @param a_cx The total width.
|
---|
157 | * @param a_cy The total height.
|
---|
158 | * @param a_fResize Whether to resize it as well.
|
---|
159 | */
|
---|
160 | void vReposition(int a_x, int a_y, unsigned a_cx, unsigned a_cy, bool a_fResize);
|
---|
161 |
|
---|
162 | protected:
|
---|
163 | /**
|
---|
164 | * For polishing the window size (X11 mess).
|
---|
165 | *
|
---|
166 | * @returns true / false.
|
---|
167 | * @param a_pEvt The event.
|
---|
168 | */
|
---|
169 | virtual bool event(QEvent *a_pEvt);
|
---|
170 |
|
---|
171 | /**
|
---|
172 | * Event filter for various purposes (mainly title bar).
|
---|
173 | *
|
---|
174 | * @param pWatched The object event came to.
|
---|
175 | * @param pEvent The event being handled.
|
---|
176 | */
|
---|
177 | virtual bool eventFilter(QObject *pWatched, QEvent *pEvent);
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Internal worker for polishing the size and position (X11 hacks).
|
---|
181 | */
|
---|
182 | void vPolishSizeAndPos();
|
---|
183 |
|
---|
184 | /**
|
---|
185 | * Internal worker that guesses the border sizes.
|
---|
186 | */
|
---|
187 | QSize vGuessBorderSizes();
|
---|
188 |
|
---|
189 | private:
|
---|
190 | /** The Window title string (inflexible, read only). */
|
---|
191 | const char *m_pszTitle;
|
---|
192 | /** Whether we've done the size polishing in showEvent or not. */
|
---|
193 | bool m_fPolished;
|
---|
194 | /** The desired x coordinate. */
|
---|
195 | int m_x;
|
---|
196 | /** The desired y coordinate. */
|
---|
197 | int m_y;
|
---|
198 | /** The desired width. */
|
---|
199 | unsigned m_cx;
|
---|
200 | /** The desired height. */
|
---|
201 | unsigned m_cy;
|
---|
202 |
|
---|
203 | /** Best effort x border size (for X11). */
|
---|
204 | static unsigned m_cxBorder;
|
---|
205 | /** Best effort y border size (for X11). */
|
---|
206 | static unsigned m_cyBorder;
|
---|
207 | };
|
---|
208 |
|
---|
209 | #endif /* !DEBUGGER_INCLUDED_SRC_VBoxDbgBase_h */
|
---|
210 |
|
---|