VirtualBox

source: vbox/trunk/src/VBox/VMM/DBGFInternal.h@ 12875

Last change on this file since 12875 was 12875, checked in by vboxsync, 16 years ago

DBGF: Fix term/detach race.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.3 KB
Line 
1/* $Id: DBGFInternal.h 12875 2008-10-01 20:09:41Z vboxsync $ */
2/** @file
3 * DBGF - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ___DBGFInternal_h
23#define ___DBGFInternal_h
24
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <iprt/semaphore.h>
28#include <iprt/critsect.h>
29#include <iprt/string.h>
30#include <iprt/avl.h>
31#include <VBox/dbgf.h>
32
33
34#if !defined(IN_DBGF_R3) && !defined(IN_DBGF_R0) && !defined(IN_DBGF_GC)
35# error "Not in DBGF! This is an internal header!"
36#endif
37
38
39/** @defgroup grp_dbgf_int Internals
40 * @ingroup grp_dbgf
41 * @internal
42 * @{
43 */
44
45
46/** VMM Debugger Command. */
47typedef enum DBGFCMD
48{
49 /** No command.
50 * This is assigned to the field by the emulation thread after
51 * a command has been completed. */
52 DBGFCMD_NO_COMMAND = 0,
53 /** Halt the VM. */
54 DBGFCMD_HALT,
55 /** Resume execution. */
56 DBGFCMD_GO,
57 /** Single step execution - stepping into calls. */
58 DBGFCMD_SINGLE_STEP,
59 /** Set a breakpoint. */
60 DBGFCMD_BREAKPOINT_SET,
61 /** Set a access breakpoint. */
62 DBGFCMD_BREAKPOINT_SET_ACCESS,
63 /** Set a REM breakpoint. */
64 DBGFCMD_BREAKPOINT_SET_REM,
65 /** Clear a breakpoint. */
66 DBGFCMD_BREAKPOINT_CLEAR,
67 /** Enable a breakpoint. */
68 DBGFCMD_BREAKPOINT_ENABLE,
69 /** Disable a breakpoint. */
70 DBGFCMD_BREAKPOINT_DISABLE,
71 /** List breakpoints. */
72 DBGFCMD_BREAKPOINT_LIST,
73
74 /** Detaches the debugger.
75 * Disabling all breakpoints, watch points and the like. */
76 DBGFCMD_DETACH_DEBUGGER = 0x7ffffffe,
77 /** Detached the debugger.
78 * The isn't a command as such, it's just that it's necessary for the
79 * detaching protocol to be racefree. */
80 DBGFCMD_DETACHED_DEBUGGER = 0x7fffffff
81} DBGFCMD;
82
83/**
84 * VMM Debugger Command.
85 */
86typedef union DBGFCMDDATA
87{
88 uint32_t uDummy;
89} DBGFCMDDATA;
90/** Pointer to DBGF Command Data. */
91typedef DBGFCMDDATA *PDBGFCMDDATA;
92
93/**
94 * Info type.
95 */
96typedef enum DBGFINFOTYPE
97{
98 /** Invalid. */
99 DBGFINFOTYPE_INVALID = 0,
100 /** Device owner. */
101 DBGFINFOTYPE_DEV,
102 /** Driver owner. */
103 DBGFINFOTYPE_DRV,
104 /** Internal owner. */
105 DBGFINFOTYPE_INT,
106 /** External owner. */
107 DBGFINFOTYPE_EXT
108} DBGFINFOTYPE;
109
110
111/** Pointer to info structure. */
112typedef struct DBGFINFO *PDBGFINFO;
113
114/**
115 * Info structure.
116 */
117typedef struct DBGFINFO
118{
119 /** The flags. */
120 uint32_t fFlags;
121 /** Owner type. */
122 DBGFINFOTYPE enmType;
123 /** Per type data. */
124 union
125 {
126 /** DBGFINFOTYPE_DEV */
127 struct
128 {
129 /** Device info handler function. */
130 PFNDBGFHANDLERDEV pfnHandler;
131 /** The device instance. */
132 PPDMDEVINS pDevIns;
133 } Dev;
134
135 /** DBGFINFOTYPE_DRV */
136 struct
137 {
138 /** Driver info handler function. */
139 PFNDBGFHANDLERDRV pfnHandler;
140 /** The driver instance. */
141 PPDMDRVINS pDrvIns;
142 } Drv;
143
144 /** DBGFINFOTYPE_INT */
145 struct
146 {
147 /** Internal info handler function. */
148 PFNDBGFHANDLERINT pfnHandler;
149 } Int;
150
151 /** DBGFINFOTYPE_EXT */
152 struct
153 {
154 /** External info handler function. */
155 PFNDBGFHANDLEREXT pfnHandler;
156 /** The user argument. */
157 void *pvUser;
158 } Ext;
159 } u;
160
161 /** Pointer to the description. */
162 const char *pszDesc;
163 /** Pointer to the next info structure. */
164 PDBGFINFO pNext;
165 /** The identifier name length. */
166 size_t cchName;
167 /** The identifier name. (Extends 'beyond' the struct as usual.) */
168 char szName[1];
169} DBGFINFO;
170
171
172/**
173 * Guest OS digger instance.
174 */
175typedef struct DBGFOS
176{
177 /** Pointer to the registration record. */
178 PCDBGFOSREG pReg;
179 /** Pointer to the next OS we've registered. */
180 struct DBGFOS *pNext;
181 /** The instance data (variable size). */
182 uint8_t abData[16];
183} DBGFOS;
184/** Pointer to guest OS digger instance. */
185typedef DBGFOS *PDBGFOS;
186/** Pointer to const guest OS digger instance. */
187typedef DBGFOS const *PCDBGFOS;
188
189
190/**
191 * Converts a DBGF pointer into a VM pointer.
192 * @returns Pointer to the VM structure the CPUM is part of.
193 * @param pDBGF Pointer to DBGF instance data.
194 */
195#define DBGF2VM(pDBGF) ( (PVM)((char*)pDBGF - pDBGF->offVM) )
196
197
198/**
199 * DBGF Data (part of VM)
200 */
201typedef struct DBGF
202{
203 /** Offset to the VM structure. */
204 RTINT offVM;
205
206 /** Debugger Attached flag.
207 * Set if a debugger is attached, elsewise it's clear.
208 */
209 bool volatile fAttached;
210
211 /** Stopped in the Hypervisor.
212 * Set if we're stopped on a trace, breakpoint or assertion inside
213 * the hypervisor and have to restrict the available operations.
214 */
215 bool volatile fStoppedInHyper;
216
217 /**
218 * Ping-Pong construct where the Ping side is the VMM and the Pong side
219 * the Debugger.
220 */
221 RTPINGPONG PingPong;
222
223 /** The Event to the debugger.
224 * The VMM will ping the debugger when the event is ready. The event is
225 * either a response to a command or to a break/watch point issued
226 * previously.
227 */
228 DBGFEVENT DbgEvent;
229
230 /** The Command to the VMM.
231 * Operated in an atomic fashion since the VMM will poll on this.
232 * This means that a the command data must be written before this member
233 * is set. The VMM will reset this member to the no-command state
234 * when it have processed it.
235 */
236 DBGFCMD volatile enmVMMCmd;
237 /** The Command data.
238 * Not all commands take data. */
239 DBGFCMDDATA VMMCmdData;
240
241 /** List of registered info handlers. */
242 R3PTRTYPE(PDBGFINFO) pInfoFirst;
243 /** Critical section protecting the above list. */
244 RTCRITSECT InfoCritSect;
245
246 /** Range tree containing the loaded symbols of the a VM.
247 * This tree will never have blind spots. */
248 R3PTRTYPE(AVLRGCPTRTREE) SymbolTree;
249 /** Symbol name space. */
250 R3PTRTYPE(PRTSTRSPACE) pSymbolSpace;
251 /** Indicates whether DBGFSym.cpp is initialized or not.
252 * This part is initialized in a lazy manner for performance reasons. */
253 bool fSymInited;
254 /** Alignment padding. */
255 RTUINT uAlignment0;
256
257 /** The number of hardware breakpoints. */
258 RTUINT cHwBreakpoints;
259 /** The number of active breakpoints. */
260 RTUINT cBreakpoints;
261 /** Array of hardware breakpoints. (0..3) */
262 DBGFBP aHwBreakpoints[4];
263 /** Array of int 3 and REM breakpoints. (4..)
264 * @remark This is currently a fixed size array for reasons of simplicity. */
265 DBGFBP aBreakpoints[32];
266 /** Current active breakpoint (id).
267 * This is ~0U if not active. It is set when a execution engine
268 * encounters a breakpoint and returns VINF_EM_DBG_BREAKPOINT. This is
269 * currently not used for REM breakpoints because of the lazy coupling
270 * between VBox and REM. */
271 RTUINT iActiveBp;
272 /** Set if we're singlestepping in raw mode.
273 * This is checked and cleared in the \#DB handler. */
274 bool fSingleSteppingRaw;
275
276 /** The current Guest OS digger. */
277 R3PTRTYPE(PDBGFOS) pCurOS;
278 /** The head of the Guest OS digger instances. */
279 R3PTRTYPE(PDBGFOS) pOSHead;
280} DBGF;
281/** Pointer to DBGF Data. */
282typedef DBGF *PDBGF;
283
284
285extern int dbgfR3InfoInit(PVM pVM);
286extern int dbgfR3InfoTerm(PVM pVM);
287extern void dbgfR3OSTerm(PVM pVM);
288extern int dbgfR3SymInit(PVM pVM);
289extern int dbgfR3SymTerm(PVM pVM);
290extern int dbgfR3BpInit(PVM pVM);
291
292
293
294#ifdef IN_RING3
295
296#endif
297
298/** @} */
299
300#endif
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