1 | /** @file
|
---|
2 | * DBGF - Debugger Facility. (VMM)
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | *
|
---|
25 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
26 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
27 | * additional information or have any questions.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifndef ___VBox_dbgf_h
|
---|
31 | #define ___VBox_dbgf_h
|
---|
32 |
|
---|
33 | #include <VBox/cdefs.h>
|
---|
34 | #include <VBox/types.h>
|
---|
35 | #include <VBox/vmm.h>
|
---|
36 | #include <VBox/log.h> /* LOG_ENABLED */
|
---|
37 | #include <VBox/dbgfsel.h>
|
---|
38 |
|
---|
39 | #include <iprt/stdarg.h>
|
---|
40 | #include <iprt/dbg.h>
|
---|
41 |
|
---|
42 | RT_C_DECLS_BEGIN
|
---|
43 |
|
---|
44 |
|
---|
45 | /** @defgroup grp_dbgf The Debugger Facility API
|
---|
46 | * @{
|
---|
47 | */
|
---|
48 |
|
---|
49 | #if defined(IN_RC)|| defined(IN_RING0)
|
---|
50 | /** @addgroup grp_dbgf_rz The RZ DBGF API
|
---|
51 | * @ingroup grp_dbgf
|
---|
52 | * @{
|
---|
53 | */
|
---|
54 | VMMRZDECL(int) DBGFRZTrap01Handler(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCUINTREG uDr6);
|
---|
55 | VMMRZDECL(int) DBGFRZTrap03Handler(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
|
---|
56 | /** @} */
|
---|
57 | #endif
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * Mixed address.
|
---|
63 | */
|
---|
64 | typedef struct DBGFADDRESS
|
---|
65 | {
|
---|
66 | /** The flat address. */
|
---|
67 | RTGCUINTPTR FlatPtr;
|
---|
68 | /** The selector offset address. */
|
---|
69 | RTGCUINTPTR off;
|
---|
70 | /** The selector. DBGF_SEL_FLAT is a legal value. */
|
---|
71 | RTSEL Sel;
|
---|
72 | /** Flags describing further details about the address. */
|
---|
73 | uint16_t fFlags;
|
---|
74 | } DBGFADDRESS;
|
---|
75 | /** Pointer to a mixed address. */
|
---|
76 | typedef DBGFADDRESS *PDBGFADDRESS;
|
---|
77 | /** Pointer to a const mixed address. */
|
---|
78 | typedef const DBGFADDRESS *PCDBGFADDRESS;
|
---|
79 |
|
---|
80 | /** @name DBGFADDRESS Flags.
|
---|
81 | * @{ */
|
---|
82 | /** A 16:16 far address. */
|
---|
83 | #define DBGFADDRESS_FLAGS_FAR16 0
|
---|
84 | /** A 16:32 far address. */
|
---|
85 | #define DBGFADDRESS_FLAGS_FAR32 1
|
---|
86 | /** A 16:64 far address. */
|
---|
87 | #define DBGFADDRESS_FLAGS_FAR64 2
|
---|
88 | /** A flat address. */
|
---|
89 | #define DBGFADDRESS_FLAGS_FLAT 3
|
---|
90 | /** A physical address. */
|
---|
91 | #define DBGFADDRESS_FLAGS_PHYS 4
|
---|
92 | /** A physical address. */
|
---|
93 | #define DBGFADDRESS_FLAGS_RING0 5
|
---|
94 | /** The address type mask. */
|
---|
95 | #define DBGFADDRESS_FLAGS_TYPE_MASK 7
|
---|
96 |
|
---|
97 | /** Set if the address is valid. */
|
---|
98 | #define DBGFADDRESS_FLAGS_VALID RT_BIT(3)
|
---|
99 |
|
---|
100 | /** The address is within the hypervisor memoary area (HMA).
|
---|
101 | * If not set, the address can be assumed to be a guest address. */
|
---|
102 | #define DBGFADDRESS_FLAGS_HMA RT_BIT(4)
|
---|
103 |
|
---|
104 | /** Checks if the mixed address is flat or not. */
|
---|
105 | #define DBGFADDRESS_IS_FLAT(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_FLAT )
|
---|
106 | /** Checks if the mixed address is flat or not. */
|
---|
107 | #define DBGFADDRESS_IS_PHYS(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_PHYS )
|
---|
108 | /** Checks if the mixed address is far 16:16 or not. */
|
---|
109 | #define DBGFADDRESS_IS_FAR16(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_FAR16 )
|
---|
110 | /** Checks if the mixed address is far 16:32 or not. */
|
---|
111 | #define DBGFADDRESS_IS_FAR32(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_FAR32 )
|
---|
112 | /** Checks if the mixed address is far 16:64 or not. */
|
---|
113 | #define DBGFADDRESS_IS_FAR64(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_FAR64 )
|
---|
114 | /** Checks if the mixed address is valid. */
|
---|
115 | #define DBGFADDRESS_IS_VALID(pAddress) ( !!((pAddress)->fFlags & DBGFADDRESS_FLAGS_VALID) )
|
---|
116 | /** Checks if the address is flagged as within the HMA. */
|
---|
117 | #define DBGFADDRESS_IS_HMA(pAddress) ( !!((pAddress)->fFlags & DBGFADDRESS_FLAGS_HMA) )
|
---|
118 | /** @} */
|
---|
119 |
|
---|
120 | VMMR3DECL(int) DBGFR3AddrFromSelOff(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, RTSEL Sel, RTUINTPTR off);
|
---|
121 | VMMR3DECL(int) DBGFR3AddrFromSelInfoOff(PVM pVM, PDBGFADDRESS pAddress, PCDBGFSELINFO pSelInfo, RTUINTPTR off);
|
---|
122 | VMMR3DECL(PDBGFADDRESS) DBGFR3AddrFromFlat(PVM pVM, PDBGFADDRESS pAddress, RTGCUINTPTR FlatPtr);
|
---|
123 | VMMR3DECL(PDBGFADDRESS) DBGFR3AddrFromPhys(PVM pVM, PDBGFADDRESS pAddress, RTGCPHYS PhysAddr);
|
---|
124 | VMMR3DECL(bool) DBGFR3AddrIsValid(PVM pVM, PCDBGFADDRESS pAddress);
|
---|
125 | VMMR3DECL(int) DBGFR3AddrToPhys(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, PRTGCPHYS pGCPhys);
|
---|
126 | VMMR3DECL(int) DBGFR3AddrToHostPhys(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, PRTHCPHYS pHCPhys);
|
---|
127 | VMMR3DECL(int) DBGFR3AddrToVolatileR3Ptr(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, bool fReadOnly, void **ppvR3Ptr);
|
---|
128 | VMMR3DECL(PDBGFADDRESS) DBGFR3AddrAdd(PDBGFADDRESS pAddress, RTGCUINTPTR uAddend);
|
---|
129 | VMMR3DECL(PDBGFADDRESS) DBGFR3AddrSub(PDBGFADDRESS pAddress, RTGCUINTPTR uSubtrahend);
|
---|
130 |
|
---|
131 |
|
---|
132 |
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * VMM Debug Event Type.
|
---|
136 | */
|
---|
137 | typedef enum DBGFEVENTTYPE
|
---|
138 | {
|
---|
139 | /** Halt completed.
|
---|
140 | * This notifies that a halt command have been successfully completed.
|
---|
141 | */
|
---|
142 | DBGFEVENT_HALT_DONE = 0,
|
---|
143 | /** Detach completed.
|
---|
144 | * This notifies that the detach command have been successfully completed.
|
---|
145 | */
|
---|
146 | DBGFEVENT_DETACH_DONE,
|
---|
147 | /** The command from the debugger is not recognized.
|
---|
148 | * This means internal error or half implemented features.
|
---|
149 | */
|
---|
150 | DBGFEVENT_INVALID_COMMAND,
|
---|
151 |
|
---|
152 |
|
---|
153 | /** Fatal error.
|
---|
154 | * This notifies a fatal error in the VMM and that the debugger get's a
|
---|
155 | * chance to first hand information about the the problem.
|
---|
156 | */
|
---|
157 | DBGFEVENT_FATAL_ERROR = 100,
|
---|
158 | /** Breakpoint Hit.
|
---|
159 | * This notifies that a breakpoint installed by the debugger was hit. The
|
---|
160 | * identifier of the breakpoint can be found in the DBGFEVENT::u::Bp::iBp member.
|
---|
161 | */
|
---|
162 | DBGFEVENT_BREAKPOINT,
|
---|
163 | /** Breakpoint Hit in the Hypervisor.
|
---|
164 | * This notifies that a breakpoint installed by the debugger was hit. The
|
---|
165 | * identifier of the breakpoint can be found in the DBGFEVENT::u::Bp::iBp member.
|
---|
166 | */
|
---|
167 | DBGFEVENT_BREAKPOINT_HYPER,
|
---|
168 | /** Assertion in the Hypervisor (breakpoint instruction).
|
---|
169 | * This notifies that a breakpoint instruction was hit in the hypervisor context.
|
---|
170 | */
|
---|
171 | DBGFEVENT_ASSERTION_HYPER,
|
---|
172 | /** Single Stepped.
|
---|
173 | * This notifies that a single step operation was completed.
|
---|
174 | */
|
---|
175 | DBGFEVENT_STEPPED,
|
---|
176 | /** Single Stepped.
|
---|
177 | * This notifies that a hypervisor single step operation was completed.
|
---|
178 | */
|
---|
179 | DBGFEVENT_STEPPED_HYPER,
|
---|
180 | /** The developer have used the DBGFSTOP macro or the PDMDeviceDBGFSTOP function
|
---|
181 | * to bring up the debugger at a specific place.
|
---|
182 | */
|
---|
183 | DBGFEVENT_DEV_STOP,
|
---|
184 | /** The VM is terminating.
|
---|
185 | * When this notification is received, the debugger thread should detach ASAP.
|
---|
186 | */
|
---|
187 | DBGFEVENT_TERMINATING,
|
---|
188 |
|
---|
189 | /** The usual 32-bit hack. */
|
---|
190 | DBGFEVENT_32BIT_HACK = 0x7fffffff
|
---|
191 | } DBGFEVENTTYPE;
|
---|
192 |
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * The context of an event.
|
---|
196 | */
|
---|
197 | typedef enum DBGFEVENTCTX
|
---|
198 | {
|
---|
199 | /** The usual invalid entry. */
|
---|
200 | DBGFEVENTCTX_INVALID = 0,
|
---|
201 | /** Raw mode. */
|
---|
202 | DBGFEVENTCTX_RAW,
|
---|
203 | /** Recompiled mode. */
|
---|
204 | DBGFEVENTCTX_REM,
|
---|
205 | /** VMX / AVT mode. */
|
---|
206 | DBGFEVENTCTX_HWACCL,
|
---|
207 | /** Hypervisor context. */
|
---|
208 | DBGFEVENTCTX_HYPER,
|
---|
209 | /** Other mode */
|
---|
210 | DBGFEVENTCTX_OTHER,
|
---|
211 |
|
---|
212 | /** The usual 32-bit hack */
|
---|
213 | DBGFEVENTCTX_32BIT_HACK = 0x7fffffff
|
---|
214 | } DBGFEVENTCTX;
|
---|
215 |
|
---|
216 | /**
|
---|
217 | * VMM Debug Event.
|
---|
218 | */
|
---|
219 | typedef struct DBGFEVENT
|
---|
220 | {
|
---|
221 | /** Type. */
|
---|
222 | DBGFEVENTTYPE enmType;
|
---|
223 | /** Context */
|
---|
224 | DBGFEVENTCTX enmCtx;
|
---|
225 | /** Type specific data. */
|
---|
226 | union
|
---|
227 | {
|
---|
228 | /** Fatal error details. */
|
---|
229 | struct
|
---|
230 | {
|
---|
231 | /** The GC return code. */
|
---|
232 | int rc;
|
---|
233 | } FatalError;
|
---|
234 |
|
---|
235 | /** Source location. */
|
---|
236 | struct
|
---|
237 | {
|
---|
238 | /** File name. */
|
---|
239 | R3PTRTYPE(const char *) pszFile;
|
---|
240 | /** Function name. */
|
---|
241 | R3PTRTYPE(const char *) pszFunction;
|
---|
242 | /** Message. */
|
---|
243 | R3PTRTYPE(const char *) pszMessage;
|
---|
244 | /** Line number. */
|
---|
245 | unsigned uLine;
|
---|
246 | } Src;
|
---|
247 |
|
---|
248 | /** Assertion messages. */
|
---|
249 | struct
|
---|
250 | {
|
---|
251 | /** The first message. */
|
---|
252 | R3PTRTYPE(const char *) pszMsg1;
|
---|
253 | /** The second message. */
|
---|
254 | R3PTRTYPE(const char *) pszMsg2;
|
---|
255 | } Assert;
|
---|
256 |
|
---|
257 | /** Breakpoint. */
|
---|
258 | struct DBGFEVENTBP
|
---|
259 | {
|
---|
260 | /** The identifier of the breakpoint which was hit. */
|
---|
261 | RTUINT iBp;
|
---|
262 | } Bp;
|
---|
263 | /** Padding for ensuring that the structure is 8 byte aligned. */
|
---|
264 | uint64_t au64Padding[4];
|
---|
265 | } u;
|
---|
266 | } DBGFEVENT;
|
---|
267 | /** Pointer to VMM Debug Event. */
|
---|
268 | typedef DBGFEVENT *PDBGFEVENT;
|
---|
269 | /** Pointer to const VMM Debug Event. */
|
---|
270 | typedef const DBGFEVENT *PCDBGFEVENT;
|
---|
271 |
|
---|
272 |
|
---|
273 | /** @def DBGFSTOP
|
---|
274 | * Stops the debugger raising a DBGFEVENT_DEVELOPER_STOP event.
|
---|
275 | *
|
---|
276 | * @returns VBox status code which must be propagated up to EM if not VINF_SUCCESS.
|
---|
277 | * @param pVM VM Handle.
|
---|
278 | */
|
---|
279 | #ifdef VBOX_STRICT
|
---|
280 | # define DBGFSTOP(pVM) DBGFR3EventSrc(pVM, DBGFEVENT_DEV_STOP, __FILE__, __LINE__, __PRETTY_FUNCTION__, NULL)
|
---|
281 | #else
|
---|
282 | # define DBGFSTOP(pVM) VINF_SUCCESS
|
---|
283 | #endif
|
---|
284 |
|
---|
285 | VMMR3DECL(int) DBGFR3Init(PVM pVM);
|
---|
286 | VMMR3DECL(int) DBGFR3Term(PVM pVM);
|
---|
287 | VMMR3DECL(void) DBGFR3Relocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
288 | VMMR3DECL(int) DBGFR3VMMForcedAction(PVM pVM);
|
---|
289 | VMMR3DECL(int) DBGFR3Event(PVM pVM, DBGFEVENTTYPE enmEvent);
|
---|
290 | VMMR3DECL(int) DBGFR3EventSrc(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszFile, unsigned uLine, const char *pszFunction, const char *pszFormat, ...);
|
---|
291 | VMMR3DECL(int) DBGFR3EventSrcV(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszFile, unsigned uLine, const char *pszFunction, const char *pszFormat, va_list args);
|
---|
292 | VMMR3DECL(int) DBGFR3EventAssertion(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszMsg1, const char *pszMsg2);
|
---|
293 | VMMR3DECL(int) DBGFR3EventBreakpoint(PVM pVM, DBGFEVENTTYPE enmEvent);
|
---|
294 | VMMR3DECL(int) DBGFR3Attach(PVM pVM);
|
---|
295 | VMMR3DECL(int) DBGFR3Detach(PVM pVM);
|
---|
296 | VMMR3DECL(int) DBGFR3EventWait(PVM pVM, unsigned cMillies, PCDBGFEVENT *ppEvent);
|
---|
297 | VMMR3DECL(int) DBGFR3Halt(PVM pVM);
|
---|
298 | VMMR3DECL(bool) DBGFR3IsHalted(PVM pVM);
|
---|
299 | VMMR3DECL(bool) DBGFR3CanWait(PVM pVM);
|
---|
300 | VMMR3DECL(int) DBGFR3Resume(PVM pVM);
|
---|
301 | VMMR3DECL(int) DBGFR3Step(PVM pVM, VMCPUID idCpu);
|
---|
302 | VMMR3DECL(int) DBGFR3PrgStep(PVMCPU pVCpu);
|
---|
303 |
|
---|
304 |
|
---|
305 | /** Breakpoint type. */
|
---|
306 | typedef enum DBGFBPTYPE
|
---|
307 | {
|
---|
308 | /** Free breakpoint entry. */
|
---|
309 | DBGFBPTYPE_FREE = 0,
|
---|
310 | /** Debug register. */
|
---|
311 | DBGFBPTYPE_REG,
|
---|
312 | /** INT 3 instruction. */
|
---|
313 | DBGFBPTYPE_INT3,
|
---|
314 | /** Recompiler. */
|
---|
315 | DBGFBPTYPE_REM,
|
---|
316 | /** ensure 32-bit size. */
|
---|
317 | DBGFBPTYPE_32BIT_HACK = 0x7fffffff
|
---|
318 | } DBGFBPTYPE;
|
---|
319 |
|
---|
320 |
|
---|
321 | /**
|
---|
322 | * A Breakpoint.
|
---|
323 | */
|
---|
324 | typedef struct DBGFBP
|
---|
325 | {
|
---|
326 | /** The number of breakpoint hits. */
|
---|
327 | uint64_t cHits;
|
---|
328 | /** The hit number which starts to trigger the breakpoint. */
|
---|
329 | uint64_t iHitTrigger;
|
---|
330 | /** The hit number which stops triggering the breakpoint (disables it).
|
---|
331 | * Use ~(uint64_t)0 if it should never stop. */
|
---|
332 | uint64_t iHitDisable;
|
---|
333 | /** The Flat GC address of the breakpoint.
|
---|
334 | * (PC register value if REM type?) */
|
---|
335 | RTGCUINTPTR GCPtr;
|
---|
336 | /** The breakpoint id. */
|
---|
337 | RTUINT iBp;
|
---|
338 | /** The breakpoint status - enabled or disabled. */
|
---|
339 | bool fEnabled;
|
---|
340 |
|
---|
341 | /** The breakpoint type. */
|
---|
342 | DBGFBPTYPE enmType;
|
---|
343 |
|
---|
344 | #if GC_ARCH_BITS == 64
|
---|
345 | uint32_t u32Padding;
|
---|
346 | #endif
|
---|
347 |
|
---|
348 | /** Union of type specific data. */
|
---|
349 | union
|
---|
350 | {
|
---|
351 | /** Debug register data. */
|
---|
352 | struct DBGFBPREG
|
---|
353 | {
|
---|
354 | /** The debug register number. */
|
---|
355 | uint8_t iReg;
|
---|
356 | /** The access type (one of the X86_DR7_RW_* value). */
|
---|
357 | uint8_t fType;
|
---|
358 | /** The access size. */
|
---|
359 | uint8_t cb;
|
---|
360 | } Reg;
|
---|
361 | /** Recompiler breakpoint data. */
|
---|
362 | struct DBGFBPINT3
|
---|
363 | {
|
---|
364 | /** The byte value we replaced by the INT 3 instruction. */
|
---|
365 | uint8_t bOrg;
|
---|
366 | } Int3;
|
---|
367 |
|
---|
368 | /** Recompiler breakpoint data. */
|
---|
369 | struct DBGFBPREM
|
---|
370 | {
|
---|
371 | /** nothing yet */
|
---|
372 | uint8_t fDummy;
|
---|
373 | } Rem;
|
---|
374 | /** Paddind to ensure that the size is identical on win32 and linux. */
|
---|
375 | uint64_t u64Padding;
|
---|
376 | } u;
|
---|
377 | } DBGFBP;
|
---|
378 |
|
---|
379 | /** Pointer to a breakpoint. */
|
---|
380 | typedef DBGFBP *PDBGFBP;
|
---|
381 | /** Pointer to a const breakpoint. */
|
---|
382 | typedef const DBGFBP *PCDBGFBP;
|
---|
383 |
|
---|
384 |
|
---|
385 | VMMR3DECL(int) DBGFR3BpSet(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp);
|
---|
386 | VMMR3DECL(int) DBGFR3BpSetReg(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable,
|
---|
387 | uint8_t fType, uint8_t cb, PRTUINT piBp);
|
---|
388 | VMMR3DECL(int) DBGFR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp);
|
---|
389 | VMMR3DECL(int) DBGFR3BpClear(PVM pVM, RTUINT iBp);
|
---|
390 | VMMR3DECL(int) DBGFR3BpEnable(PVM pVM, RTUINT iBp);
|
---|
391 | VMMR3DECL(int) DBGFR3BpDisable(PVM pVM, RTUINT iBp);
|
---|
392 |
|
---|
393 | /**
|
---|
394 | * Breakpoint enumeration callback function.
|
---|
395 | *
|
---|
396 | * @returns VBox status code. Any failure will stop the enumeration.
|
---|
397 | * @param pVM The VM handle.
|
---|
398 | * @param pvUser The user argument.
|
---|
399 | * @param pBp Pointer to the breakpoint information. (readonly)
|
---|
400 | */
|
---|
401 | typedef DECLCALLBACK(int) FNDBGFBPENUM(PVM pVM, void *pvUser, PCDBGFBP pBp);
|
---|
402 | /** Pointer to a breakpoint enumeration callback function. */
|
---|
403 | typedef FNDBGFBPENUM *PFNDBGFBPENUM;
|
---|
404 |
|
---|
405 | VMMR3DECL(int) DBGFR3BpEnum(PVM pVM, PFNDBGFBPENUM pfnCallback, void *pvUser);
|
---|
406 | VMMDECL(RTGCUINTREG) DBGFBpGetDR7(PVM pVM);
|
---|
407 | VMMDECL(RTGCUINTREG) DBGFBpGetDR0(PVM pVM);
|
---|
408 | VMMDECL(RTGCUINTREG) DBGFBpGetDR1(PVM pVM);
|
---|
409 | VMMDECL(RTGCUINTREG) DBGFBpGetDR2(PVM pVM);
|
---|
410 | VMMDECL(RTGCUINTREG) DBGFBpGetDR3(PVM pVM);
|
---|
411 | VMMDECL(bool) DBGFIsStepping(PVMCPU pVCpu);
|
---|
412 |
|
---|
413 |
|
---|
414 |
|
---|
415 |
|
---|
416 | /** Pointer to a info helper callback structure. */
|
---|
417 | typedef struct DBGFINFOHLP *PDBGFINFOHLP;
|
---|
418 | /** Pointer to a const info helper callback structure. */
|
---|
419 | typedef const struct DBGFINFOHLP *PCDBGFINFOHLP;
|
---|
420 |
|
---|
421 | /**
|
---|
422 | * Info helper callback structure.
|
---|
423 | */
|
---|
424 | typedef struct DBGFINFOHLP
|
---|
425 | {
|
---|
426 | /**
|
---|
427 | * Print formatted string.
|
---|
428 | *
|
---|
429 | * @param pHlp Pointer to this structure.
|
---|
430 | * @param pszFormat The format string.
|
---|
431 | * @param ... Arguments.
|
---|
432 | */
|
---|
433 | DECLCALLBACKMEMBER(void, pfnPrintf)(PCDBGFINFOHLP pHlp, const char *pszFormat, ...);
|
---|
434 |
|
---|
435 | /**
|
---|
436 | * Print formatted string.
|
---|
437 | *
|
---|
438 | * @param pHlp Pointer to this structure.
|
---|
439 | * @param pszFormat The format string.
|
---|
440 | * @param args Argument list.
|
---|
441 | */
|
---|
442 | DECLCALLBACKMEMBER(void, pfnPrintfV)(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args);
|
---|
443 | } DBGFINFOHLP;
|
---|
444 |
|
---|
445 |
|
---|
446 | /**
|
---|
447 | * Info handler, device version.
|
---|
448 | *
|
---|
449 | * @param pDevIns Device instance which registered the info.
|
---|
450 | * @param pHlp Callback functions for doing output.
|
---|
451 | * @param pszArgs Argument string. Optional and specific to the handler.
|
---|
452 | */
|
---|
453 | typedef DECLCALLBACK(void) FNDBGFHANDLERDEV(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
|
---|
454 | /** Pointer to a FNDBGFHANDLERDEV function. */
|
---|
455 | typedef FNDBGFHANDLERDEV *PFNDBGFHANDLERDEV;
|
---|
456 |
|
---|
457 | /**
|
---|
458 | * Info handler, driver version.
|
---|
459 | *
|
---|
460 | * @param pDrvIns Driver instance which registered the info.
|
---|
461 | * @param pHlp Callback functions for doing output.
|
---|
462 | * @param pszArgs Argument string. Optional and specific to the handler.
|
---|
463 | */
|
---|
464 | typedef DECLCALLBACK(void) FNDBGFHANDLERDRV(PPDMDRVINS pDrvIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
|
---|
465 | /** Pointer to a FNDBGFHANDLERDRV function. */
|
---|
466 | typedef FNDBGFHANDLERDRV *PFNDBGFHANDLERDRV;
|
---|
467 |
|
---|
468 | /**
|
---|
469 | * Info handler, internal version.
|
---|
470 | *
|
---|
471 | * @param pVM The VM handle.
|
---|
472 | * @param pHlp Callback functions for doing output.
|
---|
473 | * @param pszArgs Argument string. Optional and specific to the handler.
|
---|
474 | */
|
---|
475 | typedef DECLCALLBACK(void) FNDBGFHANDLERINT(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
|
---|
476 | /** Pointer to a FNDBGFHANDLERINT function. */
|
---|
477 | typedef FNDBGFHANDLERINT *PFNDBGFHANDLERINT;
|
---|
478 |
|
---|
479 | /**
|
---|
480 | * Info handler, external version.
|
---|
481 | *
|
---|
482 | * @param pvUser User argument.
|
---|
483 | * @param pHlp Callback functions for doing output.
|
---|
484 | * @param pszArgs Argument string. Optional and specific to the handler.
|
---|
485 | */
|
---|
486 | typedef DECLCALLBACK(void) FNDBGFHANDLEREXT(void *pvUser, PCDBGFINFOHLP pHlp, const char *pszArgs);
|
---|
487 | /** Pointer to a FNDBGFHANDLEREXT function. */
|
---|
488 | typedef FNDBGFHANDLEREXT *PFNDBGFHANDLEREXT;
|
---|
489 |
|
---|
490 |
|
---|
491 | /** @name Flags for the info registration functions.
|
---|
492 | * @{ */
|
---|
493 | /** The handler must run on the EMT. */
|
---|
494 | #define DBGFINFO_FLAGS_RUN_ON_EMT RT_BIT(0)
|
---|
495 | /** @} */
|
---|
496 |
|
---|
497 | VMMR3DECL(int) DBGFR3InfoRegisterDevice(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler, PPDMDEVINS pDevIns);
|
---|
498 | VMMR3DECL(int) DBGFR3InfoRegisterDriver(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler, PPDMDRVINS pDrvIns);
|
---|
499 | VMMR3DECL(int) DBGFR3InfoRegisterInternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler);
|
---|
500 | VMMR3DECL(int) DBGFR3InfoRegisterInternalEx(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler, uint32_t fFlags);
|
---|
501 | VMMR3DECL(int) DBGFR3InfoRegisterExternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLEREXT pfnHandler, void *pvUser);
|
---|
502 | VMMR3DECL(int) DBGFR3InfoDeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName);
|
---|
503 | VMMR3DECL(int) DBGFR3InfoDeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName);
|
---|
504 | VMMR3DECL(int) DBGFR3InfoDeregisterInternal(PVM pVM, const char *pszName);
|
---|
505 | VMMR3DECL(int) DBGFR3InfoDeregisterExternal(PVM pVM, const char *pszName);
|
---|
506 | VMMR3DECL(int) DBGFR3Info(PVM pVM, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp);
|
---|
507 | VMMR3DECL(int) DBGFR3InfoLogRel(PVM pVM, const char *pszName, const char *pszArgs);
|
---|
508 | VMMR3DECL(int) DBGFR3InfoStdErr(PVM pVM, const char *pszName, const char *pszArgs);
|
---|
509 |
|
---|
510 | /** @def DBGFR3InfoLog
|
---|
511 | * Display a piece of info writing to the log if enabled.
|
---|
512 | *
|
---|
513 | * @param pVM VM handle.
|
---|
514 | * @param pszName The identifier of the info to display.
|
---|
515 | * @param pszArgs Arguments to the info handler.
|
---|
516 | */
|
---|
517 | #ifdef LOG_ENABLED
|
---|
518 | #define DBGFR3InfoLog(pVM, pszName, pszArgs) \
|
---|
519 | do { \
|
---|
520 | if (LogIsEnabled()) \
|
---|
521 | DBGFR3Info(pVM, pszName, pszArgs, NULL); \
|
---|
522 | } while (0)
|
---|
523 | #else
|
---|
524 | #define DBGFR3InfoLog(pVM, pszName, pszArgs) do { } while (0)
|
---|
525 | #endif
|
---|
526 |
|
---|
527 | /**
|
---|
528 | * Enumeration callback for use with DBGFR3InfoEnum.
|
---|
529 | *
|
---|
530 | * @returns VBox status code.
|
---|
531 | * A status code indicating failure will end the enumeration
|
---|
532 | * and DBGFR3InfoEnum will return with that status code.
|
---|
533 | * @param pVM VM handle.
|
---|
534 | * @param pszName Info identifier name.
|
---|
535 | * @param pszDesc The description.
|
---|
536 | */
|
---|
537 | typedef DECLCALLBACK(int) FNDBGFINFOENUM(PVM pVM, const char *pszName, const char *pszDesc, void *pvUser);
|
---|
538 | /** Pointer to a FNDBGFINFOENUM function. */
|
---|
539 | typedef FNDBGFINFOENUM *PFNDBGFINFOENUM;
|
---|
540 |
|
---|
541 | VMMR3DECL(int) DBGFR3InfoEnum(PVM pVM, PFNDBGFINFOENUM pfnCallback, void *pvUser);
|
---|
542 | VMMR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogHlp(void);
|
---|
543 | VMMR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogRelHlp(void);
|
---|
544 |
|
---|
545 |
|
---|
546 |
|
---|
547 | VMMR3DECL(int) DBGFR3LogModifyGroups(PVM pVM, const char *pszGroupSettings);
|
---|
548 | VMMR3DECL(int) DBGFR3LogModifyFlags(PVM pVM, const char *pszFlagSettings);
|
---|
549 | VMMR3DECL(int) DBGFR3LogModifyDestinations(PVM pVM, const char *pszDestSettings);
|
---|
550 |
|
---|
551 |
|
---|
552 |
|
---|
553 | /** Max length (including '\\0') of a symbol name. */
|
---|
554 | #define DBGF_SYMBOL_NAME_LENGTH 512
|
---|
555 |
|
---|
556 | /**
|
---|
557 | * Debug symbol.
|
---|
558 | */
|
---|
559 | typedef struct DBGFSYMBOL
|
---|
560 | {
|
---|
561 | /** Symbol value (address). */
|
---|
562 | RTGCUINTPTR Value;
|
---|
563 | /** Symbol size. */
|
---|
564 | uint32_t cb;
|
---|
565 | /** Symbol Flags. (reserved). */
|
---|
566 | uint32_t fFlags;
|
---|
567 | /** Symbol name. */
|
---|
568 | char szName[DBGF_SYMBOL_NAME_LENGTH];
|
---|
569 | } DBGFSYMBOL;
|
---|
570 | /** Pointer to debug symbol. */
|
---|
571 | typedef DBGFSYMBOL *PDBGFSYMBOL;
|
---|
572 | /** Pointer to const debug symbol. */
|
---|
573 | typedef const DBGFSYMBOL *PCDBGFSYMBOL;
|
---|
574 |
|
---|
575 | /**
|
---|
576 | * Debug line number information.
|
---|
577 | */
|
---|
578 | typedef struct DBGFLINE
|
---|
579 | {
|
---|
580 | /** Address. */
|
---|
581 | RTGCUINTPTR Address;
|
---|
582 | /** Line number. */
|
---|
583 | uint32_t uLineNo;
|
---|
584 | /** Filename. */
|
---|
585 | char szFilename[260];
|
---|
586 | } DBGFLINE;
|
---|
587 | /** Pointer to debug line number. */
|
---|
588 | typedef DBGFLINE *PDBGFLINE;
|
---|
589 | /** Pointer to const debug line number. */
|
---|
590 | typedef const DBGFLINE *PCDBGFLINE;
|
---|
591 |
|
---|
592 | /** @name Address spaces aliases.
|
---|
593 | * @{ */
|
---|
594 | /** The guest global address space. */
|
---|
595 | #define DBGF_AS_GLOBAL ((RTDBGAS)-1)
|
---|
596 | /** The guest kernel address space.
|
---|
597 | * This is usually resolves to the same as DBGF_AS_GLOBAL. */
|
---|
598 | #define DBGF_AS_KERNEL ((RTDBGAS)-2)
|
---|
599 | /** The physical address space. */
|
---|
600 | #define DBGF_AS_PHYS ((RTDBGAS)-3)
|
---|
601 | /** Raw-mode context. */
|
---|
602 | #define DBGF_AS_RC ((RTDBGAS)-4)
|
---|
603 | /** Ring-0 context. */
|
---|
604 | #define DBGF_AS_R0 ((RTDBGAS)-5)
|
---|
605 | /** Raw-mode context and then global guest context.
|
---|
606 | * When used for looking up information, it works as if the call was first made
|
---|
607 | * with DBGF_AS_RC and then on failure with DBGF_AS_GLOBAL. When called for
|
---|
608 | * making address space changes, it works as if DBGF_AS_RC was used. */
|
---|
609 | #define DBGF_AS_RC_AND_GC_GLOBAL ((RTDBGAS)-6)
|
---|
610 |
|
---|
611 | /** The first special one. */
|
---|
612 | #define DBGF_AS_FIRST DBGF_AS_RC_AND_GC_GLOBAL
|
---|
613 | /** The last special one. */
|
---|
614 | #define DBGF_AS_LAST DBGF_AS_GLOBAL
|
---|
615 | /** The number of special address space handles. */
|
---|
616 | #define DBGF_AS_COUNT (6U)
|
---|
617 | /** Converts an alias handle to an array index. */
|
---|
618 | #define DBGF_AS_ALIAS_2_INDEX(hAlias) \
|
---|
619 | ( (uintptr_t)(hAlias) - (uintptr_t)DBGF_AS_FIRST )
|
---|
620 | /** Predicat macro that check if the specified handle is an alias. */
|
---|
621 | #define DBGF_AS_IS_ALIAS(hAlias) \
|
---|
622 | ( DBGF_AS_ALIAS_2_INDEX(hAlias) < DBGF_AS_COUNT )
|
---|
623 | /** Predicat macro that check if the specified alias is a fixed one or not. */
|
---|
624 | #define DBGF_AS_IS_FIXED_ALIAS(hAlias) \
|
---|
625 | ( DBGF_AS_ALIAS_2_INDEX(hAlias) < (uintptr_t)DBGF_AS_PHYS - (uintptr_t)DBGF_AS_FIRST + 1U )
|
---|
626 |
|
---|
627 | /** @} */
|
---|
628 |
|
---|
629 | VMMR3DECL(int) DBGFR3AsAdd(PVM pVM, RTDBGAS hDbgAs, RTPROCESS ProcId);
|
---|
630 | VMMR3DECL(int) DBGFR3AsDelete(PVM pVM, RTDBGAS hDbgAs);
|
---|
631 | VMMR3DECL(int) DBGFR3AsSetAlias(PVM pVM, RTDBGAS hAlias, RTDBGAS hAliasFor);
|
---|
632 | VMMR3DECL(RTDBGAS) DBGFR3AsResolve(PVM pVM, RTDBGAS hAlias);
|
---|
633 | VMMR3DECL(RTDBGAS) DBGFR3AsResolveAndRetain(PVM pVM, RTDBGAS hAlias);
|
---|
634 | VMMR3DECL(RTDBGAS) DBGFR3AsQueryByName(PVM pVM, const char *pszName);
|
---|
635 | VMMR3DECL(RTDBGAS) DBGFR3AsQueryByPid(PVM pVM, RTPROCESS ProcId);
|
---|
636 |
|
---|
637 | VMMR3DECL(int) DBGFR3AsLoadImage(PVM pVM, RTDBGAS hDbgAs, const char *pszFilename, const char *pszModName, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, uint32_t fFlags);
|
---|
638 | VMMR3DECL(int) DBGFR3AsLoadMap(PVM pVM, RTDBGAS hDbgAs, const char *pszFilename, const char *pszModName, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, RTGCUINTPTR uSubtrahend, uint32_t fFlags);
|
---|
639 | VMMR3DECL(int) DBGFR3AsLinkModule(PVM pVM, RTDBGAS hDbgAs, RTDBGMOD hMod, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, uint32_t fFlags);
|
---|
640 |
|
---|
641 | VMMR3DECL(int) DBGFR3AsSymbolByAddr(PVM pVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, PRTGCINTPTR poffDisp, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
|
---|
642 | VMMR3DECL(PRTDBGSYMBOL) DBGFR3AsSymbolByAddrA(PVM pVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, PRTGCINTPTR poffDisp, PRTDBGMOD phMod);
|
---|
643 | VMMR3DECL(int) DBGFR3AsSymbolByName(PVM pVM, RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
|
---|
644 |
|
---|
645 | /* The following are soon to be obsoleted: */
|
---|
646 | VMMR3DECL(int) DBGFR3ModuleLoad(PVM pVM, const char *pszFilename, RTGCUINTPTR AddressDelta, const char *pszName, RTGCUINTPTR ModuleAddress, unsigned cbImage);
|
---|
647 | VMMR3DECL(void) DBGFR3ModuleRelocate(PVM pVM, RTGCUINTPTR OldImageBase, RTGCUINTPTR NewImageBase, RTGCUINTPTR cbImage,
|
---|
648 | const char *pszFilename, const char *pszName);
|
---|
649 | VMMR3DECL(int) DBGFR3SymbolAdd(PVM pVM, RTGCUINTPTR ModuleAddress, RTGCUINTPTR SymbolAddress, RTUINT cbSymbol, const char *pszSymbol);
|
---|
650 | VMMR3DECL(int) DBGFR3SymbolByAddr(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFSYMBOL pSymbol);
|
---|
651 | VMMR3DECL(int) DBGFR3SymbolByName(PVM pVM, const char *pszSymbol, PDBGFSYMBOL pSymbol);
|
---|
652 |
|
---|
653 | VMMR3DECL(int) DBGFR3LineByAddr(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFLINE pLine);
|
---|
654 | VMMR3DECL(PDBGFLINE) DBGFR3LineByAddrAlloc(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement);
|
---|
655 | VMMR3DECL(void) DBGFR3LineFree(PDBGFLINE pLine);
|
---|
656 |
|
---|
657 |
|
---|
658 | /**
|
---|
659 | * Return type.
|
---|
660 | */
|
---|
661 | typedef enum DBGFRETRUNTYPE
|
---|
662 | {
|
---|
663 | /** The usual invalid 0 value. */
|
---|
664 | DBGFRETURNTYPE_INVALID = 0,
|
---|
665 | /** Near 16-bit return. */
|
---|
666 | DBGFRETURNTYPE_NEAR16,
|
---|
667 | /** Near 32-bit return. */
|
---|
668 | DBGFRETURNTYPE_NEAR32,
|
---|
669 | /** Near 64-bit return. */
|
---|
670 | DBGFRETURNTYPE_NEAR64,
|
---|
671 | /** Far 16:16 return. */
|
---|
672 | DBGFRETURNTYPE_FAR16,
|
---|
673 | /** Far 16:32 return. */
|
---|
674 | DBGFRETURNTYPE_FAR32,
|
---|
675 | /** Far 16:64 return. */
|
---|
676 | DBGFRETURNTYPE_FAR64,
|
---|
677 | /** 16-bit iret return (e.g. real or 286 protect mode). */
|
---|
678 | DBGFRETURNTYPE_IRET16,
|
---|
679 | /** 32-bit iret return. */
|
---|
680 | DBGFRETURNTYPE_IRET32,
|
---|
681 | /** 32-bit iret return. */
|
---|
682 | DBGFRETURNTYPE_IRET32_PRIV,
|
---|
683 | /** 32-bit iret return to V86 mode. */
|
---|
684 | DBGFRETURNTYPE_IRET32_V86,
|
---|
685 | /** @todo 64-bit iret return. */
|
---|
686 | DBGFRETURNTYPE_IRET64,
|
---|
687 | /** The end of the valid return types. */
|
---|
688 | DBGFRETURNTYPE_END,
|
---|
689 | /** The usual 32-bit blowup. */
|
---|
690 | DBGFRETURNTYPE_32BIT_HACK = 0x7fffffff
|
---|
691 | } DBGFRETURNTYPE;
|
---|
692 |
|
---|
693 | /**
|
---|
694 | * Figures the size of the return state on the stack.
|
---|
695 | *
|
---|
696 | * @returns number of bytes. 0 if invalid parameter.
|
---|
697 | * @param enmRetType The type of return.
|
---|
698 | */
|
---|
699 | DECLINLINE(unsigned) DBGFReturnTypeSize(DBGFRETURNTYPE enmRetType)
|
---|
700 | {
|
---|
701 | switch (enmRetType)
|
---|
702 | {
|
---|
703 | case DBGFRETURNTYPE_NEAR16: return 2;
|
---|
704 | case DBGFRETURNTYPE_NEAR32: return 4;
|
---|
705 | case DBGFRETURNTYPE_NEAR64: return 8;
|
---|
706 | case DBGFRETURNTYPE_FAR16: return 4;
|
---|
707 | case DBGFRETURNTYPE_FAR32: return 4;
|
---|
708 | case DBGFRETURNTYPE_FAR64: return 8;
|
---|
709 | case DBGFRETURNTYPE_IRET16: return 6;
|
---|
710 | case DBGFRETURNTYPE_IRET32: return 4*3;
|
---|
711 | case DBGFRETURNTYPE_IRET32_PRIV: return 4*5;
|
---|
712 | case DBGFRETURNTYPE_IRET32_V86: return 4*9;
|
---|
713 | case DBGFRETURNTYPE_IRET64:
|
---|
714 | default:
|
---|
715 | return 0;
|
---|
716 | }
|
---|
717 | }
|
---|
718 |
|
---|
719 |
|
---|
720 | /** Pointer to stack frame info. */
|
---|
721 | typedef struct DBGFSTACKFRAME *PDBGFSTACKFRAME;
|
---|
722 | /** Pointer to const stack frame info. */
|
---|
723 | typedef struct DBGFSTACKFRAME const *PCDBGFSTACKFRAME;
|
---|
724 | /**
|
---|
725 | * Info about a stack frame.
|
---|
726 | */
|
---|
727 | typedef struct DBGFSTACKFRAME
|
---|
728 | {
|
---|
729 | /** Frame number. */
|
---|
730 | uint32_t iFrame;
|
---|
731 | /** Frame flags. */
|
---|
732 | uint32_t fFlags;
|
---|
733 | /** The frame address.
|
---|
734 | * The off member is [e|r]bp and the Sel member is ss. */
|
---|
735 | DBGFADDRESS AddrFrame;
|
---|
736 | /** The stack address of the frame.
|
---|
737 | * The off member is [e|r]sp and the Sel member is ss. */
|
---|
738 | DBGFADDRESS AddrStack;
|
---|
739 | /** The program counter (PC) address of the frame.
|
---|
740 | * The off member is [e|r]ip and the Sel member is cs. */
|
---|
741 | DBGFADDRESS AddrPC;
|
---|
742 | /** Pointer to the symbol nearest the program counter (PC). NULL if not found. */
|
---|
743 | PRTDBGSYMBOL pSymPC;
|
---|
744 | /** Pointer to the linnumber nearest the program counter (PC). NULL if not found. */
|
---|
745 | PDBGFLINE pLinePC;
|
---|
746 |
|
---|
747 | /** The return frame address.
|
---|
748 | * The off member is [e|r]bp and the Sel member is ss. */
|
---|
749 | DBGFADDRESS AddrReturnFrame;
|
---|
750 | /** The return stack address.
|
---|
751 | * The off member is [e|r]sp and the Sel member is ss. */
|
---|
752 | DBGFADDRESS AddrReturnStack;
|
---|
753 | /** The way this frame returns to the next one. */
|
---|
754 | DBGFRETURNTYPE enmReturnType;
|
---|
755 |
|
---|
756 | /** The program counter (PC) address which the frame returns to.
|
---|
757 | * The off member is [e|r]ip and the Sel member is cs. */
|
---|
758 | DBGFADDRESS AddrReturnPC;
|
---|
759 | /** Pointer to the symbol nearest the return PC. NULL if not found. */
|
---|
760 | PRTDBGSYMBOL pSymReturnPC;
|
---|
761 | /** Pointer to the linnumber nearest the return PC. NULL if not found. */
|
---|
762 | PDBGFLINE pLineReturnPC;
|
---|
763 |
|
---|
764 | /** 32-bytes of stack arguments. */
|
---|
765 | union
|
---|
766 | {
|
---|
767 | /** 64-bit view */
|
---|
768 | uint64_t au64[4];
|
---|
769 | /** 32-bit view */
|
---|
770 | uint32_t au32[8];
|
---|
771 | /** 16-bit view */
|
---|
772 | uint16_t au16[16];
|
---|
773 | /** 8-bit view */
|
---|
774 | uint8_t au8[32];
|
---|
775 | } Args;
|
---|
776 |
|
---|
777 | /** Pointer to the next frame.
|
---|
778 | * Might not be used in some cases, so consider it internal. */
|
---|
779 | PCDBGFSTACKFRAME pNextInternal;
|
---|
780 | /** Pointer to the first frame.
|
---|
781 | * Might not be used in some cases, so consider it internal. */
|
---|
782 | PCDBGFSTACKFRAME pFirstInternal;
|
---|
783 | } DBGFSTACKFRAME;
|
---|
784 |
|
---|
785 | /** @name DBGFSTACKFRAME Flags.
|
---|
786 | * @{ */
|
---|
787 | /** Set if the content of the frame is filled in by DBGFR3StackWalk() and can be used
|
---|
788 | * to construct the next frame. */
|
---|
789 | #define DBGFSTACKFRAME_FLAGS_ALL_VALID RT_BIT(0)
|
---|
790 | /** This is the last stack frame we can read.
|
---|
791 | * This flag is not set if the walk stop because of max dept or recursion. */
|
---|
792 | #define DBGFSTACKFRAME_FLAGS_LAST RT_BIT(1)
|
---|
793 | /** This is the last record because we detected a loop. */
|
---|
794 | #define DBGFSTACKFRAME_FLAGS_LOOP RT_BIT(2)
|
---|
795 | /** This is the last record because we reached the maximum depth. */
|
---|
796 | #define DBGFSTACKFRAME_FLAGS_MAX_DEPTH RT_BIT(3)
|
---|
797 | /** 16-bit frame. */
|
---|
798 | #define DBGFSTACKFRAME_FLAGS_16BIT RT_BIT(4)
|
---|
799 | /** 32-bit frame. */
|
---|
800 | #define DBGFSTACKFRAME_FLAGS_32BIT RT_BIT(5)
|
---|
801 | /** 64-bit frame. */
|
---|
802 | #define DBGFSTACKFRAME_FLAGS_64BIT RT_BIT(6)
|
---|
803 | /** @} */
|
---|
804 |
|
---|
805 | /** @name DBGFCODETYPE
|
---|
806 | * @{ */
|
---|
807 | typedef enum DBGFCODETYPE
|
---|
808 | {
|
---|
809 | /** The usual invalid 0 value. */
|
---|
810 | DBGFCODETYPE_INVALID = 0,
|
---|
811 | /** Stack walk for guest code. */
|
---|
812 | DBGFCODETYPE_GUEST,
|
---|
813 | /** Stack walk for hypervisor code. */
|
---|
814 | DBGFCODETYPE_HYPER,
|
---|
815 | /** Stack walk for ring 0 code. */
|
---|
816 | DBGFCODETYPE_RING0,
|
---|
817 | /** The usual 32-bit blowup. */
|
---|
818 | DBGFCODETYPE_32BIT_HACK = 0x7fffffff
|
---|
819 | } DBGFCODETYPE;
|
---|
820 | /** @} */
|
---|
821 |
|
---|
822 | VMMR3DECL(int) DBGFR3StackWalkBegin(PVM pVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType, PCDBGFSTACKFRAME *ppFirstFrame);
|
---|
823 | VMMR3DECL(int) DBGFR3StackWalkBeginEx(PVM pVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType, PCDBGFADDRESS pAddrFrame,
|
---|
824 | PCDBGFADDRESS pAddrStack,PCDBGFADDRESS pAddrPC,
|
---|
825 | DBGFRETURNTYPE enmReturnType, PCDBGFSTACKFRAME *ppFirstFrame);
|
---|
826 | VMMR3DECL(PCDBGFSTACKFRAME) DBGFR3StackWalkNext(PCDBGFSTACKFRAME pCurrent);
|
---|
827 | VMMR3DECL(void) DBGFR3StackWalkEnd(PCDBGFSTACKFRAME pFirstFrame);
|
---|
828 |
|
---|
829 |
|
---|
830 |
|
---|
831 |
|
---|
832 | /** Flags to pass to DBGFR3DisasInstrEx().
|
---|
833 | * @{ */
|
---|
834 | /** Disassemble the current guest instruction, with annotations. */
|
---|
835 | #define DBGF_DISAS_FLAGS_CURRENT_GUEST RT_BIT(0)
|
---|
836 | /** Disassemble the current hypervisor instruction, with annotations. */
|
---|
837 | #define DBGF_DISAS_FLAGS_CURRENT_HYPER RT_BIT(1)
|
---|
838 | /** No annotations for current context. */
|
---|
839 | #define DBGF_DISAS_FLAGS_NO_ANNOTATION RT_BIT(2)
|
---|
840 | /** No symbol lookup. */
|
---|
841 | #define DBGF_DISAS_FLAGS_NO_SYMBOLS RT_BIT(3)
|
---|
842 | /** No instruction bytes. */
|
---|
843 | #define DBGF_DISAS_FLAGS_NO_BYTES RT_BIT(4)
|
---|
844 | /** No address in the output. */
|
---|
845 | #define DBGF_DISAS_FLAGS_NO_ADDRESS RT_BIT(5)
|
---|
846 | /** @} */
|
---|
847 |
|
---|
848 | /** Special flat selector. */
|
---|
849 | #define DBGF_SEL_FLAT 1
|
---|
850 |
|
---|
851 | VMMR3DECL(int) DBGFR3DisasInstrEx(PVM pVM, VMCPUID idCpu, RTSEL Sel, RTGCPTR GCPtr, unsigned fFlags, char *pszOutput, uint32_t cchOutput, uint32_t *pcbInstr);
|
---|
852 | VMMR3DECL(int) DBGFR3DisasInstrCurrent(PVMCPU pVCpu, char *pszOutput, uint32_t cbOutput);
|
---|
853 | VMMR3DECL(int) DBGFR3DisasInstrCurrentLogInternal(PVMCPU pVCpu, const char *pszPrefix);
|
---|
854 |
|
---|
855 | /** @def DBGFR3DisasInstrCurrentLog
|
---|
856 | * Disassembles the current guest context instruction and writes it to the log.
|
---|
857 | * All registers and data will be displayed. Addresses will be attempted resolved to symbols.
|
---|
858 | */
|
---|
859 | #ifdef LOG_ENABLED
|
---|
860 | # define DBGFR3DisasInstrCurrentLog(pVCpu, pszPrefix) \
|
---|
861 | do { \
|
---|
862 | if (LogIsEnabled()) \
|
---|
863 | DBGFR3DisasInstrCurrentLogInternal(pVCpu, pszPrefix); \
|
---|
864 | } while (0)
|
---|
865 | #else
|
---|
866 | # define DBGFR3DisasInstrCurrentLog(pVCpu, pszPrefix) do { } while (0)
|
---|
867 | #endif
|
---|
868 |
|
---|
869 | VMMR3DECL(int) DBGFR3DisasInstrLogInternal(PVMCPU pVCpu, RTSEL Sel, RTGCPTR GCPtr);
|
---|
870 |
|
---|
871 | /** @def DBGFR3DisasInstrLog
|
---|
872 | * Disassembles the specified guest context instruction and writes it to the log.
|
---|
873 | * Addresses will be attempted resolved to symbols.
|
---|
874 | * @thread Any EMT.
|
---|
875 | */
|
---|
876 | #ifdef LOG_ENABLED
|
---|
877 | # define DBGFR3DisasInstrLog(pVCpu, Sel, GCPtr) \
|
---|
878 | do { \
|
---|
879 | if (LogIsEnabled()) \
|
---|
880 | DBGFR3DisasInstrLogInternal(pVCpu, Sel, GCPtr); \
|
---|
881 | } while (0)
|
---|
882 | #else
|
---|
883 | # define DBGFR3DisasInstrLog(pVCpu, Sel, GCPtr) do { } while (0)
|
---|
884 | #endif
|
---|
885 |
|
---|
886 |
|
---|
887 | VMMR3DECL(int) DBGFR3MemScan(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PDBGFADDRESS pHitAddress);
|
---|
888 | VMMR3DECL(int) DBGFR3MemRead(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void *pvBuf, size_t cbRead);
|
---|
889 | VMMR3DECL(int) DBGFR3MemReadString(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, char *pszBuf, size_t cbBuf);
|
---|
890 | VMMR3DECL(int) DBGFR3MemWrite(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void const *pvBuf, size_t cbRead);
|
---|
891 |
|
---|
892 |
|
---|
893 | /** @name DBGFR3SelQueryInfo flags.
|
---|
894 | * @{ */
|
---|
895 | /** Get the info from the guest descriptor table. */
|
---|
896 | #define DBGFSELQI_FLAGS_DT_GUEST UINT32_C(0)
|
---|
897 | /** Get the info from the shadow descriptor table.
|
---|
898 | * Only works in raw-mode. */
|
---|
899 | #define DBGFSELQI_FLAGS_DT_SHADOW UINT32_C(1)
|
---|
900 | /** If currently executing in in 64-bit mode, blow up data selectors. */
|
---|
901 | #define DBGFSELQI_FLAGS_DT_ADJ_64BIT_MODE UINT32_C(2)
|
---|
902 | /** @} */
|
---|
903 | VMMR3DECL(int) DBGFR3SelQueryInfo(PVM pVM, VMCPUID idCpu, RTSEL Sel, uint32_t fFlags, PDBGFSELINFO pSelInfo);
|
---|
904 |
|
---|
905 |
|
---|
906 | /**
|
---|
907 | * Guest OS digger interface identifier.
|
---|
908 | *
|
---|
909 | * This is for use together with PDBGFR3QueryInterface and is used to
|
---|
910 | * obtain access to optional interfaces.
|
---|
911 | */
|
---|
912 | typedef enum DBGFOSINTERFACE
|
---|
913 | {
|
---|
914 | /** The usual invalid entry. */
|
---|
915 | DBGFOSINTERFACE_INVALID = 0,
|
---|
916 | /** Process info. */
|
---|
917 | DBGFOSINTERFACE_PROCESS,
|
---|
918 | /** Thread info. */
|
---|
919 | DBGFOSINTERFACE_THREAD,
|
---|
920 | /** The end of the valid entries. */
|
---|
921 | DBGFOSINTERFACE_END,
|
---|
922 | /** The usual 32-bit type blowup. */
|
---|
923 | DBGFOSINTERFACE_32BIT_HACK = 0x7fffffff
|
---|
924 | } DBGFOSINTERFACE;
|
---|
925 | /** Pointer to a Guest OS digger interface identifier. */
|
---|
926 | typedef DBGFOSINTERFACE *PDBGFOSINTERFACE;
|
---|
927 | /** Pointer to a const Guest OS digger interface identifier. */
|
---|
928 | typedef DBGFOSINTERFACE const *PCDBGFOSINTERFACE;
|
---|
929 |
|
---|
930 |
|
---|
931 | /**
|
---|
932 | * Guest OS Digger Registration Record.
|
---|
933 | *
|
---|
934 | * This is used with the DBGFR3OSRegister() API.
|
---|
935 | */
|
---|
936 | typedef struct DBGFOSREG
|
---|
937 | {
|
---|
938 | /** Magic value (DBGFOSREG_MAGIC). */
|
---|
939 | uint32_t u32Magic;
|
---|
940 | /** Flags. Reserved. */
|
---|
941 | uint32_t fFlags;
|
---|
942 | /** The size of the instance data. */
|
---|
943 | uint32_t cbData;
|
---|
944 | /** Operative System name. */
|
---|
945 | char szName[24];
|
---|
946 |
|
---|
947 | /**
|
---|
948 | * Constructs the instance.
|
---|
949 | *
|
---|
950 | * @returns VBox status code.
|
---|
951 | * @param pVM Pointer to the shared VM structure.
|
---|
952 | * @param pvData Pointer to the instance data.
|
---|
953 | */
|
---|
954 | DECLCALLBACKMEMBER(int, pfnConstruct)(PVM pVM, void *pvData);
|
---|
955 |
|
---|
956 | /**
|
---|
957 | * Destroys the instance.
|
---|
958 | *
|
---|
959 | * @param pVM Pointer to the shared VM structure.
|
---|
960 | * @param pvData Pointer to the instance data.
|
---|
961 | */
|
---|
962 | DECLCALLBACKMEMBER(void, pfnDestruct)(PVM pVM, void *pvData);
|
---|
963 |
|
---|
964 | /**
|
---|
965 | * Probes the guest memory for OS finger prints.
|
---|
966 | *
|
---|
967 | * No setup or so is performed, it will be followed by a call to pfnInit
|
---|
968 | * or pfnRefresh that should take care of that.
|
---|
969 | *
|
---|
970 | * @returns true if is an OS handled by this module, otherwise false.
|
---|
971 | * @param pVM Pointer to the shared VM structure.
|
---|
972 | * @param pvData Pointer to the instance data.
|
---|
973 | */
|
---|
974 | DECLCALLBACKMEMBER(bool, pfnProbe)(PVM pVM, void *pvData);
|
---|
975 |
|
---|
976 | /**
|
---|
977 | * Initializes a fresly detected guest, loading symbols and such useful stuff.
|
---|
978 | *
|
---|
979 | * This is called after pfnProbe.
|
---|
980 | *
|
---|
981 | * @returns VBox status code.
|
---|
982 | * @param pVM Pointer to the shared VM structure.
|
---|
983 | * @param pvData Pointer to the instance data.
|
---|
984 | */
|
---|
985 | DECLCALLBACKMEMBER(int, pfnInit)(PVM pVM, void *pvData);
|
---|
986 |
|
---|
987 | /**
|
---|
988 | * Refreshes symbols and stuff following a redetection of the same OS.
|
---|
989 | *
|
---|
990 | * This is called after pfnProbe.
|
---|
991 | *
|
---|
992 | * @returns VBox status code.
|
---|
993 | * @param pVM Pointer to the shared VM structure.
|
---|
994 | * @param pvData Pointer to the instance data.
|
---|
995 | */
|
---|
996 | DECLCALLBACKMEMBER(int, pfnRefresh)(PVM pVM, void *pvData);
|
---|
997 |
|
---|
998 | /**
|
---|
999 | * Terminates an OS when a new (or none) OS has been detected,
|
---|
1000 | * and before destruction.
|
---|
1001 | *
|
---|
1002 | * This is called after pfnProbe and if needed before pfnDestruct.
|
---|
1003 | *
|
---|
1004 | * @param pVM Pointer to the shared VM structure.
|
---|
1005 | * @param pvData Pointer to the instance data.
|
---|
1006 | */
|
---|
1007 | DECLCALLBACKMEMBER(void, pfnTerm)(PVM pVM, void *pvData);
|
---|
1008 |
|
---|
1009 | /**
|
---|
1010 | * Queries the version of the running OS.
|
---|
1011 | *
|
---|
1012 | * This is only called after pfnInit().
|
---|
1013 | *
|
---|
1014 | * @returns VBox status code.
|
---|
1015 | * @param pVM Pointer to the shared VM structure.
|
---|
1016 | * @param pvData Pointer to the instance data.
|
---|
1017 | * @param pszVersion Where to store the version string.
|
---|
1018 | * @param cchVersion The size of the version string buffer.
|
---|
1019 | */
|
---|
1020 | DECLCALLBACKMEMBER(int, pfnQueryVersion)(PVM pVM, void *pvData, char *pszVersion, size_t cchVersion);
|
---|
1021 |
|
---|
1022 | /**
|
---|
1023 | * Queries the pointer to a interface.
|
---|
1024 | *
|
---|
1025 | * This is called after pfnProbe.
|
---|
1026 | *
|
---|
1027 | * @returns Pointer to the interface if available, NULL if not available.
|
---|
1028 | * @param pVM Pointer to the shared VM structure.
|
---|
1029 | * @param pvData Pointer to the instance data.
|
---|
1030 | * @param enmIf The interface identifier.
|
---|
1031 | */
|
---|
1032 | DECLCALLBACKMEMBER(void *, pfnQueryInterface)(PVM pVM, void *pvData, DBGFOSINTERFACE enmIf);
|
---|
1033 |
|
---|
1034 | /** Trailing magic (DBGFOSREG_MAGIC). */
|
---|
1035 | uint32_t u32EndMagic;
|
---|
1036 | } DBGFOSREG;
|
---|
1037 | /** Pointer to a Guest OS digger registration record. */
|
---|
1038 | typedef DBGFOSREG *PDBGFOSREG;
|
---|
1039 | /** Pointer to a const Guest OS digger registration record. */
|
---|
1040 | typedef DBGFOSREG const *PCDBGFOSREG;
|
---|
1041 |
|
---|
1042 | /** Magic value for DBGFOSREG::u32Magic and DBGFOSREG::u32EndMagic. (Hitomi Kanehara) */
|
---|
1043 | #define DBGFOSREG_MAGIC 0x19830808
|
---|
1044 |
|
---|
1045 | VMMR3DECL(int) DBGFR3OSRegister(PVM pVM, PCDBGFOSREG pReg);
|
---|
1046 | VMMR3DECL(int) DBGFR3OSDeregister(PVM pVM, PCDBGFOSREG pReg);
|
---|
1047 | VMMR3DECL(int) DBGFR3OSDetect(PVM pVM, char *pszName, size_t cchName);
|
---|
1048 | VMMR3DECL(int) DBGFR3OSQueryNameAndVersion(PVM pVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion);
|
---|
1049 | VMMR3DECL(void *) DBGFR3OSQueryInterface(PVM pVM, DBGFOSINTERFACE enmIf);
|
---|
1050 |
|
---|
1051 | /** @} */
|
---|
1052 |
|
---|
1053 |
|
---|
1054 | RT_C_DECLS_END
|
---|
1055 |
|
---|
1056 | #endif
|
---|
1057 |
|
---|