VirtualBox

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

Last change on this file since 65049 was 64770, checked in by vboxsync, 8 years ago

VMM/DBGF, HM: Fix int3 based breakpoints set in the VM debugger when using VT-x.

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