VirtualBox

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

Last change on this file since 46175 was 46167, checked in by vboxsync, 12 years ago

Buried DBGFSym.cpp and with it loadsyms - rip.

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