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