VirtualBox

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

Last change on this file since 58903 was 58903, checked in by vboxsync, 9 years ago

DBGF: I/O and MMIO breakpoint API changes.

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