VirtualBox

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

Last change on this file since 75853 was 73491, checked in by vboxsync, 6 years ago

DBGF,DBGPluInWinNt: Produce more useful module names (e.g. stuff that works in DBGC).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 111.4 KB
Line 
1/** @file
2 * DBGF - Debugger Facility.
3 */
4
5/*
6 * Copyright (C) 2006-2017 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 * @ingroup grp_vmm
42 * @{
43 */
44
45#if defined(IN_RC) || defined(IN_RING0)
46/** @defgroup grp_dbgf_rz The RZ DBGF API
47 * @{
48 */
49VMMRZ_INT_DECL(int) DBGFRZTrap01Handler(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCUINTREG uDr6, bool fAltStepping);
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 ring-0 host address (internal use only). */
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 any kind of far address. */
112#define DBGFADDRESS_IS_FAR(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) <= DBGFADDRESS_FLAGS_FAR64 )
113/** Checks if the mixed address host context ring-0 (special). */
114#define DBGFADDRESS_IS_R0_HC(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_RING0 )
115/** Checks if the mixed address a virtual guest context address (incl HMA). */
116#define DBGFADDRESS_IS_VIRT_GC(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) <= DBGFADDRESS_FLAGS_FLAT )
117/** Checks if the mixed address is valid. */
118#define DBGFADDRESS_IS_VALID(pAddress) RT_BOOL((pAddress)->fFlags & DBGFADDRESS_FLAGS_VALID)
119/** Checks if the address is flagged as within the HMA. */
120#define DBGFADDRESS_IS_HMA(pAddress) RT_BOOL((pAddress)->fFlags & DBGFADDRESS_FLAGS_HMA)
121/** @} */
122
123VMMR3DECL(int) DBGFR3AddrFromSelOff(PUVM pUVM, VMCPUID idCpu, PDBGFADDRESS pAddress, RTSEL Sel, RTUINTPTR off);
124VMMR3DECL(int) DBGFR3AddrFromSelInfoOff(PUVM pUVM, PDBGFADDRESS pAddress, PCDBGFSELINFO pSelInfo, RTUINTPTR off);
125VMMR3DECL(PDBGFADDRESS) DBGFR3AddrFromFlat(PUVM pUVM, PDBGFADDRESS pAddress, RTGCUINTPTR FlatPtr);
126VMMR3DECL(PDBGFADDRESS) DBGFR3AddrFromPhys(PUVM pUVM, PDBGFADDRESS pAddress, RTGCPHYS PhysAddr);
127VMMR3_INT_DECL(PDBGFADDRESS) DBGFR3AddrFromHostR0(PDBGFADDRESS pAddress, RTR0UINTPTR R0Ptr);
128VMMR3DECL(bool) DBGFR3AddrIsValid(PUVM pUVM, PCDBGFADDRESS pAddress);
129VMMR3DECL(int) DBGFR3AddrToPhys(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, PRTGCPHYS pGCPhys);
130VMMR3DECL(int) DBGFR3AddrToHostPhys(PUVM pUVM, VMCPUID idCpu, PDBGFADDRESS pAddress, PRTHCPHYS pHCPhys);
131VMMR3DECL(int) DBGFR3AddrToVolatileR3Ptr(PUVM pUVM, VMCPUID idCpu, PDBGFADDRESS pAddress, bool fReadOnly, void **ppvR3Ptr);
132VMMR3DECL(PDBGFADDRESS) DBGFR3AddrAdd(PDBGFADDRESS pAddress, RTGCUINTPTR uAddend);
133VMMR3DECL(PDBGFADDRESS) DBGFR3AddrSub(PDBGFADDRESS pAddress, RTGCUINTPTR uSubtrahend);
134
135#endif /* IN_RING3 */
136
137
138
139/**
140 * VMM Debug Event Type.
141 */
142typedef enum DBGFEVENTTYPE
143{
144 /** Halt completed.
145 * This notifies that a halt command have been successfully completed.
146 */
147 DBGFEVENT_HALT_DONE = 0,
148 /** Detach completed.
149 * This notifies that the detach command have been successfully completed.
150 */
151 DBGFEVENT_DETACH_DONE,
152 /** The command from the debugger is not recognized.
153 * This means internal error or half implemented features.
154 */
155 DBGFEVENT_INVALID_COMMAND,
156
157 /** Fatal error.
158 * This notifies a fatal error in the VMM and that the debugger get's a
159 * chance to first hand information about the the problem.
160 */
161 DBGFEVENT_FATAL_ERROR,
162 /** Breakpoint Hit.
163 * This notifies that a breakpoint installed by the debugger was hit. The
164 * identifier of the breakpoint can be found in the DBGFEVENT::u::Bp::iBp member.
165 */
166 DBGFEVENT_BREAKPOINT,
167 /** I/O port breakpoint.
168 * @todo not yet implemented. */
169 DBGFEVENT_BREAKPOINT_IO,
170 /** MMIO breakpoint.
171 * @todo not yet implemented. */
172 DBGFEVENT_BREAKPOINT_MMIO,
173 /** Breakpoint Hit in the Hypervisor.
174 * This notifies that a breakpoint installed by the debugger was hit. The
175 * identifier of the breakpoint can be found in the DBGFEVENT::u::Bp::iBp member.
176 */
177 DBGFEVENT_BREAKPOINT_HYPER,
178 /** Assertion in the Hypervisor (breakpoint instruction).
179 * This notifies that a breakpoint instruction was hit in the hypervisor context.
180 */
181 DBGFEVENT_ASSERTION_HYPER,
182 /** Single Stepped.
183 * This notifies that a single step operation was completed.
184 */
185 DBGFEVENT_STEPPED,
186 /** Single Stepped.
187 * This notifies that a hypervisor single step operation was completed.
188 */
189 DBGFEVENT_STEPPED_HYPER,
190 /** The developer have used the DBGFSTOP macro or the PDMDeviceDBGFSTOP function
191 * to bring up the debugger at a specific place.
192 */
193 DBGFEVENT_DEV_STOP,
194 /** The VM is powering off.
195 * When this notification is received, the debugger thread should detach ASAP.
196 */
197 DBGFEVENT_POWERING_OFF,
198
199 /** Hardware Interrupt break.
200 * @todo not yet implemented. */
201 DBGFEVENT_INTERRUPT_HARDWARE,
202 /** Software Interrupt break.
203 * @todo not yet implemented. */
204 DBGFEVENT_INTERRUPT_SOFTWARE,
205
206 /** The first selectable event.
207 * Whether the debugger wants or doesn't want these events can be configured
208 * via DBGFR3xxx and queried via DBGFR3yyy. */
209 DBGFEVENT_FIRST_SELECTABLE,
210 /** Tripple fault. */
211 DBGFEVENT_TRIPLE_FAULT = DBGFEVENT_FIRST_SELECTABLE,
212
213 /** @name Exception events
214 * The exception events normally represents guest exceptions, but depending on
215 * the execution mode some virtualization exceptions may occure (no nested
216 * paging, raw-mode, ++). When necessary, we will request additional VM exits.
217 * @{ */
218 DBGFEVENT_XCPT_FIRST, /**< The first exception event. */
219 DBGFEVENT_XCPT_DE /**< 0x00 - \#DE - Fault - NoErr - Integer divide error (zero/overflow). */
220 = DBGFEVENT_XCPT_FIRST,
221 DBGFEVENT_XCPT_DB, /**< 0x01 - \#DB - trap/fault - NoErr - debug event. */
222 DBGFEVENT_XCPT_02, /**< 0x02 - Reserved for NMI, see interrupt events. */
223 DBGFEVENT_XCPT_BP, /**< 0x03 - \#BP - Trap - NoErr - Breakpoint, INT 3 instruction. */
224 DBGFEVENT_XCPT_OF, /**< 0x04 - \#OF - Trap - NoErr - Overflow, INTO instruction. */
225 DBGFEVENT_XCPT_BR, /**< 0x05 - \#BR - Fault - NoErr - BOUND Range Exceeded, BOUND instruction. */
226 DBGFEVENT_XCPT_UD, /**< 0x06 - \#UD - Fault - NoErr - Undefined(/Invalid) Opcode. */
227 DBGFEVENT_XCPT_NM, /**< 0x07 - \#NM - Fault - NoErr - Device not available, FP or (F)WAIT instruction. */
228 DBGFEVENT_XCPT_DF, /**< 0x08 - \#DF - Abort - Err=0 - Double fault. */
229 DBGFEVENT_XCPT_09, /**< 0x09 - Int9 - Fault - NoErr - Coprocessor Segment Overrun (obsolete). */
230 DBGFEVENT_XCPT_TS, /**< 0x0a - \#TS - Fault - ErrCd - Invalid TSS, Taskswitch or TSS access. */
231 DBGFEVENT_XCPT_NP, /**< 0x0b - \#NP - Fault - ErrCd - Segment not present. */
232 DBGFEVENT_XCPT_SS, /**< 0x0c - \#SS - Fault - ErrCd - Stack-Segment fault. */
233 DBGFEVENT_XCPT_GP, /**< 0x0d - \#GP - Fault - ErrCd - General protection fault. */
234 DBGFEVENT_XCPT_PF, /**< 0x0e - \#PF - Fault - ErrCd - Page fault. - interrupt gate!!! */
235 DBGFEVENT_XCPT_0f, /**< 0x0f - Rsvd - Resvd - Resvd - Intel Reserved. */
236 DBGFEVENT_XCPT_MF, /**< 0x10 - \#MF - Fault - NoErr - x86 FPU Floating-Point Error (Math fault), FP or (F)WAIT instruction. */
237 DBGFEVENT_XCPT_AC, /**< 0x11 - \#AC - Fault - Err=0 - Alignment Check. */
238 DBGFEVENT_XCPT_MC, /**< 0x12 - \#MC - Abort - NoErr - Machine Check. */
239 DBGFEVENT_XCPT_XF, /**< 0x13 - \#XF - Fault - NoErr - SIMD Floating-Point Exception. */
240 DBGFEVENT_XCPT_VE, /**< 0x14 - \#VE - Fault - Noerr - Virtualization exception. */
241 DBGFEVENT_XCPT_15, /**< 0x15 - Intel Reserved. */
242 DBGFEVENT_XCPT_16, /**< 0x16 - Intel Reserved. */
243 DBGFEVENT_XCPT_17, /**< 0x17 - Intel Reserved. */
244 DBGFEVENT_XCPT_18, /**< 0x18 - Intel Reserved. */
245 DBGFEVENT_XCPT_19, /**< 0x19 - Intel Reserved. */
246 DBGFEVENT_XCPT_1a, /**< 0x1a - Intel Reserved. */
247 DBGFEVENT_XCPT_1b, /**< 0x1b - Intel Reserved. */
248 DBGFEVENT_XCPT_1c, /**< 0x1c - Intel Reserved. */
249 DBGFEVENT_XCPT_1d, /**< 0x1d - Intel Reserved. */
250 DBGFEVENT_XCPT_SX, /**< 0x1e - \#SX - Fault - ErrCd - Security Exception. */
251 DBGFEVENT_XCPT_1f, /**< 0x1f - Intel Reserved. */
252 DBGFEVENT_XCPT_LAST /**< The last exception event. */
253 = DBGFEVENT_XCPT_1f,
254 /** @} */
255
256 /** @name Instruction events
257 * The instruction events exerts all possible effort to intercept the
258 * relevant instructions. However, in some execution modes we won't be able
259 * to catch them. So it goes.
260 * @{ */
261 DBGFEVENT_INSTR_FIRST, /**< The first VM instruction event. */
262 DBGFEVENT_INSTR_HALT /**< Instruction: HALT */
263 = DBGFEVENT_INSTR_FIRST,
264 DBGFEVENT_INSTR_MWAIT, /**< Instruction: MWAIT */
265 DBGFEVENT_INSTR_MONITOR, /**< Instruction: MONITOR */
266 DBGFEVENT_INSTR_CPUID, /**< Instruction: CPUID (missing stuff in raw-mode). */
267 DBGFEVENT_INSTR_INVD, /**< Instruction: INVD */
268 DBGFEVENT_INSTR_WBINVD, /**< Instruction: WBINVD */
269 DBGFEVENT_INSTR_INVLPG, /**< Instruction: INVLPG */
270 DBGFEVENT_INSTR_RDTSC, /**< Instruction: RDTSC */
271 DBGFEVENT_INSTR_RDTSCP, /**< Instruction: RDTSCP */
272 DBGFEVENT_INSTR_RDPMC, /**< Instruction: RDPMC */
273 DBGFEVENT_INSTR_RDMSR, /**< Instruction: RDMSR */
274 DBGFEVENT_INSTR_WRMSR, /**< Instruction: WRMSR */
275 DBGFEVENT_INSTR_CRX_READ, /**< Instruction: CRx read instruction (missing smsw in raw-mode, and reads in general in VT-x). */
276 DBGFEVENT_INSTR_CRX_WRITE, /**< Instruction: CRx write */
277 DBGFEVENT_INSTR_DRX_READ, /**< Instruction: DRx read */
278 DBGFEVENT_INSTR_DRX_WRITE, /**< Instruction: DRx write */
279 DBGFEVENT_INSTR_PAUSE, /**< Instruction: PAUSE instruction (not in raw-mode). */
280 DBGFEVENT_INSTR_XSETBV, /**< Instruction: XSETBV */
281 DBGFEVENT_INSTR_SIDT, /**< Instruction: SIDT */
282 DBGFEVENT_INSTR_LIDT, /**< Instruction: LIDT */
283 DBGFEVENT_INSTR_SGDT, /**< Instruction: SGDT */
284 DBGFEVENT_INSTR_LGDT, /**< Instruction: LGDT */
285 DBGFEVENT_INSTR_SLDT, /**< Instruction: SLDT */
286 DBGFEVENT_INSTR_LLDT, /**< Instruction: LLDT */
287 DBGFEVENT_INSTR_STR, /**< Instruction: STR */
288 DBGFEVENT_INSTR_LTR, /**< Instruction: LTR */
289 DBGFEVENT_INSTR_GETSEC, /**< Instruction: GETSEC */
290 DBGFEVENT_INSTR_RSM, /**< Instruction: RSM */
291 DBGFEVENT_INSTR_RDRAND, /**< Instruction: RDRAND */
292 DBGFEVENT_INSTR_RDSEED, /**< Instruction: RDSEED */
293 DBGFEVENT_INSTR_XSAVES, /**< Instruction: XSAVES */
294 DBGFEVENT_INSTR_XRSTORS, /**< Instruction: XRSTORS */
295 DBGFEVENT_INSTR_VMM_CALL, /**< Instruction: VMCALL (intel) or VMMCALL (AMD) */
296 DBGFEVENT_INSTR_LAST_COMMON /**< Instruction: the last common event. */
297 = DBGFEVENT_INSTR_VMM_CALL,
298 DBGFEVENT_INSTR_VMX_FIRST, /**< Instruction: VT-x - First. */
299 DBGFEVENT_INSTR_VMX_VMCLEAR /**< Instruction: VT-x VMCLEAR */
300 = DBGFEVENT_INSTR_VMX_FIRST,
301 DBGFEVENT_INSTR_VMX_VMLAUNCH, /**< Instruction: VT-x VMLAUNCH */
302 DBGFEVENT_INSTR_VMX_VMPTRLD, /**< Instruction: VT-x VMPTRLD */
303 DBGFEVENT_INSTR_VMX_VMPTRST, /**< Instruction: VT-x VMPTRST */
304 DBGFEVENT_INSTR_VMX_VMREAD, /**< Instruction: VT-x VMREAD */
305 DBGFEVENT_INSTR_VMX_VMRESUME, /**< Instruction: VT-x VMRESUME */
306 DBGFEVENT_INSTR_VMX_VMWRITE, /**< Instruction: VT-x VMWRITE */
307 DBGFEVENT_INSTR_VMX_VMXOFF, /**< Instruction: VT-x VMXOFF */
308 DBGFEVENT_INSTR_VMX_VMXON, /**< Instruction: VT-x VMXON */
309 DBGFEVENT_INSTR_VMX_VMFUNC, /**< Instruction: VT-x VMFUNC */
310 DBGFEVENT_INSTR_VMX_INVEPT, /**< Instruction: VT-x INVEPT */
311 DBGFEVENT_INSTR_VMX_INVVPID, /**< Instruction: VT-x INVVPID */
312 DBGFEVENT_INSTR_VMX_INVPCID, /**< Instruction: VT-x INVPCID */
313 DBGFEVENT_INSTR_VMX_LAST /**< Instruction: VT-x - Last. */
314 = DBGFEVENT_INSTR_VMX_INVPCID,
315 DBGFEVENT_INSTR_SVM_FIRST, /**< Instruction: AMD-V - first */
316 DBGFEVENT_INSTR_SVM_VMRUN /**< Instruction: AMD-V VMRUN */
317 = DBGFEVENT_INSTR_SVM_FIRST,
318 DBGFEVENT_INSTR_SVM_VMLOAD, /**< Instruction: AMD-V VMLOAD */
319 DBGFEVENT_INSTR_SVM_VMSAVE, /**< Instruction: AMD-V VMSAVE */
320 DBGFEVENT_INSTR_SVM_STGI, /**< Instruction: AMD-V STGI */
321 DBGFEVENT_INSTR_SVM_CLGI, /**< Instruction: AMD-V CLGI */
322 DBGFEVENT_INSTR_SVM_LAST /**< Instruction: The last ADM-V VM exit event. */
323 = DBGFEVENT_INSTR_SVM_CLGI,
324 DBGFEVENT_INSTR_LAST /**< Instruction: The last instruction event. */
325 = DBGFEVENT_INSTR_SVM_LAST,
326 /** @} */
327
328
329 /** @name VM exit events.
330 * VM exits events for VT-x and AMD-V execution mode. Many of the VM exits
331 * behind these events are also directly translated into instruction events, but
332 * the difference here is that the exit events will not try provoke the exits.
333 * @{ */
334 DBGFEVENT_EXIT_FIRST, /**< The first VM exit event. */
335 DBGFEVENT_EXIT_TASK_SWITCH /**< Exit: Task switch. */
336 = DBGFEVENT_EXIT_FIRST,
337 DBGFEVENT_EXIT_HALT, /**< Exit: HALT instruction. */
338 DBGFEVENT_EXIT_MWAIT, /**< Exit: MWAIT instruction. */
339 DBGFEVENT_EXIT_MONITOR, /**< Exit: MONITOR instruction. */
340 DBGFEVENT_EXIT_CPUID, /**< Exit: CPUID instruction (missing stuff in raw-mode). */
341 DBGFEVENT_EXIT_INVD, /**< Exit: INVD instruction. */
342 DBGFEVENT_EXIT_WBINVD, /**< Exit: WBINVD instruction. */
343 DBGFEVENT_EXIT_INVLPG, /**< Exit: INVLPG instruction. */
344 DBGFEVENT_EXIT_RDTSC, /**< Exit: RDTSC instruction. */
345 DBGFEVENT_EXIT_RDTSCP, /**< Exit: RDTSCP instruction. */
346 DBGFEVENT_EXIT_RDPMC, /**< Exit: RDPMC instruction. */
347 DBGFEVENT_EXIT_RDMSR, /**< Exit: RDMSR instruction. */
348 DBGFEVENT_EXIT_WRMSR, /**< Exit: WRMSR instruction. */
349 DBGFEVENT_EXIT_CRX_READ, /**< Exit: CRx read instruction (missing smsw in raw-mode, and reads in general in VT-x). */
350 DBGFEVENT_EXIT_CRX_WRITE, /**< Exit: CRx write instruction. */
351 DBGFEVENT_EXIT_DRX_READ, /**< Exit: DRx read instruction. */
352 DBGFEVENT_EXIT_DRX_WRITE, /**< Exit: DRx write instruction. */
353 DBGFEVENT_EXIT_PAUSE, /**< Exit: PAUSE instruction (not in raw-mode). */
354 DBGFEVENT_EXIT_XSETBV, /**< Exit: XSETBV instruction. */
355 DBGFEVENT_EXIT_SIDT, /**< Exit: SIDT instruction. */
356 DBGFEVENT_EXIT_LIDT, /**< Exit: LIDT instruction. */
357 DBGFEVENT_EXIT_SGDT, /**< Exit: SGDT instruction. */
358 DBGFEVENT_EXIT_LGDT, /**< Exit: LGDT instruction. */
359 DBGFEVENT_EXIT_SLDT, /**< Exit: SLDT instruction. */
360 DBGFEVENT_EXIT_LLDT, /**< Exit: LLDT instruction. */
361 DBGFEVENT_EXIT_STR, /**< Exit: STR instruction. */
362 DBGFEVENT_EXIT_LTR, /**< Exit: LTR instruction. */
363 DBGFEVENT_EXIT_GETSEC, /**< Exit: GETSEC instruction. */
364 DBGFEVENT_EXIT_RSM, /**< Exit: RSM instruction. */
365 DBGFEVENT_EXIT_RDRAND, /**< Exit: RDRAND instruction. */
366 DBGFEVENT_EXIT_RDSEED, /**< Exit: RDSEED instruction. */
367 DBGFEVENT_EXIT_XSAVES, /**< Exit: XSAVES instruction. */
368 DBGFEVENT_EXIT_XRSTORS, /**< Exit: XRSTORS instruction. */
369 DBGFEVENT_EXIT_VMM_CALL, /**< Exit: VMCALL (intel) or VMMCALL (AMD) instruction. */
370 DBGFEVENT_EXIT_LAST_COMMON /**< Exit: the last common event. */
371 = DBGFEVENT_EXIT_VMM_CALL,
372 DBGFEVENT_EXIT_VMX_FIRST, /**< Exit: VT-x - First. */
373 DBGFEVENT_EXIT_VMX_VMCLEAR /**< Exit: VT-x VMCLEAR instruction. */
374 = DBGFEVENT_EXIT_VMX_FIRST,
375 DBGFEVENT_EXIT_VMX_VMLAUNCH, /**< Exit: VT-x VMLAUNCH instruction. */
376 DBGFEVENT_EXIT_VMX_VMPTRLD, /**< Exit: VT-x VMPTRLD instruction. */
377 DBGFEVENT_EXIT_VMX_VMPTRST, /**< Exit: VT-x VMPTRST instruction. */
378 DBGFEVENT_EXIT_VMX_VMREAD, /**< Exit: VT-x VMREAD instruction. */
379 DBGFEVENT_EXIT_VMX_VMRESUME, /**< Exit: VT-x VMRESUME instruction. */
380 DBGFEVENT_EXIT_VMX_VMWRITE, /**< Exit: VT-x VMWRITE instruction. */
381 DBGFEVENT_EXIT_VMX_VMXOFF, /**< Exit: VT-x VMXOFF instruction. */
382 DBGFEVENT_EXIT_VMX_VMXON, /**< Exit: VT-x VMXON instruction. */
383 DBGFEVENT_EXIT_VMX_VMFUNC, /**< Exit: VT-x VMFUNC instruction. */
384 DBGFEVENT_EXIT_VMX_INVEPT, /**< Exit: VT-x INVEPT instruction. */
385 DBGFEVENT_EXIT_VMX_INVVPID, /**< Exit: VT-x INVVPID instruction. */
386 DBGFEVENT_EXIT_VMX_INVPCID, /**< Exit: VT-x INVPCID instruction. */
387 DBGFEVENT_EXIT_VMX_EPT_VIOLATION, /**< Exit: VT-x EPT violation. */
388 DBGFEVENT_EXIT_VMX_EPT_MISCONFIG, /**< Exit: VT-x EPT misconfiguration. */
389 DBGFEVENT_EXIT_VMX_VAPIC_ACCESS, /**< Exit: VT-x Virtual APIC page access. */
390 DBGFEVENT_EXIT_VMX_VAPIC_WRITE, /**< Exit: VT-x Virtual APIC write. */
391 DBGFEVENT_EXIT_VMX_LAST /**< Exit: VT-x - Last. */
392 = DBGFEVENT_EXIT_VMX_VAPIC_WRITE,
393 DBGFEVENT_EXIT_SVM_FIRST, /**< Exit: AMD-V - first */
394 DBGFEVENT_EXIT_SVM_VMRUN /**< Exit: AMD-V VMRUN instruction. */
395 = DBGFEVENT_EXIT_SVM_FIRST,
396 DBGFEVENT_EXIT_SVM_VMLOAD, /**< Exit: AMD-V VMLOAD instruction. */
397 DBGFEVENT_EXIT_SVM_VMSAVE, /**< Exit: AMD-V VMSAVE instruction. */
398 DBGFEVENT_EXIT_SVM_STGI, /**< Exit: AMD-V STGI instruction. */
399 DBGFEVENT_EXIT_SVM_CLGI, /**< Exit: AMD-V CLGI instruction. */
400 DBGFEVENT_EXIT_SVM_LAST /**< Exit: The last ADM-V VM exit event. */
401 = DBGFEVENT_EXIT_SVM_CLGI,
402 DBGFEVENT_EXIT_LAST /**< Exit: The last VM exit event. */
403 = DBGFEVENT_EXIT_SVM_LAST,
404 /** @} */
405
406
407 /** Access to an unassigned I/O port.
408 * @todo not yet implemented. */
409 DBGFEVENT_IOPORT_UNASSIGNED,
410 /** Access to an unused I/O port on a device.
411 * @todo not yet implemented. */
412 DBGFEVENT_IOPORT_UNUSED,
413 /** Unassigned memory event.
414 * @todo not yet implemented. */
415 DBGFEVENT_MEMORY_UNASSIGNED,
416 /** Attempt to write to unshadowed ROM.
417 * @todo not yet implemented. */
418 DBGFEVENT_MEMORY_ROM_WRITE,
419
420 /** Windows guest reported BSOD via hyperv MSRs. */
421 DBGFEVENT_BSOD_MSR,
422 /** Windows guest reported BSOD via EFI variables. */
423 DBGFEVENT_BSOD_EFI,
424 /** Windows guest reported BSOD via VMMDev. */
425 DBGFEVENT_BSOD_VMMDEV,
426
427 /** End of valid event values. */
428 DBGFEVENT_END,
429 /** The usual 32-bit hack. */
430 DBGFEVENT_32BIT_HACK = 0x7fffffff
431} DBGFEVENTTYPE;
432AssertCompile(DBGFEVENT_XCPT_LAST - DBGFEVENT_XCPT_FIRST == 0x1f);
433
434/**
435 * The context of an event.
436 */
437typedef enum DBGFEVENTCTX
438{
439 /** The usual invalid entry. */
440 DBGFEVENTCTX_INVALID = 0,
441 /** Raw mode. */
442 DBGFEVENTCTX_RAW,
443 /** Recompiled mode. */
444 DBGFEVENTCTX_REM,
445 /** VMX / AVT mode. */
446 DBGFEVENTCTX_HM,
447 /** Hypervisor context. */
448 DBGFEVENTCTX_HYPER,
449 /** Other mode */
450 DBGFEVENTCTX_OTHER,
451
452 /** The usual 32-bit hack */
453 DBGFEVENTCTX_32BIT_HACK = 0x7fffffff
454} DBGFEVENTCTX;
455
456/**
457 * VMM Debug Event.
458 */
459typedef struct DBGFEVENT
460{
461 /** Type. */
462 DBGFEVENTTYPE enmType;
463 /** Context */
464 DBGFEVENTCTX enmCtx;
465 /** Type specific data. */
466 union
467 {
468 /** Fatal error details. */
469 struct
470 {
471 /** The GC return code. */
472 int rc;
473 } FatalError;
474
475 /** Source location. */
476 struct
477 {
478 /** File name. */
479 R3PTRTYPE(const char *) pszFile;
480 /** Function name. */
481 R3PTRTYPE(const char *) pszFunction;
482 /** Message. */
483 R3PTRTYPE(const char *) pszMessage;
484 /** Line number. */
485 unsigned uLine;
486 } Src;
487
488 /** Assertion messages. */
489 struct
490 {
491 /** The first message. */
492 R3PTRTYPE(const char *) pszMsg1;
493 /** The second message. */
494 R3PTRTYPE(const char *) pszMsg2;
495 } Assert;
496
497 /** Breakpoint. */
498 struct DBGFEVENTBP
499 {
500 /** The identifier of the breakpoint which was hit. */
501 RTUINT iBp;
502 } Bp;
503
504 /** Generic debug event. */
505 struct DBGFEVENTGENERIC
506 {
507 /** Number of arguments. */
508 uint8_t cArgs;
509 /** Alignmnet padding. */
510 uint8_t uPadding[7];
511 /** Arguments. */
512 uint64_t auArgs[6];
513 } Generic;
514
515 /** Padding for ensuring that the structure is 8 byte aligned. */
516 uint64_t au64Padding[7];
517 } u;
518} DBGFEVENT;
519AssertCompileSizeAlignment(DBGFEVENT, 8);
520/** Pointer to VMM Debug Event. */
521typedef DBGFEVENT *PDBGFEVENT;
522/** Pointer to const VMM Debug Event. */
523typedef const DBGFEVENT *PCDBGFEVENT;
524
525#ifdef IN_RING3 /* The event API only works in ring-3. */
526
527/** @def DBGFSTOP
528 * Stops the debugger raising a DBGFEVENT_DEVELOPER_STOP event.
529 *
530 * @returns VBox status code which must be propagated up to EM if not VINF_SUCCESS.
531 * @param pVM The cross context VM structure.
532 */
533# ifdef VBOX_STRICT
534# define DBGFSTOP(pVM) DBGFR3EventSrc(pVM, DBGFEVENT_DEV_STOP, __FILE__, __LINE__, __PRETTY_FUNCTION__, NULL)
535# else
536# define DBGFSTOP(pVM) VINF_SUCCESS
537# endif
538
539VMMR3_INT_DECL(int) DBGFR3Init(PVM pVM);
540VMMR3_INT_DECL(int) DBGFR3Term(PVM pVM);
541VMMR3_INT_DECL(void) DBGFR3PowerOff(PVM pVM);
542VMMR3_INT_DECL(void) DBGFR3Relocate(PVM pVM, RTGCINTPTR offDelta);
543
544VMMR3_INT_DECL(int) DBGFR3VMMForcedAction(PVM pVM, PVMCPU pVCpu);
545VMMR3_INT_DECL(VBOXSTRICTRC) DBGFR3EventHandlePending(PVM pVM, PVMCPU pVCpu);
546VMMR3DECL(int) DBGFR3Event(PVM pVM, DBGFEVENTTYPE enmEvent);
547VMMR3DECL(int) DBGFR3EventSrc(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszFile, unsigned uLine,
548 const char *pszFunction, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(6, 7);
549VMMR3DECL(int) DBGFR3EventSrcV(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszFile, unsigned uLine,
550 const char *pszFunction, const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(6, 0);
551VMMR3_INT_DECL(int) DBGFR3EventAssertion(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszMsg1, const char *pszMsg2);
552VMMR3_INT_DECL(int) DBGFR3EventBreakpoint(PVM pVM, DBGFEVENTTYPE enmEvent);
553
554VMMR3_INT_DECL(int) DBGFR3PrgStep(PVMCPU pVCpu);
555
556VMMR3DECL(int) DBGFR3Attach(PUVM pUVM);
557VMMR3DECL(int) DBGFR3Detach(PUVM pUVM);
558VMMR3DECL(int) DBGFR3EventWait(PUVM pUVM, RTMSINTERVAL cMillies, PCDBGFEVENT *ppEvent);
559VMMR3DECL(int) DBGFR3Halt(PUVM pUVM);
560VMMR3DECL(bool) DBGFR3IsHalted(PUVM pUVM);
561VMMR3DECL(int) DBGFR3QueryWaitable(PUVM pUVM);
562VMMR3DECL(int) DBGFR3Resume(PUVM pUVM);
563VMMR3DECL(int) DBGFR3InjectNMI(PUVM pUVM, VMCPUID idCpu);
564VMMR3DECL(int) DBGFR3Step(PUVM pUVM, VMCPUID idCpu);
565VMMR3DECL(int) DBGFR3StepEx(PUVM pUVM, VMCPUID idCpu, uint32_t fFlags, PCDBGFADDRESS pStopPcAddr,
566 PCDBGFADDRESS pStopPopAddr, RTGCUINTPTR cbStopPop, uint32_t cMaxSteps);
567
568/** @name DBGF_STEP_F_XXX - Flags for DBGFR3StepEx.
569 *
570 * @note The stop filters are not applied to the starting instruction.
571 *
572 * @{ */
573/** Step into CALL, INT, SYSCALL and SYSENTER instructions. */
574#define DBGF_STEP_F_INTO RT_BIT_32(0)
575/** Step over CALL, INT, SYSCALL and SYSENTER instruction when considering
576 * what's "next". */
577#define DBGF_STEP_F_OVER RT_BIT_32(1)
578
579/** Stop on the next CALL, INT, SYSCALL, SYSENTER instruction. */
580#define DBGF_STEP_F_STOP_ON_CALL RT_BIT_32(8)
581/** Stop on the next RET, IRET, SYSRET, SYSEXIT instruction. */
582#define DBGF_STEP_F_STOP_ON_RET RT_BIT_32(9)
583/** Stop after the next RET, IRET, SYSRET, SYSEXIT instruction. */
584#define DBGF_STEP_F_STOP_AFTER_RET RT_BIT_32(10)
585/** Stop on the given address.
586 * The comparison will be made using effective (flat) addresses. */
587#define DBGF_STEP_F_STOP_ON_ADDRESS RT_BIT_32(11)
588/** Stop when the stack pointer pops to or past the given address.
589 * The comparison will be made using effective (flat) addresses. */
590#define DBGF_STEP_F_STOP_ON_STACK_POP RT_BIT_32(12)
591/** Mask of stop filter flags. */
592#define DBGF_STEP_F_STOP_FILTER_MASK UINT32_C(0x00001f00)
593
594/** Mask of valid flags. */
595#define DBGF_STEP_F_VALID_MASK UINT32_C(0x00001f03)
596/** @} */
597
598/**
599 * Event configuration array element, see DBGFR3EventConfigEx.
600 */
601typedef struct DBGFEVENTCONFIG
602{
603 /** The event to configure */
604 DBGFEVENTTYPE enmType;
605 /** The new state. */
606 bool fEnabled;
607 /** Unused. */
608 uint8_t abUnused[3];
609} DBGFEVENTCONFIG;
610/** Pointer to an event config. */
611typedef DBGFEVENTCONFIG *PDBGFEVENTCONFIG;
612/** Pointer to a const event config. */
613typedef const DBGFEVENTCONFIG *PCDBGFEVENTCONFIG;
614
615VMMR3DECL(int) DBGFR3EventConfigEx(PUVM pUVM, PCDBGFEVENTCONFIG paConfigs, size_t cConfigs);
616VMMR3DECL(int) DBGFR3EventConfig(PUVM pUVM, DBGFEVENTTYPE enmEvent, bool fEnabled);
617VMMR3DECL(bool) DBGFR3EventIsEnabled(PUVM pUVM, DBGFEVENTTYPE enmEvent);
618VMMR3DECL(int) DBGFR3EventQuery(PUVM pUVM, PDBGFEVENTCONFIG paConfigs, size_t cConfigs);
619
620/** @name DBGFINTERRUPTSTATE_XXX - interrupt break state.
621 * @{ */
622#define DBGFINTERRUPTSTATE_DISABLED 0
623#define DBGFINTERRUPTSTATE_ENABLED 1
624#define DBGFINTERRUPTSTATE_DONT_TOUCH 2
625/** @} */
626
627/**
628 * Interrupt break state configuration entry.
629 */
630typedef struct DBGFINTERRUPTCONFIG
631{
632 /** The interrupt number. */
633 uint8_t iInterrupt;
634 /** The hardware interrupt state (DBGFINTERRUPTSTATE_XXX). */
635 uint8_t enmHardState;
636 /** The software interrupt state (DBGFINTERRUPTSTATE_XXX). */
637 uint8_t enmSoftState;
638} DBGFINTERRUPTCONFIG;
639/** Pointer to an interrupt break state config entyr. */
640typedef DBGFINTERRUPTCONFIG *PDBGFINTERRUPTCONFIG;
641/** Pointer to a const interrupt break state config entyr. */
642typedef DBGFINTERRUPTCONFIG const *PCDBGFINTERRUPTCONFIG;
643
644VMMR3DECL(int) DBGFR3InterruptConfigEx(PUVM pUVM, PCDBGFINTERRUPTCONFIG paConfigs, size_t cConfigs);
645VMMR3DECL(int) DBGFR3InterruptHardwareConfig(PUVM pUVM, uint8_t iInterrupt, bool fEnabled);
646VMMR3DECL(int) DBGFR3InterruptSoftwareConfig(PUVM pUVM, uint8_t iInterrupt, bool fEnabled);
647VMMR3DECL(int) DBGFR3InterruptHardwareIsEnabled(PUVM pUVM, uint8_t iInterrupt);
648VMMR3DECL(int) DBGFR3InterruptSoftwareIsEnabled(PUVM pUVM, uint8_t iInterrupt);
649
650#endif /* IN_RING3 */
651
652/** @def DBGF_IS_EVENT_ENABLED
653 * Checks if a selectable debug event is enabled or not (fast).
654 *
655 * @returns true/false.
656 * @param a_pVM Pointer to the cross context VM structure.
657 * @param a_enmEvent The selectable event to check.
658 * @remarks Only for use internally in the VMM. Use DBGFR3EventIsEnabled elsewhere.
659 */
660#if defined(VBOX_STRICT) && defined(RT_COMPILER_SUPPORTS_LAMBDA)
661# define DBGF_IS_EVENT_ENABLED(a_pVM, a_enmEvent) \
662 ([](PVM a_pLambdaVM, DBGFEVENTTYPE a_enmLambdaEvent) -> bool { \
663 Assert( a_enmLambdaEvent >= DBGFEVENT_FIRST_SELECTABLE \
664 || a_enmLambdaEvent == DBGFEVENT_INTERRUPT_HARDWARE \
665 || a_enmLambdaEvent == DBGFEVENT_INTERRUPT_SOFTWARE); \
666 Assert(a_enmLambdaEvent < DBGFEVENT_END); \
667 return ASMBitTest(&a_pLambdaVM->dbgf.ro.bmSelectedEvents, a_enmLambdaEvent); \
668 }(a_pVM, a_enmEvent))
669#elif defined(VBOX_STRICT) && defined(__GNUC__)
670# define DBGF_IS_EVENT_ENABLED(a_pVM, a_enmEvent) \
671 __extension__ ({ \
672 Assert( (a_enmEvent) >= DBGFEVENT_FIRST_SELECTABLE \
673 || (a_enmEvent) == DBGFEVENT_INTERRUPT_HARDWARE \
674 || (a_enmEvent) == DBGFEVENT_INTERRUPT_SOFTWARE); \
675 Assert((a_enmEvent) < DBGFEVENT_END); \
676 ASMBitTest(&(a_pVM)->dbgf.ro.bmSelectedEvents, (a_enmEvent)); \
677 })
678#else
679# define DBGF_IS_EVENT_ENABLED(a_pVM, a_enmEvent) \
680 ASMBitTest(&(a_pVM)->dbgf.ro.bmSelectedEvents, (a_enmEvent))
681#endif
682
683
684/** @def DBGF_IS_HARDWARE_INT_ENABLED
685 * Checks if hardware interrupt interception is enabled or not for an interrupt.
686 *
687 * @returns true/false.
688 * @param a_pVM Pointer to the cross context VM structure.
689 * @param a_iInterrupt Interrupt to check.
690 * @remarks Only for use internally in the VMM. Use
691 * DBGFR3InterruptHardwareIsEnabled elsewhere.
692 */
693#define DBGF_IS_HARDWARE_INT_ENABLED(a_pVM, a_iInterrupt) \
694 ASMBitTest(&(a_pVM)->dbgf.ro.bmHardIntBreakpoints, (uint8_t)(a_iInterrupt))
695
696/** @def DBGF_IS_SOFTWARE_INT_ENABLED
697 * Checks if software interrupt interception is enabled or not for an interrupt.
698 *
699 * @returns true/false.
700 * @param a_pVM Pointer to the cross context VM structure.
701 * @param a_iInterrupt Interrupt to check.
702 * @remarks Only for use internally in the VMM. Use
703 * DBGFR3InterruptSoftwareIsEnabled elsewhere.
704 */
705#define DBGF_IS_SOFTWARE_INT_ENABLED(a_pVM, a_iInterrupt) \
706 ASMBitTest(&(a_pVM)->dbgf.ro.bmSoftIntBreakpoints, (uint8_t)(a_iInterrupt))
707
708
709
710/** Breakpoint type. */
711typedef enum DBGFBPTYPE
712{
713 /** Free breakpoint entry. */
714 DBGFBPTYPE_FREE = 0,
715 /** Debug register. */
716 DBGFBPTYPE_REG,
717 /** INT 3 instruction. */
718 DBGFBPTYPE_INT3,
719 /** Recompiler. */
720 DBGFBPTYPE_REM,
721 /** Port I/O breakpoint. */
722 DBGFBPTYPE_PORT_IO,
723 /** Memory mapped I/O breakpoint. */
724 DBGFBPTYPE_MMIO,
725 /** ensure 32-bit size. */
726 DBGFBPTYPE_32BIT_HACK = 0x7fffffff
727} DBGFBPTYPE;
728
729
730/** @name DBGFBPIOACCESS_XXX - I/O (port + mmio) access types.
731 * @{ */
732/** Byte sized read accesses. */
733#define DBGFBPIOACCESS_READ_BYTE UINT32_C(0x00000001)
734/** Word sized accesses. */
735#define DBGFBPIOACCESS_READ_WORD UINT32_C(0x00000002)
736/** Double word sized accesses. */
737#define DBGFBPIOACCESS_READ_DWORD UINT32_C(0x00000004)
738/** Quad word sized accesses - not available for I/O ports. */
739#define DBGFBPIOACCESS_READ_QWORD UINT32_C(0x00000008)
740/** Other sized accesses - not available for I/O ports. */
741#define DBGFBPIOACCESS_READ_OTHER UINT32_C(0x00000010)
742/** Read mask. */
743#define DBGFBPIOACCESS_READ_MASK UINT32_C(0x0000001f)
744
745/** Byte sized write accesses. */
746#define DBGFBPIOACCESS_WRITE_BYTE UINT32_C(0x00000100)
747/** Word sized write accesses. */
748#define DBGFBPIOACCESS_WRITE_WORD UINT32_C(0x00000200)
749/** Double word sized write accesses. */
750#define DBGFBPIOACCESS_WRITE_DWORD UINT32_C(0x00000400)
751/** Quad word sized write accesses - not available for I/O ports. */
752#define DBGFBPIOACCESS_WRITE_QWORD UINT32_C(0x00000800)
753/** Other sized write accesses - not available for I/O ports. */
754#define DBGFBPIOACCESS_WRITE_OTHER UINT32_C(0x00001000)
755/** Write mask. */
756#define DBGFBPIOACCESS_WRITE_MASK UINT32_C(0x00001f00)
757
758/** All kind of access (read, write, all sizes). */
759#define DBGFBPIOACCESS_ALL UINT32_C(0x00001f1f)
760
761/** The acceptable mask for I/O ports. */
762#define DBGFBPIOACCESS_VALID_MASK_PORT_IO UINT32_C(0x00000303)
763/** The acceptable mask for MMIO. */
764#define DBGFBPIOACCESS_VALID_MASK_MMIO UINT32_C(0x00001f1f)
765/** @} */
766
767/**
768 * A Breakpoint.
769 */
770typedef struct DBGFBP
771{
772 /** The number of breakpoint hits. */
773 uint64_t cHits;
774 /** The hit number which starts to trigger the breakpoint. */
775 uint64_t iHitTrigger;
776 /** The hit number which stops triggering the breakpoint (disables it).
777 * Use ~(uint64_t)0 if it should never stop. */
778 uint64_t iHitDisable;
779 /** The breakpoint id. */
780 uint16_t iBp;
781 /** The breakpoint status - enabled or disabled. */
782 bool fEnabled;
783 /** The breakpoint type. */
784 DBGFBPTYPE enmType;
785
786 /** Union of type specific data. */
787 union
788 {
789 /** The flat GC address breakpoint address for REG, INT3 and REM breakpoints. */
790 RTGCUINTPTR GCPtr;
791
792 /** Debug register data. */
793 struct DBGFBPREG
794 {
795 /** The flat GC address of the breakpoint. */
796 RTGCUINTPTR GCPtr;
797 /** The debug register number. */
798 uint8_t iReg;
799 /** The access type (one of the X86_DR7_RW_* value). */
800 uint8_t fType;
801 /** The access size. */
802 uint8_t cb;
803 } Reg;
804
805 /** INT3 breakpoint data. */
806 struct DBGFBPINT3
807 {
808 /** The flat GC address of the breakpoint. */
809 RTGCUINTPTR GCPtr;
810 /** The physical address of the breakpoint. */
811 RTGCPHYS PhysAddr;
812 /** The byte value we replaced by the INT 3 instruction. */
813 uint8_t bOrg;
814 } Int3;
815
816 /** Recompiler breakpoint data. */
817 struct DBGFBPREM
818 {
819 /** The flat GC address of the breakpoint.
820 * (PC register value?) */
821 RTGCUINTPTR GCPtr;
822 } Rem;
823
824 /** I/O port breakpoint data. */
825 struct DBGFBPPORTIO
826 {
827 /** The first port. */
828 RTIOPORT uPort;
829 /** The number of ports. */
830 RTIOPORT cPorts;
831 /** Valid DBGFBPIOACCESS_XXX selection, max DWORD size. */
832 uint32_t fAccess;
833 } PortIo;
834
835 /** Memory mapped I/O breakpoint data. */
836 struct DBGFBPMMIO
837 {
838 /** The first MMIO address. */
839 RTGCPHYS PhysAddr;
840 /** The size of the MMIO range in bytes. */
841 uint32_t cb;
842 /** Valid DBGFBPIOACCESS_XXX selection, max DWORD size. */
843 uint32_t fAccess;
844 } Mmio;
845
846 /** Paddind to ensure that the size is identical on win32 and linux. */
847 uint64_t u64Padding[3];
848 } u;
849} DBGFBP;
850AssertCompileMembersAtSameOffset(DBGFBP, u.GCPtr, DBGFBP, u.Reg.GCPtr);
851AssertCompileMembersAtSameOffset(DBGFBP, u.GCPtr, DBGFBP, u.Int3.GCPtr);
852AssertCompileMembersAtSameOffset(DBGFBP, u.GCPtr, DBGFBP, u.Rem.GCPtr);
853
854/** Pointer to a breakpoint. */
855typedef DBGFBP *PDBGFBP;
856/** Pointer to a const breakpoint. */
857typedef const DBGFBP *PCDBGFBP;
858
859#ifdef IN_RING3 /* The breakpoint management API is only available in ring-3. */
860VMMR3DECL(int) DBGFR3BpSetInt3(PUVM pUVM, VMCPUID idSrcCpu, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
861VMMR3DECL(int) DBGFR3BpSetReg(PUVM pUVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable,
862 uint8_t fType, uint8_t cb, uint32_t *piBp);
863VMMR3DECL(int) DBGFR3BpSetREM(PUVM pUVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
864VMMR3DECL(int) DBGFR3BpSetPortIo(PUVM pUVM, RTIOPORT uPort, RTIOPORT cPorts, uint32_t fAccess,
865 uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
866VMMR3DECL(int) DBGFR3BpSetMmio(PUVM pUVM, RTGCPHYS GCPhys, uint32_t cb, uint32_t fAccess,
867 uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
868VMMR3DECL(int) DBGFR3BpClear(PUVM pUVM, uint32_t iBp);
869VMMR3DECL(int) DBGFR3BpEnable(PUVM pUVM, uint32_t iBp);
870VMMR3DECL(int) DBGFR3BpDisable(PUVM pUVM, uint32_t iBp);
871
872/**
873 * Breakpoint enumeration callback function.
874 *
875 * @returns VBox status code.
876 * The enumeration stops on failure status and VINF_CALLBACK_RETURN.
877 * @param pUVM The user mode VM handle.
878 * @param pvUser The user argument.
879 * @param pBp Pointer to the breakpoint information. (readonly)
880 */
881typedef DECLCALLBACK(int) FNDBGFBPENUM(PUVM pUVM, void *pvUser, PCDBGFBP pBp);
882/** Pointer to a breakpoint enumeration callback function. */
883typedef FNDBGFBPENUM *PFNDBGFBPENUM;
884
885VMMR3DECL(int) DBGFR3BpEnum(PUVM pUVM, PFNDBGFBPENUM pfnCallback, void *pvUser);
886#endif /* IN_RING3 */
887
888VMM_INT_DECL(RTGCUINTREG) DBGFBpGetDR7(PVM pVM);
889VMM_INT_DECL(RTGCUINTREG) DBGFBpGetDR0(PVM pVM);
890VMM_INT_DECL(RTGCUINTREG) DBGFBpGetDR1(PVM pVM);
891VMM_INT_DECL(RTGCUINTREG) DBGFBpGetDR2(PVM pVM);
892VMM_INT_DECL(RTGCUINTREG) DBGFBpGetDR3(PVM pVM);
893VMM_INT_DECL(bool) DBGFBpIsHwArmed(PVM pVM);
894VMM_INT_DECL(bool) DBGFBpIsHwIoArmed(PVM pVM);
895VMM_INT_DECL(bool) DBGFBpIsInt3Armed(PVM pVM);
896VMM_INT_DECL(bool) DBGFIsStepping(PVMCPU pVCpu);
897VMM_INT_DECL(VBOXSTRICTRC) DBGFBpCheckIo(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, RTIOPORT uIoPort, uint8_t cbValue);
898VMM_INT_DECL(VBOXSTRICTRC) DBGFEventGenericWithArgs(PVM pVM, PVMCPU pVCpu, DBGFEVENTTYPE enmEvent, DBGFEVENTCTX enmCtx,
899 unsigned cArgs, ...);
900
901
902#ifdef IN_RING3 /* The CPU mode API only works in ring-3. */
903VMMR3DECL(CPUMMODE) DBGFR3CpuGetMode(PUVM pUVM, VMCPUID idCpu);
904VMMR3DECL(VMCPUID) DBGFR3CpuGetCount(PUVM pUVM);
905VMMR3DECL(bool) DBGFR3CpuIsIn64BitCode(PUVM pUVM, VMCPUID idCpu);
906VMMR3DECL(bool) DBGFR3CpuIsInV86Code(PUVM pUVM, VMCPUID idCpu);
907#endif
908
909
910
911#ifdef IN_RING3 /* The info callbacks API only works in ring-3. */
912
913/**
914 * Info helper callback structure.
915 */
916typedef struct DBGFINFOHLP
917{
918 /**
919 * Print formatted string.
920 *
921 * @param pHlp Pointer to this structure.
922 * @param pszFormat The format string.
923 * @param ... Arguments.
924 */
925 DECLCALLBACKMEMBER(void, pfnPrintf)(PCDBGFINFOHLP pHlp, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3);
926
927 /**
928 * Print formatted string.
929 *
930 * @param pHlp Pointer to this structure.
931 * @param pszFormat The format string.
932 * @param args Argument list.
933 */
934 DECLCALLBACKMEMBER(void, pfnPrintfV)(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(2, 0);
935} DBGFINFOHLP;
936
937
938/**
939 * Info handler, device version.
940 *
941 * @param pDevIns The device instance which registered the info.
942 * @param pHlp Callback functions for doing output.
943 * @param pszArgs Argument string. Optional and specific to the handler.
944 */
945typedef DECLCALLBACK(void) FNDBGFHANDLERDEV(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
946/** Pointer to a FNDBGFHANDLERDEV function. */
947typedef FNDBGFHANDLERDEV *PFNDBGFHANDLERDEV;
948
949/**
950 * Info handler, USB device version.
951 *
952 * @param pUsbIns The USB device instance which registered the info.
953 * @param pHlp Callback functions for doing output.
954 * @param pszArgs Argument string. Optional and specific to the handler.
955 */
956typedef DECLCALLBACK(void) FNDBGFHANDLERUSB(PPDMUSBINS pUsbIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
957/** Pointer to a FNDBGFHANDLERUSB function. */
958typedef FNDBGFHANDLERUSB *PFNDBGFHANDLERUSB;
959
960/**
961 * Info handler, driver version.
962 *
963 * @param pDrvIns The driver instance which registered the info.
964 * @param pHlp Callback functions for doing output.
965 * @param pszArgs Argument string. Optional and specific to the handler.
966 */
967typedef DECLCALLBACK(void) FNDBGFHANDLERDRV(PPDMDRVINS pDrvIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
968/** Pointer to a FNDBGFHANDLERDRV function. */
969typedef FNDBGFHANDLERDRV *PFNDBGFHANDLERDRV;
970
971/**
972 * Info handler, internal version.
973 *
974 * @param pVM The cross context VM structure.
975 * @param pHlp Callback functions for doing output.
976 * @param pszArgs Argument string. Optional and specific to the handler.
977 */
978typedef DECLCALLBACK(void) FNDBGFHANDLERINT(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
979/** Pointer to a FNDBGFHANDLERINT function. */
980typedef FNDBGFHANDLERINT *PFNDBGFHANDLERINT;
981
982/**
983 * Info handler, external version.
984 *
985 * @param pvUser User argument.
986 * @param pHlp Callback functions for doing output.
987 * @param pszArgs Argument string. Optional and specific to the handler.
988 */
989typedef DECLCALLBACK(void) FNDBGFHANDLEREXT(void *pvUser, PCDBGFINFOHLP pHlp, const char *pszArgs);
990/** Pointer to a FNDBGFHANDLEREXT function. */
991typedef FNDBGFHANDLEREXT *PFNDBGFHANDLEREXT;
992
993
994/** @name Flags for the info registration functions.
995 * @{ */
996/** The handler must run on the EMT. */
997#define DBGFINFO_FLAGS_RUN_ON_EMT RT_BIT(0)
998/** Call on all EMTs when a specific isn't specified. */
999#define DBGFINFO_FLAGS_ALL_EMTS RT_BIT(1)
1000/** @} */
1001
1002VMMR3_INT_DECL(int) DBGFR3InfoRegisterDevice(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler, PPDMDEVINS pDevIns);
1003VMMR3_INT_DECL(int) DBGFR3InfoRegisterDriver(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler, PPDMDRVINS pDrvIns);
1004VMMR3_INT_DECL(int) DBGFR3InfoRegisterInternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler);
1005VMMR3_INT_DECL(int) DBGFR3InfoRegisterInternalEx(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler, uint32_t fFlags);
1006VMMR3DECL(int) DBGFR3InfoRegisterExternal(PUVM pUVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLEREXT pfnHandler, void *pvUser);
1007VMMR3_INT_DECL(int) DBGFR3InfoDeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName);
1008VMMR3_INT_DECL(int) DBGFR3InfoDeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName);
1009VMMR3_INT_DECL(int) DBGFR3InfoDeregisterInternal(PVM pVM, const char *pszName);
1010VMMR3DECL(int) DBGFR3InfoDeregisterExternal(PUVM pUVM, const char *pszName);
1011VMMR3DECL(int) DBGFR3Info(PUVM pUVM, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp);
1012VMMR3DECL(int) DBGFR3InfoEx(PUVM pUVM, VMCPUID idCpu, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp);
1013VMMR3DECL(int) DBGFR3InfoLogRel(PUVM pUVM, const char *pszName, const char *pszArgs);
1014VMMR3DECL(int) DBGFR3InfoStdErr(PUVM pUVM, const char *pszName, const char *pszArgs);
1015VMMR3_INT_DECL(int) DBGFR3InfoMulti(PVM pVM, const char *pszIncludePat, const char *pszExcludePat,
1016 const char *pszSepFmt, PCDBGFINFOHLP pHlp);
1017
1018/** @def DBGFR3_INFO_LOG
1019 * Display a piece of info writing to the log if enabled.
1020 *
1021 * This is for execution on EMTs and will only show the items on the calling
1022 * EMT. This is to avoid deadlocking against other CPUs if a rendezvous is
1023 * initiated in parallel to this call. (Besides, nobody really wants or need
1024 * info for the other EMTs when using this macro.)
1025 *
1026 * @param a_pVM The shared VM handle.
1027 * @param a_pVCpu The cross context per CPU structure of the calling EMT.
1028 * @param a_pszName The identifier of the info to display.
1029 * @param a_pszArgs Arguments to the info handler.
1030 */
1031#ifdef LOG_ENABLED
1032# define DBGFR3_INFO_LOG(a_pVM, a_pVCpu, a_pszName, a_pszArgs) \
1033 do { \
1034 if (LogIsEnabled()) \
1035 DBGFR3InfoEx((a_pVM)->pUVM, (a_pVCpu)->idCpu, a_pszName, a_pszArgs, NULL); \
1036 } while (0)
1037#else
1038# define DBGFR3_INFO_LOG(a_pVM, a_pVCpu, a_pszName, a_pszArgs) do { } while (0)
1039#endif
1040
1041/** @def DBGFR3_INFO_LOG_SAFE
1042 * Display a piece of info (rendezvous safe) writing to the log if enabled.
1043 *
1044 * @param a_pVM The shared VM handle.
1045 * @param a_pszName The identifier of the info to display.
1046 * @param a_pszArgs Arguments to the info handler.
1047 *
1048 * @remarks Use DBGFR3_INFO_LOG where ever possible!
1049 */
1050#ifdef LOG_ENABLED
1051# define DBGFR3_INFO_LOG_SAFE(a_pVM, a_pszName, a_pszArgs) \
1052 do { \
1053 if (LogIsEnabled()) \
1054 DBGFR3Info((a_pVM)->pUVM, a_pszName, a_pszArgs, NULL); \
1055 } while (0)
1056#else
1057# define DBGFR3_INFO_LOG_SAFE(a_pVM, a_pszName, a_pszArgs) do { } while (0)
1058#endif
1059
1060/**
1061 * Enumeration callback for use with DBGFR3InfoEnum.
1062 *
1063 * @returns VBox status code.
1064 * A status code indicating failure will end the enumeration
1065 * and DBGFR3InfoEnum will return with that status code.
1066 * @param pUVM The user mode VM handle.
1067 * @param pszName Info identifier name.
1068 * @param pszDesc The description.
1069 */
1070typedef DECLCALLBACK(int) FNDBGFINFOENUM(PUVM pUVM, const char *pszName, const char *pszDesc, void *pvUser);
1071/** Pointer to a FNDBGFINFOENUM function. */
1072typedef FNDBGFINFOENUM *PFNDBGFINFOENUM;
1073
1074VMMR3DECL(int) DBGFR3InfoEnum(PUVM pUVM, PFNDBGFINFOENUM pfnCallback, void *pvUser);
1075VMMR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogHlp(void);
1076VMMR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogRelHlp(void);
1077
1078#endif /* IN_RING3 */
1079
1080
1081#ifdef IN_RING3 /* The log contrl API only works in ring-3. */
1082VMMR3DECL(int) DBGFR3LogModifyGroups(PUVM pUVM, const char *pszGroupSettings);
1083VMMR3DECL(int) DBGFR3LogModifyFlags(PUVM pUVM, const char *pszFlagSettings);
1084VMMR3DECL(int) DBGFR3LogModifyDestinations(PUVM pUVM, const char *pszDestSettings);
1085#endif /* IN_RING3 */
1086
1087#ifdef IN_RING3 /* The debug information management APIs only works in ring-3. */
1088
1089/** Max length (including '\\0') of a symbol name. */
1090#define DBGF_SYMBOL_NAME_LENGTH 512
1091
1092/**
1093 * Debug symbol.
1094 */
1095typedef struct DBGFSYMBOL
1096{
1097 /** Symbol value (address). */
1098 RTGCUINTPTR Value;
1099 /** Symbol size. */
1100 uint32_t cb;
1101 /** Symbol Flags. (reserved). */
1102 uint32_t fFlags;
1103 /** Symbol name. */
1104 char szName[DBGF_SYMBOL_NAME_LENGTH];
1105} DBGFSYMBOL;
1106/** Pointer to debug symbol. */
1107typedef DBGFSYMBOL *PDBGFSYMBOL;
1108/** Pointer to const debug symbol. */
1109typedef const DBGFSYMBOL *PCDBGFSYMBOL;
1110
1111/**
1112 * Debug line number information.
1113 */
1114typedef struct DBGFLINE
1115{
1116 /** Address. */
1117 RTGCUINTPTR Address;
1118 /** Line number. */
1119 uint32_t uLineNo;
1120 /** Filename. */
1121 char szFilename[260];
1122} DBGFLINE;
1123/** Pointer to debug line number. */
1124typedef DBGFLINE *PDBGFLINE;
1125/** Pointer to const debug line number. */
1126typedef const DBGFLINE *PCDBGFLINE;
1127
1128/** @name Address spaces aliases.
1129 * @{ */
1130/** The guest global address space. */
1131#define DBGF_AS_GLOBAL ((RTDBGAS)-1)
1132/** The guest kernel address space.
1133 * This is usually resolves to the same as DBGF_AS_GLOBAL. */
1134#define DBGF_AS_KERNEL ((RTDBGAS)-2)
1135/** The physical address space. */
1136#define DBGF_AS_PHYS ((RTDBGAS)-3)
1137/** Raw-mode context. */
1138#define DBGF_AS_RC ((RTDBGAS)-4)
1139/** Ring-0 context. */
1140#define DBGF_AS_R0 ((RTDBGAS)-5)
1141/** Raw-mode context and then global guest context.
1142 * When used for looking up information, it works as if the call was first made
1143 * with DBGF_AS_RC and then on failure with DBGF_AS_GLOBAL. When called for
1144 * making address space changes, it works as if DBGF_AS_RC was used. */
1145#define DBGF_AS_RC_AND_GC_GLOBAL ((RTDBGAS)-6)
1146
1147/** The first special one. */
1148#define DBGF_AS_FIRST DBGF_AS_RC_AND_GC_GLOBAL
1149/** The last special one. */
1150#define DBGF_AS_LAST DBGF_AS_GLOBAL
1151#endif
1152/** The number of special address space handles. */
1153#define DBGF_AS_COUNT (6U)
1154#ifdef IN_RING3
1155/** Converts an alias handle to an array index. */
1156#define DBGF_AS_ALIAS_2_INDEX(hAlias) \
1157 ( (uintptr_t)(hAlias) - (uintptr_t)DBGF_AS_FIRST )
1158/** Predicat macro that check if the specified handle is an alias. */
1159#define DBGF_AS_IS_ALIAS(hAlias) \
1160 ( DBGF_AS_ALIAS_2_INDEX(hAlias) < DBGF_AS_COUNT )
1161/** Predicat macro that check if the specified alias is a fixed one or not. */
1162#define DBGF_AS_IS_FIXED_ALIAS(hAlias) \
1163 ( DBGF_AS_ALIAS_2_INDEX(hAlias) < (uintptr_t)DBGF_AS_PHYS - (uintptr_t)DBGF_AS_FIRST + 1U )
1164
1165/** @} */
1166
1167VMMR3DECL(RTDBGCFG) DBGFR3AsGetConfig(PUVM pUVM);
1168
1169VMMR3DECL(int) DBGFR3AsAdd(PUVM pUVM, RTDBGAS hDbgAs, RTPROCESS ProcId);
1170VMMR3DECL(int) DBGFR3AsDelete(PUVM pUVM, RTDBGAS hDbgAs);
1171VMMR3DECL(int) DBGFR3AsSetAlias(PUVM pUVM, RTDBGAS hAlias, RTDBGAS hAliasFor);
1172VMMR3DECL(RTDBGAS) DBGFR3AsResolve(PUVM pUVM, RTDBGAS hAlias);
1173VMMR3DECL(RTDBGAS) DBGFR3AsResolveAndRetain(PUVM pUVM, RTDBGAS hAlias);
1174VMMR3DECL(RTDBGAS) DBGFR3AsQueryByName(PUVM pUVM, const char *pszName);
1175VMMR3DECL(RTDBGAS) DBGFR3AsQueryByPid(PUVM pUVM, RTPROCESS ProcId);
1176
1177VMMR3DECL(int) DBGFR3AsLoadImage(PUVM pUVM, RTDBGAS hDbgAs, const char *pszFilename, const char *pszModName,
1178 RTLDRARCH enmArch, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, uint32_t fFlags);
1179VMMR3DECL(int) DBGFR3AsLoadMap(PUVM pUVM, RTDBGAS hDbgAs, const char *pszFilename, const char *pszModName, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, RTGCUINTPTR uSubtrahend, uint32_t fFlags);
1180VMMR3DECL(int) DBGFR3AsLinkModule(PUVM pUVM, RTDBGAS hDbgAs, RTDBGMOD hMod, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, uint32_t fFlags);
1181VMMR3DECL(int) DBGFR3AsUnlinkModuleByName(PUVM pUVM, RTDBGAS hDbgAs, const char *pszModName);
1182
1183VMMR3DECL(int) DBGFR3AsSymbolByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, uint32_t fFlags,
1184 PRTGCINTPTR poffDisp, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
1185VMMR3DECL(PRTDBGSYMBOL) DBGFR3AsSymbolByAddrA(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, uint32_t Flags,
1186 PRTGCINTPTR poffDisp, PRTDBGMOD phMod);
1187VMMR3DECL(int) DBGFR3AsSymbolByName(PUVM pUVM, RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
1188
1189VMMR3DECL(int) DBGFR3AsLineByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
1190 PRTGCINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod);
1191VMMR3DECL(PRTDBGLINE) DBGFR3AsLineByAddrA(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
1192 PRTGCINTPTR poffDisp, PRTDBGMOD phMod);
1193
1194/** @name DBGFMOD_PE_F_XXX - flags for
1195 * @{ */
1196/** NT 3.1 images were a little different, so make allowances for that. */
1197#define DBGFMODINMEM_F_PE_NT31 RT_BIT_32(0)
1198/** No container fallback. */
1199#define DBGFMODINMEM_F_NO_CONTAINER_FALLBACK RT_BIT_32(1)
1200/** No in-memory reader fallback. */
1201#define DBGFMODINMEM_F_NO_READER_FALLBACK RT_BIT_32(2)
1202/** Valid flags. */
1203#define DBGFMODINMEM_F_VALID_MASK UINT32_C(0x00000007)
1204/** @} */
1205VMMR3DECL(int) DBGFR3ModInMem(PUVM pUVM, PCDBGFADDRESS pImageAddr, uint32_t fFlags, const char *pszName,
1206 const char *pszFilename, RTLDRARCH enmArch, uint32_t cbImage,
1207 PRTDBGMOD phDbgMod, PRTERRINFO pErrInfo);
1208
1209#endif /* IN_RING3 */
1210
1211#ifdef IN_RING3 /* The stack API only works in ring-3. */
1212
1213/** Pointer to stack frame info. */
1214typedef struct DBGFSTACKFRAME *PDBGFSTACKFRAME;
1215/** Pointer to const stack frame info. */
1216typedef struct DBGFSTACKFRAME const *PCDBGFSTACKFRAME;
1217/**
1218 * Info about a stack frame.
1219 */
1220typedef struct DBGFSTACKFRAME
1221{
1222 /** Frame number. */
1223 uint32_t iFrame;
1224 /** Frame flags (DBGFSTACKFRAME_FLAGS_XXX). */
1225 uint32_t fFlags;
1226 /** The stack address of the frame.
1227 * The off member is [e|r]sp and the Sel member is ss. */
1228 DBGFADDRESS AddrStack;
1229 /** The program counter (PC) address of the frame.
1230 * The off member is [e|r]ip and the Sel member is cs. */
1231 DBGFADDRESS AddrPC;
1232 /** Pointer to the symbol nearest the program counter (PC). NULL if not found. */
1233 PRTDBGSYMBOL pSymPC;
1234 /** Pointer to the linenumber nearest the program counter (PC). NULL if not found. */
1235 PRTDBGLINE pLinePC;
1236 /** The frame address.
1237 * The off member is [e|r]bp and the Sel member is ss. */
1238 DBGFADDRESS AddrFrame;
1239 /** The way this frame returns to the next one. */
1240 RTDBGRETURNTYPE enmReturnType;
1241
1242 /** The way the next frame returns.
1243 * Only valid when DBGFSTACKFRAME_FLAGS_UNWIND_INFO_RET is set. */
1244 RTDBGRETURNTYPE enmReturnFrameReturnType;
1245 /** The return frame address.
1246 * The off member is [e|r]bp and the Sel member is ss. */
1247 DBGFADDRESS AddrReturnFrame;
1248 /** The return stack address.
1249 * The off member is [e|r]sp and the Sel member is ss. */
1250 DBGFADDRESS AddrReturnStack;
1251
1252 /** The program counter (PC) address which the frame returns to.
1253 * The off member is [e|r]ip and the Sel member is cs. */
1254 DBGFADDRESS AddrReturnPC;
1255 /** Pointer to the symbol nearest the return PC. NULL if not found. */
1256 PRTDBGSYMBOL pSymReturnPC;
1257 /** Pointer to the linenumber nearest the return PC. NULL if not found. */
1258 PRTDBGLINE pLineReturnPC;
1259
1260 /** 32-bytes of stack arguments. */
1261 union
1262 {
1263 /** 64-bit view */
1264 uint64_t au64[4];
1265 /** 32-bit view */
1266 uint32_t au32[8];
1267 /** 16-bit view */
1268 uint16_t au16[16];
1269 /** 8-bit view */
1270 uint8_t au8[32];
1271 } Args;
1272
1273 /** Number of registers values we can be sure about.
1274 * @note This is generally zero in the first frame. */
1275 uint32_t cSureRegs;
1276 /** Registers we can be sure about (length given by cSureRegs). */
1277 struct DBGFREGVALEX *paSureRegs;
1278
1279 /** Pointer to the next frame.
1280 * Might not be used in some cases, so consider it internal. */
1281 PCDBGFSTACKFRAME pNextInternal;
1282 /** Pointer to the first frame.
1283 * Might not be used in some cases, so consider it internal. */
1284 PCDBGFSTACKFRAME pFirstInternal;
1285} DBGFSTACKFRAME;
1286
1287/** @name DBGFSTACKFRAME_FLAGS_XXX - DBGFSTACKFRAME Flags.
1288 * @{ */
1289/** This is the last stack frame we can read.
1290 * This flag is not set if the walk stop because of max dept or recursion. */
1291# define DBGFSTACKFRAME_FLAGS_LAST RT_BIT(1)
1292/** This is the last record because we detected a loop. */
1293# define DBGFSTACKFRAME_FLAGS_LOOP RT_BIT(2)
1294/** This is the last record because we reached the maximum depth. */
1295# define DBGFSTACKFRAME_FLAGS_MAX_DEPTH RT_BIT(3)
1296/** 16-bit frame. */
1297# define DBGFSTACKFRAME_FLAGS_16BIT RT_BIT(4)
1298/** 32-bit frame. */
1299# define DBGFSTACKFRAME_FLAGS_32BIT RT_BIT(5)
1300/** 64-bit frame. */
1301# define DBGFSTACKFRAME_FLAGS_64BIT RT_BIT(6)
1302/** Real mode or V86 frame. */
1303# define DBGFSTACKFRAME_FLAGS_REAL_V86 RT_BIT(7)
1304/** Is a trap frame (NT term). */
1305# define DBGFSTACKFRAME_FLAGS_TRAP_FRAME RT_BIT(8)
1306
1307/** Used Odd/even heuristics for far/near return. */
1308# define DBGFSTACKFRAME_FLAGS_USED_ODD_EVEN RT_BIT(29)
1309/** Set if we used unwind info to construct the frame. (Kind of internal.) */
1310# define DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO RT_BIT(30)
1311/** Internal: Unwind info used for the return frame. */
1312# define DBGFSTACKFRAME_FLAGS_UNWIND_INFO_RET RT_BIT(31)
1313/** @} */
1314
1315/** @name DBGFCODETYPE
1316 * @{ */
1317typedef enum DBGFCODETYPE
1318{
1319 /** The usual invalid 0 value. */
1320 DBGFCODETYPE_INVALID = 0,
1321 /** Stack walk for guest code. */
1322 DBGFCODETYPE_GUEST,
1323 /** Stack walk for hypervisor code. */
1324 DBGFCODETYPE_HYPER,
1325 /** Stack walk for ring 0 code. */
1326 DBGFCODETYPE_RING0,
1327 /** The usual 32-bit blowup. */
1328 DBGFCODETYPE_32BIT_HACK = 0x7fffffff
1329} DBGFCODETYPE;
1330/** @} */
1331
1332VMMR3DECL(int) DBGFR3StackWalkBegin(PUVM pUVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType,
1333 PCDBGFSTACKFRAME *ppFirstFrame);
1334VMMR3DECL(int) DBGFR3StackWalkBeginEx(PUVM pUVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType, PCDBGFADDRESS pAddrFrame,
1335 PCDBGFADDRESS pAddrStack,PCDBGFADDRESS pAddrPC,
1336 RTDBGRETURNTYPE enmReturnType, PCDBGFSTACKFRAME *ppFirstFrame);
1337VMMR3DECL(PCDBGFSTACKFRAME) DBGFR3StackWalkNext(PCDBGFSTACKFRAME pCurrent);
1338VMMR3DECL(void) DBGFR3StackWalkEnd(PCDBGFSTACKFRAME pFirstFrame);
1339
1340#endif /* IN_RING3 */
1341
1342
1343#ifdef IN_RING3 /* The disassembly API only works in ring-3. */
1344
1345/** @name Flags to pass to DBGFR3DisasInstrEx().
1346 * @{ */
1347/** Disassemble the current guest instruction, with annotations. */
1348#define DBGF_DISAS_FLAGS_CURRENT_GUEST RT_BIT(0)
1349/** Disassemble the current hypervisor instruction, with annotations. */
1350#define DBGF_DISAS_FLAGS_CURRENT_HYPER RT_BIT(1)
1351/** No annotations for current context. */
1352#define DBGF_DISAS_FLAGS_NO_ANNOTATION RT_BIT(2)
1353/** No symbol lookup. */
1354#define DBGF_DISAS_FLAGS_NO_SYMBOLS RT_BIT(3)
1355/** No instruction bytes. */
1356#define DBGF_DISAS_FLAGS_NO_BYTES RT_BIT(4)
1357/** No address in the output. */
1358#define DBGF_DISAS_FLAGS_NO_ADDRESS RT_BIT(5)
1359/** Probably a hypervisor instruction. */
1360#define DBGF_DISAS_FLAGS_HYPER RT_BIT(6)
1361/** Disassemble original unpatched bytes (PATM). */
1362#define DBGF_DISAS_FLAGS_UNPATCHED_BYTES RT_BIT(7)
1363/** Annotate patched instructions. */
1364#define DBGF_DISAS_FLAGS_ANNOTATE_PATCHED RT_BIT(8)
1365/** Disassemble in the default mode of the specific context. */
1366#define DBGF_DISAS_FLAGS_DEFAULT_MODE UINT32_C(0x00000000)
1367/** Disassemble in 16-bit mode. */
1368#define DBGF_DISAS_FLAGS_16BIT_MODE UINT32_C(0x10000000)
1369/** Disassemble in 16-bit mode with real mode address translation. */
1370#define DBGF_DISAS_FLAGS_16BIT_REAL_MODE UINT32_C(0x20000000)
1371/** Disassemble in 32-bit mode. */
1372#define DBGF_DISAS_FLAGS_32BIT_MODE UINT32_C(0x30000000)
1373/** Disassemble in 64-bit mode. */
1374#define DBGF_DISAS_FLAGS_64BIT_MODE UINT32_C(0x40000000)
1375/** The disassembly mode mask. */
1376#define DBGF_DISAS_FLAGS_MODE_MASK UINT32_C(0x70000000)
1377/** Mask containing the valid flags. */
1378#define DBGF_DISAS_FLAGS_VALID_MASK UINT32_C(0x700001ff)
1379/** @} */
1380
1381/** Special flat selector. */
1382#define DBGF_SEL_FLAT 1
1383
1384VMMR3DECL(int) DBGFR3DisasInstrEx(PUVM pUVM, VMCPUID idCpu, RTSEL Sel, RTGCPTR GCPtr, uint32_t fFlags,
1385 char *pszOutput, uint32_t cbOutput, uint32_t *pcbInstr);
1386VMMR3_INT_DECL(int) DBGFR3DisasInstrCurrent(PVMCPU pVCpu, char *pszOutput, uint32_t cbOutput);
1387VMMR3DECL(int) DBGFR3DisasInstrCurrentLogInternal(PVMCPU pVCpu, const char *pszPrefix);
1388
1389/** @def DBGFR3_DISAS_INSTR_CUR_LOG
1390 * Disassembles the current guest context instruction and writes it to the log.
1391 * All registers and data will be displayed. Addresses will be attempted resolved to symbols.
1392 */
1393#ifdef LOG_ENABLED
1394# define DBGFR3_DISAS_INSTR_CUR_LOG(pVCpu, pszPrefix) \
1395 do { \
1396 if (LogIsEnabled()) \
1397 DBGFR3DisasInstrCurrentLogInternal(pVCpu, pszPrefix); \
1398 } while (0)
1399#else
1400# define DBGFR3_DISAS_INSTR_CUR_LOG(pVCpu, pszPrefix) do { } while (0)
1401#endif
1402
1403VMMR3DECL(int) DBGFR3DisasInstrLogInternal(PVMCPU pVCpu, RTSEL Sel, RTGCPTR GCPtr, const char *pszPrefix);
1404
1405/** @def DBGFR3_DISAS_INSTR_LOG
1406 * Disassembles the specified guest context instruction and writes it to the log.
1407 * Addresses will be attempted resolved to symbols.
1408 * @thread Any EMT.
1409 */
1410# ifdef LOG_ENABLED
1411# define DBGFR3_DISAS_INSTR_LOG(pVCpu, Sel, GCPtr, pszPrefix) \
1412 do { \
1413 if (LogIsEnabled()) \
1414 DBGFR3DisasInstrLogInternal(pVCpu, Sel, GCPtr, pszPrefix); \
1415 } while (0)
1416# else
1417# define DBGFR3_DISAS_INSTR_LOG(pVCpu, Sel, GCPtr, pszPrefix) do { } while (0)
1418# endif
1419#endif
1420
1421
1422#ifdef IN_RING3
1423VMMR3DECL(int) DBGFR3MemScan(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, RTGCUINTPTR uAlign,
1424 const void *pvNeedle, size_t cbNeedle, PDBGFADDRESS pHitAddress);
1425VMMR3DECL(int) DBGFR3MemRead(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void *pvBuf, size_t cbRead);
1426VMMR3DECL(int) DBGFR3MemReadString(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, char *pszBuf, size_t cbBuf);
1427VMMR3DECL(int) DBGFR3MemWrite(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void const *pvBuf, size_t cbRead);
1428#endif
1429
1430
1431/** @name Flags for DBGFR3PagingDumpEx, PGMR3DumpHierarchyHCEx and
1432 * PGMR3DumpHierarchyGCEx
1433 * @{ */
1434/** The CR3 from the current CPU state. */
1435#define DBGFPGDMP_FLAGS_CURRENT_CR3 RT_BIT_32(0)
1436/** The current CPU paging mode (PSE, PAE, LM, EPT, NX). */
1437#define DBGFPGDMP_FLAGS_CURRENT_MODE RT_BIT_32(1)
1438/** Whether PSE is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
1439 * Same value as X86_CR4_PSE. */
1440#define DBGFPGDMP_FLAGS_PSE RT_BIT_32(4) /* */
1441/** Whether PAE is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
1442 * Same value as X86_CR4_PAE. */
1443#define DBGFPGDMP_FLAGS_PAE RT_BIT_32(5) /* */
1444/** Whether LME is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
1445 * Same value as MSR_K6_EFER_LME. */
1446#define DBGFPGDMP_FLAGS_LME RT_BIT_32(8)
1447/** Whether nested paging is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE). */
1448#define DBGFPGDMP_FLAGS_NP RT_BIT_32(9)
1449/** Whether extended nested page tables are enabled
1450 * (!DBGFPGDMP_FLAGS_CURRENT_STATE). */
1451#define DBGFPGDMP_FLAGS_EPT RT_BIT_32(10)
1452/** Whether no-execution is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
1453 * Same value as MSR_K6_EFER_NXE. */
1454#define DBGFPGDMP_FLAGS_NXE RT_BIT_32(11)
1455/** Whether to print the CR3. */
1456#define DBGFPGDMP_FLAGS_PRINT_CR3 RT_BIT_32(27)
1457/** Whether to print the header. */
1458#define DBGFPGDMP_FLAGS_HEADER RT_BIT_32(28)
1459/** Whether to dump additional page information. */
1460#define DBGFPGDMP_FLAGS_PAGE_INFO RT_BIT_32(29)
1461/** Dump the shadow tables if set.
1462 * Cannot be used together with DBGFPGDMP_FLAGS_GUEST. */
1463#define DBGFPGDMP_FLAGS_SHADOW RT_BIT_32(30)
1464/** Dump the guest tables if set.
1465 * Cannot be used together with DBGFPGDMP_FLAGS_SHADOW. */
1466#define DBGFPGDMP_FLAGS_GUEST RT_BIT_32(31)
1467/** Mask of valid bits. */
1468#define DBGFPGDMP_FLAGS_VALID_MASK UINT32_C(0xf8000f33)
1469/** The mask of bits controlling the paging mode. */
1470#define DBGFPGDMP_FLAGS_MODE_MASK UINT32_C(0x00000f32)
1471/** @} */
1472VMMDECL(int) DBGFR3PagingDumpEx(PUVM pUVM, VMCPUID idCpu, uint32_t fFlags, uint64_t cr3, uint64_t u64FirstAddr,
1473 uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
1474
1475
1476/** @name DBGFR3SelQueryInfo flags.
1477 * @{ */
1478/** Get the info from the guest descriptor table. */
1479#define DBGFSELQI_FLAGS_DT_GUEST UINT32_C(0)
1480/** Get the info from the shadow descriptor table.
1481 * Only works in raw-mode. */
1482#define DBGFSELQI_FLAGS_DT_SHADOW UINT32_C(1)
1483/** If currently executing in in 64-bit mode, blow up data selectors. */
1484#define DBGFSELQI_FLAGS_DT_ADJ_64BIT_MODE UINT32_C(2)
1485/** @} */
1486VMMR3DECL(int) DBGFR3SelQueryInfo(PUVM pUVM, VMCPUID idCpu, RTSEL Sel, uint32_t fFlags, PDBGFSELINFO pSelInfo);
1487
1488
1489/**
1490 * Register identifiers.
1491 */
1492typedef enum DBGFREG
1493{
1494 /* General purpose registers: */
1495 DBGFREG_AL = 0,
1496 DBGFREG_AX = DBGFREG_AL,
1497 DBGFREG_EAX = DBGFREG_AL,
1498 DBGFREG_RAX = DBGFREG_AL,
1499
1500 DBGFREG_CL,
1501 DBGFREG_CX = DBGFREG_CL,
1502 DBGFREG_ECX = DBGFREG_CL,
1503 DBGFREG_RCX = DBGFREG_CL,
1504
1505 DBGFREG_DL,
1506 DBGFREG_DX = DBGFREG_DL,
1507 DBGFREG_EDX = DBGFREG_DL,
1508 DBGFREG_RDX = DBGFREG_DL,
1509
1510 DBGFREG_BL,
1511 DBGFREG_BX = DBGFREG_BL,
1512 DBGFREG_EBX = DBGFREG_BL,
1513 DBGFREG_RBX = DBGFREG_BL,
1514
1515 DBGFREG_SPL,
1516 DBGFREG_SP = DBGFREG_SPL,
1517 DBGFREG_ESP = DBGFREG_SPL,
1518 DBGFREG_RSP = DBGFREG_SPL,
1519
1520 DBGFREG_BPL,
1521 DBGFREG_BP = DBGFREG_BPL,
1522 DBGFREG_EBP = DBGFREG_BPL,
1523 DBGFREG_RBP = DBGFREG_BPL,
1524
1525 DBGFREG_SIL,
1526 DBGFREG_SI = DBGFREG_SIL,
1527 DBGFREG_ESI = DBGFREG_SIL,
1528 DBGFREG_RSI = DBGFREG_SIL,
1529
1530 DBGFREG_DIL,
1531 DBGFREG_DI = DBGFREG_DIL,
1532 DBGFREG_EDI = DBGFREG_DIL,
1533 DBGFREG_RDI = DBGFREG_DIL,
1534
1535 DBGFREG_R8,
1536 DBGFREG_R8B = DBGFREG_R8,
1537 DBGFREG_R8W = DBGFREG_R8,
1538 DBGFREG_R8D = DBGFREG_R8,
1539
1540 DBGFREG_R9,
1541 DBGFREG_R9B = DBGFREG_R9,
1542 DBGFREG_R9W = DBGFREG_R9,
1543 DBGFREG_R9D = DBGFREG_R9,
1544
1545 DBGFREG_R10,
1546 DBGFREG_R10B = DBGFREG_R10,
1547 DBGFREG_R10W = DBGFREG_R10,
1548 DBGFREG_R10D = DBGFREG_R10,
1549
1550 DBGFREG_R11,
1551 DBGFREG_R11B = DBGFREG_R11,
1552 DBGFREG_R11W = DBGFREG_R11,
1553 DBGFREG_R11D = DBGFREG_R11,
1554
1555 DBGFREG_R12,
1556 DBGFREG_R12B = DBGFREG_R12,
1557 DBGFREG_R12W = DBGFREG_R12,
1558 DBGFREG_R12D = DBGFREG_R12,
1559
1560 DBGFREG_R13,
1561 DBGFREG_R13B = DBGFREG_R13,
1562 DBGFREG_R13W = DBGFREG_R13,
1563 DBGFREG_R13D = DBGFREG_R13,
1564
1565 DBGFREG_R14,
1566 DBGFREG_R14B = DBGFREG_R14,
1567 DBGFREG_R14W = DBGFREG_R14,
1568 DBGFREG_R14D = DBGFREG_R14,
1569
1570 DBGFREG_R15,
1571 DBGFREG_R15B = DBGFREG_R15,
1572 DBGFREG_R15W = DBGFREG_R15,
1573 DBGFREG_R15D = DBGFREG_R15,
1574
1575 /* Segments and other special registers: */
1576 DBGFREG_CS,
1577 DBGFREG_CS_ATTR,
1578 DBGFREG_CS_BASE,
1579 DBGFREG_CS_LIMIT,
1580
1581 DBGFREG_DS,
1582 DBGFREG_DS_ATTR,
1583 DBGFREG_DS_BASE,
1584 DBGFREG_DS_LIMIT,
1585
1586 DBGFREG_ES,
1587 DBGFREG_ES_ATTR,
1588 DBGFREG_ES_BASE,
1589 DBGFREG_ES_LIMIT,
1590
1591 DBGFREG_FS,
1592 DBGFREG_FS_ATTR,
1593 DBGFREG_FS_BASE,
1594 DBGFREG_FS_LIMIT,
1595
1596 DBGFREG_GS,
1597 DBGFREG_GS_ATTR,
1598 DBGFREG_GS_BASE,
1599 DBGFREG_GS_LIMIT,
1600
1601 DBGFREG_SS,
1602 DBGFREG_SS_ATTR,
1603 DBGFREG_SS_BASE,
1604 DBGFREG_SS_LIMIT,
1605
1606 DBGFREG_IP,
1607 DBGFREG_EIP = DBGFREG_IP,
1608 DBGFREG_RIP = DBGFREG_IP,
1609
1610 DBGFREG_FLAGS,
1611 DBGFREG_EFLAGS = DBGFREG_FLAGS,
1612 DBGFREG_RFLAGS = DBGFREG_FLAGS,
1613
1614 /* FPU: */
1615 DBGFREG_FCW,
1616 DBGFREG_FSW,
1617 DBGFREG_FTW,
1618 DBGFREG_FOP,
1619 DBGFREG_FPUIP,
1620 DBGFREG_FPUCS,
1621 DBGFREG_FPUDP,
1622 DBGFREG_FPUDS,
1623 DBGFREG_MXCSR,
1624 DBGFREG_MXCSR_MASK,
1625
1626 DBGFREG_ST0,
1627 DBGFREG_ST1,
1628 DBGFREG_ST2,
1629 DBGFREG_ST3,
1630 DBGFREG_ST4,
1631 DBGFREG_ST5,
1632 DBGFREG_ST6,
1633 DBGFREG_ST7,
1634
1635 DBGFREG_MM0,
1636 DBGFREG_MM1,
1637 DBGFREG_MM2,
1638 DBGFREG_MM3,
1639 DBGFREG_MM4,
1640 DBGFREG_MM5,
1641 DBGFREG_MM6,
1642 DBGFREG_MM7,
1643
1644 /* SSE: */
1645 DBGFREG_XMM0,
1646 DBGFREG_XMM1,
1647 DBGFREG_XMM2,
1648 DBGFREG_XMM3,
1649 DBGFREG_XMM4,
1650 DBGFREG_XMM5,
1651 DBGFREG_XMM6,
1652 DBGFREG_XMM7,
1653 DBGFREG_XMM8,
1654 DBGFREG_XMM9,
1655 DBGFREG_XMM10,
1656 DBGFREG_XMM11,
1657 DBGFREG_XMM12,
1658 DBGFREG_XMM13,
1659 DBGFREG_XMM14,
1660 DBGFREG_XMM15,
1661 /** @todo add XMM aliases. */
1662
1663 /* AVX: */
1664 DBGFREG_YMM0,
1665 DBGFREG_YMM1,
1666 DBGFREG_YMM2,
1667 DBGFREG_YMM3,
1668 DBGFREG_YMM4,
1669 DBGFREG_YMM5,
1670 DBGFREG_YMM6,
1671 DBGFREG_YMM7,
1672 DBGFREG_YMM8,
1673 DBGFREG_YMM9,
1674 DBGFREG_YMM10,
1675 DBGFREG_YMM11,
1676 DBGFREG_YMM12,
1677 DBGFREG_YMM13,
1678 DBGFREG_YMM14,
1679 DBGFREG_YMM15,
1680
1681 /* System registers: */
1682 DBGFREG_GDTR_BASE,
1683 DBGFREG_GDTR_LIMIT,
1684 DBGFREG_IDTR_BASE,
1685 DBGFREG_IDTR_LIMIT,
1686 DBGFREG_LDTR,
1687 DBGFREG_LDTR_ATTR,
1688 DBGFREG_LDTR_BASE,
1689 DBGFREG_LDTR_LIMIT,
1690 DBGFREG_TR,
1691 DBGFREG_TR_ATTR,
1692 DBGFREG_TR_BASE,
1693 DBGFREG_TR_LIMIT,
1694
1695 DBGFREG_CR0,
1696 DBGFREG_CR2,
1697 DBGFREG_CR3,
1698 DBGFREG_CR4,
1699 DBGFREG_CR8,
1700
1701 DBGFREG_DR0,
1702 DBGFREG_DR1,
1703 DBGFREG_DR2,
1704 DBGFREG_DR3,
1705 DBGFREG_DR6,
1706 DBGFREG_DR7,
1707
1708 /* MSRs: */
1709 DBGFREG_MSR_IA32_APICBASE,
1710 DBGFREG_MSR_IA32_CR_PAT,
1711 DBGFREG_MSR_IA32_PERF_STATUS,
1712 DBGFREG_MSR_IA32_SYSENTER_CS,
1713 DBGFREG_MSR_IA32_SYSENTER_EIP,
1714 DBGFREG_MSR_IA32_SYSENTER_ESP,
1715 DBGFREG_MSR_IA32_TSC,
1716 DBGFREG_MSR_K6_EFER,
1717 DBGFREG_MSR_K6_STAR,
1718 DBGFREG_MSR_K8_CSTAR,
1719 DBGFREG_MSR_K8_FS_BASE,
1720 DBGFREG_MSR_K8_GS_BASE,
1721 DBGFREG_MSR_K8_KERNEL_GS_BASE,
1722 DBGFREG_MSR_K8_LSTAR,
1723 DBGFREG_MSR_K8_SF_MASK,
1724 DBGFREG_MSR_K8_TSC_AUX,
1725
1726 /** The number of registers to pass to DBGFR3RegQueryAll. */
1727 DBGFREG_ALL_COUNT,
1728
1729 /* Misc aliases that doesn't need be part of the 'all' query: */
1730 DBGFREG_AH = DBGFREG_ALL_COUNT,
1731 DBGFREG_CH,
1732 DBGFREG_DH,
1733 DBGFREG_BH,
1734 DBGFREG_GDTR,
1735 DBGFREG_IDTR,
1736
1737 /** The end of the registers. */
1738 DBGFREG_END,
1739 /** The usual 32-bit type hack. */
1740 DBGFREG_32BIT_HACK = 0x7fffffff
1741} DBGFREG;
1742/** Pointer to a register identifier. */
1743typedef DBGFREG *PDBGFREG;
1744/** Pointer to a const register identifier. */
1745typedef DBGFREG const *PCDBGFREG;
1746
1747/**
1748 * Register value type.
1749 */
1750typedef enum DBGFREGVALTYPE
1751{
1752 DBGFREGVALTYPE_INVALID = 0,
1753 /** Unsigned 8-bit register value. */
1754 DBGFREGVALTYPE_U8,
1755 /** Unsigned 16-bit register value. */
1756 DBGFREGVALTYPE_U16,
1757 /** Unsigned 32-bit register value. */
1758 DBGFREGVALTYPE_U32,
1759 /** Unsigned 64-bit register value. */
1760 DBGFREGVALTYPE_U64,
1761 /** Unsigned 128-bit register value. */
1762 DBGFREGVALTYPE_U128,
1763 /** Unsigned 256-bit register value. */
1764 DBGFREGVALTYPE_U256,
1765 /** Unsigned 512-bit register value. */
1766 DBGFREGVALTYPE_U512,
1767 /** Long double register value. */
1768 DBGFREGVALTYPE_R80,
1769 /** Descriptor table register value. */
1770 DBGFREGVALTYPE_DTR,
1771 /** End of the valid register value types. */
1772 DBGFREGVALTYPE_END,
1773 /** The usual 32-bit type hack. */
1774 DBGFREGVALTYPE_32BIT_HACK = 0x7fffffff
1775} DBGFREGVALTYPE;
1776/** Pointer to a register value type. */
1777typedef DBGFREGVALTYPE *PDBGFREGVALTYPE;
1778
1779/**
1780 * A generic register value type.
1781 */
1782typedef union DBGFREGVAL
1783{
1784 uint64_t au64[8]; /**< The 64-bit array view. First because of the initializer. */
1785 uint32_t au32[16]; /**< The 32-bit array view. */
1786 uint16_t au16[32]; /**< The 16-bit array view. */
1787 uint8_t au8[64]; /**< The 8-bit array view. */
1788
1789 uint8_t u8; /**< The 8-bit view. */
1790 uint16_t u16; /**< The 16-bit view. */
1791 uint32_t u32; /**< The 32-bit view. */
1792 uint64_t u64; /**< The 64-bit view. */
1793 RTUINT128U u128; /**< The 128-bit view. */
1794 RTUINT256U u256; /**< The 256-bit view. */
1795 RTUINT512U u512; /**< The 512-bit view. */
1796 RTFLOAT80U r80; /**< The 80-bit floating point view. */
1797 RTFLOAT80U2 r80Ex; /**< The 80-bit floating point view v2. */
1798 /** GDTR or LDTR (DBGFREGVALTYPE_DTR). */
1799 struct
1800 {
1801 /** The table address. */
1802 uint64_t u64Base;
1803 /** The table limit (length minus 1). */
1804 uint32_t u32Limit; /**< @todo Limit should be uint16_t */
1805 } dtr;
1806} DBGFREGVAL;
1807/** Pointer to a generic register value type. */
1808typedef DBGFREGVAL *PDBGFREGVAL;
1809/** Pointer to a const generic register value type. */
1810typedef DBGFREGVAL const *PCDBGFREGVAL;
1811
1812/** Initialize a DBGFREGVAL variable to all zeros. */
1813#define DBGFREGVAL_INITIALIZE_ZERO { { 0, 0, 0, 0, 0, 0, 0, 0 } }
1814/** Initialize a DBGFREGVAL variable to all bits set . */
1815#define DBGFREGVAL_INITIALIZE_FFFF { { UINT64_MAX, UINT64_MAX, UINT64_MAX, UINT64_MAX, UINT64_MAX, UINT64_MAX, UINT64_MAX, UINT64_MAX } }
1816
1817/**
1818 * Extended register value, including register ID and type.
1819 *
1820 * This is currently only used by the stack walker.
1821 */
1822typedef struct DBGFREGVALEX
1823{
1824 /** The register value. */
1825 DBGFREGVAL Value;
1826 /** The register value type. */
1827 DBGFREGVALTYPE enmType;
1828 /** The register ID, DBGFREG_END if not applicable. */
1829 DBGFREG enmReg;
1830 /** Pointer to read-only register name string if no register ID could be found. */
1831 const char *pszName;
1832} DBGFREGVALEX;
1833/** Pointer to an extended register value struct. */
1834typedef DBGFREGVALEX *PDBGFREGVALEX;
1835/** Pointer to a const extended register value struct. */
1836typedef DBGFREGVALEX const *PCDBGFREGVALEX;
1837
1838
1839VMMDECL(ssize_t) DBGFR3RegFormatValue(char *pszBuf, size_t cbBuf, PCDBGFREGVAL pValue, DBGFREGVALTYPE enmType, bool fSpecial);
1840VMMDECL(ssize_t) DBGFR3RegFormatValueEx(char *pszBuf, size_t cbBuf, PCDBGFREGVAL pValue, DBGFREGVALTYPE enmType,
1841 unsigned uBase, signed int cchWidth, signed int cchPrecision, uint32_t fFlags);
1842
1843/**
1844 * Register sub-field descriptor.
1845 */
1846typedef struct DBGFREGSUBFIELD
1847{
1848 /** The name of the sub-field. NULL is used to terminate the array. */
1849 const char *pszName;
1850 /** The index of the first bit. Ignored if pfnGet is set. */
1851 uint8_t iFirstBit;
1852 /** The number of bits. Mandatory. */
1853 uint8_t cBits;
1854 /** The shift count. Not applied when pfnGet is set, but used to
1855 * calculate the minimum type. */
1856 int8_t cShift;
1857 /** Sub-field flags, DBGFREGSUBFIELD_FLAGS_XXX. */
1858 uint8_t fFlags;
1859 /** Getter (optional).
1860 * @remarks Does not take the device lock or anything like that.
1861 */
1862 DECLCALLBACKMEMBER(int, pfnGet)(void *pvUser, struct DBGFREGSUBFIELD const *pSubField, PRTUINT128U puValue);
1863 /** Setter (optional).
1864 * @remarks Does not take the device lock or anything like that.
1865 */
1866 DECLCALLBACKMEMBER(int, pfnSet)(void *pvUser, struct DBGFREGSUBFIELD const *pSubField, RTUINT128U uValue, RTUINT128U fMask);
1867} DBGFREGSUBFIELD;
1868/** Pointer to a const register sub-field descriptor. */
1869typedef DBGFREGSUBFIELD const *PCDBGFREGSUBFIELD;
1870
1871/** @name DBGFREGSUBFIELD_FLAGS_XXX
1872 * @{ */
1873/** The sub-field is read-only. */
1874#define DBGFREGSUBFIELD_FLAGS_READ_ONLY UINT8_C(0x01)
1875/** @} */
1876
1877/** Macro for creating a read-write sub-field entry without getters. */
1878#define DBGFREGSUBFIELD_RW(a_szName, a_iFirstBit, a_cBits, a_cShift) \
1879 { a_szName, a_iFirstBit, a_cBits, a_cShift, 0 /*fFlags*/, NULL /*pfnGet*/, NULL /*pfnSet*/ }
1880/** Macro for creating a read-write sub-field entry with getters. */
1881#define DBGFREGSUBFIELD_RW_SG(a_szName, a_cBits, a_cShift, a_pfnGet, a_pfnSet) \
1882 { a_szName, 0 /*iFirstBit*/, a_cBits, a_cShift, 0 /*fFlags*/, a_pfnGet, a_pfnSet }
1883/** Macro for creating a read-only sub-field entry without getters. */
1884#define DBGFREGSUBFIELD_RO(a_szName, a_iFirstBit, a_cBits, a_cShift) \
1885 { a_szName, a_iFirstBit, a_cBits, a_cShift, DBGFREGSUBFIELD_FLAGS_READ_ONLY, NULL /*pfnGet*/, NULL /*pfnSet*/ }
1886/** Macro for creating a terminator sub-field entry. */
1887#define DBGFREGSUBFIELD_TERMINATOR() \
1888 { NULL, 0, 0, 0, 0, NULL, NULL }
1889
1890/**
1891 * Register alias descriptor.
1892 */
1893typedef struct DBGFREGALIAS
1894{
1895 /** The alias name. NULL is used to terminate the array. */
1896 const char *pszName;
1897 /** Set to a valid type if the alias has a different type. */
1898 DBGFREGVALTYPE enmType;
1899} DBGFREGALIAS;
1900/** Pointer to a const register alias descriptor. */
1901typedef DBGFREGALIAS const *PCDBGFREGALIAS;
1902
1903/**
1904 * Register descriptor.
1905 */
1906typedef struct DBGFREGDESC
1907{
1908 /** The normal register name. */
1909 const char *pszName;
1910 /** The register identifier if this is a CPU register. */
1911 DBGFREG enmReg;
1912 /** The default register type. */
1913 DBGFREGVALTYPE enmType;
1914 /** Flags, see DBGFREG_FLAGS_XXX. */
1915 uint32_t fFlags;
1916 /** The internal register indicator.
1917 * For CPU registers this is the offset into the CPUMCTX structure,
1918 * thuse the 'off' prefix. */
1919 uint32_t offRegister;
1920 /** Getter.
1921 * @remarks Does not take the device lock or anything like that.
1922 */
1923 DECLCALLBACKMEMBER(int, pfnGet)(void *pvUser, struct DBGFREGDESC const *pDesc, PDBGFREGVAL pValue);
1924 /** Setter.
1925 * @remarks Does not take the device lock or anything like that.
1926 */
1927 DECLCALLBACKMEMBER(int, pfnSet)(void *pvUser, struct DBGFREGDESC const *pDesc, PCDBGFREGVAL pValue, PCDBGFREGVAL pfMask);
1928 /** Aliases (optional). */
1929 PCDBGFREGALIAS paAliases;
1930 /** Sub fields (optional). */
1931 PCDBGFREGSUBFIELD paSubFields;
1932} DBGFREGDESC;
1933
1934/** @name Macros for constructing DBGFREGDESC arrays.
1935 * @{ */
1936#define DBGFREGDESC_RW(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet) \
1937 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, 0 /*fFlags*/, a_offRegister, a_pfnGet, a_pfnSet, NULL /*paAlises*/, NULL /*paSubFields*/ }
1938#define DBGFREGDESC_RO(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet) \
1939 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, DBGFREG_FLAGS_READ_ONLY, a_offRegister, a_pfnGet, a_pfnSet, NULL /*paAlises*/, NULL /*paSubFields*/ }
1940#define DBGFREGDESC_RW_A(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases) \
1941 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, 0 /*fFlags*/, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, NULL /*paSubFields*/ }
1942#define DBGFREGDESC_RO_A(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases) \
1943 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, DBGFREG_FLAGS_READ_ONLY, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, NULL /*paSubFields*/ }
1944#define DBGFREGDESC_RW_S(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paSubFields) \
1945 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, 0 /*fFlags*/, a_offRegister, a_pfnGet, a_pfnSet, /*paAliases*/, a_paSubFields }
1946#define DBGFREGDESC_RO_S(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paSubFields) \
1947 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, DBGFREG_FLAGS_READ_ONLY, a_offRegister, a_pfnGet, a_pfnSet, /*paAliases*/, a_paSubFields }
1948#define DBGFREGDESC_RW_AS(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, a_paSubFields) \
1949 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, 0 /*fFlags*/, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, a_paSubFields }
1950#define DBGFREGDESC_RO_AS(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, a_paSubFields) \
1951 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, DBGFREG_FLAGS_READ_ONLY, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, a_paSubFields }
1952#define DBGFREGDESC_TERMINATOR() \
1953 { NULL, DBGFREG_END, DBGFREGVALTYPE_INVALID, 0, 0, NULL, NULL, NULL, NULL }
1954/** @} */
1955
1956
1957/** @name DBGFREG_FLAGS_XXX
1958 * @{ */
1959/** The register is read-only. */
1960#define DBGFREG_FLAGS_READ_ONLY RT_BIT_32(0)
1961/** @} */
1962
1963/**
1964 * Entry in a batch query or set operation.
1965 */
1966typedef struct DBGFREGENTRY
1967{
1968 /** The register identifier. */
1969 DBGFREG enmReg;
1970 /** The size of the value in bytes. */
1971 DBGFREGVALTYPE enmType;
1972 /** The register value. The valid view is indicated by enmType. */
1973 DBGFREGVAL Val;
1974} DBGFREGENTRY;
1975/** Pointer to a register entry in a batch operation. */
1976typedef DBGFREGENTRY *PDBGFREGENTRY;
1977/** Pointer to a const register entry in a batch operation. */
1978typedef DBGFREGENTRY const *PCDBGFREGENTRY;
1979
1980/** Used with DBGFR3Reg* to indicate the hypervisor register set instead of the
1981 * guest. */
1982#define DBGFREG_HYPER_VMCPUID UINT32_C(0x01000000)
1983
1984VMMR3DECL(int) DBGFR3RegCpuQueryU8( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint8_t *pu8);
1985VMMR3DECL(int) DBGFR3RegCpuQueryU16( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint16_t *pu16);
1986VMMR3DECL(int) DBGFR3RegCpuQueryU32( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint32_t *pu32);
1987VMMR3DECL(int) DBGFR3RegCpuQueryU64( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t *pu64);
1988VMMR3DECL(int) DBGFR3RegCpuQueryU128(PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint128_t *pu128);
1989VMMR3DECL(int) DBGFR3RegCpuQueryLrd( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, long double *plrd);
1990VMMR3DECL(int) DBGFR3RegCpuQueryXdtr(PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t *pu64Base, uint16_t *pu16Limit);
1991#if 0
1992VMMR3DECL(int) DBGFR3RegCpuQueryBatch(PUVM pUVM,VMCPUID idCpu, PDBGFREGENTRY paRegs, size_t cRegs);
1993VMMR3DECL(int) DBGFR3RegCpuQueryAll( PUVM pUVM, VMCPUID idCpu, PDBGFREGENTRY paRegs, size_t cRegs);
1994
1995VMMR3DECL(int) DBGFR3RegCpuSetU8( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint8_t u8);
1996VMMR3DECL(int) DBGFR3RegCpuSetU16( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint16_t u16);
1997VMMR3DECL(int) DBGFR3RegCpuSetU32( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint32_t u32);
1998VMMR3DECL(int) DBGFR3RegCpuSetU64( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t u64);
1999VMMR3DECL(int) DBGFR3RegCpuSetU128( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint128_t u128);
2000VMMR3DECL(int) DBGFR3RegCpuSetLrd( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, long double lrd);
2001VMMR3DECL(int) DBGFR3RegCpuSetBatch( PUVM pUVM, VMCPUID idCpu, PCDBGFREGENTRY paRegs, size_t cRegs);
2002#endif
2003
2004VMMR3DECL(const char *) DBGFR3RegCpuName(PUVM pUVM, DBGFREG enmReg, DBGFREGVALTYPE enmType);
2005
2006VMMR3_INT_DECL(int) DBGFR3RegRegisterCpu(PVM pVM, PVMCPU pVCpu, PCDBGFREGDESC paRegisters, bool fGuestRegs);
2007VMMR3_INT_DECL(int) DBGFR3RegRegisterDevice(PVM pVM, PCDBGFREGDESC paRegisters, PPDMDEVINS pDevIns,
2008 const char *pszPrefix, uint32_t iInstance);
2009
2010/**
2011 * Entry in a named batch query or set operation.
2012 */
2013typedef struct DBGFREGENTRYNM
2014{
2015 /** The register name. */
2016 const char *pszName;
2017 /** The size of the value in bytes. */
2018 DBGFREGVALTYPE enmType;
2019 /** The register value. The valid view is indicated by enmType. */
2020 DBGFREGVAL Val;
2021} DBGFREGENTRYNM;
2022/** Pointer to a named register entry in a batch operation. */
2023typedef DBGFREGENTRYNM *PDBGFREGENTRYNM;
2024/** Pointer to a const named register entry in a batch operation. */
2025typedef DBGFREGENTRYNM const *PCDBGFREGENTRYNM;
2026
2027VMMR3DECL(int) DBGFR3RegNmValidate( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg);
2028
2029VMMR3DECL(int) DBGFR3RegNmQuery( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, PDBGFREGVAL pValue, PDBGFREGVALTYPE penmType);
2030VMMR3DECL(int) DBGFR3RegNmQueryU8( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint8_t *pu8);
2031VMMR3DECL(int) DBGFR3RegNmQueryU16( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint16_t *pu16);
2032VMMR3DECL(int) DBGFR3RegNmQueryU32( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint32_t *pu32);
2033VMMR3DECL(int) DBGFR3RegNmQueryU64( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint64_t *pu64);
2034VMMR3DECL(int) DBGFR3RegNmQueryU128(PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, PRTUINT128U pu128);
2035/*VMMR3DECL(int) DBGFR3RegNmQueryLrd( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, long double *plrd);*/
2036VMMR3DECL(int) DBGFR3RegNmQueryXdtr(PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint64_t *pu64Base, uint16_t *pu16Limit);
2037VMMR3DECL(int) DBGFR3RegNmQueryBatch(PUVM pUVM,VMCPUID idDefCpu, PDBGFREGENTRYNM paRegs, size_t cRegs);
2038VMMR3DECL(int) DBGFR3RegNmQueryAllCount(PUVM pUVM, size_t *pcRegs);
2039VMMR3DECL(int) DBGFR3RegNmQueryAll( PUVM pUVM, PDBGFREGENTRYNM paRegs, size_t cRegs);
2040
2041VMMR3DECL(int) DBGFR3RegNmSet( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, PCDBGFREGVAL pValue, DBGFREGVALTYPE enmType);
2042VMMR3DECL(int) DBGFR3RegNmSetU8( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint8_t u8);
2043VMMR3DECL(int) DBGFR3RegNmSetU16( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint16_t u16);
2044VMMR3DECL(int) DBGFR3RegNmSetU32( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint32_t u32);
2045VMMR3DECL(int) DBGFR3RegNmSetU64( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint64_t u64);
2046VMMR3DECL(int) DBGFR3RegNmSetU128( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, RTUINT128U u128);
2047VMMR3DECL(int) DBGFR3RegNmSetLrd( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, long double lrd);
2048VMMR3DECL(int) DBGFR3RegNmSetBatch( PUVM pUVM, VMCPUID idDefCpu, PCDBGFREGENTRYNM paRegs, size_t cRegs);
2049
2050/** @todo add enumeration methods. */
2051
2052VMMR3DECL(int) DBGFR3RegPrintf( PUVM pUVM, VMCPUID idDefCpu, char *pszBuf, size_t cbBuf, const char *pszFormat, ...);
2053VMMR3DECL(int) DBGFR3RegPrintfV(PUVM pUVM, VMCPUID idDefCpu, char *pszBuf, size_t cbBuf, const char *pszFormat, va_list va);
2054
2055
2056#ifdef IN_RING3
2057
2058/**
2059 * Guest OS digger interface identifier.
2060 *
2061 * This is for use together with PDBGFR3QueryInterface and is used to
2062 * obtain access to optional interfaces.
2063 */
2064typedef enum DBGFOSINTERFACE
2065{
2066 /** The usual invalid entry. */
2067 DBGFOSINTERFACE_INVALID = 0,
2068 /** Process info. */
2069 DBGFOSINTERFACE_PROCESS,
2070 /** Thread info. */
2071 DBGFOSINTERFACE_THREAD,
2072 /** Kernel message log - DBGFOSIDMESG. */
2073 DBGFOSINTERFACE_DMESG,
2074 /** The end of the valid entries. */
2075 DBGFOSINTERFACE_END,
2076 /** The usual 32-bit type blowup. */
2077 DBGFOSINTERFACE_32BIT_HACK = 0x7fffffff
2078} DBGFOSINTERFACE;
2079/** Pointer to a Guest OS digger interface identifier. */
2080typedef DBGFOSINTERFACE *PDBGFOSINTERFACE;
2081/** Pointer to a const Guest OS digger interface identifier. */
2082typedef DBGFOSINTERFACE const *PCDBGFOSINTERFACE;
2083
2084
2085/**
2086 * Guest OS Digger Registration Record.
2087 *
2088 * This is used with the DBGFR3OSRegister() API.
2089 */
2090typedef struct DBGFOSREG
2091{
2092 /** Magic value (DBGFOSREG_MAGIC). */
2093 uint32_t u32Magic;
2094 /** Flags. Reserved. */
2095 uint32_t fFlags;
2096 /** The size of the instance data. */
2097 uint32_t cbData;
2098 /** Operative System name. */
2099 char szName[24];
2100
2101 /**
2102 * Constructs the instance.
2103 *
2104 * @returns VBox status code.
2105 * @param pUVM The user mode VM handle.
2106 * @param pvData Pointer to the instance data.
2107 */
2108 DECLCALLBACKMEMBER(int, pfnConstruct)(PUVM pUVM, void *pvData);
2109
2110 /**
2111 * Destroys the instance.
2112 *
2113 * @param pUVM The user mode VM handle.
2114 * @param pvData Pointer to the instance data.
2115 */
2116 DECLCALLBACKMEMBER(void, pfnDestruct)(PUVM pUVM, void *pvData);
2117
2118 /**
2119 * Probes the guest memory for OS finger prints.
2120 *
2121 * No setup or so is performed, it will be followed by a call to pfnInit
2122 * or pfnRefresh that should take care of that.
2123 *
2124 * @returns true if is an OS handled by this module, otherwise false.
2125 * @param pUVM The user mode VM handle.
2126 * @param pvData Pointer to the instance data.
2127 */
2128 DECLCALLBACKMEMBER(bool, pfnProbe)(PUVM pUVM, void *pvData);
2129
2130 /**
2131 * Initializes a fresly detected guest, loading symbols and such useful stuff.
2132 *
2133 * This is called after pfnProbe.
2134 *
2135 * @returns VBox status code.
2136 * @param pUVM The user mode VM handle.
2137 * @param pvData Pointer to the instance data.
2138 */
2139 DECLCALLBACKMEMBER(int, pfnInit)(PUVM pUVM, void *pvData);
2140
2141 /**
2142 * Refreshes symbols and stuff following a redetection of the same OS.
2143 *
2144 * This is called after pfnProbe.
2145 *
2146 * @returns VBox status code.
2147 * @param pUVM The user mode VM handle.
2148 * @param pvData Pointer to the instance data.
2149 */
2150 DECLCALLBACKMEMBER(int, pfnRefresh)(PUVM pUVM, void *pvData);
2151
2152 /**
2153 * Terminates an OS when a new (or none) OS has been detected,
2154 * and before destruction.
2155 *
2156 * This is called after pfnProbe and if needed before pfnDestruct.
2157 *
2158 * @param pUVM The user mode VM handle.
2159 * @param pvData Pointer to the instance data.
2160 */
2161 DECLCALLBACKMEMBER(void, pfnTerm)(PUVM pUVM, void *pvData);
2162
2163 /**
2164 * Queries the version of the running OS.
2165 *
2166 * This is only called after pfnInit().
2167 *
2168 * @returns VBox status code.
2169 * @param pUVM The user mode VM handle.
2170 * @param pvData Pointer to the instance data.
2171 * @param pszVersion Where to store the version string.
2172 * @param cchVersion The size of the version string buffer.
2173 */
2174 DECLCALLBACKMEMBER(int, pfnQueryVersion)(PUVM pUVM, void *pvData, char *pszVersion, size_t cchVersion);
2175
2176 /**
2177 * Queries the pointer to a interface.
2178 *
2179 * This is called after pfnProbe.
2180 *
2181 * The returned interface must be valid until pfnDestruct is called. Two calls
2182 * to this method with the same @a enmIf value must return the same pointer.
2183 *
2184 * @returns Pointer to the interface if available, NULL if not available.
2185 * @param pUVM The user mode VM handle.
2186 * @param pvData Pointer to the instance data.
2187 * @param enmIf The interface identifier.
2188 */
2189 DECLCALLBACKMEMBER(void *, pfnQueryInterface)(PUVM pUVM, void *pvData, DBGFOSINTERFACE enmIf);
2190
2191 /**
2192 * Stack unwind assist callback.
2193 *
2194 * This is only called after pfnInit().
2195 *
2196 * @returns VBox status code (allocation error or something of similar fatality).
2197 * @param pUVM The user mode VM handle.
2198 * @param pvData Pointer to the instance data.
2199 * @param idCpu The CPU that's unwinding it's stack.
2200 * @param pFrame The current frame. Okay to modify it a little.
2201 * @param pState The unwind state. Okay to modify it.
2202 * @param pInitialCtx The initial register context.
2203 * @param hAs The address space being used for the unwind.
2204 * @param puScratch Scratch area (initialized to zero, no dtor).
2205 */
2206 DECLCALLBACKMEMBER(int, pfnStackUnwindAssist)(PUVM pUVM, void *pvData, VMCPUID idCpu, PDBGFSTACKFRAME pFrame,
2207 PRTDBGUNWINDSTATE pState, PCCPUMCTX pInitialCtx, RTDBGAS hAs,
2208 uint64_t *puScratch);
2209
2210 /** Trailing magic (DBGFOSREG_MAGIC). */
2211 uint32_t u32EndMagic;
2212} DBGFOSREG;
2213/** Pointer to a Guest OS digger registration record. */
2214typedef DBGFOSREG *PDBGFOSREG;
2215/** Pointer to a const Guest OS digger registration record. */
2216typedef DBGFOSREG const *PCDBGFOSREG;
2217
2218/** Magic value for DBGFOSREG::u32Magic and DBGFOSREG::u32EndMagic. (Hitomi Kanehara) */
2219#define DBGFOSREG_MAGIC 0x19830808
2220
2221
2222/**
2223 * Interface for querying kernel log messages (DBGFOSINTERFACE_DMESG).
2224 */
2225typedef struct DBGFOSIDMESG
2226{
2227 /** Trailing magic (DBGFOSIDMESG_MAGIC). */
2228 uint32_t u32Magic;
2229
2230 /**
2231 * Query the kernel log.
2232 *
2233 * @returns VBox status code.
2234 * @retval VERR_NOT_FOUND if the messages could not be located.
2235 * @retval VERR_INVALID_STATE if the messages was found to have unknown/invalid
2236 * format.
2237 * @retval VERR_BUFFER_OVERFLOW if the buffer isn't large enough, pcbActual
2238 * will be set to the required buffer size. The buffer, however, will
2239 * be filled with as much data as it can hold (properly zero terminated
2240 * of course).
2241 *
2242 * @param pThis Pointer to the interface structure.
2243 * @param pUVM The user mode VM handle.
2244 * @param fFlags Flags reserved for future use, MBZ.
2245 * @param cMessages The number of messages to retrieve, counting from the
2246 * end of the log (i.e. like tail), use UINT32_MAX for all.
2247 * @param pszBuf The output buffer.
2248 * @param cbBuf The buffer size.
2249 * @param pcbActual Where to store the number of bytes actually returned,
2250 * including zero terminator. On VERR_BUFFER_OVERFLOW this
2251 * holds the necessary buffer size. Optional.
2252 */
2253 DECLCALLBACKMEMBER(int, pfnQueryKernelLog)(struct DBGFOSIDMESG *pThis, PUVM pUVM, uint32_t fFlags, uint32_t cMessages,
2254 char *pszBuf, size_t cbBuf, size_t *pcbActual);
2255 /** Trailing magic (DBGFOSIDMESG_MAGIC). */
2256 uint32_t u32EndMagic;
2257} DBGFOSIDMESG;
2258/** Pointer to the interface for query kernel log messages (DBGFOSINTERFACE_DMESG). */
2259typedef DBGFOSIDMESG *PDBGFOSIDMESG;
2260/** Magic value for DBGFOSIDMESG::32Magic and DBGFOSIDMESG::u32EndMagic. (Kenazburo Oe) */
2261#define DBGFOSIDMESG_MAGIC UINT32_C(0x19350131)
2262
2263
2264VMMR3DECL(int) DBGFR3OSRegister(PUVM pUVM, PCDBGFOSREG pReg);
2265VMMR3DECL(int) DBGFR3OSDeregister(PUVM pUVM, PCDBGFOSREG pReg);
2266VMMR3DECL(int) DBGFR3OSDetect(PUVM pUVM, char *pszName, size_t cchName);
2267VMMR3DECL(int) DBGFR3OSQueryNameAndVersion(PUVM pUVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion);
2268VMMR3DECL(void *) DBGFR3OSQueryInterface(PUVM pUVM, DBGFOSINTERFACE enmIf);
2269
2270
2271VMMR3DECL(int) DBGFR3CoreWrite(PUVM pUVM, const char *pszFilename, bool fReplaceFile);
2272
2273
2274
2275/** @defgroup grp_dbgf_plug_in The DBGF Plug-in Interface
2276 * @{
2277 */
2278
2279/** The plug-in module name prefix. */
2280# define DBGF_PLUG_IN_PREFIX "DbgPlugIn"
2281
2282/** The name of the plug-in entry point (FNDBGFPLUGIN) */
2283# define DBGF_PLUG_IN_ENTRYPOINT "DbgPlugInEntry"
2284
2285/**
2286 * DBGF plug-in operations.
2287 */
2288typedef enum DBGFPLUGINOP
2289{
2290 /** The usual invalid first value. */
2291 DBGFPLUGINOP_INVALID,
2292 /** Initialize the plug-in for a VM, register all the stuff.
2293 * The plug-in will be unloaded on failure.
2294 * uArg: The full VirtualBox version, see VBox/version.h. */
2295 DBGFPLUGINOP_INIT,
2296 /** Terminate the plug-ing for a VM, deregister all the stuff.
2297 * The plug-in will be unloaded after this call regardless of the return
2298 * code. */
2299 DBGFPLUGINOP_TERM,
2300 /** The usual 32-bit hack. */
2301 DBGFPLUGINOP_32BIT_HACK = 0x7fffffff
2302} DBGFPLUGINOP;
2303
2304/**
2305 * DBGF plug-in main entry point.
2306 *
2307 * @returns VBox status code.
2308 *
2309 * @param enmOperation The operation.
2310 * @param pUVM The user mode VM handle. This may be NULL.
2311 * @param uArg Extra argument.
2312 */
2313typedef DECLCALLBACK(int) FNDBGFPLUGIN(DBGFPLUGINOP enmOperation, PUVM pUVM, uintptr_t uArg);
2314/** Pointer to a FNDBGFPLUGIN. */
2315typedef FNDBGFPLUGIN *PFNDBGFPLUGIN;
2316
2317/** @copydoc FNDBGFPLUGIN */
2318DECLEXPORT(int) DbgPlugInEntry(DBGFPLUGINOP enmOperation, PUVM pUVM, uintptr_t uArg);
2319
2320VMMR3DECL(int) DBGFR3PlugInLoad(PUVM pUVM, const char *pszPlugIn, char *pszActual, size_t cbActual, PRTERRINFO pErrInfo);
2321VMMR3DECL(int) DBGFR3PlugInUnload(PUVM pUVM, const char *pszName);
2322VMMR3DECL(void) DBGFR3PlugInLoadAll(PUVM pUVM);
2323VMMR3DECL(void) DBGFR3PlugInUnloadAll(PUVM pUVM);
2324
2325/** @} */
2326
2327
2328/** @defgroup grp_dbgf_types The DBGF type system Interface.
2329 * @{
2330 */
2331
2332/** A few forward declarations. */
2333/** Pointer to a type registration structure. */
2334typedef struct DBGFTYPEREG *PDBGFTYPEREG;
2335/** Pointer to a const type registration structure. */
2336typedef const struct DBGFTYPEREG *PCDBGFTYPEREG;
2337/** Pointer to a typed buffer. */
2338typedef struct DBGFTYPEVAL *PDBGFTYPEVAL;
2339
2340/**
2341 * DBGF built-in types.
2342 */
2343typedef enum DBGFTYPEBUILTIN
2344{
2345 /** The usual invalid first value. */
2346 DBGFTYPEBUILTIN_INVALID,
2347 /** Unsigned 8bit integer. */
2348 DBGFTYPEBUILTIN_UINT8,
2349 /** Signed 8bit integer. */
2350 DBGFTYPEBUILTIN_INT8,
2351 /** Unsigned 16bit integer. */
2352 DBGFTYPEBUILTIN_UINT16,
2353 /** Signed 16bit integer. */
2354 DBGFTYPEBUILTIN_INT16,
2355 /** Unsigned 32bit integer. */
2356 DBGFTYPEBUILTIN_UINT32,
2357 /** Signed 32bit integer. */
2358 DBGFTYPEBUILTIN_INT32,
2359 /** Unsigned 64bit integer. */
2360 DBGFTYPEBUILTIN_UINT64,
2361 /** Signed 64bit integer. */
2362 DBGFTYPEBUILTIN_INT64,
2363 /** 32bit Guest pointer */
2364 DBGFTYPEBUILTIN_PTR32,
2365 /** 64bit Guest pointer */
2366 DBGFTYPEBUILTIN_PTR64,
2367 /** Guest pointer - size depends on the guest bitness */
2368 DBGFTYPEBUILTIN_PTR,
2369 /** Type indicating a size, like size_t this can have different sizes
2370 * on 32bit and 64bit systems */
2371 DBGFTYPEBUILTIN_SIZE,
2372 /** 32bit float. */
2373 DBGFTYPEBUILTIN_FLOAT32,
2374 /** 64bit float (also known as double). */
2375 DBGFTYPEBUILTIN_FLOAT64,
2376 /** Compund types like structs and unions. */
2377 DBGFTYPEBUILTIN_COMPOUND,
2378 /** The usual 32-bit hack. */
2379 DBGFTYPEBUILTIN_32BIT_HACK = 0x7fffffff
2380} DBGFTYPEBUILTIN;
2381/** Pointer to a built-in type. */
2382typedef DBGFTYPEBUILTIN *PDBGFTYPEBUILTIN;
2383/** Pointer to a const built-in type. */
2384typedef const DBGFTYPEBUILTIN *PCDBGFTYPEBUILTIN;
2385
2386/**
2387 * DBGF type value buffer.
2388 */
2389typedef union DBGFTYPEVALBUF
2390{
2391 uint8_t u8;
2392 int8_t i8;
2393 uint16_t u16;
2394 int16_t i16;
2395 uint32_t u32;
2396 int32_t i32;
2397 uint64_t u64;
2398 int64_t i64;
2399 float f32;
2400 double f64;
2401 uint64_t size; /* For the built-in size_t which can be either 32-bit or 64-bit. */
2402 RTGCPTR GCPtr;
2403 /** For embedded structs. */
2404 PDBGFTYPEVAL pVal;
2405} DBGFTYPEVALBUF;
2406/** Pointer to a value. */
2407typedef DBGFTYPEVALBUF *PDBGFTYPEVALBUF;
2408
2409/**
2410 * DBGF type value entry.
2411 */
2412typedef struct DBGFTYPEVALENTRY
2413{
2414 /** DBGF built-in type. */
2415 DBGFTYPEBUILTIN enmType;
2416 /** Size of the type. */
2417 size_t cbType;
2418 /** Number of entries, for arrays this can be > 1. */
2419 uint32_t cEntries;
2420 /** Value buffer, depends on whether this is an array. */
2421 union
2422 {
2423 /** Single value. */
2424 DBGFTYPEVALBUF Val;
2425 /** Pointer to the array of values. */
2426 PDBGFTYPEVALBUF pVal;
2427 } Buf;
2428} DBGFTYPEVALENTRY;
2429/** Pointer to a type value entry. */
2430typedef DBGFTYPEVALENTRY *PDBGFTYPEVALENTRY;
2431/** Pointer to a const type value entry. */
2432typedef const DBGFTYPEVALENTRY *PCDBGFTYPEVALENTRY;
2433
2434/**
2435 * DBGF typed value.
2436 */
2437typedef struct DBGFTYPEVAL
2438{
2439 /** Pointer to the registration structure for this type. */
2440 PCDBGFTYPEREG pTypeReg;
2441 /** Number of value entries. */
2442 uint32_t cEntries;
2443 /** Variable sized array of value entries. */
2444 DBGFTYPEVALENTRY aEntries[1];
2445} DBGFTYPEVAL;
2446
2447/**
2448 * DBGF type variant.
2449 */
2450typedef enum DBGFTYPEVARIANT
2451{
2452 /** The usual invalid first value. */
2453 DBGFTYPEVARIANT_INVALID,
2454 /** A struct. */
2455 DBGFTYPEVARIANT_STRUCT,
2456 /** Union. */
2457 DBGFTYPEVARIANT_UNION,
2458 /** Alias for an existing type. */
2459 DBGFTYPEVARIANT_ALIAS,
2460 /** The usual 32-bit hack. */
2461 DBGFTYPEVARIANT_32BIT_HACK = 0x7fffffff
2462} DBGFTYPEVARIANT;
2463
2464/** @name DBGFTYPEREGMEMBER Flags.
2465 * @{ */
2466/** The member is an array with a fixed size. */
2467# define DBGFTYPEREGMEMBER_F_ARRAY RT_BIT_32(0)
2468/** The member denotes a pointer. */
2469# define DBGFTYPEREGMEMBER_F_POINTER RT_BIT_32(1)
2470/** @} */
2471
2472/**
2473 * DBGF type member.
2474 */
2475typedef struct DBGFTYPEREGMEMBER
2476{
2477 /** Name of the member. */
2478 const char *pszName;
2479 /** Flags for this member, see DBGFTYPEREGMEMBER_F_XXX. */
2480 uint32_t fFlags;
2481 /** Type identifier. */
2482 const char *pszType;
2483 /** The number of elements in the array, only valid for arrays. */
2484 uint32_t cElements;
2485} DBGFTYPEREGMEMBER;
2486/** Pointer to a member. */
2487typedef DBGFTYPEREGMEMBER *PDBGFTYPEREGMEMBER;
2488/** Pointer to a const member. */
2489typedef const DBGFTYPEREGMEMBER *PCDBGFTYPEREGMEMBER;
2490
2491/** @name DBGFTYPEREG Flags.
2492 * @{ */
2493/** The type is a packed structure. */
2494# define DBGFTYPEREG_F_PACKED RT_BIT_32(0)
2495/** @} */
2496
2497/**
2498 * New type registration structure.
2499 */
2500typedef struct DBGFTYPEREG
2501{
2502 /** Name of the type. */
2503 const char *pszType;
2504 /** The type variant. */
2505 DBGFTYPEVARIANT enmVariant;
2506 /** Some registration flags, see DBGFTYPEREG_F_XXX. */
2507 uint32_t fFlags;
2508 /** Number of members this type has, only valid for structs or unions. */
2509 uint32_t cMembers;
2510 /** Pointer to the member fields, only valid for structs or unions. */
2511 PCDBGFTYPEREGMEMBER paMembers;
2512 /** Name of the aliased type for aliases. */
2513 const char *pszAliasedType;
2514} DBGFTYPEREG;
2515
2516/**
2517 * DBGF typed value dumper callback.
2518 *
2519 * @returns VBox status code. Any non VINF_SUCCESS status code will abort the dumping.
2520 *
2521 * @param off The byte offset of the entry from the start of the type.
2522 * @param pszField The name of the field for the value.
2523 * @param iLvl The current level.
2524 * @param enmType The type enum.
2525 * @param cbType Size of the type.
2526 * @param pValBuf Pointer to the value buffer.
2527 * @param cValBufs Number of value buffers (for arrays).
2528 * @param pvUser Opaque user data.
2529 */
2530typedef DECLCALLBACK(int) FNDBGFR3TYPEVALDUMP(uint32_t off, const char *pszField, uint32_t iLvl,
2531 DBGFTYPEBUILTIN enmType, size_t cbType,
2532 PDBGFTYPEVALBUF pValBuf, uint32_t cValBufs,
2533 void *pvUser);
2534/** Pointer to a FNDBGFR3TYPEVALDUMP. */
2535typedef FNDBGFR3TYPEVALDUMP *PFNDBGFR3TYPEVALDUMP;
2536
2537/**
2538 * DBGF type information dumper callback.
2539 *
2540 * @returns VBox status code. Any non VINF_SUCCESS status code will abort the dumping.
2541 *
2542 * @param off The byte offset of the entry from the start of the type.
2543 * @param pszField The name of the field for the value.
2544 * @param iLvl The current level.
2545 * @param pszType The type of the field.
2546 * @param fTypeFlags Flags for this type, see DBGFTYPEREGMEMBER_F_XXX.
2547 * @param cElements Number of for the field ( > 0 for arrays).
2548 * @param pvUser Opaque user data.
2549 */
2550typedef DECLCALLBACK(int) FNDBGFR3TYPEDUMP(uint32_t off, const char *pszField, uint32_t iLvl,
2551 const char *pszType, uint32_t fTypeFlags,
2552 uint32_t cElements, void *pvUser);
2553/** Pointer to a FNDBGFR3TYPEDUMP. */
2554typedef FNDBGFR3TYPEDUMP *PFNDBGFR3TYPEDUMP;
2555
2556VMMR3DECL(int) DBGFR3TypeRegister( PUVM pUVM, uint32_t cTypes, PCDBGFTYPEREG paTypes);
2557VMMR3DECL(int) DBGFR3TypeDeregister(PUVM pUVM, const char *pszType);
2558VMMR3DECL(int) DBGFR3TypeQueryReg( PUVM pUVM, const char *pszType, PCDBGFTYPEREG *ppTypeReg);
2559
2560VMMR3DECL(int) DBGFR3TypeQuerySize( PUVM pUVM, const char *pszType, size_t *pcbType);
2561VMMR3DECL(int) DBGFR3TypeSetSize( PUVM pUVM, const char *pszType, size_t cbType);
2562VMMR3DECL(int) DBGFR3TypeDumpEx( PUVM pUVM, const char *pszType, uint32_t fFlags,
2563 uint32_t cLvlMax, PFNDBGFR3TYPEDUMP pfnDump, void *pvUser);
2564VMMR3DECL(int) DBGFR3TypeQueryValByType(PUVM pUVM, PCDBGFADDRESS pAddress, const char *pszType,
2565 PDBGFTYPEVAL *ppVal);
2566VMMR3DECL(void) DBGFR3TypeValFree(PDBGFTYPEVAL pVal);
2567VMMR3DECL(int) DBGFR3TypeValDumpEx(PUVM pUVM, PCDBGFADDRESS pAddress, const char *pszType, uint32_t fFlags,
2568 uint32_t cLvlMax, FNDBGFR3TYPEVALDUMP pfnDump, void *pvUser);
2569
2570/** @} */
2571
2572
2573/** @defgroup grp_dbgf_flow The DBGF control flow graph Interface.
2574 * @{
2575 */
2576
2577/** A DBGF control flow graph handle. */
2578typedef struct DBGFFLOWINT *DBGFFLOW;
2579/** Pointer to a DBGF control flow graph handle. */
2580typedef DBGFFLOW *PDBGFFLOW;
2581/** A DBGF control flow graph basic block handle. */
2582typedef struct DBGFFLOWBBINT *DBGFFLOWBB;
2583/** Pointer to a DBGF control flow graph basic block handle. */
2584typedef DBGFFLOWBB *PDBGFFLOWBB;
2585/** A DBGF control flow graph branch table handle. */
2586typedef struct DBGFFLOWBRANCHTBLINT *DBGFFLOWBRANCHTBL;
2587/** Pointer to a DBGF flow control graph branch table handle. */
2588typedef DBGFFLOWBRANCHTBL *PDBGFFLOWBRANCHTBL;
2589/** A DBGF control flow graph iterator. */
2590typedef struct DBGFFLOWITINT *DBGFFLOWIT;
2591/** Pointer to a control flow graph iterator. */
2592typedef DBGFFLOWIT *PDBGFFLOWIT;
2593/** A DBGF control flow graph branch table iterator. */
2594typedef struct DBGFFLOWBRANCHTBLITINT *DBGFFLOWBRANCHTBLIT;
2595/** Pointer to a control flow graph branch table iterator. */
2596typedef DBGFFLOWBRANCHTBLIT *PDBGFFLOWBRANCHTBLIT;
2597
2598/** @name DBGFFLOWBB Flags.
2599 * @{ */
2600/** The basic block is the entry into the owning control flow graph. */
2601#define DBGF_FLOW_BB_F_ENTRY RT_BIT_32(0)
2602/** The basic block was not populated because the limit was reached. */
2603#define DBGF_FLOW_BB_F_EMPTY RT_BIT_32(1)
2604/** The basic block is not complete because an error happened during disassembly. */
2605#define DBGF_FLOW_BB_F_INCOMPLETE_ERR RT_BIT_32(2)
2606/** The basic block is reached through a branch table. */
2607#define DBGF_FLOW_BB_F_BRANCH_TABLE RT_BIT_32(3)
2608/** @} */
2609
2610/** @name Flags controlling the creating of a control flow graph.
2611 * @{ */
2612/** Default options. */
2613#define DBGF_FLOW_CREATE_F_DEFAULT 0
2614/** Tries to resolve indirect branches, useful for code using
2615 * jump tables generated for large switch statements by some compilers. */
2616#define DBGF_FLOW_CREATE_F_TRY_RESOLVE_INDIRECT_BRANCHES RT_BIT_32(0)
2617/** @} */
2618
2619/**
2620 * DBGF control graph basic block end type.
2621 */
2622typedef enum DBGFFLOWBBENDTYPE
2623{
2624 /** Invalid type. */
2625 DBGFFLOWBBENDTYPE_INVALID = 0,
2626 /** Basic block is the exit block and has no successor. */
2627 DBGFFLOWBBENDTYPE_EXIT,
2628 /** Basic block is the last disassembled block because the
2629 * maximum amount to disassemble was reached but is not an
2630 * exit block - no successors.
2631 */
2632 DBGFFLOWBBENDTYPE_LAST_DISASSEMBLED,
2633 /** Unconditional control flow change because the successor is referenced by multiple
2634 * basic blocks. - 1 successor. */
2635 DBGFFLOWBBENDTYPE_UNCOND,
2636 /** Unconditional control flow change because of an direct branch - 1 successor. */
2637 DBGFFLOWBBENDTYPE_UNCOND_JMP,
2638 /** Unconditional control flow change because of an indirect branch - n successors. */
2639 DBGFFLOWBBENDTYPE_UNCOND_INDIRECT_JMP,
2640 /** Conditional control flow change - 2 successors. */
2641 DBGFFLOWBBENDTYPE_COND,
2642 /** 32bit hack. */
2643 DBGFFLOWBBENDTYPE_32BIT_HACK = 0x7fffffff
2644} DBGFFLOWBBENDTYPE;
2645
2646/**
2647 * DBGF control flow graph iteration order.
2648 */
2649typedef enum DBGFFLOWITORDER
2650{
2651 /** Invalid order. */
2652 DBGFFLOWITORDER_INVALID = 0,
2653 /** From lowest to highest basic block start address. */
2654 DBGFFLOWITORDER_BY_ADDR_LOWEST_FIRST,
2655 /** From highest to lowest basic block start address. */
2656 DBGFFLOWITORDER_BY_ADDR_HIGHEST_FIRST,
2657 /** Depth first traversing starting from the entry block. */
2658 DBGFFLOWITORDER_DEPTH_FRIST,
2659 /** Breadth first traversing starting from the entry block. */
2660 DBGFFLOWITORDER_BREADTH_FIRST,
2661 /** Usual 32bit hack. */
2662 DBGFFLOWITORDER_32BIT_HACK = 0x7fffffff
2663} DBGFFLOWITORDER;
2664/** Pointer to a iteration order enum. */
2665typedef DBGFFLOWITORDER *PDBGFFLOWITORDER;
2666
2667
2668VMMR3DECL(int) DBGFR3FlowCreate(PUVM pUVM, VMCPUID idCpu, PDBGFADDRESS pAddressStart, uint32_t cbDisasmMax,
2669 uint32_t fFlagsFlow, uint32_t fFlagsDisasm, PDBGFFLOW phFlow);
2670VMMR3DECL(uint32_t) DBGFR3FlowRetain(DBGFFLOW hFlow);
2671VMMR3DECL(uint32_t) DBGFR3FlowRelease(DBGFFLOW hFlow);
2672VMMR3DECL(int) DBGFR3FlowQueryStartBb(DBGFFLOW hFlow, PDBGFFLOWBB phFlowBb);
2673VMMR3DECL(int) DBGFR3FlowQueryBbByAddress(DBGFFLOW hFlow, PDBGFADDRESS pAddr, PDBGFFLOWBB phFlowBb);
2674VMMR3DECL(int) DBGFR3FlowQueryBranchTblByAddress(DBGFFLOW hFlow, PDBGFADDRESS pAddr, PDBGFFLOWBRANCHTBL phFlowBranchTbl);
2675VMMR3DECL(uint32_t) DBGFR3FlowGetBbCount(DBGFFLOW hFlow);
2676VMMR3DECL(uint32_t) DBGFR3FlowGetBranchTblCount(DBGFFLOW hFlow);
2677
2678VMMR3DECL(uint32_t) DBGFR3FlowBbRetain(DBGFFLOWBB hFlowBb);
2679VMMR3DECL(uint32_t) DBGFR3FlowBbRelease(DBGFFLOWBB hFlowBb);
2680VMMR3DECL(PDBGFADDRESS) DBGFR3FlowBbGetStartAddress(DBGFFLOWBB hFlowBb, PDBGFADDRESS pAddrStart);
2681VMMR3DECL(PDBGFADDRESS) DBGFR3FlowBbGetEndAddress(DBGFFLOWBB hFlowBb, PDBGFADDRESS pAddrEnd);
2682VMMR3DECL(PDBGFADDRESS) DBGFR3FlowBbGetBranchAddress(DBGFFLOWBB hFlowBb, PDBGFADDRESS pAddrTarget);
2683VMMR3DECL(PDBGFADDRESS) DBGFR3FlowBbGetFollowingAddress(DBGFFLOWBB hFlowBb, PDBGFADDRESS pAddrFollow);
2684VMMR3DECL(DBGFFLOWBBENDTYPE) DBGFR3FlowBbGetType(DBGFFLOWBB hFlowBb);
2685VMMR3DECL(uint32_t) DBGFR3FlowBbGetInstrCount(DBGFFLOWBB hFlowBb);
2686VMMR3DECL(uint32_t) DBGFR3FlowBbGetFlags(DBGFFLOWBB hFlowBb);
2687VMMR3DECL(int) DBGFR3FlowBbQueryBranchTbl(DBGFFLOWBB hFlowBb, PDBGFFLOWBRANCHTBL phBranchTbl);
2688VMMR3DECL(int) DBGFR3FlowBbQueryError(DBGFFLOWBB hFlowBb, const char **ppszErr);
2689VMMR3DECL(int) DBGFR3FlowBbQueryInstr(DBGFFLOWBB hFlowBb, uint32_t idxInstr, PDBGFADDRESS pAddrInstr,
2690 uint32_t *pcbInstr, const char **ppszInstr);
2691VMMR3DECL(int) DBGFR3FlowBbQuerySuccessors(DBGFFLOWBB hFlowBb, PDBGFFLOWBB phFlowBbFollow,
2692 PDBGFFLOWBB phFlowBbTarget);
2693VMMR3DECL(uint32_t) DBGFR3FlowBbGetRefBbCount(DBGFFLOWBB hFlowBb);
2694VMMR3DECL(int) DBGFR3FlowBbGetRefBb(DBGFFLOWBB hFlowBb, PDBGFFLOWBB pahFlowBbRef, uint32_t cRef);
2695
2696VMMR3DECL(uint32_t) DBGFR3FlowBranchTblRetain(DBGFFLOWBRANCHTBL hFlowBranchTbl);
2697VMMR3DECL(uint32_t) DBGFR3FlowBranchTblRelease(DBGFFLOWBRANCHTBL hFlowBranchTbl);
2698VMMR3DECL(uint32_t) DBGFR3FlowBranchTblGetSlots(DBGFFLOWBRANCHTBL hFlowBranchTbl);
2699VMMR3DECL(PDBGFADDRESS) DBGFR3FlowBranchTblGetStartAddress(DBGFFLOWBRANCHTBL hFlowBranchTbl, PDBGFADDRESS pAddrStart);
2700VMMR3DECL(PDBGFADDRESS) DBGFR3FlowBranchTblGetAddrAtSlot(DBGFFLOWBRANCHTBL hFlowBranchTbl, uint32_t idxSlot, PDBGFADDRESS pAddrSlot);
2701VMMR3DECL(int) DBGFR3FlowBranchTblQueryAddresses(DBGFFLOWBRANCHTBL hFlowBranchTbl, PDBGFADDRESS paAddrs, uint32_t cAddrs);
2702
2703VMMR3DECL(int) DBGFR3FlowItCreate(DBGFFLOW hFlow, DBGFFLOWITORDER enmOrder, PDBGFFLOWIT phFlowIt);
2704VMMR3DECL(void) DBGFR3FlowItDestroy(DBGFFLOWIT hFlowIt);
2705VMMR3DECL(DBGFFLOWBB) DBGFR3FlowItNext(DBGFFLOWIT hFlowIt);
2706VMMR3DECL(int) DBGFR3FlowItReset(DBGFFLOWIT hFlowIt);
2707
2708VMMR3DECL(int) DBGFR3FlowBranchTblItCreate(DBGFFLOW hFlow, DBGFFLOWITORDER enmOrder, PDBGFFLOWBRANCHTBLIT phFlowBranchTblIt);
2709VMMR3DECL(void) DBGFR3FlowBranchTblItDestroy(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt);
2710VMMR3DECL(DBGFFLOWBRANCHTBL) DBGFR3FlowBranchTblItNext(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt);
2711VMMR3DECL(int) DBGFR3FlowBranchTblItReset(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt);
2712
2713/** @} */
2714
2715
2716/** @defgroup grp_dbgf_misc Misc DBGF interfaces.
2717 * @{ */
2718VMMR3DECL(VBOXSTRICTRC) DBGFR3ReportBugCheck(PVM pVM, PVMCPU pVCpu, DBGFEVENTTYPE enmEvent, uint64_t uBugCheck,
2719 uint64_t uP1, uint64_t uP2, uint64_t uP3, uint64_t uP4);
2720VMMR3DECL(int) DBGFR3FormatBugCheck(PUVM pUVM, char *pszDetails, size_t cbDetails,
2721 uint64_t uP0, uint64_t uP1, uint64_t uP2, uint64_t uP3, uint64_t uP4);
2722/** @} */
2723#endif /* IN_RING3 */
2724
2725/** @} */
2726
2727
2728RT_C_DECLS_END
2729
2730#endif
2731
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