VirtualBox

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

Last change on this file since 37738 was 37410, checked in by vboxsync, 13 years ago

VMM,SUPDrv: Created DBGFTrace.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.4 KB
Line 
1/* $Id: DBGFInternal.h 37410 2011-06-10 15:11:40Z vboxsync $ */
2/** @file
3 * DBGF - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2007 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 ___DBGFInternal_h
19#define ___DBGFInternal_h
20
21#include <VBox/cdefs.h>
22#include <VBox/types.h>
23#include <iprt/semaphore.h>
24#include <iprt/critsect.h>
25#include <iprt/string.h>
26#include <iprt/avl.h>
27#include <VBox/vmm/dbgf.h>
28
29
30
31/** @defgroup grp_dbgf_int Internals
32 * @ingroup grp_dbgf
33 * @internal
34 * @{
35 */
36
37
38/** VMM Debugger Command. */
39typedef enum DBGFCMD
40{
41 /** No command.
42 * This is assigned to the field by the emulation thread after
43 * a command has been completed. */
44 DBGFCMD_NO_COMMAND = 0,
45 /** Halt the VM. */
46 DBGFCMD_HALT,
47 /** Resume execution. */
48 DBGFCMD_GO,
49 /** Single step execution - stepping into calls. */
50 DBGFCMD_SINGLE_STEP,
51 /** Set a breakpoint. */
52 DBGFCMD_BREAKPOINT_SET,
53 /** Set a access breakpoint. */
54 DBGFCMD_BREAKPOINT_SET_ACCESS,
55 /** Set a REM breakpoint. */
56 DBGFCMD_BREAKPOINT_SET_REM,
57 /** Clear a breakpoint. */
58 DBGFCMD_BREAKPOINT_CLEAR,
59 /** Enable a breakpoint. */
60 DBGFCMD_BREAKPOINT_ENABLE,
61 /** Disable a breakpoint. */
62 DBGFCMD_BREAKPOINT_DISABLE,
63 /** List breakpoints. */
64 DBGFCMD_BREAKPOINT_LIST,
65
66 /** Detaches the debugger.
67 * Disabling all breakpoints, watch points and the like. */
68 DBGFCMD_DETACH_DEBUGGER = 0x7ffffffe,
69 /** Detached the debugger.
70 * The isn't a command as such, it's just that it's necessary for the
71 * detaching protocol to be racefree. */
72 DBGFCMD_DETACHED_DEBUGGER = 0x7fffffff
73} DBGFCMD;
74
75/**
76 * VMM Debugger Command.
77 */
78typedef union DBGFCMDDATA
79{
80 uint32_t uDummy;
81} DBGFCMDDATA;
82/** Pointer to DBGF Command Data. */
83typedef DBGFCMDDATA *PDBGFCMDDATA;
84
85/**
86 * Info type.
87 */
88typedef enum DBGFINFOTYPE
89{
90 /** Invalid. */
91 DBGFINFOTYPE_INVALID = 0,
92 /** Device owner. */
93 DBGFINFOTYPE_DEV,
94 /** Driver owner. */
95 DBGFINFOTYPE_DRV,
96 /** Internal owner. */
97 DBGFINFOTYPE_INT,
98 /** External owner. */
99 DBGFINFOTYPE_EXT
100} DBGFINFOTYPE;
101
102
103/** Pointer to info structure. */
104typedef struct DBGFINFO *PDBGFINFO;
105
106/**
107 * Info structure.
108 */
109typedef struct DBGFINFO
110{
111 /** The flags. */
112 uint32_t fFlags;
113 /** Owner type. */
114 DBGFINFOTYPE enmType;
115 /** Per type data. */
116 union
117 {
118 /** DBGFINFOTYPE_DEV */
119 struct
120 {
121 /** Device info handler function. */
122 PFNDBGFHANDLERDEV pfnHandler;
123 /** The device instance. */
124 PPDMDEVINS pDevIns;
125 } Dev;
126
127 /** DBGFINFOTYPE_DRV */
128 struct
129 {
130 /** Driver info handler function. */
131 PFNDBGFHANDLERDRV pfnHandler;
132 /** The driver instance. */
133 PPDMDRVINS pDrvIns;
134 } Drv;
135
136 /** DBGFINFOTYPE_INT */
137 struct
138 {
139 /** Internal info handler function. */
140 PFNDBGFHANDLERINT pfnHandler;
141 } Int;
142
143 /** DBGFINFOTYPE_EXT */
144 struct
145 {
146 /** External info handler function. */
147 PFNDBGFHANDLEREXT pfnHandler;
148 /** The user argument. */
149 void *pvUser;
150 } Ext;
151 } u;
152
153 /** Pointer to the description. */
154 const char *pszDesc;
155 /** Pointer to the next info structure. */
156 PDBGFINFO pNext;
157 /** The identifier name length. */
158 size_t cchName;
159 /** The identifier name. (Extends 'beyond' the struct as usual.) */
160 char szName[1];
161} DBGFINFO;
162
163
164/**
165 * Guest OS digger instance.
166 */
167typedef struct DBGFOS
168{
169 /** Pointer to the registration record. */
170 PCDBGFOSREG pReg;
171 /** Pointer to the next OS we've registered. */
172 struct DBGFOS *pNext;
173 /** The instance data (variable size). */
174 uint8_t abData[16];
175} DBGFOS;
176/** Pointer to guest OS digger instance. */
177typedef DBGFOS *PDBGFOS;
178/** Pointer to const guest OS digger instance. */
179typedef DBGFOS const *PCDBGFOS;
180
181
182/**
183 * Converts a DBGF pointer into a VM pointer.
184 * @returns Pointer to the VM structure the CPUM is part of.
185 * @param pDBGF Pointer to DBGF instance data.
186 */
187#define DBGF2VM(pDBGF) ( (PVM)((char*)pDBGF - pDBGF->offVM) )
188
189
190/**
191 * DBGF Data (part of VM)
192 */
193typedef struct DBGF
194{
195 /** Offset to the VM structure. */
196 int32_t offVM;
197
198 /** Debugger Attached flag.
199 * Set if a debugger is attached, elsewise it's clear.
200 */
201 bool volatile fAttached;
202
203 /** Stopped in the Hypervisor.
204 * Set if we're stopped on a trace, breakpoint or assertion inside
205 * the hypervisor and have to restrict the available operations.
206 */
207 bool volatile fStoppedInHyper;
208
209 /**
210 * Ping-Pong construct where the Ping side is the VMM and the Pong side
211 * the Debugger.
212 */
213 RTPINGPONG PingPong;
214
215 /** The Event to the debugger.
216 * The VMM will ping the debugger when the event is ready. The event is
217 * either a response to a command or to a break/watch point issued
218 * previously.
219 */
220 DBGFEVENT DbgEvent;
221
222 /** The Command to the VMM.
223 * Operated in an atomic fashion since the VMM will poll on this.
224 * This means that a the command data must be written before this member
225 * is set. The VMM will reset this member to the no-command state
226 * when it have processed it.
227 */
228 DBGFCMD volatile enmVMMCmd;
229 /** The Command data.
230 * Not all commands take data. */
231 DBGFCMDDATA VMMCmdData;
232
233 /** List of registered info handlers. */
234 R3PTRTYPE(PDBGFINFO) pInfoFirst;
235 /** Critical section protecting the above list. */
236 RTCRITSECT InfoCritSect;
237
238 /** Range tree containing the loaded symbols of the a VM.
239 * This tree will never have blind spots. */
240 R3PTRTYPE(AVLRGCPTRTREE) SymbolTree;
241 /** Symbol name space. */
242 R3PTRTYPE(PRTSTRSPACE) pSymbolSpace;
243 /** Indicates whether DBGFSym.cpp is initialized or not.
244 * This part is initialized in a lazy manner for performance reasons. */
245 bool fSymInited;
246 /** Alignment padding. */
247 uint32_t uAlignment0;
248
249 /** The number of hardware breakpoints. */
250 uint32_t cHwBreakpoints;
251 /** The number of active breakpoints. */
252 uint32_t cBreakpoints;
253 /** Array of hardware breakpoints. (0..3)
254 * This is shared among all the CPUs because life is much simpler that way. */
255 DBGFBP aHwBreakpoints[4];
256 /** Array of int 3 and REM breakpoints. (4..)
257 * @remark This is currently a fixed size array for reasons of simplicity. */
258 DBGFBP aBreakpoints[32];
259
260 /** The address space database lock. */
261 RTSEMRW hAsDbLock;
262 /** The address space handle database. (Protected by hAsDbLock.) */
263 R3PTRTYPE(AVLPVTREE) AsHandleTree;
264 /** The address space process id database. (Protected by hAsDbLock.) */
265 R3PTRTYPE(AVLU32TREE) AsPidTree;
266 /** The address space name database. (Protected by hAsDbLock.) */
267 R3PTRTYPE(RTSTRSPACE) AsNameSpace;
268 /** Special address space aliases. (Protected by hAsDbLock.) */
269 RTDBGAS volatile ahAsAliases[DBGF_AS_COUNT];
270 /** For lazily populating the aliased address spaces. */
271 bool volatile afAsAliasPopuplated[DBGF_AS_COUNT];
272 /** Alignment padding. */
273 bool afAlignment1[2];
274
275 /** The register database lock. */
276 RTSEMRW hRegDbLock;
277 /** String space for looking up registers. (Protected by hRegDbLock.) */
278 R3PTRTYPE(RTSTRSPACE) RegSpace;
279 /** String space holding the register sets. (Protected by hRegDbLock.) */
280 R3PTRTYPE(RTSTRSPACE) RegSetSpace;
281 /** The number of registers (aliases, sub-fields and the special CPU
282 * register aliases (eg AH) are not counted). */
283 uint32_t cRegs;
284 /** For early initialization by . */
285 bool volatile fRegDbInitialized;
286 /** Alignment padding. */
287 bool afAlignment2[3];
288
289 /** The current Guest OS digger. */
290 R3PTRTYPE(PDBGFOS) pCurOS;
291 /** The head of the Guest OS digger instances. */
292 R3PTRTYPE(PDBGFOS) pOSHead;
293} DBGF;
294/** Pointer to DBGF Data. */
295typedef DBGF *PDBGF;
296
297
298/** Converts a DBGFCPU pointer into a VM pointer. */
299#define DBGFCPU_2_VM(pDbgfCpu) ((PVM)((uint8_t *)(pDbgfCpu) + (pDbgfCpu)->offVM))
300
301/**
302 * The per CPU data for DBGF.
303 */
304typedef struct DBGFCPU
305{
306 /** The offset into the VM structure.
307 * @see DBGFCPU_2_VM(). */
308 uint32_t offVM;
309
310 /** Current active breakpoint (id).
311 * This is ~0U if not active. It is set when a execution engine
312 * encounters a breakpoint and returns VINF_EM_DBG_BREAKPOINT. This is
313 * currently not used for REM breakpoints because of the lazy coupling
314 * between VBox and REM. */
315 uint32_t iActiveBp;
316 /** Set if we're singlestepping in raw mode.
317 * This is checked and cleared in the \#DB handler. */
318 bool fSingleSteppingRaw;
319
320 /** Padding the structure to 16 bytes. */
321 bool afReserved[7];
322
323 /** The guest register set for this CPU. Can be NULL. */
324 R3PTRTYPE(struct DBGFREGSET *) pGuestRegSet;
325 /** The hypervisor register set for this CPU. Can be NULL. */
326 R3PTRTYPE(struct DBGFREGSET *) pHyperRegSet;
327} DBGFCPU;
328/** Pointer to DBGFCPU data. */
329typedef DBGFCPU *PDBGFCPU;
330
331
332int dbgfR3AsInit(PVM pVM);
333void dbgfR3AsTerm(PVM pVM);
334void dbgfR3AsRelocate(PVM pVM, RTGCUINTPTR offDelta);
335int dbgfR3BpInit(PVM pVM);
336int dbgfR3InfoInit(PVM pVM);
337int dbgfR3InfoTerm(PVM pVM);
338void dbgfR3OSTerm(PVM pVM);
339int dbgfR3RegInit(PVM pVM);
340void dbgfR3RegTerm(PVM pVM);
341int dbgfR3SymInit(PVM pVM);
342int dbgfR3SymTerm(PVM pVM);
343int dbgfR3TraceInit(PVM pVM);
344void dbgfR3TraceRelocate(PVM pVM);
345void dbgfR3TraceTerm(PVM pVM);
346
347
348
349#ifdef IN_RING3
350
351#endif
352
353/** @} */
354
355#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