VirtualBox

source: vbox/trunk/include/VBox/vmm/dbgf.h@ 44351

Last change on this file since 44351 was 43394, checked in by vboxsync, 12 years ago

VMM: HM cleanup.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 60.6 KB
Line 
1/** @file
2 * DBGF - Debugger Facility.
3 */
4
5/*
6 * Copyright (C) 2006-2010 Oracle Corporation
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
26#ifndef ___VBox_vmm_dbgf_h
27#define ___VBox_vmm_dbgf_h
28
29#include <VBox/types.h>
30#include <VBox/log.h> /* LOG_ENABLED */
31#include <VBox/vmm/vmm.h>
32#include <VBox/vmm/dbgfsel.h>
33
34#include <iprt/stdarg.h>
35#include <iprt/dbg.h>
36
37RT_C_DECLS_BEGIN
38
39
40/** @defgroup grp_dbgf The Debugger Facility API
41 * @{
42 */
43
44#if defined(IN_RC) || defined(IN_RING0)
45/** @addgroup grp_dbgf_rz The RZ DBGF API
46 * @ingroup grp_dbgf
47 * @{
48 */
49VMMRZDECL(int) DBGFRZTrap01Handler(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCUINTREG uDr6);
50VMMRZDECL(int) DBGFRZTrap03Handler(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
51/** @} */
52#endif
53
54
55
56#ifdef IN_RING3
57
58/**
59 * Mixed address.
60 */
61typedef struct DBGFADDRESS
62{
63 /** The flat address. */
64 RTGCUINTPTR FlatPtr;
65 /** The selector offset address. */
66 RTGCUINTPTR off;
67 /** The selector. DBGF_SEL_FLAT is a legal value. */
68 RTSEL Sel;
69 /** Flags describing further details about the address. */
70 uint16_t fFlags;
71} DBGFADDRESS;
72/** Pointer to a mixed address. */
73typedef DBGFADDRESS *PDBGFADDRESS;
74/** Pointer to a const mixed address. */
75typedef const DBGFADDRESS *PCDBGFADDRESS;
76
77/** @name DBGFADDRESS Flags.
78 * @{ */
79/** A 16:16 far address. */
80#define DBGFADDRESS_FLAGS_FAR16 0
81/** A 16:32 far address. */
82#define DBGFADDRESS_FLAGS_FAR32 1
83/** A 16:64 far address. */
84#define DBGFADDRESS_FLAGS_FAR64 2
85/** A flat address. */
86#define DBGFADDRESS_FLAGS_FLAT 3
87/** A physical address. */
88#define DBGFADDRESS_FLAGS_PHYS 4
89/** A physical address. */
90#define DBGFADDRESS_FLAGS_RING0 5
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
117VMMR3DECL(int) DBGFR3AddrFromSelOff(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, RTSEL Sel, RTUINTPTR off);
118VMMR3DECL(int) DBGFR3AddrFromSelInfoOff(PVM pVM, PDBGFADDRESS pAddress, PCDBGFSELINFO pSelInfo, RTUINTPTR off);
119VMMR3DECL(PDBGFADDRESS) DBGFR3AddrFromFlat(PVM pVM, PDBGFADDRESS pAddress, RTGCUINTPTR FlatPtr);
120VMMR3DECL(PDBGFADDRESS) DBGFR3AddrFromPhys(PVM pVM, PDBGFADDRESS pAddress, RTGCPHYS PhysAddr);
121VMMR3DECL(bool) DBGFR3AddrIsValid(PVM pVM, PCDBGFADDRESS pAddress);
122VMMR3DECL(int) DBGFR3AddrToPhys(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, PRTGCPHYS pGCPhys);
123VMMR3DECL(int) DBGFR3AddrToHostPhys(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, PRTHCPHYS pHCPhys);
124VMMR3DECL(int) DBGFR3AddrToVolatileR3Ptr(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, bool fReadOnly, void **ppvR3Ptr);
125VMMR3DECL(PDBGFADDRESS) DBGFR3AddrAdd(PDBGFADDRESS pAddress, RTGCUINTPTR uAddend);
126VMMR3DECL(PDBGFADDRESS) DBGFR3AddrSub(PDBGFADDRESS pAddress, RTGCUINTPTR uSubtrahend);
127
128#endif /* IN_RING3 */
129
130
131
132/**
133 * VMM Debug Event Type.
134 */
135typedef enum DBGFEVENTTYPE
136{
137 /** Halt completed.
138 * This notifies that a halt command have been successfully completed.
139 */
140 DBGFEVENT_HALT_DONE = 0,
141 /** Detach completed.
142 * This notifies that the detach command have been successfully completed.
143 */
144 DBGFEVENT_DETACH_DONE,
145 /** The command from the debugger is not recognized.
146 * This means internal error or half implemented features.
147 */
148 DBGFEVENT_INVALID_COMMAND,
149
150
151 /** Fatal error.
152 * This notifies a fatal error in the VMM and that the debugger get's a
153 * chance to first hand information about the the problem.
154 */
155 DBGFEVENT_FATAL_ERROR = 100,
156 /** Breakpoint Hit.
157 * This notifies that a breakpoint installed by the debugger was hit. The
158 * identifier of the breakpoint can be found in the DBGFEVENT::u::Bp::iBp member.
159 */
160 DBGFEVENT_BREAKPOINT,
161 /** Breakpoint Hit in the Hypervisor.
162 * This notifies that a breakpoint installed by the debugger was hit. The
163 * identifier of the breakpoint can be found in the DBGFEVENT::u::Bp::iBp member.
164 */
165 DBGFEVENT_BREAKPOINT_HYPER,
166 /** Assertion in the Hypervisor (breakpoint instruction).
167 * This notifies that a breakpoint instruction was hit in the hypervisor context.
168 */
169 DBGFEVENT_ASSERTION_HYPER,
170 /** Single Stepped.
171 * This notifies that a single step operation was completed.
172 */
173 DBGFEVENT_STEPPED,
174 /** Single Stepped.
175 * This notifies that a hypervisor single step operation was completed.
176 */
177 DBGFEVENT_STEPPED_HYPER,
178 /** The developer have used the DBGFSTOP macro or the PDMDeviceDBGFSTOP function
179 * to bring up the debugger at a specific place.
180 */
181 DBGFEVENT_DEV_STOP,
182 /** The VM is terminating.
183 * When this notification is received, the debugger thread should detach ASAP.
184 */
185 DBGFEVENT_TERMINATING,
186
187 /** The usual 32-bit hack. */
188 DBGFEVENT_32BIT_HACK = 0x7fffffff
189} DBGFEVENTTYPE;
190
191
192/**
193 * The context of an event.
194 */
195typedef enum DBGFEVENTCTX
196{
197 /** The usual invalid entry. */
198 DBGFEVENTCTX_INVALID = 0,
199 /** Raw mode. */
200 DBGFEVENTCTX_RAW,
201 /** Recompiled mode. */
202 DBGFEVENTCTX_REM,
203 /** VMX / AVT mode. */
204 DBGFEVENTCTX_HM,
205 /** Hypervisor context. */
206 DBGFEVENTCTX_HYPER,
207 /** Other mode */
208 DBGFEVENTCTX_OTHER,
209
210 /** The usual 32-bit hack */
211 DBGFEVENTCTX_32BIT_HACK = 0x7fffffff
212} DBGFEVENTCTX;
213
214/**
215 * VMM Debug Event.
216 */
217typedef struct DBGFEVENT
218{
219 /** Type. */
220 DBGFEVENTTYPE enmType;
221 /** Context */
222 DBGFEVENTCTX enmCtx;
223 /** Type specific data. */
224 union
225 {
226 /** Fatal error details. */
227 struct
228 {
229 /** The GC return code. */
230 int rc;
231 } FatalError;
232
233 /** Source location. */
234 struct
235 {
236 /** File name. */
237 R3PTRTYPE(const char *) pszFile;
238 /** Function name. */
239 R3PTRTYPE(const char *) pszFunction;
240 /** Message. */
241 R3PTRTYPE(const char *) pszMessage;
242 /** Line number. */
243 unsigned uLine;
244 } Src;
245
246 /** Assertion messages. */
247 struct
248 {
249 /** The first message. */
250 R3PTRTYPE(const char *) pszMsg1;
251 /** The second message. */
252 R3PTRTYPE(const char *) pszMsg2;
253 } Assert;
254
255 /** Breakpoint. */
256 struct DBGFEVENTBP
257 {
258 /** The identifier of the breakpoint which was hit. */
259 RTUINT iBp;
260 } Bp;
261 /** Padding for ensuring that the structure is 8 byte aligned. */
262 uint64_t au64Padding[4];
263 } u;
264} DBGFEVENT;
265/** Pointer to VMM Debug Event. */
266typedef DBGFEVENT *PDBGFEVENT;
267/** Pointer to const VMM Debug Event. */
268typedef const DBGFEVENT *PCDBGFEVENT;
269
270#ifdef IN_RING3 /* The event API only works in ring-3. */
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
284VMMR3DECL(int) DBGFR3Init(PVM pVM);
285VMMR3DECL(int) DBGFR3Term(PVM pVM);
286VMMR3DECL(void) DBGFR3Relocate(PVM pVM, RTGCINTPTR offDelta);
287VMMR3DECL(int) DBGFR3VMMForcedAction(PVM pVM);
288VMMR3DECL(int) DBGFR3Event(PVM pVM, DBGFEVENTTYPE enmEvent);
289VMMR3DECL(int) DBGFR3EventSrc(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszFile, unsigned uLine, const char *pszFunction, const char *pszFormat, ...);
290VMMR3DECL(int) DBGFR3EventSrcV(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszFile, unsigned uLine, const char *pszFunction, const char *pszFormat, va_list args);
291VMMR3DECL(int) DBGFR3EventAssertion(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszMsg1, const char *pszMsg2);
292VMMR3DECL(int) DBGFR3EventBreakpoint(PVM pVM, DBGFEVENTTYPE enmEvent);
293VMMR3DECL(int) DBGFR3Attach(PVM pVM);
294VMMR3DECL(int) DBGFR3Detach(PVM pVM);
295VMMR3DECL(int) DBGFR3EventWait(PVM pVM, RTMSINTERVAL cMillies, PCDBGFEVENT *ppEvent);
296VMMR3DECL(int) DBGFR3Halt(PVM pVM);
297VMMR3DECL(bool) DBGFR3IsHalted(PVM pVM);
298VMMR3DECL(bool) DBGFR3CanWait(PVM pVM);
299VMMR3DECL(int) DBGFR3Resume(PVM pVM);
300VMMR3DECL(int) DBGFR3Step(PVM pVM, VMCPUID idCpu);
301VMMR3DECL(int) DBGFR3PrgStep(PVMCPU pVCpu);
302
303#endif /* IN_RING3 */
304
305
306
307/** Breakpoint type. */
308typedef enum DBGFBPTYPE
309{
310 /** Free breakpoint entry. */
311 DBGFBPTYPE_FREE = 0,
312 /** Debug register. */
313 DBGFBPTYPE_REG,
314 /** INT 3 instruction. */
315 DBGFBPTYPE_INT3,
316 /** Recompiler. */
317 DBGFBPTYPE_REM,
318 /** ensure 32-bit size. */
319 DBGFBPTYPE_32BIT_HACK = 0x7fffffff
320} DBGFBPTYPE;
321
322
323/**
324 * A Breakpoint.
325 */
326typedef struct DBGFBP
327{
328 /** The number of breakpoint hits. */
329 uint64_t cHits;
330 /** The hit number which starts to trigger the breakpoint. */
331 uint64_t iHitTrigger;
332 /** The hit number which stops triggering the breakpoint (disables it).
333 * Use ~(uint64_t)0 if it should never stop. */
334 uint64_t iHitDisable;
335 /** The Flat GC address of the breakpoint.
336 * (PC register value if REM type?) */
337 RTGCUINTPTR GCPtr;
338 /** The breakpoint id. */
339 uint32_t iBp;
340 /** The breakpoint status - enabled or disabled. */
341 bool fEnabled;
342
343 /** The breakpoint type. */
344 DBGFBPTYPE enmType;
345
346#if GC_ARCH_BITS == 64
347 uint32_t u32Padding;
348#endif
349
350 /** Union of type specific data. */
351 union
352 {
353 /** Debug register data. */
354 struct DBGFBPREG
355 {
356 /** The debug register number. */
357 uint8_t iReg;
358 /** The access type (one of the X86_DR7_RW_* value). */
359 uint8_t fType;
360 /** The access size. */
361 uint8_t cb;
362 } Reg;
363 /** Recompiler breakpoint data. */
364 struct DBGFBPINT3
365 {
366 /** The byte value we replaced by the INT 3 instruction. */
367 uint8_t bOrg;
368 } Int3;
369
370 /** Recompiler breakpoint data. */
371 struct DBGFBPREM
372 {
373 /** nothing yet */
374 uint8_t fDummy;
375 } Rem;
376 /** Paddind to ensure that the size is identical on win32 and linux. */
377 uint64_t u64Padding;
378 } u;
379} DBGFBP;
380
381/** Pointer to a breakpoint. */
382typedef DBGFBP *PDBGFBP;
383/** Pointer to a const breakpoint. */
384typedef const DBGFBP *PCDBGFBP;
385
386#ifdef IN_RING3 /* The breakpoint management API is only available in ring-3. */
387VMMR3DECL(int) DBGFR3BpSet(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
388VMMR3DECL(int) DBGFR3BpSetReg(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable,
389 uint8_t fType, uint8_t cb, uint32_t *piBp);
390VMMR3DECL(int) DBGFR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
391VMMR3DECL(int) DBGFR3BpClear(PVM pVM, uint32_t iBp);
392VMMR3DECL(int) DBGFR3BpEnable(PVM pVM, uint32_t iBp);
393VMMR3DECL(int) DBGFR3BpDisable(PVM pVM, uint32_t iBp);
394
395/**
396 * Breakpoint enumeration callback function.
397 *
398 * @returns VBox status code. Any failure will stop the enumeration.
399 * @param pVM The VM handle.
400 * @param pvUser The user argument.
401 * @param pBp Pointer to the breakpoint information. (readonly)
402 */
403typedef DECLCALLBACK(int) FNDBGFBPENUM(PVM pVM, void *pvUser, PCDBGFBP pBp);
404/** Pointer to a breakpoint enumeration callback function. */
405typedef FNDBGFBPENUM *PFNDBGFBPENUM;
406
407VMMR3DECL(int) DBGFR3BpEnum(PVM pVM, PFNDBGFBPENUM pfnCallback, void *pvUser);
408#endif /* IN_RING3 */
409
410VMMDECL(RTGCUINTREG) DBGFBpGetDR7(PVM pVM);
411VMMDECL(RTGCUINTREG) DBGFBpGetDR0(PVM pVM);
412VMMDECL(RTGCUINTREG) DBGFBpGetDR1(PVM pVM);
413VMMDECL(RTGCUINTREG) DBGFBpGetDR2(PVM pVM);
414VMMDECL(RTGCUINTREG) DBGFBpGetDR3(PVM pVM);
415VMMDECL(bool) DBGFIsStepping(PVMCPU pVCpu);
416
417
418#ifdef IN_RING3 /* The CPU mode API only works in ring-3. */
419VMMR3DECL(CPUMMODE) DBGFR3CpuGetMode(PVM pVM, VMCPUID idCpu);
420#endif
421
422
423
424#ifdef IN_RING3 /* The info callbacks API only works in ring-3. */
425
426/**
427 * Info helper callback structure.
428 */
429typedef struct DBGFINFOHLP
430{
431 /**
432 * Print formatted string.
433 *
434 * @param pHlp Pointer to this structure.
435 * @param pszFormat The format string.
436 * @param ... Arguments.
437 */
438 DECLCALLBACKMEMBER(void, pfnPrintf)(PCDBGFINFOHLP pHlp, const char *pszFormat, ...);
439
440 /**
441 * Print formatted string.
442 *
443 * @param pHlp Pointer to this structure.
444 * @param pszFormat The format string.
445 * @param args Argument list.
446 */
447 DECLCALLBACKMEMBER(void, pfnPrintfV)(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args);
448} DBGFINFOHLP;
449
450
451/**
452 * Info handler, device version.
453 *
454 * @param pDevIns The device instance which registered the info.
455 * @param pHlp Callback functions for doing output.
456 * @param pszArgs Argument string. Optional and specific to the handler.
457 */
458typedef DECLCALLBACK(void) FNDBGFHANDLERDEV(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
459/** Pointer to a FNDBGFHANDLERDEV function. */
460typedef FNDBGFHANDLERDEV *PFNDBGFHANDLERDEV;
461
462/**
463 * Info handler, USB device version.
464 *
465 * @param pUsbIns The USB device instance which registered the info.
466 * @param pHlp Callback functions for doing output.
467 * @param pszArgs Argument string. Optional and specific to the handler.
468 */
469typedef DECLCALLBACK(void) FNDBGFHANDLERUSB(PPDMUSBINS pUsbIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
470/** Pointer to a FNDBGFHANDLERUSB function. */
471typedef FNDBGFHANDLERUSB *PFNDBGFHANDLERUSB;
472
473/**
474 * Info handler, driver version.
475 *
476 * @param pDrvIns The driver instance which registered the info.
477 * @param pHlp Callback functions for doing output.
478 * @param pszArgs Argument string. Optional and specific to the handler.
479 */
480typedef DECLCALLBACK(void) FNDBGFHANDLERDRV(PPDMDRVINS pDrvIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
481/** Pointer to a FNDBGFHANDLERDRV function. */
482typedef FNDBGFHANDLERDRV *PFNDBGFHANDLERDRV;
483
484/**
485 * Info handler, internal version.
486 *
487 * @param pVM The VM handle.
488 * @param pHlp Callback functions for doing output.
489 * @param pszArgs Argument string. Optional and specific to the handler.
490 */
491typedef DECLCALLBACK(void) FNDBGFHANDLERINT(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
492/** Pointer to a FNDBGFHANDLERINT function. */
493typedef FNDBGFHANDLERINT *PFNDBGFHANDLERINT;
494
495/**
496 * Info handler, external version.
497 *
498 * @param pvUser User argument.
499 * @param pHlp Callback functions for doing output.
500 * @param pszArgs Argument string. Optional and specific to the handler.
501 */
502typedef DECLCALLBACK(void) FNDBGFHANDLEREXT(void *pvUser, PCDBGFINFOHLP pHlp, const char *pszArgs);
503/** Pointer to a FNDBGFHANDLEREXT function. */
504typedef FNDBGFHANDLEREXT *PFNDBGFHANDLEREXT;
505
506
507/** @name Flags for the info registration functions.
508 * @{ */
509/** The handler must run on the EMT. */
510#define DBGFINFO_FLAGS_RUN_ON_EMT RT_BIT(0)
511/** @} */
512
513VMMR3DECL(int) DBGFR3InfoRegisterDevice(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler, PPDMDEVINS pDevIns);
514VMMR3DECL(int) DBGFR3InfoRegisterDriver(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler, PPDMDRVINS pDrvIns);
515VMMR3DECL(int) DBGFR3InfoRegisterInternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler);
516VMMR3DECL(int) DBGFR3InfoRegisterInternalEx(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler, uint32_t fFlags);
517VMMR3DECL(int) DBGFR3InfoRegisterExternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLEREXT pfnHandler, void *pvUser);
518VMMR3DECL(int) DBGFR3InfoDeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName);
519VMMR3DECL(int) DBGFR3InfoDeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName);
520VMMR3DECL(int) DBGFR3InfoDeregisterInternal(PVM pVM, const char *pszName);
521VMMR3DECL(int) DBGFR3InfoDeregisterExternal(PVM pVM, const char *pszName);
522VMMR3DECL(int) DBGFR3Info(PVM pVM, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp);
523VMMR3DECL(int) DBGFR3InfoEx(PVM pVM, VMCPUID idCpu, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp);
524VMMR3DECL(int) DBGFR3InfoLogRel(PVM pVM, const char *pszName, const char *pszArgs);
525VMMR3DECL(int) DBGFR3InfoStdErr(PVM pVM, const char *pszName, const char *pszArgs);
526VMMR3DECL(int) DBGFR3InfoMulti(PVM pVM, const char *pszIncludePat, const char *pszExcludePat,
527 const char *pszSepFmt, PCDBGFINFOHLP pHlp);
528
529/** @def DBGFR3InfoLog
530 * Display a piece of info writing to the log if enabled.
531 *
532 * @param pVM VM handle.
533 * @param pszName The identifier of the info to display.
534 * @param pszArgs Arguments to the info handler.
535 */
536#ifdef LOG_ENABLED
537#define DBGFR3InfoLog(pVM, pszName, pszArgs) \
538 do { \
539 if (LogIsEnabled()) \
540 DBGFR3Info(pVM, pszName, pszArgs, NULL); \
541 } while (0)
542#else
543#define DBGFR3InfoLog(pVM, pszName, pszArgs) do { } while (0)
544#endif
545
546/**
547 * Enumeration callback for use with DBGFR3InfoEnum.
548 *
549 * @returns VBox status code.
550 * A status code indicating failure will end the enumeration
551 * and DBGFR3InfoEnum will return with that status code.
552 * @param pVM VM handle.
553 * @param pszName Info identifier name.
554 * @param pszDesc The description.
555 */
556typedef DECLCALLBACK(int) FNDBGFINFOENUM(PVM pVM, const char *pszName, const char *pszDesc, void *pvUser);
557/** Pointer to a FNDBGFINFOENUM function. */
558typedef FNDBGFINFOENUM *PFNDBGFINFOENUM;
559
560VMMR3DECL(int) DBGFR3InfoEnum(PVM pVM, PFNDBGFINFOENUM pfnCallback, void *pvUser);
561VMMR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogHlp(void);
562VMMR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogRelHlp(void);
563
564#endif /* IN_RING3 */
565
566
567#ifdef IN_RING3 /* The log contrl API only works in ring-3. */
568VMMR3DECL(int) DBGFR3LogModifyGroups(PVM pVM, const char *pszGroupSettings);
569VMMR3DECL(int) DBGFR3LogModifyFlags(PVM pVM, const char *pszFlagSettings);
570VMMR3DECL(int) DBGFR3LogModifyDestinations(PVM pVM, const char *pszDestSettings);
571#endif /* IN_RING3 */
572
573#ifdef IN_RING3 /* The debug information management APIs only works in ring-3. */
574
575/** Max length (including '\\0') of a symbol name. */
576#define DBGF_SYMBOL_NAME_LENGTH 512
577
578/**
579 * Debug symbol.
580 */
581typedef struct DBGFSYMBOL
582{
583 /** Symbol value (address). */
584 RTGCUINTPTR Value;
585 /** Symbol size. */
586 uint32_t cb;
587 /** Symbol Flags. (reserved). */
588 uint32_t fFlags;
589 /** Symbol name. */
590 char szName[DBGF_SYMBOL_NAME_LENGTH];
591} DBGFSYMBOL;
592/** Pointer to debug symbol. */
593typedef DBGFSYMBOL *PDBGFSYMBOL;
594/** Pointer to const debug symbol. */
595typedef const DBGFSYMBOL *PCDBGFSYMBOL;
596
597/**
598 * Debug line number information.
599 */
600typedef struct DBGFLINE
601{
602 /** Address. */
603 RTGCUINTPTR Address;
604 /** Line number. */
605 uint32_t uLineNo;
606 /** Filename. */
607 char szFilename[260];
608} DBGFLINE;
609/** Pointer to debug line number. */
610typedef DBGFLINE *PDBGFLINE;
611/** Pointer to const debug line number. */
612typedef const DBGFLINE *PCDBGFLINE;
613
614/** @name Address spaces aliases.
615 * @{ */
616/** The guest global address space. */
617#define DBGF_AS_GLOBAL ((RTDBGAS)-1)
618/** The guest kernel address space.
619 * This is usually resolves to the same as DBGF_AS_GLOBAL. */
620#define DBGF_AS_KERNEL ((RTDBGAS)-2)
621/** The physical address space. */
622#define DBGF_AS_PHYS ((RTDBGAS)-3)
623/** Raw-mode context. */
624#define DBGF_AS_RC ((RTDBGAS)-4)
625/** Ring-0 context. */
626#define DBGF_AS_R0 ((RTDBGAS)-5)
627/** Raw-mode context and then global guest context.
628 * When used for looking up information, it works as if the call was first made
629 * with DBGF_AS_RC and then on failure with DBGF_AS_GLOBAL. When called for
630 * making address space changes, it works as if DBGF_AS_RC was used. */
631#define DBGF_AS_RC_AND_GC_GLOBAL ((RTDBGAS)-6)
632
633/** The first special one. */
634#define DBGF_AS_FIRST DBGF_AS_RC_AND_GC_GLOBAL
635/** The last special one. */
636#define DBGF_AS_LAST DBGF_AS_GLOBAL
637#endif
638/** The number of special address space handles. */
639#define DBGF_AS_COUNT (6U)
640#ifdef IN_RING3
641/** Converts an alias handle to an array index. */
642#define DBGF_AS_ALIAS_2_INDEX(hAlias) \
643 ( (uintptr_t)(hAlias) - (uintptr_t)DBGF_AS_FIRST )
644/** Predicat macro that check if the specified handle is an alias. */
645#define DBGF_AS_IS_ALIAS(hAlias) \
646 ( DBGF_AS_ALIAS_2_INDEX(hAlias) < DBGF_AS_COUNT )
647/** Predicat macro that check if the specified alias is a fixed one or not. */
648#define DBGF_AS_IS_FIXED_ALIAS(hAlias) \
649 ( DBGF_AS_ALIAS_2_INDEX(hAlias) < (uintptr_t)DBGF_AS_PHYS - (uintptr_t)DBGF_AS_FIRST + 1U )
650
651/** @} */
652
653VMMR3DECL(int) DBGFR3AsAdd(PVM pVM, RTDBGAS hDbgAs, RTPROCESS ProcId);
654VMMR3DECL(int) DBGFR3AsDelete(PVM pVM, RTDBGAS hDbgAs);
655VMMR3DECL(int) DBGFR3AsSetAlias(PVM pVM, RTDBGAS hAlias, RTDBGAS hAliasFor);
656VMMR3DECL(RTDBGAS) DBGFR3AsResolve(PVM pVM, RTDBGAS hAlias);
657VMMR3DECL(RTDBGAS) DBGFR3AsResolveAndRetain(PVM pVM, RTDBGAS hAlias);
658VMMR3DECL(RTDBGAS) DBGFR3AsQueryByName(PVM pVM, const char *pszName);
659VMMR3DECL(RTDBGAS) DBGFR3AsQueryByPid(PVM pVM, RTPROCESS ProcId);
660
661VMMR3DECL(int) DBGFR3AsLoadImage(PVM pVM, RTDBGAS hDbgAs, const char *pszFilename, const char *pszModName, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, uint32_t fFlags);
662VMMR3DECL(int) DBGFR3AsLoadMap(PVM pVM, RTDBGAS hDbgAs, const char *pszFilename, const char *pszModName, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, RTGCUINTPTR uSubtrahend, uint32_t fFlags);
663VMMR3DECL(int) DBGFR3AsLinkModule(PVM pVM, RTDBGAS hDbgAs, RTDBGMOD hMod, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, uint32_t fFlags);
664
665VMMR3DECL(int) DBGFR3AsSymbolByAddr(PVM pVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, PRTGCINTPTR poffDisp, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
666VMMR3DECL(PRTDBGSYMBOL) DBGFR3AsSymbolByAddrA(PVM pVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, PRTGCINTPTR poffDisp, PRTDBGMOD phMod);
667VMMR3DECL(int) DBGFR3AsSymbolByName(PVM pVM, RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
668
669/* The following are soon to be obsoleted: */
670VMMR3DECL(int) DBGFR3ModuleLoad(PVM pVM, const char *pszFilename, RTGCUINTPTR AddressDelta, const char *pszName, RTGCUINTPTR ModuleAddress, unsigned cbImage);
671VMMR3DECL(void) DBGFR3ModuleRelocate(PVM pVM, RTGCUINTPTR OldImageBase, RTGCUINTPTR NewImageBase, RTGCUINTPTR cbImage,
672 const char *pszFilename, const char *pszName);
673VMMR3DECL(int) DBGFR3SymbolAdd(PVM pVM, RTGCUINTPTR ModuleAddress, RTGCUINTPTR SymbolAddress, RTUINT cbSymbol, const char *pszSymbol);
674VMMR3DECL(int) DBGFR3SymbolByAddr(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFSYMBOL pSymbol);
675VMMR3DECL(int) DBGFR3SymbolByName(PVM pVM, const char *pszSymbol, PDBGFSYMBOL pSymbol);
676
677VMMR3DECL(int) DBGFR3LineByAddr(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFLINE pLine);
678VMMR3DECL(PDBGFLINE) DBGFR3LineByAddrAlloc(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement);
679VMMR3DECL(void) DBGFR3LineFree(PDBGFLINE pLine);
680
681#endif /* IN_RING3 */
682
683#ifdef IN_RING3 /* The stack API only works in ring-3. */
684
685/**
686 * Return type.
687 */
688typedef enum DBGFRETRUNTYPE
689{
690 /** The usual invalid 0 value. */
691 DBGFRETURNTYPE_INVALID = 0,
692 /** Near 16-bit return. */
693 DBGFRETURNTYPE_NEAR16,
694 /** Near 32-bit return. */
695 DBGFRETURNTYPE_NEAR32,
696 /** Near 64-bit return. */
697 DBGFRETURNTYPE_NEAR64,
698 /** Far 16:16 return. */
699 DBGFRETURNTYPE_FAR16,
700 /** Far 16:32 return. */
701 DBGFRETURNTYPE_FAR32,
702 /** Far 16:64 return. */
703 DBGFRETURNTYPE_FAR64,
704 /** 16-bit iret return (e.g. real or 286 protect mode). */
705 DBGFRETURNTYPE_IRET16,
706 /** 32-bit iret return. */
707 DBGFRETURNTYPE_IRET32,
708 /** 32-bit iret return. */
709 DBGFRETURNTYPE_IRET32_PRIV,
710 /** 32-bit iret return to V86 mode. */
711 DBGFRETURNTYPE_IRET32_V86,
712 /** @todo 64-bit iret return. */
713 DBGFRETURNTYPE_IRET64,
714 /** The end of the valid return types. */
715 DBGFRETURNTYPE_END,
716 /** The usual 32-bit blowup. */
717 DBGFRETURNTYPE_32BIT_HACK = 0x7fffffff
718} DBGFRETURNTYPE;
719
720/**
721 * Figures the size of the return state on the stack.
722 *
723 * @returns number of bytes. 0 if invalid parameter.
724 * @param enmRetType The type of return.
725 */
726DECLINLINE(unsigned) DBGFReturnTypeSize(DBGFRETURNTYPE enmRetType)
727{
728 switch (enmRetType)
729 {
730 case DBGFRETURNTYPE_NEAR16: return 2;
731 case DBGFRETURNTYPE_NEAR32: return 4;
732 case DBGFRETURNTYPE_NEAR64: return 8;
733 case DBGFRETURNTYPE_FAR16: return 4;
734 case DBGFRETURNTYPE_FAR32: return 4;
735 case DBGFRETURNTYPE_FAR64: return 8;
736 case DBGFRETURNTYPE_IRET16: return 6;
737 case DBGFRETURNTYPE_IRET32: return 4*3;
738 case DBGFRETURNTYPE_IRET32_PRIV: return 4*5;
739 case DBGFRETURNTYPE_IRET32_V86: return 4*9;
740 case DBGFRETURNTYPE_IRET64:
741 default:
742 return 0;
743 }
744}
745
746
747/** Pointer to stack frame info. */
748typedef struct DBGFSTACKFRAME *PDBGFSTACKFRAME;
749/** Pointer to const stack frame info. */
750typedef struct DBGFSTACKFRAME const *PCDBGFSTACKFRAME;
751/**
752 * Info about a stack frame.
753 */
754typedef struct DBGFSTACKFRAME
755{
756 /** Frame number. */
757 uint32_t iFrame;
758 /** Frame flags. */
759 uint32_t fFlags;
760 /** The frame address.
761 * The off member is [e|r]bp and the Sel member is ss. */
762 DBGFADDRESS AddrFrame;
763 /** The stack address of the frame.
764 * The off member is [e|r]sp and the Sel member is ss. */
765 DBGFADDRESS AddrStack;
766 /** The program counter (PC) address of the frame.
767 * The off member is [e|r]ip and the Sel member is cs. */
768 DBGFADDRESS AddrPC;
769 /** Pointer to the symbol nearest the program counter (PC). NULL if not found. */
770 PRTDBGSYMBOL pSymPC;
771 /** Pointer to the linnumber nearest the program counter (PC). NULL if not found. */
772 PDBGFLINE pLinePC;
773
774 /** The return frame address.
775 * The off member is [e|r]bp and the Sel member is ss. */
776 DBGFADDRESS AddrReturnFrame;
777 /** The return stack address.
778 * The off member is [e|r]sp and the Sel member is ss. */
779 DBGFADDRESS AddrReturnStack;
780 /** The way this frame returns to the next one. */
781 DBGFRETURNTYPE enmReturnType;
782
783 /** The program counter (PC) address which the frame returns to.
784 * The off member is [e|r]ip and the Sel member is cs. */
785 DBGFADDRESS AddrReturnPC;
786 /** Pointer to the symbol nearest the return PC. NULL if not found. */
787 PRTDBGSYMBOL pSymReturnPC;
788 /** Pointer to the linnumber nearest the return PC. NULL if not found. */
789 PDBGFLINE pLineReturnPC;
790
791 /** 32-bytes of stack arguments. */
792 union
793 {
794 /** 64-bit view */
795 uint64_t au64[4];
796 /** 32-bit view */
797 uint32_t au32[8];
798 /** 16-bit view */
799 uint16_t au16[16];
800 /** 8-bit view */
801 uint8_t au8[32];
802 } Args;
803
804 /** Pointer to the next frame.
805 * Might not be used in some cases, so consider it internal. */
806 PCDBGFSTACKFRAME pNextInternal;
807 /** Pointer to the first frame.
808 * Might not be used in some cases, so consider it internal. */
809 PCDBGFSTACKFRAME pFirstInternal;
810} DBGFSTACKFRAME;
811
812/** @name DBGFSTACKFRAME Flags.
813 * @{ */
814/** Set if the content of the frame is filled in by DBGFR3StackWalk() and can be used
815 * to construct the next frame. */
816# define DBGFSTACKFRAME_FLAGS_ALL_VALID RT_BIT(0)
817/** This is the last stack frame we can read.
818 * This flag is not set if the walk stop because of max dept or recursion. */
819# define DBGFSTACKFRAME_FLAGS_LAST RT_BIT(1)
820/** This is the last record because we detected a loop. */
821# define DBGFSTACKFRAME_FLAGS_LOOP RT_BIT(2)
822/** This is the last record because we reached the maximum depth. */
823# define DBGFSTACKFRAME_FLAGS_MAX_DEPTH RT_BIT(3)
824/** 16-bit frame. */
825# define DBGFSTACKFRAME_FLAGS_16BIT RT_BIT(4)
826/** 32-bit frame. */
827# define DBGFSTACKFRAME_FLAGS_32BIT RT_BIT(5)
828/** 64-bit frame. */
829# define DBGFSTACKFRAME_FLAGS_64BIT RT_BIT(6)
830/** @} */
831
832/** @name DBGFCODETYPE
833 * @{ */
834typedef enum DBGFCODETYPE
835{
836 /** The usual invalid 0 value. */
837 DBGFCODETYPE_INVALID = 0,
838 /** Stack walk for guest code. */
839 DBGFCODETYPE_GUEST,
840 /** Stack walk for hypervisor code. */
841 DBGFCODETYPE_HYPER,
842 /** Stack walk for ring 0 code. */
843 DBGFCODETYPE_RING0,
844 /** The usual 32-bit blowup. */
845 DBGFCODETYPE_32BIT_HACK = 0x7fffffff
846} DBGFCODETYPE;
847/** @} */
848
849VMMR3DECL(int) DBGFR3StackWalkBegin(PVM pVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType, PCDBGFSTACKFRAME *ppFirstFrame);
850VMMR3DECL(int) DBGFR3StackWalkBeginEx(PVM pVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType, PCDBGFADDRESS pAddrFrame,
851 PCDBGFADDRESS pAddrStack,PCDBGFADDRESS pAddrPC,
852 DBGFRETURNTYPE enmReturnType, PCDBGFSTACKFRAME *ppFirstFrame);
853VMMR3DECL(PCDBGFSTACKFRAME) DBGFR3StackWalkNext(PCDBGFSTACKFRAME pCurrent);
854VMMR3DECL(void) DBGFR3StackWalkEnd(PCDBGFSTACKFRAME pFirstFrame);
855
856#endif /* IN_RING3 */
857
858
859#ifdef IN_RING3 /* The disassembly API only works in ring-3. */
860
861/** Flags to pass to DBGFR3DisasInstrEx().
862 * @{ */
863/** Disassemble the current guest instruction, with annotations. */
864#define DBGF_DISAS_FLAGS_CURRENT_GUEST RT_BIT(0)
865/** Disassemble the current hypervisor instruction, with annotations. */
866#define DBGF_DISAS_FLAGS_CURRENT_HYPER RT_BIT(1)
867/** No annotations for current context. */
868#define DBGF_DISAS_FLAGS_NO_ANNOTATION RT_BIT(2)
869/** No symbol lookup. */
870#define DBGF_DISAS_FLAGS_NO_SYMBOLS RT_BIT(3)
871/** No instruction bytes. */
872#define DBGF_DISAS_FLAGS_NO_BYTES RT_BIT(4)
873/** No address in the output. */
874#define DBGF_DISAS_FLAGS_NO_ADDRESS RT_BIT(5)
875/** Disassemble in the default mode of the specific context. */
876#define DBGF_DISAS_FLAGS_DEFAULT_MODE UINT32_C(0x00000000)
877/** Disassemble in 16-bit mode. */
878#define DBGF_DISAS_FLAGS_16BIT_MODE UINT32_C(0x10000000)
879/** Disassemble in 16-bit mode with real mode address translation. */
880#define DBGF_DISAS_FLAGS_16BIT_REAL_MODE UINT32_C(0x20000000)
881/** Disassemble in 32-bit mode. */
882#define DBGF_DISAS_FLAGS_32BIT_MODE UINT32_C(0x30000000)
883/** Disassemble in 64-bit mode. */
884#define DBGF_DISAS_FLAGS_64BIT_MODE UINT32_C(0x40000000)
885/** The disassembly mode mask. */
886#define DBGF_DISAS_FLAGS_MODE_MASK UINT32_C(0x70000000)
887/** Mask containing the valid flags. */
888#define DBGF_DISAS_FLAGS_VALID_MASK UINT32_C(0x7000007f)
889/** @} */
890
891/** Special flat selector. */
892#define DBGF_SEL_FLAT 1
893
894VMMR3DECL(int) DBGFR3DisasInstrEx(PVM pVM, VMCPUID idCpu, RTSEL Sel, RTGCPTR GCPtr, uint32_t fFlags,
895 char *pszOutput, uint32_t cbOutput, uint32_t *pcbInstr);
896VMMR3DECL(int) DBGFR3DisasInstrCurrent(PVMCPU pVCpu, char *pszOutput, uint32_t cbOutput);
897VMMR3DECL(int) DBGFR3DisasInstrCurrentLogInternal(PVMCPU pVCpu, const char *pszPrefix);
898
899/** @def DBGFR3DisasInstrCurrentLog
900 * Disassembles the current guest context instruction and writes it to the log.
901 * All registers and data will be displayed. Addresses will be attempted resolved to symbols.
902 */
903#ifdef LOG_ENABLED
904# define DBGFR3DisasInstrCurrentLog(pVCpu, pszPrefix) \
905 do { \
906 if (LogIsEnabled()) \
907 DBGFR3DisasInstrCurrentLogInternal(pVCpu, pszPrefix); \
908 } while (0)
909#else
910# define DBGFR3DisasInstrCurrentLog(pVCpu, pszPrefix) do { } while (0)
911#endif
912
913VMMR3DECL(int) DBGFR3DisasInstrLogInternal(PVMCPU pVCpu, RTSEL Sel, RTGCPTR GCPtr, const char *pszPrefix);
914
915/** @def DBGFR3DisasInstrLog
916 * Disassembles the specified guest context instruction and writes it to the log.
917 * Addresses will be attempted resolved to symbols.
918 * @thread Any EMT.
919 */
920# ifdef LOG_ENABLED
921# define DBGFR3DisasInstrLog(pVCpu, Sel, GCPtr, pszPrefix) \
922 do { \
923 if (LogIsEnabled()) \
924 DBGFR3DisasInstrLogInternal(pVCpu, Sel, GCPtr, pszPrefix); \
925 } while (0)
926# else
927# define DBGFR3DisasInstrLog(pVCpu, Sel, GCPtr, pszPrefix) do { } while (0)
928# endif
929#endif
930
931
932#ifdef IN_RING3
933VMMR3DECL(int) DBGFR3MemScan(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, RTGCUINTPTR uAlign,
934 const void *pvNeedle, size_t cbNeedle, PDBGFADDRESS pHitAddress);
935VMMR3DECL(int) DBGFR3MemRead(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void *pvBuf, size_t cbRead);
936VMMR3DECL(int) DBGFR3MemReadString(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, char *pszBuf, size_t cbBuf);
937VMMR3DECL(int) DBGFR3MemWrite(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void const *pvBuf, size_t cbRead);
938#endif
939
940
941/** @name Flags for DBGFR3PagingDumpEx, PGMR3DumpHierarchyHCEx and
942 * PGMR3DumpHierarchyGCEx
943 * @{ */
944/** The CR3 from the current CPU state. */
945#define DBGFPGDMP_FLAGS_CURRENT_CR3 RT_BIT_32(0)
946/** The current CPU paging mode (PSE, PAE, LM, EPT, NX). */
947#define DBGFPGDMP_FLAGS_CURRENT_MODE RT_BIT_32(1)
948/** Whether PSE is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
949 * Same value as X86_CR4_PSE. */
950#define DBGFPGDMP_FLAGS_PSE RT_BIT_32(4) /* */
951/** Whether PAE is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
952 * Same value as X86_CR4_PAE. */
953#define DBGFPGDMP_FLAGS_PAE RT_BIT_32(5) /* */
954/** Whether LME is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
955 * Same value as MSR_K6_EFER_LME. */
956#define DBGFPGDMP_FLAGS_LME RT_BIT_32(8)
957/** Whether nested paging is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE). */
958#define DBGFPGDMP_FLAGS_NP RT_BIT_32(9)
959/** Whether extended nested page tables are enabled
960 * (!DBGFPGDMP_FLAGS_CURRENT_STATE). */
961#define DBGFPGDMP_FLAGS_EPT RT_BIT_32(10)
962/** Whether no-execution is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
963 * Same value as MSR_K6_EFER_NXE. */
964#define DBGFPGDMP_FLAGS_NXE RT_BIT_32(11)
965/** Whether to print the CR3. */
966#define DBGFPGDMP_FLAGS_PRINT_CR3 RT_BIT_32(27)
967/** Whether to print the header. */
968#define DBGFPGDMP_FLAGS_HEADER RT_BIT_32(28)
969/** Whether to dump additional page information. */
970#define DBGFPGDMP_FLAGS_PAGE_INFO RT_BIT_32(29)
971/** Dump the shadow tables if set.
972 * Cannot be used together with DBGFPGDMP_FLAGS_GUEST. */
973#define DBGFPGDMP_FLAGS_SHADOW RT_BIT_32(30)
974/** Dump the guest tables if set.
975 * Cannot be used together with DBGFPGDMP_FLAGS_SHADOW. */
976#define DBGFPGDMP_FLAGS_GUEST RT_BIT_32(31)
977/** Mask of valid bits. */
978#define DBGFPGDMP_FLAGS_VALID_MASK UINT32_C(0xf8000f33)
979/** The mask of bits controlling the paging mode. */
980#define DBGFPGDMP_FLAGS_MODE_MASK UINT32_C(0x00000f32)
981/** @} */
982VMMDECL(int) DBGFR3PagingDumpEx(PVM pVM, VMCPUID idCpu, uint32_t fFlags, uint64_t cr3, uint64_t u64FirstAddr,
983 uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
984
985
986/** @name DBGFR3SelQueryInfo flags.
987 * @{ */
988/** Get the info from the guest descriptor table. */
989#define DBGFSELQI_FLAGS_DT_GUEST UINT32_C(0)
990/** Get the info from the shadow descriptor table.
991 * Only works in raw-mode. */
992#define DBGFSELQI_FLAGS_DT_SHADOW UINT32_C(1)
993/** If currently executing in in 64-bit mode, blow up data selectors. */
994#define DBGFSELQI_FLAGS_DT_ADJ_64BIT_MODE UINT32_C(2)
995/** @} */
996VMMR3DECL(int) DBGFR3SelQueryInfo(PVM pVM, VMCPUID idCpu, RTSEL Sel, uint32_t fFlags, PDBGFSELINFO pSelInfo);
997
998
999/**
1000 * Register identifiers.
1001 */
1002typedef enum DBGFREG
1003{
1004 /* General purpose registers: */
1005 DBGFREG_AL = 0,
1006 DBGFREG_AX = DBGFREG_AL,
1007 DBGFREG_EAX = DBGFREG_AL,
1008 DBGFREG_RAX = DBGFREG_AL,
1009
1010 DBGFREG_CL,
1011 DBGFREG_CX = DBGFREG_CL,
1012 DBGFREG_ECX = DBGFREG_CL,
1013 DBGFREG_RCX = DBGFREG_CL,
1014
1015 DBGFREG_DL,
1016 DBGFREG_DX = DBGFREG_DL,
1017 DBGFREG_EDX = DBGFREG_DL,
1018 DBGFREG_RDX = DBGFREG_DL,
1019
1020 DBGFREG_BL,
1021 DBGFREG_BX = DBGFREG_BL,
1022 DBGFREG_EBX = DBGFREG_BL,
1023 DBGFREG_RBX = DBGFREG_BL,
1024
1025 DBGFREG_SPL,
1026 DBGFREG_SP = DBGFREG_SPL,
1027 DBGFREG_ESP = DBGFREG_SPL,
1028 DBGFREG_RSP = DBGFREG_SPL,
1029
1030 DBGFREG_BPL,
1031 DBGFREG_BP = DBGFREG_BPL,
1032 DBGFREG_EBP = DBGFREG_BPL,
1033 DBGFREG_RBP = DBGFREG_BPL,
1034
1035 DBGFREG_SIL,
1036 DBGFREG_SI = DBGFREG_SIL,
1037 DBGFREG_ESI = DBGFREG_SIL,
1038 DBGFREG_RSI = DBGFREG_SIL,
1039
1040 DBGFREG_DIL,
1041 DBGFREG_DI = DBGFREG_DIL,
1042 DBGFREG_EDI = DBGFREG_DIL,
1043 DBGFREG_RDI = DBGFREG_DIL,
1044
1045 DBGFREG_R8,
1046 DBGFREG_R8B = DBGFREG_R8,
1047 DBGFREG_R8W = DBGFREG_R8,
1048 DBGFREG_R8D = DBGFREG_R8,
1049
1050 DBGFREG_R9,
1051 DBGFREG_R9B = DBGFREG_R9,
1052 DBGFREG_R9W = DBGFREG_R9,
1053 DBGFREG_R9D = DBGFREG_R9,
1054
1055 DBGFREG_R10,
1056 DBGFREG_R10B = DBGFREG_R10,
1057 DBGFREG_R10W = DBGFREG_R10,
1058 DBGFREG_R10D = DBGFREG_R10,
1059
1060 DBGFREG_R11,
1061 DBGFREG_R11B = DBGFREG_R11,
1062 DBGFREG_R11W = DBGFREG_R11,
1063 DBGFREG_R11D = DBGFREG_R11,
1064
1065 DBGFREG_R12,
1066 DBGFREG_R12B = DBGFREG_R12,
1067 DBGFREG_R12W = DBGFREG_R12,
1068 DBGFREG_R12D = DBGFREG_R12,
1069
1070 DBGFREG_R13,
1071 DBGFREG_R13B = DBGFREG_R13,
1072 DBGFREG_R13W = DBGFREG_R13,
1073 DBGFREG_R13D = DBGFREG_R13,
1074
1075 DBGFREG_R14,
1076 DBGFREG_R14B = DBGFREG_R14,
1077 DBGFREG_R14W = DBGFREG_R14,
1078 DBGFREG_R14D = DBGFREG_R14,
1079
1080 DBGFREG_R15,
1081 DBGFREG_R15B = DBGFREG_R15,
1082 DBGFREG_R15W = DBGFREG_R15,
1083 DBGFREG_R15D = DBGFREG_R15,
1084
1085 /* Segments and other special registers: */
1086 DBGFREG_CS,
1087 DBGFREG_CS_ATTR,
1088 DBGFREG_CS_BASE,
1089 DBGFREG_CS_LIMIT,
1090
1091 DBGFREG_DS,
1092 DBGFREG_DS_ATTR,
1093 DBGFREG_DS_BASE,
1094 DBGFREG_DS_LIMIT,
1095
1096 DBGFREG_ES,
1097 DBGFREG_ES_ATTR,
1098 DBGFREG_ES_BASE,
1099 DBGFREG_ES_LIMIT,
1100
1101 DBGFREG_FS,
1102 DBGFREG_FS_ATTR,
1103 DBGFREG_FS_BASE,
1104 DBGFREG_FS_LIMIT,
1105
1106 DBGFREG_GS,
1107 DBGFREG_GS_ATTR,
1108 DBGFREG_GS_BASE,
1109 DBGFREG_GS_LIMIT,
1110
1111 DBGFREG_SS,
1112 DBGFREG_SS_ATTR,
1113 DBGFREG_SS_BASE,
1114 DBGFREG_SS_LIMIT,
1115
1116 DBGFREG_IP,
1117 DBGFREG_EIP = DBGFREG_IP,
1118 DBGFREG_RIP = DBGFREG_IP,
1119
1120 DBGFREG_FLAGS,
1121 DBGFREG_EFLAGS = DBGFREG_FLAGS,
1122 DBGFREG_RFLAGS = DBGFREG_FLAGS,
1123
1124 /* FPU: */
1125 DBGFREG_FCW,
1126 DBGFREG_FSW,
1127 DBGFREG_FTW,
1128 DBGFREG_FOP,
1129 DBGFREG_FPUIP,
1130 DBGFREG_FPUCS,
1131 DBGFREG_FPUDP,
1132 DBGFREG_FPUDS,
1133 DBGFREG_MXCSR,
1134 DBGFREG_MXCSR_MASK,
1135
1136 DBGFREG_ST0,
1137 DBGFREG_ST1,
1138 DBGFREG_ST2,
1139 DBGFREG_ST3,
1140 DBGFREG_ST4,
1141 DBGFREG_ST5,
1142 DBGFREG_ST6,
1143 DBGFREG_ST7,
1144
1145 DBGFREG_MM0,
1146 DBGFREG_MM1,
1147 DBGFREG_MM2,
1148 DBGFREG_MM3,
1149 DBGFREG_MM4,
1150 DBGFREG_MM5,
1151 DBGFREG_MM6,
1152 DBGFREG_MM7,
1153
1154 /* SSE: */
1155 DBGFREG_XMM0,
1156 DBGFREG_XMM1,
1157 DBGFREG_XMM2,
1158 DBGFREG_XMM3,
1159 DBGFREG_XMM4,
1160 DBGFREG_XMM5,
1161 DBGFREG_XMM6,
1162 DBGFREG_XMM7,
1163 DBGFREG_XMM8,
1164 DBGFREG_XMM9,
1165 DBGFREG_XMM10,
1166 DBGFREG_XMM11,
1167 DBGFREG_XMM12,
1168 DBGFREG_XMM13,
1169 DBGFREG_XMM14,
1170 DBGFREG_XMM15,
1171 /** @todo add XMM aliases. */
1172
1173 /* System registers: */
1174 DBGFREG_GDTR_BASE,
1175 DBGFREG_GDTR_LIMIT,
1176 DBGFREG_IDTR_BASE,
1177 DBGFREG_IDTR_LIMIT,
1178 DBGFREG_LDTR,
1179 DBGFREG_LDTR_ATTR,
1180 DBGFREG_LDTR_BASE,
1181 DBGFREG_LDTR_LIMIT,
1182 DBGFREG_TR,
1183 DBGFREG_TR_ATTR,
1184 DBGFREG_TR_BASE,
1185 DBGFREG_TR_LIMIT,
1186
1187 DBGFREG_CR0,
1188 DBGFREG_CR2,
1189 DBGFREG_CR3,
1190 DBGFREG_CR4,
1191 DBGFREG_CR8,
1192
1193 DBGFREG_DR0,
1194 DBGFREG_DR1,
1195 DBGFREG_DR2,
1196 DBGFREG_DR3,
1197 DBGFREG_DR6,
1198 DBGFREG_DR7,
1199
1200 /* MSRs: */
1201 DBGFREG_MSR_IA32_APICBASE,
1202 DBGFREG_MSR_IA32_CR_PAT,
1203 DBGFREG_MSR_IA32_PERF_STATUS,
1204 DBGFREG_MSR_IA32_SYSENTER_CS,
1205 DBGFREG_MSR_IA32_SYSENTER_EIP,
1206 DBGFREG_MSR_IA32_SYSENTER_ESP,
1207 DBGFREG_MSR_IA32_TSC,
1208 DBGFREG_MSR_K6_EFER,
1209 DBGFREG_MSR_K6_STAR,
1210 DBGFREG_MSR_K8_CSTAR,
1211 DBGFREG_MSR_K8_FS_BASE,
1212 DBGFREG_MSR_K8_GS_BASE,
1213 DBGFREG_MSR_K8_KERNEL_GS_BASE,
1214 DBGFREG_MSR_K8_LSTAR,
1215 DBGFREG_MSR_K8_SF_MASK,
1216 DBGFREG_MSR_K8_TSC_AUX,
1217
1218 /** The number of registers to pass to DBGFR3RegQueryAll. */
1219 DBGFREG_ALL_COUNT,
1220
1221 /* Misc aliases that doesn't need be part of the 'all' query: */
1222 DBGFREG_AH = DBGFREG_ALL_COUNT,
1223 DBGFREG_CH,
1224 DBGFREG_DH,
1225 DBGFREG_BH,
1226 DBGFREG_GDTR,
1227 DBGFREG_IDTR,
1228
1229 /** The end of the registers. */
1230 DBGFREG_END,
1231 /** The usual 32-bit type hack. */
1232 DBGFREG_32BIT_HACK = 0x7fffffff
1233} DBGFREG;
1234/** Pointer to a register identifier. */
1235typedef DBGFREG *PDBGFREG;
1236/** Pointer to a const register identifier. */
1237typedef DBGFREG const *PCDBGFREG;
1238
1239/**
1240 * Register value type.
1241 */
1242typedef enum DBGFREGVALTYPE
1243{
1244 DBGFREGVALTYPE_INVALID = 0,
1245 /** Unsigned 8-bit register value. */
1246 DBGFREGVALTYPE_U8,
1247 /** Unsigned 16-bit register value. */
1248 DBGFREGVALTYPE_U16,
1249 /** Unsigned 32-bit register value. */
1250 DBGFREGVALTYPE_U32,
1251 /** Unsigned 64-bit register value. */
1252 DBGFREGVALTYPE_U64,
1253 /** Unsigned 128-bit register value. */
1254 DBGFREGVALTYPE_U128,
1255 /** Long double register value. */
1256 DBGFREGVALTYPE_R80,
1257 /** Descriptor table register value. */
1258 DBGFREGVALTYPE_DTR,
1259 /** End of the valid register value types. */
1260 DBGFREGVALTYPE_END,
1261 /** The usual 32-bit type hack. */
1262 DBGFREGVALTYPE_32BIT_HACK = 0x7fffffff
1263} DBGFREGVALTYPE;
1264/** Pointer to a register value type. */
1265typedef DBGFREGVALTYPE *PDBGFREGVALTYPE;
1266
1267/**
1268 * A generic register value type.
1269 */
1270typedef union DBGFREGVAL
1271{
1272 uint8_t u8; /**< The 8-bit view. */
1273 uint16_t u16; /**< The 16-bit view. */
1274 uint32_t u32; /**< The 32-bit view. */
1275 uint64_t u64; /**< The 64-bit view. */
1276 RTUINT128U u128; /**< The 128-bit view. */
1277 RTFLOAT80U r80; /**< The 80-bit floating point view. */
1278 RTFLOAT80U2 r80Ex; /**< The 80-bit floating point view v2. */
1279 /** GDTR or LDTR (DBGFREGVALTYPE_DTR). */
1280 struct
1281 {
1282 /** The table address. */
1283 uint64_t u64Base;
1284 /** The table limit (length minus 1). */
1285 uint32_t u32Limit;
1286 } dtr;
1287
1288 uint8_t au8[16]; /**< The 8-bit array view. */
1289 uint16_t au16[8]; /**< The 16-bit array view. */
1290 uint32_t au32[4]; /**< The 32-bit array view. */
1291 uint64_t au64[2]; /**< The 64-bit array view. */
1292 RTUINT128U u;
1293} DBGFREGVAL;
1294/** Pointer to a generic register value type. */
1295typedef DBGFREGVAL *PDBGFREGVAL;
1296/** Pointer to a const generic register value type. */
1297typedef DBGFREGVAL const *PCDBGFREGVAL;
1298
1299VMMDECL(ssize_t) DBGFR3RegFormatValue(char *pszBuf, size_t cbBuf, PCDBGFREGVAL pValue, DBGFREGVALTYPE enmType, bool fSpecial);
1300VMMDECL(ssize_t) DBGFR3RegFormatValueEx(char *pszBuf, size_t cbBuf, PCDBGFREGVAL pValue, DBGFREGVALTYPE enmType,
1301 unsigned uBase, signed int cchWidth, signed int cchPrecision, uint32_t fFlags);
1302
1303/**
1304 * Register sub-field descriptor.
1305 */
1306typedef struct DBGFREGSUBFIELD
1307{
1308 /** The name of the sub-field. NULL is used to terminate the array. */
1309 const char *pszName;
1310 /** The index of the first bit. Ignored if pfnGet is set. */
1311 uint8_t iFirstBit;
1312 /** The number of bits. Mandatory. */
1313 uint8_t cBits;
1314 /** The shift count. Not applied when pfnGet is set, but used to
1315 * calculate the minimum type. */
1316 int8_t cShift;
1317 /** Sub-field flags, DBGFREGSUBFIELD_FLAGS_XXX. */
1318 uint8_t fFlags;
1319 /** Getter (optional). */
1320 DECLCALLBACKMEMBER(int, pfnGet)(void *pvUser, struct DBGFREGSUBFIELD const *pSubField, PRTUINT128U puValue);
1321 /** Setter (optional). */
1322 DECLCALLBACKMEMBER(int, pfnSet)(void *pvUser, struct DBGFREGSUBFIELD const *pSubField, RTUINT128U uValue, RTUINT128U fMask);
1323} DBGFREGSUBFIELD;
1324/** Pointer to a const register sub-field descriptor. */
1325typedef DBGFREGSUBFIELD const *PCDBGFREGSUBFIELD;
1326
1327/** @name DBGFREGSUBFIELD_FLAGS_XXX
1328 * @{ */
1329/** The sub-field is read-only. */
1330#define DBGFREGSUBFIELD_FLAGS_READ_ONLY UINT8_C(0x01)
1331/** @} */
1332
1333/** Macro for creating a read-write sub-field entry without getters. */
1334#define DBGFREGSUBFIELD_RW(a_szName, a_iFirstBit, a_cBits, a_cShift) \
1335 { a_szName, a_iFirstBit, a_cBits, a_cShift, 0 /*fFlags*/, NULL /*pfnGet*/, NULL /*pfnSet*/ }
1336/** Macro for creating a read-write sub-field entry with getters. */
1337#define DBGFREGSUBFIELD_RW_SG(a_szName, a_cBits, a_cShift, a_pfnGet, a_pfnSet) \
1338 { a_szName, 0 /*iFirstBit*/, a_cBits, a_cShift, 0 /*fFlags*/, a_pfnGet, a_pfnSet }
1339/** Macro for creating a terminator sub-field entry. */
1340#define DBGFREGSUBFIELD_TERMINATOR() \
1341 { NULL, 0, 0, 0, 0, NULL, NULL }
1342
1343/**
1344 * Register alias descriptor.
1345 */
1346typedef struct DBGFREGALIAS
1347{
1348 /** The alias name. NULL is used to terminate the array. */
1349 const char *pszName;
1350 /** Set to a valid type if the alias has a different type. */
1351 DBGFREGVALTYPE enmType;
1352} DBGFREGALIAS;
1353/** Pointer to a const register alias descriptor. */
1354typedef DBGFREGALIAS const *PCDBGFREGALIAS;
1355
1356/**
1357 * Register descriptor.
1358 */
1359typedef struct DBGFREGDESC
1360{
1361 /** The normal register name. */
1362 const char *pszName;
1363 /** The register identifier if this is a CPU register. */
1364 DBGFREG enmReg;
1365 /** The default register type. */
1366 DBGFREGVALTYPE enmType;
1367 /** Flags, see DBGFREG_FLAGS_XXX. */
1368 uint32_t fFlags;
1369 /** The internal register indicator.
1370 * For CPU registers this is the offset into the CPUMCTX structure,
1371 * thuse the 'off' prefix. */
1372 uint32_t offRegister;
1373 /** Getter. */
1374 DECLCALLBACKMEMBER(int, pfnGet)(void *pvUser, struct DBGFREGDESC const *pDesc, PDBGFREGVAL pValue);
1375 /** Setter. */
1376 DECLCALLBACKMEMBER(int, pfnSet)(void *pvUser, struct DBGFREGDESC const *pDesc, PCDBGFREGVAL pValue, PCDBGFREGVAL pfMask);
1377 /** Aliases (optional). */
1378 PCDBGFREGALIAS paAliases;
1379 /** Sub fields (optional). */
1380 PCDBGFREGSUBFIELD paSubFields;
1381} DBGFREGDESC;
1382
1383/** @name Macros for constructing DBGFREGDESC arrays.
1384 * @{ */
1385#define DBGFREGDESC_RW(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet) \
1386 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, 0 /*fFlags*/, a_offRegister, a_pfnGet, a_pfnSet, NULL /*paAlises*/, NULL /*paSubFields*/ }
1387#define DBGFREGDESC_RO(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet) \
1388 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, DBGFREG_FLAGS_READ_ONLY, a_offRegister, a_pfnGet, a_pfnSet, NULL /*paAlises*/, NULL /*paSubFields*/ }
1389#define DBGFREGDESC_RW_A(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases) \
1390 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, 0 /*fFlags*/, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, NULL /*paSubFields*/ }
1391#define DBGFREGDESC_RO_A(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases) \
1392 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, DBGFREG_FLAGS_READ_ONLY, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, NULL /*paSubFields*/ }
1393#define DBGFREGDESC_RW_S(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paSubFields) \
1394 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, 0 /*fFlags*/, a_offRegister, a_pfnGet, a_pfnSet, /*paAliases*/, a_paSubFields }
1395#define DBGFREGDESC_RO_S(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paSubFields) \
1396 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, DBGFREG_FLAGS_READ_ONLY, a_offRegister, a_pfnGet, a_pfnSet, /*paAliases*/, a_paSubFields }
1397#define DBGFREGDESC_RW_AS(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, a_paSubFields) \
1398 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, 0 /*fFlags*/, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, a_paSubFields }
1399#define DBGFREGDESC_RO_AS(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, a_paSubFields) \
1400 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, DBGFREG_FLAGS_READ_ONLY, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, a_paSubFields }
1401#define DBGFREGDESC_TERMINATOR() \
1402 { NULL, DBGFREG_END, DBGFREGVALTYPE_INVALID, 0, 0, NULL, NULL, NULL, NULL }
1403/** @} */
1404
1405
1406/** @name DBGFREG_FLAGS_XXX
1407 * @{ */
1408/** The register is read-only. */
1409#define DBGFREG_FLAGS_READ_ONLY RT_BIT_32(0)
1410/** @} */
1411
1412/**
1413 * Entry in a batch query or set operation.
1414 */
1415typedef struct DBGFREGENTRY
1416{
1417 /** The register identifier. */
1418 DBGFREG enmReg;
1419 /** The size of the value in bytes. */
1420 DBGFREGVALTYPE enmType;
1421 /** The register value. The valid view is indicated by enmType. */
1422 DBGFREGVAL Val;
1423} DBGFREGENTRY;
1424/** Pointer to a register entry in a batch operation. */
1425typedef DBGFREGENTRY *PDBGFREGENTRY;
1426/** Pointer to a const register entry in a batch operation. */
1427typedef DBGFREGENTRY const *PCDBGFREGENTRY;
1428
1429/** Used with DBGFR3Reg* to indicate the hypervisor register set instead of the
1430 * guest. */
1431#define DBGFREG_HYPER_VMCPUID UINT32_C(0x01000000)
1432
1433VMMR3DECL(int) DBGFR3RegCpuQueryU8( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint8_t *pu8);
1434VMMR3DECL(int) DBGFR3RegCpuQueryU16( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint16_t *pu16);
1435VMMR3DECL(int) DBGFR3RegCpuQueryU32( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint32_t *pu32);
1436VMMR3DECL(int) DBGFR3RegCpuQueryU64( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t *pu64);
1437VMMR3DECL(int) DBGFR3RegCpuQueryU128(PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint128_t *pu128);
1438VMMR3DECL(int) DBGFR3RegCpuQueryLrd( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, long double *plrd);
1439VMMR3DECL(int) DBGFR3RegCpuQueryXdtr(PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t *pu64Base, uint16_t *pu16Limit);
1440#if 0
1441VMMR3DECL(int) DBGFR3RegCpuQueryBatch(PVM pVM,VMCPUID idCpu, PDBGFREGENTRY paRegs, size_t cRegs);
1442VMMR3DECL(int) DBGFR3RegCpuQueryAll( PVM pVM, VMCPUID idCpu, PDBGFREGENTRY paRegs, size_t cRegs);
1443
1444VMMR3DECL(int) DBGFR3RegCpuSetU8( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint8_t u8);
1445VMMR3DECL(int) DBGFR3RegCpuSetU16( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint16_t u16);
1446VMMR3DECL(int) DBGFR3RegCpuSetU32( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint32_t u32);
1447VMMR3DECL(int) DBGFR3RegCpuSetU64( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t u64);
1448VMMR3DECL(int) DBGFR3RegCpuSetU128( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint128_t u128);
1449VMMR3DECL(int) DBGFR3RegCpuSetLrd( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, long double lrd);
1450VMMR3DECL(int) DBGFR3RegCpuSetBatch( PVM pVM, VMCPUID idCpu, PCDBGFREGENTRY paRegs, size_t cRegs);
1451#endif
1452
1453VMMR3DECL(const char *) DBGFR3RegCpuName(PVM pVM, DBGFREG enmReg, DBGFREGVALTYPE enmType);
1454
1455VMMR3_INT_DECL(int) DBGFR3RegRegisterCpu(PVM pVM, PVMCPU pVCpu, PCDBGFREGDESC paRegisters, bool fGuestRegs);
1456VMMR3DECL(int) DBGFR3RegRegisterDevice(PVM pVM, PCDBGFREGDESC paRegisters, PPDMDEVINS pDevIns, const char *pszPrefix, uint32_t iInstance);
1457
1458/**
1459 * Entry in a named batch query or set operation.
1460 */
1461typedef struct DBGFREGENTRYNM
1462{
1463 /** The register name. */
1464 const char *pszName;
1465 /** The size of the value in bytes. */
1466 DBGFREGVALTYPE enmType;
1467 /** The register value. The valid view is indicated by enmType. */
1468 DBGFREGVAL Val;
1469} DBGFREGENTRYNM;
1470/** Pointer to a named register entry in a batch operation. */
1471typedef DBGFREGENTRYNM *PDBGFREGENTRYNM;
1472/** Pointer to a const named register entry in a batch operation. */
1473typedef DBGFREGENTRYNM const *PCDBGFREGENTRYNM;
1474
1475VMMR3DECL(int) DBGFR3RegNmValidate( PVM pVM, VMCPUID idDefCpu, const char *pszReg);
1476
1477VMMR3DECL(int) DBGFR3RegNmQuery( PVM pVM, VMCPUID idDefCpu, const char *pszReg, PDBGFREGVAL pValue, PDBGFREGVALTYPE penmType);
1478VMMR3DECL(int) DBGFR3RegNmQueryU8( PVM pVM, VMCPUID idDefCpu, const char *pszReg, uint8_t *pu8);
1479VMMR3DECL(int) DBGFR3RegNmQueryU16( PVM pVM, VMCPUID idDefCpu, const char *pszReg, uint16_t *pu16);
1480VMMR3DECL(int) DBGFR3RegNmQueryU32( PVM pVM, VMCPUID idDefCpu, const char *pszReg, uint32_t *pu32);
1481VMMR3DECL(int) DBGFR3RegNmQueryU64( PVM pVM, VMCPUID idDefCpu, const char *pszReg, uint64_t *pu64);
1482VMMR3DECL(int) DBGFR3RegNmQueryU128(PVM pVM, VMCPUID idDefCpu, const char *pszReg, PRTUINT128U pu128);
1483/*VMMR3DECL(int) DBGFR3RegNmQueryLrd( PVM pVM, VMCPUID idDefCpu, const char *pszReg, long double *plrd);*/
1484VMMR3DECL(int) DBGFR3RegNmQueryXdtr(PVM pVM, VMCPUID idDefCpu, const char *pszReg, uint64_t *pu64Base, uint16_t *pu16Limit);
1485VMMR3DECL(int) DBGFR3RegNmQueryBatch(PVM pVM,VMCPUID idDefCpu, PDBGFREGENTRYNM paRegs, size_t cRegs);
1486VMMR3DECL(int) DBGFR3RegNmQueryAllCount(PVM pVM, size_t *pcRegs);
1487VMMR3DECL(int) DBGFR3RegNmQueryAll( PVM pVM, PDBGFREGENTRYNM paRegs, size_t cRegs);
1488
1489VMMR3DECL(int) DBGFR3RegNmSet( PVM pVM, VMCPUID idDefCpu, const char *pszReg, PCDBGFREGVAL pValue, DBGFREGVALTYPE enmType);
1490VMMR3DECL(int) DBGFR3RegNmSetU8( PVM pVM, VMCPUID idDefCpu, const char *pszReg, uint8_t u8);
1491VMMR3DECL(int) DBGFR3RegNmSetU16( PVM pVM, VMCPUID idDefCpu, const char *pszReg, uint16_t u16);
1492VMMR3DECL(int) DBGFR3RegNmSetU32( PVM pVM, VMCPUID idDefCpu, const char *pszReg, uint32_t u32);
1493VMMR3DECL(int) DBGFR3RegNmSetU64( PVM pVM, VMCPUID idDefCpu, const char *pszReg, uint64_t u64);
1494VMMR3DECL(int) DBGFR3RegNmSetU128( PVM pVM, VMCPUID idDefCpu, const char *pszReg, RTUINT128U u128);
1495VMMR3DECL(int) DBGFR3RegNmSetLrd( PVM pVM, VMCPUID idDefCpu, const char *pszReg, long double lrd);
1496VMMR3DECL(int) DBGFR3RegNmSetBatch( PVM pVM, VMCPUID idDefCpu, PCDBGFREGENTRYNM paRegs, size_t cRegs);
1497
1498/** @todo add enumeration methods. */
1499
1500VMMR3DECL(int) DBGFR3RegPrintf( PVM pVM, VMCPUID idDefCpu, char *pszBuf, size_t cbBuf, const char *pszFormat, ...);
1501VMMR3DECL(int) DBGFR3RegPrintfV(PVM pVM, VMCPUID idDefCpu, char *pszBuf, size_t cbBuf, const char *pszFormat, va_list va);
1502
1503
1504/**
1505 * Guest OS digger interface identifier.
1506 *
1507 * This is for use together with PDBGFR3QueryInterface and is used to
1508 * obtain access to optional interfaces.
1509 */
1510typedef enum DBGFOSINTERFACE
1511{
1512 /** The usual invalid entry. */
1513 DBGFOSINTERFACE_INVALID = 0,
1514 /** Process info. */
1515 DBGFOSINTERFACE_PROCESS,
1516 /** Thread info. */
1517 DBGFOSINTERFACE_THREAD,
1518 /** The end of the valid entries. */
1519 DBGFOSINTERFACE_END,
1520 /** The usual 32-bit type blowup. */
1521 DBGFOSINTERFACE_32BIT_HACK = 0x7fffffff
1522} DBGFOSINTERFACE;
1523/** Pointer to a Guest OS digger interface identifier. */
1524typedef DBGFOSINTERFACE *PDBGFOSINTERFACE;
1525/** Pointer to a const Guest OS digger interface identifier. */
1526typedef DBGFOSINTERFACE const *PCDBGFOSINTERFACE;
1527
1528
1529/**
1530 * Guest OS Digger Registration Record.
1531 *
1532 * This is used with the DBGFR3OSRegister() API.
1533 */
1534typedef struct DBGFOSREG
1535{
1536 /** Magic value (DBGFOSREG_MAGIC). */
1537 uint32_t u32Magic;
1538 /** Flags. Reserved. */
1539 uint32_t fFlags;
1540 /** The size of the instance data. */
1541 uint32_t cbData;
1542 /** Operative System name. */
1543 char szName[24];
1544
1545 /**
1546 * Constructs the instance.
1547 *
1548 * @returns VBox status code.
1549 * @param pVM Pointer to the shared VM structure.
1550 * @param pvData Pointer to the instance data.
1551 */
1552 DECLCALLBACKMEMBER(int, pfnConstruct)(PVM pVM, void *pvData);
1553
1554 /**
1555 * Destroys the instance.
1556 *
1557 * @param pVM Pointer to the shared VM structure.
1558 * @param pvData Pointer to the instance data.
1559 */
1560 DECLCALLBACKMEMBER(void, pfnDestruct)(PVM pVM, void *pvData);
1561
1562 /**
1563 * Probes the guest memory for OS finger prints.
1564 *
1565 * No setup or so is performed, it will be followed by a call to pfnInit
1566 * or pfnRefresh that should take care of that.
1567 *
1568 * @returns true if is an OS handled by this module, otherwise false.
1569 * @param pVM Pointer to the shared VM structure.
1570 * @param pvData Pointer to the instance data.
1571 */
1572 DECLCALLBACKMEMBER(bool, pfnProbe)(PVM pVM, void *pvData);
1573
1574 /**
1575 * Initializes a fresly detected guest, loading symbols and such useful stuff.
1576 *
1577 * This is called after pfnProbe.
1578 *
1579 * @returns VBox status code.
1580 * @param pVM Pointer to the shared VM structure.
1581 * @param pvData Pointer to the instance data.
1582 */
1583 DECLCALLBACKMEMBER(int, pfnInit)(PVM pVM, void *pvData);
1584
1585 /**
1586 * Refreshes symbols and stuff following a redetection of the same OS.
1587 *
1588 * This is called after pfnProbe.
1589 *
1590 * @returns VBox status code.
1591 * @param pVM Pointer to the shared VM structure.
1592 * @param pvData Pointer to the instance data.
1593 */
1594 DECLCALLBACKMEMBER(int, pfnRefresh)(PVM pVM, void *pvData);
1595
1596 /**
1597 * Terminates an OS when a new (or none) OS has been detected,
1598 * and before destruction.
1599 *
1600 * This is called after pfnProbe and if needed before pfnDestruct.
1601 *
1602 * @param pVM Pointer to the shared VM structure.
1603 * @param pvData Pointer to the instance data.
1604 */
1605 DECLCALLBACKMEMBER(void, pfnTerm)(PVM pVM, void *pvData);
1606
1607 /**
1608 * Queries the version of the running OS.
1609 *
1610 * This is only called after pfnInit().
1611 *
1612 * @returns VBox status code.
1613 * @param pVM Pointer to the shared VM structure.
1614 * @param pvData Pointer to the instance data.
1615 * @param pszVersion Where to store the version string.
1616 * @param cchVersion The size of the version string buffer.
1617 */
1618 DECLCALLBACKMEMBER(int, pfnQueryVersion)(PVM pVM, void *pvData, char *pszVersion, size_t cchVersion);
1619
1620 /**
1621 * Queries the pointer to a interface.
1622 *
1623 * This is called after pfnProbe.
1624 *
1625 * @returns Pointer to the interface if available, NULL if not available.
1626 * @param pVM Pointer to the shared VM structure.
1627 * @param pvData Pointer to the instance data.
1628 * @param enmIf The interface identifier.
1629 */
1630 DECLCALLBACKMEMBER(void *, pfnQueryInterface)(PVM pVM, void *pvData, DBGFOSINTERFACE enmIf);
1631
1632 /** Trailing magic (DBGFOSREG_MAGIC). */
1633 uint32_t u32EndMagic;
1634} DBGFOSREG;
1635/** Pointer to a Guest OS digger registration record. */
1636typedef DBGFOSREG *PDBGFOSREG;
1637/** Pointer to a const Guest OS digger registration record. */
1638typedef DBGFOSREG const *PCDBGFOSREG;
1639
1640/** Magic value for DBGFOSREG::u32Magic and DBGFOSREG::u32EndMagic. (Hitomi Kanehara) */
1641#define DBGFOSREG_MAGIC 0x19830808
1642
1643VMMR3DECL(int) DBGFR3OSRegister(PVM pVM, PCDBGFOSREG pReg);
1644VMMR3DECL(int) DBGFR3OSDeregister(PVM pVM, PCDBGFOSREG pReg);
1645VMMR3DECL(int) DBGFR3OSDetect(PVM pVM, char *pszName, size_t cchName);
1646VMMR3DECL(int) DBGFR3OSQueryNameAndVersion(PVM pVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion);
1647VMMR3DECL(void *) DBGFR3OSQueryInterface(PVM pVM, DBGFOSINTERFACE enmIf);
1648
1649
1650VMMR3DECL(int) DBGFR3CoreWrite(PVM pVM, const char *pszFilename, bool fReplaceFile);
1651
1652/** @} */
1653
1654
1655RT_C_DECLS_END
1656
1657#endif
1658
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette