VirtualBox

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

Last change on this file since 67987 was 66885, checked in by vboxsync, 8 years ago

DBGFReg: Added support for YMM registers, expanding the DBGFREVAL type to 512 in preparation for ZMM regs of AVX-512.

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