VirtualBox

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

Last change on this file since 76864 was 76564, checked in by vboxsync, 6 years ago

Debugger: Use DEBUGGER_INCLUDED_SRC_ as header guard prefix with scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: VBoxDbgBase.h 76564 2019-01-01 03:57:14Z vboxsync $ */
2/** @file
3 * VBox Debugger GUI - Base classes.
4 */
5
6/*
7 * Copyright (C) 2006-2019 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/dbg.h>
28#include <iprt/thread.h>
29#include <QString>
30#include <QWidget>
31
32class VBoxDbgGui;
33
34
35/**
36 * VBox Debugger GUI Base Class.
37 *
38 * The purpose of this class is to hide the VM handle, abstract VM
39 * operations, and finally to make sure the GUI won't crash when
40 * the VM dies.
41 */
42class VBoxDbgBase
43{
44public:
45 /**
46 * Construct the object.
47 *
48 * @param a_pDbgGui Pointer to the debugger gui object.
49 */
50 VBoxDbgBase(VBoxDbgGui *a_pDbgGui);
51
52 /**
53 * Destructor.
54 */
55 virtual ~VBoxDbgBase();
56
57
58 /**
59 * Checks if the VM is OK for normal operations.
60 * @returns true if ok, false if not.
61 */
62 bool isVMOk() const
63 {
64 return m_pUVM != NULL;
65 }
66
67 /**
68 * Checks if the current thread is the GUI thread or not.
69 * @return true/false accordingly.
70 */
71 bool isGUIThread() const
72 {
73 return m_hGUIThread == RTThreadNativeSelf();
74 }
75
76 /** @name Operations
77 * @{ */
78 /**
79 * Wrapper for STAMR3Reset().
80 */
81 int stamReset(const QString &rPat);
82 /**
83 * Wrapper for STAMR3Enum().
84 */
85 int stamEnum(const QString &rPat, PFNSTAMR3ENUM pfnEnum, void *pvUser);
86 /**
87 * Wrapper for DBGCCreate().
88 */
89 int dbgcCreate(PDBGCBACK pBack, unsigned fFlags);
90 /** @} */
91
92
93protected:
94 /** @name Signals
95 * @{ */
96 /**
97 * Called when the VM is being destroyed.
98 */
99 virtual void sigDestroying();
100 /**
101 * Called when the VM has been terminated.
102 */
103 virtual void sigTerminated();
104 /** @} */
105
106
107private:
108 /** @callback_method_impl{FNVMATSTATE} */
109 static DECLCALLBACK(void) atStateChange(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
110
111private:
112 /** Pointer to the debugger GUI object. */
113 VBoxDbgGui *m_pDbgGui;
114 /** The user mode VM handle. */
115 PUVM volatile m_pUVM;
116 /** The handle of the GUI thread. */
117 RTNATIVETHREAD m_hGUIThread;
118};
119
120
121/**
122 * VBox Debugger GUI Base Window Class.
123 *
124 * This is just a combination of QWidget and VBoxDbgBase with some additional
125 * functionality for window management. This class is not intended for control
126 * widgets, only normal top-level windows.
127 */
128class VBoxDbgBaseWindow : public QWidget, public VBoxDbgBase
129{
130public:
131 /**
132 * Construct the object.
133 *
134 * @param a_pDbgGui Pointer to the debugger gui object.
135 * @param a_pParent Pointer to the parent object.
136 */
137 VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent);
138
139 /**
140 * Destructor.
141 */
142 virtual ~VBoxDbgBaseWindow();
143
144 /**
145 * Shows the window and gives it focus.
146 */
147 void vShow();
148
149 /**
150 * Repositions the window, taking the frame decoration into account.
151 *
152 * @param a_x The new x coordinate.
153 * @param a_y The new x coordinate.
154 * @param a_cx The total width.
155 * @param a_cy The total height.
156 * @param a_fResize Whether to resize it as well.
157 */
158 void vReposition(int a_x, int a_y, unsigned a_cx, unsigned a_cy, bool a_fResize);
159
160protected:
161 /**
162 * For polishing the window size (X11 mess).
163 *
164 * @returns true / false.
165 * @param a_pEvt The event.
166 */
167 virtual bool event(QEvent *a_pEvt);
168
169 /**
170 * Internal worker for polishing the size and position (X11 hacks).
171 */
172 void vPolishSizeAndPos();
173
174 /**
175 * Internal worker that guesses the border sizes.
176 */
177 QSize vGuessBorderSizes();
178
179
180private:
181 /** Whether we've done the size polishing in showEvent or not. */
182 bool m_fPolished;
183 /** The desired x coordinate. */
184 int m_x;
185 /** The desired y coordinate. */
186 int m_y;
187 /** The desired width. */
188 unsigned m_cx;
189 /** The desired height. */
190 unsigned m_cy;
191
192 /** Best effort x border size (for X11). */
193 static unsigned m_cxBorder;
194 /** Best effort y border size (for X11). */
195 static unsigned m_cyBorder;
196};
197
198#endif /* !DEBUGGER_INCLUDED_SRC_VBoxDbgBase_h */
199
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