1 | /* $Id: VBoxDbgBase.h 31510 2010-08-10 08:48:11Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Debugger GUI - Base classes.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Oracle Corporation
|
---|
8 | *
|
---|
9 | * Oracle Corporation confidential
|
---|
10 | * All rights reserved
|
---|
11 | */
|
---|
12 |
|
---|
13 |
|
---|
14 | #ifndef ___Debugger_VBoxDbgBase_h
|
---|
15 | #define ___Debugger_VBoxDbgBase_h
|
---|
16 |
|
---|
17 |
|
---|
18 | #include <VBox/stam.h>
|
---|
19 | #include <VBox/vmapi.h>
|
---|
20 | #include <VBox/dbg.h>
|
---|
21 | #include <iprt/thread.h>
|
---|
22 | #include <QString>
|
---|
23 | #include <QWidget>
|
---|
24 |
|
---|
25 | class VBoxDbgGui;
|
---|
26 |
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * VBox Debugger GUI Base Class.
|
---|
30 | *
|
---|
31 | * The purpose of this class is to hide the VM handle, abstract VM
|
---|
32 | * operations, and finally to make sure the GUI won't crash when
|
---|
33 | * the VM dies.
|
---|
34 | */
|
---|
35 | class VBoxDbgBase
|
---|
36 | {
|
---|
37 | public:
|
---|
38 | /**
|
---|
39 | * Construct the object.
|
---|
40 | *
|
---|
41 | * @param pDbgGui Pointer to the debugger gui object.
|
---|
42 | */
|
---|
43 | VBoxDbgBase(VBoxDbgGui *a_pDbgGui);
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Destructor.
|
---|
47 | */
|
---|
48 | virtual ~VBoxDbgBase();
|
---|
49 |
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Checks if the VM is OK for normal operations.
|
---|
53 | * @returns true if ok, false if not.
|
---|
54 | */
|
---|
55 | bool isVMOk() const
|
---|
56 | {
|
---|
57 | return m_pVM != NULL;
|
---|
58 | }
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Checks if the current thread is the GUI thread or not.
|
---|
62 | * @return true/false accordingly.
|
---|
63 | */
|
---|
64 | bool isGUIThread() const
|
---|
65 | {
|
---|
66 | return m_hGUIThread == RTThreadNativeSelf();
|
---|
67 | }
|
---|
68 |
|
---|
69 | /** @name Operations
|
---|
70 | * @{ */
|
---|
71 | /**
|
---|
72 | * Wrapper for STAMR3Reset().
|
---|
73 | */
|
---|
74 | int stamReset(const QString &rPat);
|
---|
75 | /**
|
---|
76 | * Wrapper for STAMR3Enum().
|
---|
77 | */
|
---|
78 | int stamEnum(const QString &rPat, PFNSTAMR3ENUM pfnEnum, void *pvUser);
|
---|
79 | /**
|
---|
80 | * Wrapper for DBGCCreate().
|
---|
81 | */
|
---|
82 | int dbgcCreate(PDBGCBACK pBack, unsigned fFlags);
|
---|
83 | /** @} */
|
---|
84 |
|
---|
85 |
|
---|
86 | protected:
|
---|
87 | /** @name Signals
|
---|
88 | * @{ */
|
---|
89 | /**
|
---|
90 | * Called when the VM is being destroyed.
|
---|
91 | */
|
---|
92 | virtual void sigDestroying();
|
---|
93 | /**
|
---|
94 | * Called when the VM has been terminated.
|
---|
95 | */
|
---|
96 | virtual void sigTerminated();
|
---|
97 | /** @} */
|
---|
98 |
|
---|
99 |
|
---|
100 | private:
|
---|
101 | /**
|
---|
102 | * VM state callback function.
|
---|
103 | *
|
---|
104 | * You are not allowed to call any function which changes the VM state from a
|
---|
105 | * state callback, except VMR3Destroy().
|
---|
106 | *
|
---|
107 | * @param pVM The VM handle.
|
---|
108 | * @param enmState The new state.
|
---|
109 | * @param enmOldState The old state.
|
---|
110 | * @param pvUser The user argument.
|
---|
111 | */
|
---|
112 | static DECLCALLBACK(void) atStateChange(PVM pVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
|
---|
113 |
|
---|
114 | private:
|
---|
115 | /** Pointer to the debugger GUI object. */
|
---|
116 | VBoxDbgGui *m_pDbgGui;
|
---|
117 | /** The VM handle. */
|
---|
118 | PVM volatile m_pVM;
|
---|
119 | /** The handle of the GUI thread. */
|
---|
120 | RTNATIVETHREAD m_hGUIThread;
|
---|
121 | };
|
---|
122 |
|
---|
123 |
|
---|
124 | /**
|
---|
125 | * VBox Debugger GUI Base Window Class.
|
---|
126 | *
|
---|
127 | * This is just a combination of QWidget and VBoxDbgBase with some additional
|
---|
128 | * functionality for window management. This class is not intended for control
|
---|
129 | * widgets, only normal top-level windows.
|
---|
130 | */
|
---|
131 | class VBoxDbgBaseWindow : public QWidget, public VBoxDbgBase
|
---|
132 | {
|
---|
133 | public:
|
---|
134 | /**
|
---|
135 | * Construct the object.
|
---|
136 | *
|
---|
137 | * @param pDbgGui Pointer to the debugger gui object.
|
---|
138 | */
|
---|
139 | VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent);
|
---|
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 | * Internal worker for polishing the size and position (X11 hacks).
|
---|
173 | */
|
---|
174 | void vPolishSizeAndPos();
|
---|
175 |
|
---|
176 | /**
|
---|
177 | * Internal worker that guesses the border sizes.
|
---|
178 | */
|
---|
179 | QSize vGuessBorderSizes();
|
---|
180 |
|
---|
181 |
|
---|
182 | private:
|
---|
183 | /** Whether we've done the size polishing in showEvent or not. */
|
---|
184 | bool m_fPolished;
|
---|
185 | /** The desired x coordinate. */
|
---|
186 | int m_x;
|
---|
187 | /** The desired y coordinate. */
|
---|
188 | int m_y;
|
---|
189 | /** The desired width. */
|
---|
190 | unsigned m_cx;
|
---|
191 | /** The desired height. */
|
---|
192 | unsigned m_cy;
|
---|
193 |
|
---|
194 | /** Best effort x border size (for X11). */
|
---|
195 | static unsigned m_cxBorder;
|
---|
196 | /** Best effort y border size (for X11). */
|
---|
197 | static unsigned m_cyBorder;
|
---|
198 | };
|
---|
199 |
|
---|
200 | #endif
|
---|
201 |
|
---|