3 * VBox Debugger GUI - Base classes.
7 * Copyright (C) 2006-2010 Oracle Corporation
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.
19 #ifndef ___Debugger_VBoxDbgBase_h
20 #define ___Debugger_VBoxDbgBase_h
23 #include <VBox/vmm/stam.h>
24 #include <VBox/vmm/vmapi.h>
26 #include <iprt/thread.h>
34 * VBox Debugger GUI Base Class.
36 * The purpose of this class is to hide the VM handle, abstract VM
37 * operations, and finally to make sure the GUI won't crash when
44 * Construct the object.
46 * @param pDbgGui Pointer to the debugger gui object.
48 VBoxDbgBase(VBoxDbgGui
*a_pDbgGui
);
53 virtual ~VBoxDbgBase();
57 * Checks if the VM is OK for normal operations.
58 * @returns true if ok, false if not.
66 * Checks if the current thread is the GUI thread or not.
67 * @return true/false accordingly.
69 bool isGUIThread() const
71 return m_hGUIThread
== RTThreadNativeSelf();
77 * Wrapper for STAMR3Reset().
79 int stamReset(const QString
&rPat
);
81 * Wrapper for STAMR3Enum().
83 int stamEnum(const QString
&rPat
, PFNSTAMR3ENUM pfnEnum
, void *pvUser
);
85 * Wrapper for DBGCCreate().
87 int dbgcCreate(PDBGCBACK pBack
, unsigned fFlags
);
95 * Called when the VM is being destroyed.
97 virtual void sigDestroying();
99 * Called when the VM has been terminated.
101 virtual void sigTerminated();
107 * VM state callback function.
109 * You are not allowed to call any function which changes the VM state from a
110 * state callback, except VMR3Destroy().
112 * @param pVM The VM handle.
113 * @param enmState The new state.
114 * @param enmOldState The old state.
115 * @param pvUser The user argument.
117 static DECLCALLBACK(void) atStateChange(PVM pVM
, VMSTATE enmState
, VMSTATE enmOldState
, void *pvUser
);
120 /** Pointer to the debugger GUI object. */
121 VBoxDbgGui
*m_pDbgGui
;
122 /** The VM handle. */
124 /** The handle of the GUI thread. */
125 RTNATIVETHREAD m_hGUIThread
;
130 * VBox Debugger GUI Base Window Class.
132 * This is just a combination of QWidget and VBoxDbgBase with some additional
133 * functionality for window management. This class is not intended for control
134 * widgets, only normal top-level windows.
136 class VBoxDbgBaseWindow
: public QWidget
, public VBoxDbgBase
140 * Construct the object.
142 * @param pDbgGui Pointer to the debugger gui object.
144 VBoxDbgBaseWindow(VBoxDbgGui
*a_pDbgGui
, QWidget
*a_pParent
);
149 virtual ~VBoxDbgBaseWindow();
152 * Shows the window and gives it focus.
157 * Repositions the window, taking the frame decoration into account.
159 * @param a_x The new x coordinate.
160 * @param a_y The new x coordinate.
161 * @param a_cx The total width.
162 * @param a_cy The total height.
163 * @param a_fResize Whether to resize it as well.
165 void vReposition(int a_x
, int a_y
, unsigned a_cx
, unsigned a_cy
, bool a_fResize
);
169 * For polishing the window size (X11 mess).
171 * @returns true / false.
172 * @param a_pEvt The event.
174 virtual bool event(QEvent
*a_pEvt
);
177 * Internal worker for polishing the size and position (X11 hacks).
179 void vPolishSizeAndPos();
182 * Internal worker that guesses the border sizes.
184 QSize
vGuessBorderSizes();
188 /** Whether we've done the size polishing in showEvent or not. */
190 /** The desired x coordinate. */
192 /** The desired y coordinate. */
194 /** The desired width. */
196 /** The desired height. */
199 /** Best effort x border size (for X11). */
200 static unsigned m_cxBorder
;
201 /** Best effort y border size (for X11). */
202 static unsigned m_cyBorder
;