1 | /* $Id: DBGFInternal.h 450 2007-01-30 23:06:24Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DBGF - Internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
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. */
|
---|
47 | typedef 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 = 0x7fffffff
|
---|
77 |
|
---|
78 | } DBGFCMD;
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * VMM Debugger Command.
|
---|
82 | */
|
---|
83 | typedef union DBGFCMDDATA
|
---|
84 | {
|
---|
85 | uint32_t uDummy;
|
---|
86 |
|
---|
87 | } DBGFCMDDATA;
|
---|
88 | /** Pointer to DBGF Command Data. */
|
---|
89 | typedef DBGFCMDDATA *PDBGFCMDDATA;
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * Info type.
|
---|
93 | */
|
---|
94 | typedef enum DBGFINFOTYPE
|
---|
95 | {
|
---|
96 | /** Invalid. */
|
---|
97 | DBGFINFOTYPE_INVALID = 0,
|
---|
98 | /** Device owner. */
|
---|
99 | DBGFINFOTYPE_DEV,
|
---|
100 | /** Driver owner. */
|
---|
101 | DBGFINFOTYPE_DRV,
|
---|
102 | /** Internal owner. */
|
---|
103 | DBGFINFOTYPE_INT,
|
---|
104 | /** External owner. */
|
---|
105 | DBGFINFOTYPE_EXT
|
---|
106 | } DBGFINFOTYPE;
|
---|
107 |
|
---|
108 |
|
---|
109 | /** Pointer to info structure. */
|
---|
110 | typedef struct DBGFINFO *PDBGFINFO;
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * Info structure.
|
---|
114 | */
|
---|
115 | typedef struct DBGFINFO
|
---|
116 | {
|
---|
117 | /** Owner type. */
|
---|
118 | DBGFINFOTYPE enmType;
|
---|
119 | /** Per type data. */
|
---|
120 | union
|
---|
121 | {
|
---|
122 | /** DBGFINFOTYPE_DEV */
|
---|
123 | struct
|
---|
124 | {
|
---|
125 | /** Device info handler function. */
|
---|
126 | PFNDBGFHANDLERDEV pfnHandler;
|
---|
127 | /** The device instance. */
|
---|
128 | PPDMDEVINS pDevIns;
|
---|
129 | } Dev;
|
---|
130 |
|
---|
131 | /** DBGFINFOTYPE_DRV */
|
---|
132 | struct
|
---|
133 | {
|
---|
134 | /** Driver info handler function. */
|
---|
135 | PFNDBGFHANDLERDRV pfnHandler;
|
---|
136 | /** The driver instance. */
|
---|
137 | PPDMDRVINS pDrvIns;
|
---|
138 | } Drv;
|
---|
139 |
|
---|
140 | /** DBGFINFOTYPE_INT */
|
---|
141 | struct
|
---|
142 | {
|
---|
143 | /** Internal info handler function. */
|
---|
144 | PFNDBGFHANDLERINT pfnHandler;
|
---|
145 | } Int;
|
---|
146 |
|
---|
147 | /** DBGFINFOTYPE_EXT */
|
---|
148 | struct
|
---|
149 | {
|
---|
150 | /** External info handler function. */
|
---|
151 | PFNDBGFHANDLEREXT pfnHandler;
|
---|
152 | /** The user argument. */
|
---|
153 | void *pvUser;
|
---|
154 | } Ext;
|
---|
155 | } u;
|
---|
156 |
|
---|
157 | /** Pointer to the description. */
|
---|
158 | const char *pszDesc;
|
---|
159 | /** Pointer to the next info structure. */
|
---|
160 | PDBGFINFO pNext;
|
---|
161 | /** The identifier name length. */
|
---|
162 | size_t cchName;
|
---|
163 | /** The identifier name. (Extends 'beyond' the struct as usual.) */
|
---|
164 | char szName[1];
|
---|
165 | } DBGFINFO;
|
---|
166 |
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * Converts a DBGF pointer into a VM pointer.
|
---|
170 | * @returns Pointer to the VM structure the CPUM is part of.
|
---|
171 | * @param pDBGF Pointer to DBGF instance data.
|
---|
172 | */
|
---|
173 | #define DBGF2VM(pDBGF) ( (PVM)((char*)pDBGF - pDBGF->offVM) )
|
---|
174 |
|
---|
175 |
|
---|
176 | /**
|
---|
177 | * DBGF Data (part of VM)
|
---|
178 | */
|
---|
179 | typedef struct DBGF
|
---|
180 | {
|
---|
181 | /** Offset to the VM structure. */
|
---|
182 | RTINT offVM;
|
---|
183 |
|
---|
184 | /** Debugger Attached flag.
|
---|
185 | * Set if a debugger is attached, elsewise it's clear.
|
---|
186 | */
|
---|
187 | volatile bool fAttached;
|
---|
188 |
|
---|
189 | /** Stopped in the Hypervisor.
|
---|
190 | * Set if we're stopped on a trace, breakpoint or assertion inside
|
---|
191 | * the hypervisor and have to restrict the available operations.
|
---|
192 | */
|
---|
193 | volatile bool fStoppedInHyper;
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * Ping-Pong construct where the Ping side is the VMM and the Pong side
|
---|
197 | * the Debugger.
|
---|
198 | */
|
---|
199 | RTPINGPONG PingPong;
|
---|
200 |
|
---|
201 | /** The Event to the debugger.
|
---|
202 | * The VMM will ping the debugger when the event is ready. The event is
|
---|
203 | * either a response to a command or to a break/watch point issued
|
---|
204 | * previously.
|
---|
205 | */
|
---|
206 | DBGFEVENT DbgEvent;
|
---|
207 |
|
---|
208 | /** The Command to the VMM.
|
---|
209 | * Operated in an atomic fashion since the VMM will poll on this.
|
---|
210 | * This means that a the command data must be written before this member
|
---|
211 | * is set. The VMM will reset this member to the no-command state
|
---|
212 | * when it have processed it.
|
---|
213 | */
|
---|
214 | volatile DBGFCMD enmVMMCmd;
|
---|
215 | /** The Command data.
|
---|
216 | * Not all commands take data. */
|
---|
217 | DBGFCMDDATA VMMCmdData;
|
---|
218 |
|
---|
219 | /** List of registered info handlers. */
|
---|
220 | HCPTRTYPE(PDBGFINFO) pInfoFirst;
|
---|
221 | /** Critical section protecting the above list. */
|
---|
222 | RTCRITSECT InfoCritSect;
|
---|
223 |
|
---|
224 | /** Range tree containing the loaded symbols of the a VM.
|
---|
225 | * This tree will never have blind spots. */
|
---|
226 | HCPTRTYPE(AVLRGCPTRTREE) SymbolTree;
|
---|
227 | /** Symbol name space. */
|
---|
228 | HCPTRTYPE(PRTSTRSPACE) pSymbolSpace;
|
---|
229 | /** Indicates whether DBGFSym.cpp is initialized or not.
|
---|
230 | * This part is initialized in a lazy manner for performance reasons. */
|
---|
231 | bool fSymInited;
|
---|
232 | /** Alignment padding. */
|
---|
233 | RTUINT uAlignment0;
|
---|
234 |
|
---|
235 | /** The number of hardware breakpoints. */
|
---|
236 | RTUINT cHwBreakpoints;
|
---|
237 | /** The number of active breakpoints. */
|
---|
238 | RTUINT cBreakpoints;
|
---|
239 | /** Array of hardware breakpoints. (0..3) */
|
---|
240 | DBGFBP aHwBreakpoints[4];
|
---|
241 | /** Array of int 3 and REM breakpoints. (4..)
|
---|
242 | * @remark This is currently a fixed size array for reasons of simplicity. */
|
---|
243 | DBGFBP aBreakpoints[32];
|
---|
244 | /** Current active breakpoint (id).
|
---|
245 | * This is ~0U if not active. It is set when a execution engine
|
---|
246 | * encounters a breakpoint and returns VINF_EM_DBG_BREAKPOINT. This is
|
---|
247 | * currently not used for REM breakpoints because of the lazy coupling
|
---|
248 | * between VBox and REM. */
|
---|
249 | RTUINT iActiveBp;
|
---|
250 | /** Set if we're singlestepping in raw mode.
|
---|
251 | * This is checked and cleared in the \#DB handler. */
|
---|
252 | bool fSingleSteppingRaw;
|
---|
253 | } DBGF;
|
---|
254 | /** Pointer to DBGF Data. */
|
---|
255 | typedef DBGF *PDBGF;
|
---|
256 |
|
---|
257 |
|
---|
258 | extern int dbgfR3InfoInit(PVM pVM);
|
---|
259 | extern int dbgfR3InfoTerm(PVM pVM);
|
---|
260 | extern int dbgfR3SymInit(PVM pVM);
|
---|
261 | extern int dbgfR3SymTerm(PVM pVM);
|
---|
262 | extern int dbgfR3BpInit(PVM pVM);
|
---|
263 |
|
---|
264 |
|
---|
265 |
|
---|
266 | #ifdef IN_RING3
|
---|
267 |
|
---|
268 | #endif
|
---|
269 |
|
---|
270 | /** @} */
|
---|
271 |
|
---|
272 | #endif
|
---|