VirtualBox

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

Last change on this file since 44519 was 44399, checked in by vboxsync, 12 years ago

DBGF,DBGC,++: PVM -> PUVM. Some refactoring and cleanup as well.

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

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