VirtualBox

source: vbox/trunk/src/VBox/Debugger/VBoxDbg.cpp@ 31510

最後變更 在這個檔案從31510是 31510,由 vboxsync 提交於 14 年 前

The debugger is back in the OSE.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.7 KB
 
1/* $Id: VBoxDbg.cpp 31510 2010-08-10 08:48:11Z vboxsync $ */
2/** @file
3 * VBox Debugger GUI.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Oracle Corporation
8 *
9 * Oracle Corporation confidential
10 * All rights reserved
11 */
12
13/*******************************************************************************
14* Header Files *
15*******************************************************************************/
16#define LOG_GROUP LOG_GROUP_DBGG
17#define VBOX_COM_NO_ATL
18#include <VBox/dbggui.h>
19#include <VBox/vm.h>
20#include <VBox/err.h>
21#include <iprt/assert.h>
22#include <iprt/alloc.h>
23
24#include "VBoxDbgGui.h"
25
26
27/*******************************************************************************
28* Structures and Typedefs *
29*******************************************************************************/
30/**
31 * Debugger GUI instance data.
32 */
33typedef struct DBGGUI
34{
35 /** Magic number (DBGGUI_MAGIC). */
36 uint32_t u32Magic;
37 /** Pointer to the Debugger GUI manager object. */
38 VBoxDbgGui *pVBoxDbgGui;
39} DBGGUI;
40
41/** DBGGUI magic value (Werner Heisenberg). */
42#define DBGGUI_MAGIC 0x19011205
43/** Invalid DBGGUI magic value. */
44#define DBGGUI_MAGIC_DEAD 0x19760201
45
46
47/*******************************************************************************
48* Global Variables *
49*******************************************************************************/
50/** Virtual method table for simplifying dynamic linking. */
51static const DBGGUIVT g_dbgGuiVT =
52{
53 DBGGUIVT_VERSION,
54 DBGGuiDestroy,
55 DBGGuiAdjustRelativePos,
56 DBGGuiShowStatistics,
57 DBGGuiShowCommandLine,
58 DBGGuiSetParent,
59 DBGGuiSetMenu,
60 DBGGUIVT_VERSION
61};
62
63
64/**
65 * Internal worker for DBGGuiCreate and DBGGuiCreateForVM.
66 *
67 * @returns VBox status code.
68 * @param pSession The ISession interface. (DBGGuiCreate)
69 * @param pVM The VM handle. (DBGGuiCreateForVM)
70 * @param ppGui See DBGGuiCreate.
71 * @param ppGuiVT See DBGGuiCreate.
72 */
73static int dbgGuiCreate(ISession *pSession, PVM pVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT)
74{
75 /*
76 * Allocate and initialize the Debugger GUI handle.
77 */
78 PDBGGUI pGui = (PDBGGUI)RTMemAlloc(sizeof(*pGui));
79 if (!pGui)
80 return VERR_NO_MEMORY;
81 pGui->u32Magic = DBGGUI_MAGIC;
82 pGui->pVBoxDbgGui = new VBoxDbgGui();
83
84 int rc;
85 if (pSession)
86 rc = pGui->pVBoxDbgGui->init(pSession);
87 else
88 rc = pGui->pVBoxDbgGui->init(pVM);
89 if (RT_SUCCESS(rc))
90 {
91 /*
92 * Successfully initialized.
93 */
94 *ppGui = pGui;
95 if (ppGuiVT)
96 *ppGuiVT = &g_dbgGuiVT;
97 return rc;
98 }
99
100 /*
101 * Failed, cleanup.
102 */
103 delete pGui->pVBoxDbgGui;
104 RTMemFree(pGui);
105 *ppGui = NULL;
106 if (ppGuiVT)
107 *ppGuiVT = NULL;
108 return rc;
109}
110
111
112/**
113 * Creates the debugger GUI.
114 *
115 * @returns VBox status code.
116 * @param pSession The VirtualBox session.
117 * @param ppGui Where to store the pointer to the debugger instance.
118 * @param ppGuiVT Where to store the virtual method table pointer.
119 * Optional.
120 */
121DBGDECL(int) DBGGuiCreate(ISession *pSession, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT)
122{
123 AssertPtrReturn(pSession, VERR_INVALID_POINTER);
124 return dbgGuiCreate(pSession, NULL, ppGui, ppGuiVT);
125}
126
127
128/**
129 * Creates the debugger GUI given a VM handle.
130 *
131 * @returns VBox status code.
132 * @param pVM The VM handle.
133 * @param ppGui Where to store the pointer to the debugger instance.
134 * @param ppGuiVT Where to store the virtual method table pointer.
135 * Optional.
136 */
137DBGDECL(int) DBGGuiCreateForVM(PVM pVM, PDBGGUI *ppGui, PCDBGGUIVT *ppGuiVT)
138{
139 AssertPtrReturn(pVM, VERR_INVALID_POINTER);
140 return dbgGuiCreate(NULL, pVM, ppGui, ppGuiVT);
141}
142
143
144/**
145 * Destroys the debugger GUI.
146 *
147 * @returns VBox status code.
148 * @param pGui The instance returned by DBGGuiCreate().
149 */
150DBGDECL(int) DBGGuiDestroy(PDBGGUI pGui)
151{
152 /*
153 * Validate.
154 */
155 if (!pGui)
156 return VERR_INVALID_PARAMETER;
157 AssertMsgReturn(pGui->u32Magic == DBGGUI_MAGIC, ("u32Magic=%#x\n", pGui->u32Magic), VERR_INVALID_PARAMETER);
158
159 /*
160 * Do the job.
161 */
162 pGui->u32Magic = DBGGUI_MAGIC_DEAD;
163 delete pGui->pVBoxDbgGui;
164 RTMemFree(pGui);
165
166 return VINF_SUCCESS;
167}
168
169
170/**
171 * Notifies the debugger GUI that the console window (or whatever) has changed
172 * size or position.
173 *
174 * @param pGui The instance returned by DBGGuiCreate().
175 * @param x The x-coordinate of the window the debugger is relative to.
176 * @param y The y-coordinate of the window the debugger is relative to.
177 * @param cx The width of the window the debugger is relative to.
178 * @param cy The height of the window the debugger is relative to.
179 */
180DBGDECL(void) DBGGuiAdjustRelativePos(PDBGGUI pGui, int x, int y, unsigned cx, unsigned cy)
181{
182 AssertReturn(pGui, (void)VERR_INVALID_PARAMETER);
183 AssertMsgReturn(pGui->u32Magic == DBGGUI_MAGIC, ("u32Magic=%#x\n", pGui->u32Magic), (void)VERR_INVALID_PARAMETER);
184 pGui->pVBoxDbgGui->adjustRelativePos(x, y, cx, cy);
185}
186
187
188/**
189 * Shows the default statistics window.
190 *
191 * @returns VBox status code.
192 * @param pGui The instance returned by DBGGuiCreate().
193 */
194DBGDECL(int) DBGGuiShowStatistics(PDBGGUI pGui)
195{
196 AssertReturn(pGui, VERR_INVALID_PARAMETER);
197 AssertMsgReturn(pGui->u32Magic == DBGGUI_MAGIC, ("u32Magic=%#x\n", pGui->u32Magic), VERR_INVALID_PARAMETER);
198 return pGui->pVBoxDbgGui->showStatistics();
199}
200
201
202/**
203 * Shows the default command line window.
204 *
205 * @returns VBox status code.
206 * @param pGui The instance returned by DBGGuiCreate().
207 */
208DBGDECL(int) DBGGuiShowCommandLine(PDBGGUI pGui)
209{
210 AssertReturn(pGui, VERR_INVALID_PARAMETER);
211 AssertMsgReturn(pGui->u32Magic == DBGGUI_MAGIC, ("u32Magic=%#x\n", pGui->u32Magic), VERR_INVALID_PARAMETER);
212 return pGui->pVBoxDbgGui->showConsole();
213}
214
215
216/**
217 * Sets the parent windows.
218 *
219 * @param pGui The instance returned by DBGGuiCreate().
220 * @param pvParent Pointer to a QWidget object.
221 *
222 * @remarks This will no affect any existing windows, so call it right after
223 * creating the thing.
224 */
225DBGDECL(void) DBGGuiSetParent(PDBGGUI pGui, void *pvParent)
226{
227 return pGui->pVBoxDbgGui->setParent((QWidget *)pvParent);
228}
229
230
231/**
232 * Sets the debug menu object.
233 *
234 * @param pGui The instance returned by DBGGuiCreate().
235 * @param pvMenu Pointer to a QMenu object.
236 *
237 * @remarks Call right after creation or risk losing menu item.
238 */
239DBGDECL(void) DBGGuiSetMenu(PDBGGUI pGui, void *pvMenu)
240{
241 return pGui->pVBoxDbgGui->setMenu((QMenu *)pvMenu);
242}
243
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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