VirtualBox

source: vbox/trunk/src/VBox/Debugger/VBoxDbgBase.h@ 43421

Last change on this file since 43421 was 35346, checked in by vboxsync, 13 years ago

VMM reorg: Moving the public include files from include/VBox to include/VBox/vmm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: VBoxDbgBase.h 35346 2010-12-27 16:13:13Z vboxsync $ */
2/** @file
3 * VBox Debugger GUI - Base classes.
4 */
5
6/*
7 * Copyright (C) 2006-2010 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
19#ifndef ___Debugger_VBoxDbgBase_h
20#define ___Debugger_VBoxDbgBase_h
21
22
23#include <VBox/vmm/stam.h>
24#include <VBox/vmm/vmapi.h>
25#include <VBox/dbg.h>
26#include <iprt/thread.h>
27#include <QString>
28#include <QWidget>
29
30class VBoxDbgGui;
31
32
33/**
34 * VBox Debugger GUI Base Class.
35 *
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
38 * the VM dies.
39 */
40class VBoxDbgBase
41{
42public:
43 /**
44 * Construct the object.
45 *
46 * @param pDbgGui Pointer to the debugger gui object.
47 */
48 VBoxDbgBase(VBoxDbgGui *a_pDbgGui);
49
50 /**
51 * Destructor.
52 */
53 virtual ~VBoxDbgBase();
54
55
56 /**
57 * Checks if the VM is OK for normal operations.
58 * @returns true if ok, false if not.
59 */
60 bool isVMOk() const
61 {
62 return m_pVM != NULL;
63 }
64
65 /**
66 * Checks if the current thread is the GUI thread or not.
67 * @return true/false accordingly.
68 */
69 bool isGUIThread() const
70 {
71 return m_hGUIThread == RTThreadNativeSelf();
72 }
73
74 /** @name Operations
75 * @{ */
76 /**
77 * Wrapper for STAMR3Reset().
78 */
79 int stamReset(const QString &rPat);
80 /**
81 * Wrapper for STAMR3Enum().
82 */
83 int stamEnum(const QString &rPat, PFNSTAMR3ENUM pfnEnum, void *pvUser);
84 /**
85 * Wrapper for DBGCCreate().
86 */
87 int dbgcCreate(PDBGCBACK pBack, unsigned fFlags);
88 /** @} */
89
90
91protected:
92 /** @name Signals
93 * @{ */
94 /**
95 * Called when the VM is being destroyed.
96 */
97 virtual void sigDestroying();
98 /**
99 * Called when the VM has been terminated.
100 */
101 virtual void sigTerminated();
102 /** @} */
103
104
105private:
106 /**
107 * VM state callback function.
108 *
109 * You are not allowed to call any function which changes the VM state from a
110 * state callback, except VMR3Destroy().
111 *
112 * @param pVM The VM handle.
113 * @param enmState The new state.
114 * @param enmOldState The old state.
115 * @param pvUser The user argument.
116 */
117 static DECLCALLBACK(void) atStateChange(PVM pVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
118
119private:
120 /** Pointer to the debugger GUI object. */
121 VBoxDbgGui *m_pDbgGui;
122 /** The VM handle. */
123 PVM volatile m_pVM;
124 /** The handle of the GUI thread. */
125 RTNATIVETHREAD m_hGUIThread;
126};
127
128
129/**
130 * VBox Debugger GUI Base Window Class.
131 *
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.
135 */
136class VBoxDbgBaseWindow : public QWidget, public VBoxDbgBase
137{
138public:
139 /**
140 * Construct the object.
141 *
142 * @param pDbgGui Pointer to the debugger gui object.
143 */
144 VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent);
145
146 /**
147 * Destructor.
148 */
149 virtual ~VBoxDbgBaseWindow();
150
151 /**
152 * Shows the window and gives it focus.
153 */
154 void vShow();
155
156 /**
157 * Repositions the window, taking the frame decoration into account.
158 *
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.
164 */
165 void vReposition(int a_x, int a_y, unsigned a_cx, unsigned a_cy, bool a_fResize);
166
167protected:
168 /**
169 * For polishing the window size (X11 mess).
170 *
171 * @returns true / false.
172 * @param a_pEvt The event.
173 */
174 virtual bool event(QEvent *a_pEvt);
175
176 /**
177 * Internal worker for polishing the size and position (X11 hacks).
178 */
179 void vPolishSizeAndPos();
180
181 /**
182 * Internal worker that guesses the border sizes.
183 */
184 QSize vGuessBorderSizes();
185
186
187private:
188 /** Whether we've done the size polishing in showEvent or not. */
189 bool m_fPolished;
190 /** The desired x coordinate. */
191 int m_x;
192 /** The desired y coordinate. */
193 int m_y;
194 /** The desired width. */
195 unsigned m_cx;
196 /** The desired height. */
197 unsigned m_cy;
198
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;
203};
204
205#endif
206
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use