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