VirtualBox

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

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

VMM,DBGF: Improved unwinding of ring-0 assertion stacks, making the new unwind info stuff deal correctly with ring-0 pointers and such. bugref:3897

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