VirtualBox

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

Last change on this file since 74882 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/* $Id: VBoxDbgBase.h 69500 2017-10-28 15:14:05Z vboxsync $ */
2/** @file
3 * VBox Debugger GUI - Base classes.
4 */
5
6/*
7 * Copyright (C) 2006-2017 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 a_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_pUVM != 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 /** @callback_method_impl{FNVMATSTATE} */
107 static DECLCALLBACK(void) atStateChange(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
108
109private:
110 /** Pointer to the debugger GUI object. */
111 VBoxDbgGui *m_pDbgGui;
112 /** The user mode VM handle. */
113 PUVM volatile m_pUVM;
114 /** The handle of the GUI thread. */
115 RTNATIVETHREAD m_hGUIThread;
116};
117
118
119/**
120 * VBox Debugger GUI Base Window Class.
121 *
122 * This is just a combination of QWidget and VBoxDbgBase with some additional
123 * functionality for window management. This class is not intended for control
124 * widgets, only normal top-level windows.
125 */
126class VBoxDbgBaseWindow : public QWidget, public VBoxDbgBase
127{
128public:
129 /**
130 * Construct the object.
131 *
132 * @param a_pDbgGui Pointer to the debugger gui object.
133 * @param a_pParent Pointer to the parent object.
134 */
135 VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent);
136
137 /**
138 * Destructor.
139 */
140 virtual ~VBoxDbgBaseWindow();
141
142 /**
143 * Shows the window and gives it focus.
144 */
145 void vShow();
146
147 /**
148 * Repositions the window, taking the frame decoration into account.
149 *
150 * @param a_x The new x coordinate.
151 * @param a_y The new x coordinate.
152 * @param a_cx The total width.
153 * @param a_cy The total height.
154 * @param a_fResize Whether to resize it as well.
155 */
156 void vReposition(int a_x, int a_y, unsigned a_cx, unsigned a_cy, bool a_fResize);
157
158protected:
159 /**
160 * For polishing the window size (X11 mess).
161 *
162 * @returns true / false.
163 * @param a_pEvt The event.
164 */
165 virtual bool event(QEvent *a_pEvt);
166
167 /**
168 * Internal worker for polishing the size and position (X11 hacks).
169 */
170 void vPolishSizeAndPos();
171
172 /**
173 * Internal worker that guesses the border sizes.
174 */
175 QSize vGuessBorderSizes();
176
177
178private:
179 /** Whether we've done the size polishing in showEvent or not. */
180 bool m_fPolished;
181 /** The desired x coordinate. */
182 int m_x;
183 /** The desired y coordinate. */
184 int m_y;
185 /** The desired width. */
186 unsigned m_cx;
187 /** The desired height. */
188 unsigned m_cy;
189
190 /** Best effort x border size (for X11). */
191 static unsigned m_cxBorder;
192 /** Best effort y border size (for X11). */
193 static unsigned m_cyBorder;
194};
195
196#endif
197
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette