VirtualBox

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

Last change on this file since 30575 was 30072, checked in by vboxsync, 15 years ago

VMM: Ring-0 stack on guru meditations originating with an assertion for all 32-bit targets. The symbol resolving is ugly. Dump register context as well.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.3 KB
Line 
1/* $Id: DBGFInternal.h 30072 2010-06-07 13:54:47Z 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/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 RTINT 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 RTUINT uAlignment0;
248
249 /** The number of hardware breakpoints. */
250 RTUINT cHwBreakpoints;
251 /** The number of active breakpoints. */
252 RTUINT 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 afAlignment[2];
274
275 /** The current Guest OS digger. */
276 R3PTRTYPE(PDBGFOS) pCurOS;
277 /** The head of the Guest OS digger instances. */
278 R3PTRTYPE(PDBGFOS) pOSHead;
279} DBGF;
280/** Pointer to DBGF Data. */
281typedef DBGF *PDBGF;
282
283
284/** Converts a DBGFCPU pointer into a VM pointer. */
285#define DBGFCPU_2_VM(pDbgfCpu) ((PVM)((uint8_t *)(pDbgfCpu) + (pDbgfCpu)->offVM))
286
287/**
288 * The per CPU data for DBGF.
289 */
290typedef struct DBGFCPU
291{
292 /** The offset into the VM structure.
293 * @see DBGFCPU_2_VM(). */
294 uint32_t offVM;
295
296 /** Current active breakpoint (id).
297 * This is ~0U if not active. It is set when a execution engine
298 * encounters a breakpoint and returns VINF_EM_DBG_BREAKPOINT. This is
299 * currently not used for REM breakpoints because of the lazy coupling
300 * between VBox and REM. */
301 uint32_t iActiveBp;
302 /** Set if we're singlestepping in raw mode.
303 * This is checked and cleared in the \#DB handler. */
304 bool fSingleSteppingRaw;
305
306 /** Padding the structure to 16 bytes. */
307 uint8_t abReserved[3];
308} DBGFCPU;
309/** Pointer to DBGFCPU data. */
310typedef DBGFCPU *PDBGFCPU;
311
312
313int dbgfR3AsInit(PVM pVM);
314void dbgfR3AsTerm(PVM pVM);
315void dbgfR3AsRelocate(PVM pVM, RTGCUINTPTR offDelta);
316int dbgfR3InfoInit(PVM pVM);
317int dbgfR3InfoTerm(PVM pVM);
318void dbgfR3OSTerm(PVM pVM);
319int dbgfR3SymInit(PVM pVM);
320int dbgfR3SymTerm(PVM pVM);
321int dbgfR3BpInit(PVM pVM);
322
323
324
325#ifdef IN_RING3
326
327#endif
328
329/** @} */
330
331#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