1 | /* $Id: DBGFInternal.h 23 2007-01-15 14:08:28Z 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 |
|
---|
225 | /** Indicates whether DBGFSym.cpp is initialized or not.
|
---|
226 | * This part is initialized in a lazy manner for performance reasons. */
|
---|
227 | bool fSymInited;
|
---|
228 | /** Range tree containing the loaded symbols of the a VM.
|
---|
229 | * This tree will never have blind spots. */
|
---|
230 | AVLROGCPTRTREE SymbolTree;
|
---|
231 | /** Symbol name space. */
|
---|
232 | HCPTRTYPE(PRTSTRSPACE) pSymbolSpace;
|
---|
233 |
|
---|
234 | /** The number of hardware breakpoints. */
|
---|
235 | RTUINT cHwBreakpoints;
|
---|
236 | /** The number of active breakpoints. */
|
---|
237 | RTUINT cBreakpoints;
|
---|
238 | /** Array of hardware breakpoints. (0..3) */
|
---|
239 | DBGFBP aHwBreakpoints[4];
|
---|
240 | /** Array of int 3 and REM breakpoints. (4..)
|
---|
241 | * @remark This is currently a fixed size array for reasons of simplicity. */
|
---|
242 | DBGFBP aBreakpoints[32];
|
---|
243 | /** Current active breakpoint (id).
|
---|
244 | * This is ~0U if not active. It is set when a execution engine
|
---|
245 | * encounters a breakpoint and returns VINF_EM_DBG_BREAKPOINT. This is
|
---|
246 | * currently not used for REM breakpoints because of the lazy coupling
|
---|
247 | * between VBox and REM. */
|
---|
248 | RTUINT iActiveBp;
|
---|
249 | /** Set if we're singlestepping in raw mode.
|
---|
250 | * This is checked and cleared in the \#DB handler. */
|
---|
251 | bool fSingleSteppingRaw;
|
---|
252 | } DBGF;
|
---|
253 | /** Pointer to DBGF Data. */
|
---|
254 | typedef DBGF *PDBGF;
|
---|
255 |
|
---|
256 |
|
---|
257 | extern int dbgfR3InfoInit(PVM pVM);
|
---|
258 | extern int dbgfR3InfoTerm(PVM pVM);
|
---|
259 | extern int dbgfR3SymInit(PVM pVM);
|
---|
260 | extern int dbgfR3SymTerm(PVM pVM);
|
---|
261 | extern int dbgfR3BpInit(PVM pVM);
|
---|
262 |
|
---|
263 |
|
---|
264 |
|
---|
265 | #ifdef IN_RING3
|
---|
266 |
|
---|
267 | #endif
|
---|
268 |
|
---|
269 | /** @} */
|
---|
270 |
|
---|
271 | #endif
|
---|