VirtualBox

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

Last change on this file since 95512 was 93468, checked in by vboxsync, 3 years ago

VBoxDbg,VMM/STAM,Main: Converted VBoxDbg to use the VMM function table, extending the STAMR3Enum to include the unit string to avoid needing to call STAMR3GetUnit a lot. The latter would better fit with the XML based viewer, as it only gets the string version of the unit. Had to adjust a user of STAMR3Enum in Main. bugref:10074

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1/* $Id: VBoxDbgBase.h 93468 2022-01-27 21:17:12Z 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
33class 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 */
43class VBoxDbgBase
44{
45public:
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
94protected:
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
108private:
109 /** @callback_method_impl{FNVMATSTATE} */
110 static DECLCALLBACK(void) atStateChange(PUVM pUVM, PCVMMR3VTABLE pVMM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
111
112private:
113 /** Pointer to the debugger GUI object. */
114 VBoxDbgGui *m_pDbgGui;
115 /** The user mode VM handle. */
116 PUVM volatile m_pUVM;
117 /** The VMM function table. */
118 PCVMMR3VTABLE volatile m_pVMM;
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 */
131class VBoxDbgBaseWindow : public QWidget, public VBoxDbgBase
132{
133public:
134 /**
135 * Construct the object.
136 *
137 * @param a_pDbgGui Pointer to the debugger gui object.
138 * @param a_pParent Pointer to the parent object.
139 * @param a_pszTitle The window title string (persistent, not copied).
140 */
141 VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent, const char *a_pszTitle);
142
143 /**
144 * Destructor.
145 */
146 virtual ~VBoxDbgBaseWindow();
147
148 /**
149 * Shows the window and gives it focus.
150 */
151 void vShow();
152
153 /**
154 * Repositions the window, taking the frame decoration into account.
155 *
156 * @param a_x The new x coordinate.
157 * @param a_y The new x coordinate.
158 * @param a_cx The total width.
159 * @param a_cy The total height.
160 * @param a_fResize Whether to resize it as well.
161 */
162 void vReposition(int a_x, int a_y, unsigned a_cx, unsigned a_cy, bool a_fResize);
163
164protected:
165 /**
166 * For polishing the window size (X11 mess).
167 *
168 * @returns true / false.
169 * @param a_pEvt The event.
170 */
171 virtual bool event(QEvent *a_pEvt);
172
173 /**
174 * Event filter for various purposes (mainly title bar).
175 *
176 * @param pWatched The object event came to.
177 * @param pEvent The event being handled.
178 */
179 virtual bool eventFilter(QObject *pWatched, QEvent *pEvent);
180
181 /**
182 * Internal worker for polishing the size and position (X11 hacks).
183 */
184 void vPolishSizeAndPos();
185
186 /**
187 * Internal worker that guesses the border sizes.
188 */
189 QSize vGuessBorderSizes();
190
191private:
192 /** The Window title string (inflexible, read only). */
193 const char *m_pszTitle;
194 /** Whether we've done the size polishing in showEvent or not. */
195 bool m_fPolished;
196 /** The desired x coordinate. */
197 int m_x;
198 /** The desired y coordinate. */
199 int m_y;
200 /** The desired width. */
201 unsigned m_cx;
202 /** The desired height. */
203 unsigned m_cy;
204
205 /** Best effort x border size (for X11). */
206 static unsigned m_cxBorder;
207 /** Best effort y border size (for X11). */
208 static unsigned m_cyBorder;
209};
210
211#endif /* !DEBUGGER_INCLUDED_SRC_VBoxDbgBase_h */
212
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