VirtualBox

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

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

DBGF: Added DBGFR3StepEx for simple step-over support as well as both step/trace to call, step/trace to return, step/trace to one instruction after return. Also added DBGFR3CpuIsInV86Code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 108.1 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, PDBGFADDRESS 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 /** Recompiler breakpoint data. */
794 struct DBGFBPINT3
795 {
796 /** The flat GC address of the breakpoint. */
797 RTGCUINTPTR GCPtr;
798 /** The byte value we replaced by the INT 3 instruction. */
799 uint8_t bOrg;
800 } Int3;
801
802 /** Recompiler breakpoint data. */
803 struct DBGFBPREM
804 {
805 /** The flat GC address of the breakpoint.
806 * (PC register value?) */
807 RTGCUINTPTR GCPtr;
808 } Rem;
809
810 /** I/O port breakpoint data. */
811 struct DBGFBPPORTIO
812 {
813 /** The first port. */
814 RTIOPORT uPort;
815 /** The number of ports. */
816 RTIOPORT cPorts;
817 /** Valid DBGFBPIOACCESS_XXX selection, max DWORD size. */
818 uint32_t fAccess;
819 } PortIo;
820
821 /** Memory mapped I/O breakpoint data. */
822 struct DBGFBPMMIO
823 {
824 /** The first MMIO address. */
825 RTGCPHYS PhysAddr;
826 /** The size of the MMIO range in bytes. */
827 uint32_t cb;
828 /** Valid DBGFBPIOACCESS_XXX selection, max DWORD size. */
829 uint32_t fAccess;
830 } Mmio;
831
832 /** Paddind to ensure that the size is identical on win32 and linux. */
833 uint64_t u64Padding[2];
834 } u;
835} DBGFBP;
836AssertCompileMembersAtSameOffset(DBGFBP, u.GCPtr, DBGFBP, u.Reg.GCPtr);
837AssertCompileMembersAtSameOffset(DBGFBP, u.GCPtr, DBGFBP, u.Int3.GCPtr);
838AssertCompileMembersAtSameOffset(DBGFBP, u.GCPtr, DBGFBP, u.Rem.GCPtr);
839
840/** Pointer to a breakpoint. */
841typedef DBGFBP *PDBGFBP;
842/** Pointer to a const breakpoint. */
843typedef const DBGFBP *PCDBGFBP;
844
845#ifdef IN_RING3 /* The breakpoint management API is only available in ring-3. */
846VMMR3DECL(int) DBGFR3BpSet(PUVM pUVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
847VMMR3DECL(int) DBGFR3BpSetReg(PUVM pUVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable,
848 uint8_t fType, uint8_t cb, uint32_t *piBp);
849VMMR3DECL(int) DBGFR3BpSetREM(PUVM pUVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
850VMMR3DECL(int) DBGFR3BpSetPortIo(PUVM pUVM, RTIOPORT uPort, RTIOPORT cPorts, uint32_t fAccess,
851 uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
852VMMR3DECL(int) DBGFR3BpSetMmio(PUVM pUVM, RTGCPHYS GCPhys, uint32_t cb, uint32_t fAccess,
853 uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
854VMMR3DECL(int) DBGFR3BpClear(PUVM pUVM, uint32_t iBp);
855VMMR3DECL(int) DBGFR3BpEnable(PUVM pUVM, uint32_t iBp);
856VMMR3DECL(int) DBGFR3BpDisable(PUVM pUVM, uint32_t iBp);
857
858/**
859 * Breakpoint enumeration callback function.
860 *
861 * @returns VBox status code.
862 * The enumeration stops on failure status and VINF_CALLBACK_RETURN.
863 * @param pUVM The user mode VM handle.
864 * @param pvUser The user argument.
865 * @param pBp Pointer to the breakpoint information. (readonly)
866 */
867typedef DECLCALLBACK(int) FNDBGFBPENUM(PUVM pUVM, void *pvUser, PCDBGFBP pBp);
868/** Pointer to a breakpoint enumeration callback function. */
869typedef FNDBGFBPENUM *PFNDBGFBPENUM;
870
871VMMR3DECL(int) DBGFR3BpEnum(PUVM pUVM, PFNDBGFBPENUM pfnCallback, void *pvUser);
872#endif /* IN_RING3 */
873
874VMM_INT_DECL(RTGCUINTREG) DBGFBpGetDR7(PVM pVM);
875VMM_INT_DECL(RTGCUINTREG) DBGFBpGetDR0(PVM pVM);
876VMM_INT_DECL(RTGCUINTREG) DBGFBpGetDR1(PVM pVM);
877VMM_INT_DECL(RTGCUINTREG) DBGFBpGetDR2(PVM pVM);
878VMM_INT_DECL(RTGCUINTREG) DBGFBpGetDR3(PVM pVM);
879VMM_INT_DECL(bool) DBGFBpIsHwArmed(PVM pVM);
880VMM_INT_DECL(bool) DBGFBpIsHwIoArmed(PVM pVM);
881VMM_INT_DECL(bool) DBGFIsStepping(PVMCPU pVCpu);
882VMM_INT_DECL(VBOXSTRICTRC) DBGFBpCheckIo(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, RTIOPORT uIoPort, uint8_t cbValue);
883VMM_INT_DECL(VBOXSTRICTRC) DBGFEventGenericWithArg(PVM pVM, PVMCPU pVCpu, DBGFEVENTTYPE enmEvent, uint64_t uEventArg,
884 DBGFEVENTCTX enmCtx);
885
886
887#ifdef IN_RING3 /* The CPU mode API only works in ring-3. */
888VMMR3DECL(CPUMMODE) DBGFR3CpuGetMode(PUVM pUVM, VMCPUID idCpu);
889VMMR3DECL(VMCPUID) DBGFR3CpuGetCount(PUVM pUVM);
890VMMR3DECL(bool) DBGFR3CpuIsIn64BitCode(PUVM pUVM, VMCPUID idCpu);
891VMMR3DECL(bool) DBGFR3CpuIsInV86Code(PUVM pUVM, VMCPUID idCpu);
892#endif
893
894
895
896#ifdef IN_RING3 /* The info callbacks API only works in ring-3. */
897
898/**
899 * Info helper callback structure.
900 */
901typedef struct DBGFINFOHLP
902{
903 /**
904 * Print formatted string.
905 *
906 * @param pHlp Pointer to this structure.
907 * @param pszFormat The format string.
908 * @param ... Arguments.
909 */
910 DECLCALLBACKMEMBER(void, pfnPrintf)(PCDBGFINFOHLP pHlp, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3);
911
912 /**
913 * Print formatted string.
914 *
915 * @param pHlp Pointer to this structure.
916 * @param pszFormat The format string.
917 * @param args Argument list.
918 */
919 DECLCALLBACKMEMBER(void, pfnPrintfV)(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(2, 0);
920} DBGFINFOHLP;
921
922
923/**
924 * Info handler, device version.
925 *
926 * @param pDevIns The device instance which registered the info.
927 * @param pHlp Callback functions for doing output.
928 * @param pszArgs Argument string. Optional and specific to the handler.
929 */
930typedef DECLCALLBACK(void) FNDBGFHANDLERDEV(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
931/** Pointer to a FNDBGFHANDLERDEV function. */
932typedef FNDBGFHANDLERDEV *PFNDBGFHANDLERDEV;
933
934/**
935 * Info handler, USB device version.
936 *
937 * @param pUsbIns The USB device instance which registered the info.
938 * @param pHlp Callback functions for doing output.
939 * @param pszArgs Argument string. Optional and specific to the handler.
940 */
941typedef DECLCALLBACK(void) FNDBGFHANDLERUSB(PPDMUSBINS pUsbIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
942/** Pointer to a FNDBGFHANDLERUSB function. */
943typedef FNDBGFHANDLERUSB *PFNDBGFHANDLERUSB;
944
945/**
946 * Info handler, driver version.
947 *
948 * @param pDrvIns The driver instance which registered the info.
949 * @param pHlp Callback functions for doing output.
950 * @param pszArgs Argument string. Optional and specific to the handler.
951 */
952typedef DECLCALLBACK(void) FNDBGFHANDLERDRV(PPDMDRVINS pDrvIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
953/** Pointer to a FNDBGFHANDLERDRV function. */
954typedef FNDBGFHANDLERDRV *PFNDBGFHANDLERDRV;
955
956/**
957 * Info handler, internal version.
958 *
959 * @param pVM The cross context VM structure.
960 * @param pHlp Callback functions for doing output.
961 * @param pszArgs Argument string. Optional and specific to the handler.
962 */
963typedef DECLCALLBACK(void) FNDBGFHANDLERINT(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
964/** Pointer to a FNDBGFHANDLERINT function. */
965typedef FNDBGFHANDLERINT *PFNDBGFHANDLERINT;
966
967/**
968 * Info handler, external version.
969 *
970 * @param pvUser User argument.
971 * @param pHlp Callback functions for doing output.
972 * @param pszArgs Argument string. Optional and specific to the handler.
973 */
974typedef DECLCALLBACK(void) FNDBGFHANDLEREXT(void *pvUser, PCDBGFINFOHLP pHlp, const char *pszArgs);
975/** Pointer to a FNDBGFHANDLEREXT function. */
976typedef FNDBGFHANDLEREXT *PFNDBGFHANDLEREXT;
977
978
979/** @name Flags for the info registration functions.
980 * @{ */
981/** The handler must run on the EMT. */
982#define DBGFINFO_FLAGS_RUN_ON_EMT RT_BIT(0)
983/** Call on all EMTs when a specific isn't specified. */
984#define DBGFINFO_FLAGS_ALL_EMTS RT_BIT(1)
985/** @} */
986
987VMMR3_INT_DECL(int) DBGFR3InfoRegisterDevice(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler, PPDMDEVINS pDevIns);
988VMMR3_INT_DECL(int) DBGFR3InfoRegisterDriver(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler, PPDMDRVINS pDrvIns);
989VMMR3_INT_DECL(int) DBGFR3InfoRegisterInternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler);
990VMMR3_INT_DECL(int) DBGFR3InfoRegisterInternalEx(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler, uint32_t fFlags);
991VMMR3DECL(int) DBGFR3InfoRegisterExternal(PUVM pUVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLEREXT pfnHandler, void *pvUser);
992VMMR3_INT_DECL(int) DBGFR3InfoDeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName);
993VMMR3_INT_DECL(int) DBGFR3InfoDeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName);
994VMMR3_INT_DECL(int) DBGFR3InfoDeregisterInternal(PVM pVM, const char *pszName);
995VMMR3DECL(int) DBGFR3InfoDeregisterExternal(PUVM pUVM, const char *pszName);
996VMMR3DECL(int) DBGFR3Info(PUVM pUVM, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp);
997VMMR3DECL(int) DBGFR3InfoEx(PUVM pUVM, VMCPUID idCpu, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp);
998VMMR3DECL(int) DBGFR3InfoLogRel(PUVM pUVM, const char *pszName, const char *pszArgs);
999VMMR3DECL(int) DBGFR3InfoStdErr(PUVM pUVM, const char *pszName, const char *pszArgs);
1000VMMR3_INT_DECL(int) DBGFR3InfoMulti(PVM pVM, const char *pszIncludePat, const char *pszExcludePat,
1001 const char *pszSepFmt, PCDBGFINFOHLP pHlp);
1002
1003/** @def DBGFR3_INFO_LOG
1004 * Display a piece of info writing to the log if enabled.
1005 *
1006 * This is for execution on EMTs and will only show the items on the calling
1007 * EMT. This is to avoid deadlocking against other CPUs if a rendezvous is
1008 * initiated in parallel to this call. (Besides, nobody really wants or need
1009 * info for the other EMTs when using this macro.)
1010 *
1011 * @param a_pVM The shared VM handle.
1012 * @param a_pVCpu The cross context per CPU structure of the calling EMT.
1013 * @param a_pszName The identifier of the info to display.
1014 * @param a_pszArgs Arguments to the info handler.
1015 */
1016#ifdef LOG_ENABLED
1017# define DBGFR3_INFO_LOG(a_pVM, a_pVCpu, a_pszName, a_pszArgs) \
1018 do { \
1019 if (LogIsEnabled()) \
1020 DBGFR3InfoEx((a_pVM)->pUVM, (a_pVCpu)->idCpu, a_pszName, a_pszArgs, NULL); \
1021 } while (0)
1022#else
1023# define DBGFR3_INFO_LOG(a_pVM, a_pVCpu, a_pszName, a_pszArgs) do { } while (0)
1024#endif
1025
1026/** @def DBGFR3_INFO_LOG_SAFE
1027 * Display a piece of info (rendezvous safe) writing to the log if enabled.
1028 *
1029 * @param a_pVM The shared VM handle.
1030 * @param a_pszName The identifier of the info to display.
1031 * @param a_pszArgs Arguments to the info handler.
1032 *
1033 * @remarks Use DBGFR3_INFO_LOG where ever possible!
1034 */
1035#ifdef LOG_ENABLED
1036# define DBGFR3_INFO_LOG_SAFE(a_pVM, a_pszName, a_pszArgs) \
1037 do { \
1038 if (LogIsEnabled()) \
1039 DBGFR3Info((a_pVM)->pUVM, a_pszName, a_pszArgs, NULL); \
1040 } while (0)
1041#else
1042# define DBGFR3_INFO_LOG_SAFE(a_pVM, a_pszName, a_pszArgs) do { } while (0)
1043#endif
1044
1045/**
1046 * Enumeration callback for use with DBGFR3InfoEnum.
1047 *
1048 * @returns VBox status code.
1049 * A status code indicating failure will end the enumeration
1050 * and DBGFR3InfoEnum will return with that status code.
1051 * @param pUVM The user mode VM handle.
1052 * @param pszName Info identifier name.
1053 * @param pszDesc The description.
1054 */
1055typedef DECLCALLBACK(int) FNDBGFINFOENUM(PUVM pUVM, const char *pszName, const char *pszDesc, void *pvUser);
1056/** Pointer to a FNDBGFINFOENUM function. */
1057typedef FNDBGFINFOENUM *PFNDBGFINFOENUM;
1058
1059VMMR3DECL(int) DBGFR3InfoEnum(PUVM pUVM, PFNDBGFINFOENUM pfnCallback, void *pvUser);
1060VMMR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogHlp(void);
1061VMMR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogRelHlp(void);
1062
1063#endif /* IN_RING3 */
1064
1065
1066#ifdef IN_RING3 /* The log contrl API only works in ring-3. */
1067VMMR3DECL(int) DBGFR3LogModifyGroups(PUVM pUVM, const char *pszGroupSettings);
1068VMMR3DECL(int) DBGFR3LogModifyFlags(PUVM pUVM, const char *pszFlagSettings);
1069VMMR3DECL(int) DBGFR3LogModifyDestinations(PUVM pUVM, const char *pszDestSettings);
1070#endif /* IN_RING3 */
1071
1072#ifdef IN_RING3 /* The debug information management APIs only works in ring-3. */
1073
1074/** Max length (including '\\0') of a symbol name. */
1075#define DBGF_SYMBOL_NAME_LENGTH 512
1076
1077/**
1078 * Debug symbol.
1079 */
1080typedef struct DBGFSYMBOL
1081{
1082 /** Symbol value (address). */
1083 RTGCUINTPTR Value;
1084 /** Symbol size. */
1085 uint32_t cb;
1086 /** Symbol Flags. (reserved). */
1087 uint32_t fFlags;
1088 /** Symbol name. */
1089 char szName[DBGF_SYMBOL_NAME_LENGTH];
1090} DBGFSYMBOL;
1091/** Pointer to debug symbol. */
1092typedef DBGFSYMBOL *PDBGFSYMBOL;
1093/** Pointer to const debug symbol. */
1094typedef const DBGFSYMBOL *PCDBGFSYMBOL;
1095
1096/**
1097 * Debug line number information.
1098 */
1099typedef struct DBGFLINE
1100{
1101 /** Address. */
1102 RTGCUINTPTR Address;
1103 /** Line number. */
1104 uint32_t uLineNo;
1105 /** Filename. */
1106 char szFilename[260];
1107} DBGFLINE;
1108/** Pointer to debug line number. */
1109typedef DBGFLINE *PDBGFLINE;
1110/** Pointer to const debug line number. */
1111typedef const DBGFLINE *PCDBGFLINE;
1112
1113/** @name Address spaces aliases.
1114 * @{ */
1115/** The guest global address space. */
1116#define DBGF_AS_GLOBAL ((RTDBGAS)-1)
1117/** The guest kernel address space.
1118 * This is usually resolves to the same as DBGF_AS_GLOBAL. */
1119#define DBGF_AS_KERNEL ((RTDBGAS)-2)
1120/** The physical address space. */
1121#define DBGF_AS_PHYS ((RTDBGAS)-3)
1122/** Raw-mode context. */
1123#define DBGF_AS_RC ((RTDBGAS)-4)
1124/** Ring-0 context. */
1125#define DBGF_AS_R0 ((RTDBGAS)-5)
1126/** Raw-mode context and then global guest context.
1127 * When used for looking up information, it works as if the call was first made
1128 * with DBGF_AS_RC and then on failure with DBGF_AS_GLOBAL. When called for
1129 * making address space changes, it works as if DBGF_AS_RC was used. */
1130#define DBGF_AS_RC_AND_GC_GLOBAL ((RTDBGAS)-6)
1131
1132/** The first special one. */
1133#define DBGF_AS_FIRST DBGF_AS_RC_AND_GC_GLOBAL
1134/** The last special one. */
1135#define DBGF_AS_LAST DBGF_AS_GLOBAL
1136#endif
1137/** The number of special address space handles. */
1138#define DBGF_AS_COUNT (6U)
1139#ifdef IN_RING3
1140/** Converts an alias handle to an array index. */
1141#define DBGF_AS_ALIAS_2_INDEX(hAlias) \
1142 ( (uintptr_t)(hAlias) - (uintptr_t)DBGF_AS_FIRST )
1143/** Predicat macro that check if the specified handle is an alias. */
1144#define DBGF_AS_IS_ALIAS(hAlias) \
1145 ( DBGF_AS_ALIAS_2_INDEX(hAlias) < DBGF_AS_COUNT )
1146/** Predicat macro that check if the specified alias is a fixed one or not. */
1147#define DBGF_AS_IS_FIXED_ALIAS(hAlias) \
1148 ( DBGF_AS_ALIAS_2_INDEX(hAlias) < (uintptr_t)DBGF_AS_PHYS - (uintptr_t)DBGF_AS_FIRST + 1U )
1149
1150/** @} */
1151
1152VMMR3DECL(RTDBGCFG) DBGFR3AsGetConfig(PUVM pUVM);
1153
1154VMMR3DECL(int) DBGFR3AsAdd(PUVM pUVM, RTDBGAS hDbgAs, RTPROCESS ProcId);
1155VMMR3DECL(int) DBGFR3AsDelete(PUVM pUVM, RTDBGAS hDbgAs);
1156VMMR3DECL(int) DBGFR3AsSetAlias(PUVM pUVM, RTDBGAS hAlias, RTDBGAS hAliasFor);
1157VMMR3DECL(RTDBGAS) DBGFR3AsResolve(PUVM pUVM, RTDBGAS hAlias);
1158VMMR3DECL(RTDBGAS) DBGFR3AsResolveAndRetain(PUVM pUVM, RTDBGAS hAlias);
1159VMMR3DECL(RTDBGAS) DBGFR3AsQueryByName(PUVM pUVM, const char *pszName);
1160VMMR3DECL(RTDBGAS) DBGFR3AsQueryByPid(PUVM pUVM, RTPROCESS ProcId);
1161
1162VMMR3DECL(int) DBGFR3AsLoadImage(PUVM pUVM, RTDBGAS hDbgAs, const char *pszFilename, const char *pszModName,
1163 RTLDRARCH enmArch, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, uint32_t fFlags);
1164VMMR3DECL(int) DBGFR3AsLoadMap(PUVM pUVM, RTDBGAS hDbgAs, const char *pszFilename, const char *pszModName, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, RTGCUINTPTR uSubtrahend, uint32_t fFlags);
1165VMMR3DECL(int) DBGFR3AsLinkModule(PUVM pUVM, RTDBGAS hDbgAs, RTDBGMOD hMod, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, uint32_t fFlags);
1166VMMR3DECL(int) DBGFR3AsUnlinkModuleByName(PUVM pUVM, RTDBGAS hDbgAs, const char *pszModName);
1167
1168VMMR3DECL(int) DBGFR3AsSymbolByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, uint32_t fFlags,
1169 PRTGCINTPTR poffDisp, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
1170VMMR3DECL(PRTDBGSYMBOL) DBGFR3AsSymbolByAddrA(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, uint32_t Flags,
1171 PRTGCINTPTR poffDisp, PRTDBGMOD phMod);
1172VMMR3DECL(int) DBGFR3AsSymbolByName(PUVM pUVM, RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
1173
1174VMMR3DECL(int) DBGFR3AsLineByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
1175 PRTGCINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod);
1176VMMR3DECL(PRTDBGLINE) DBGFR3AsLineByAddrA(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
1177 PRTGCINTPTR poffDisp, PRTDBGMOD phMod);
1178
1179#endif /* IN_RING3 */
1180
1181#ifdef IN_RING3 /* The stack API only works in ring-3. */
1182
1183/**
1184 * Return type.
1185 */
1186typedef enum DBGFRETRUNTYPE
1187{
1188 /** The usual invalid 0 value. */
1189 DBGFRETURNTYPE_INVALID = 0,
1190 /** Near 16-bit return. */
1191 DBGFRETURNTYPE_NEAR16,
1192 /** Near 32-bit return. */
1193 DBGFRETURNTYPE_NEAR32,
1194 /** Near 64-bit return. */
1195 DBGFRETURNTYPE_NEAR64,
1196 /** Far 16:16 return. */
1197 DBGFRETURNTYPE_FAR16,
1198 /** Far 16:32 return. */
1199 DBGFRETURNTYPE_FAR32,
1200 /** Far 16:64 return. */
1201 DBGFRETURNTYPE_FAR64,
1202 /** 16-bit iret return (e.g. real or 286 protect mode). */
1203 DBGFRETURNTYPE_IRET16,
1204 /** 32-bit iret return. */
1205 DBGFRETURNTYPE_IRET32,
1206 /** 32-bit iret return. */
1207 DBGFRETURNTYPE_IRET32_PRIV,
1208 /** 32-bit iret return to V86 mode. */
1209 DBGFRETURNTYPE_IRET32_V86,
1210 /** @todo 64-bit iret return. */
1211 DBGFRETURNTYPE_IRET64,
1212 /** The end of the valid return types. */
1213 DBGFRETURNTYPE_END,
1214 /** The usual 32-bit blowup. */
1215 DBGFRETURNTYPE_32BIT_HACK = 0x7fffffff
1216} DBGFRETURNTYPE;
1217
1218/**
1219 * Figures the size of the return state on the stack.
1220 *
1221 * @returns number of bytes. 0 if invalid parameter.
1222 * @param enmRetType The type of return.
1223 */
1224DECLINLINE(unsigned) DBGFReturnTypeSize(DBGFRETURNTYPE enmRetType)
1225{
1226 switch (enmRetType)
1227 {
1228 case DBGFRETURNTYPE_NEAR16: return 2;
1229 case DBGFRETURNTYPE_NEAR32: return 4;
1230 case DBGFRETURNTYPE_NEAR64: return 8;
1231 case DBGFRETURNTYPE_FAR16: return 4;
1232 case DBGFRETURNTYPE_FAR32: return 4;
1233 case DBGFRETURNTYPE_FAR64: return 8;
1234 case DBGFRETURNTYPE_IRET16: return 6;
1235 case DBGFRETURNTYPE_IRET32: return 4*3;
1236 case DBGFRETURNTYPE_IRET32_PRIV: return 4*5;
1237 case DBGFRETURNTYPE_IRET32_V86: return 4*9;
1238 case DBGFRETURNTYPE_IRET64:
1239 default:
1240 return 0;
1241 }
1242}
1243
1244
1245/** Pointer to stack frame info. */
1246typedef struct DBGFSTACKFRAME *PDBGFSTACKFRAME;
1247/** Pointer to const stack frame info. */
1248typedef struct DBGFSTACKFRAME const *PCDBGFSTACKFRAME;
1249/**
1250 * Info about a stack frame.
1251 */
1252typedef struct DBGFSTACKFRAME
1253{
1254 /** Frame number. */
1255 uint32_t iFrame;
1256 /** Frame flags. */
1257 uint32_t fFlags;
1258 /** The frame address.
1259 * The off member is [e|r]bp and the Sel member is ss. */
1260 DBGFADDRESS AddrFrame;
1261 /** The stack address of the frame.
1262 * The off member is [e|r]sp and the Sel member is ss. */
1263 DBGFADDRESS AddrStack;
1264 /** The program counter (PC) address of the frame.
1265 * The off member is [e|r]ip and the Sel member is cs. */
1266 DBGFADDRESS AddrPC;
1267 /** Pointer to the symbol nearest the program counter (PC). NULL if not found. */
1268 PRTDBGSYMBOL pSymPC;
1269 /** Pointer to the linnumber nearest the program counter (PC). NULL if not found. */
1270 PRTDBGLINE pLinePC;
1271
1272 /** The return frame address.
1273 * The off member is [e|r]bp and the Sel member is ss. */
1274 DBGFADDRESS AddrReturnFrame;
1275 /** The return stack address.
1276 * The off member is [e|r]sp and the Sel member is ss. */
1277 DBGFADDRESS AddrReturnStack;
1278 /** The way this frame returns to the next one. */
1279 DBGFRETURNTYPE enmReturnType;
1280
1281 /** The program counter (PC) address which the frame returns to.
1282 * The off member is [e|r]ip and the Sel member is cs. */
1283 DBGFADDRESS AddrReturnPC;
1284 /** Pointer to the symbol nearest the return PC. NULL if not found. */
1285 PRTDBGSYMBOL pSymReturnPC;
1286 /** Pointer to the linnumber nearest the return PC. NULL if not found. */
1287 PRTDBGLINE pLineReturnPC;
1288
1289 /** 32-bytes of stack arguments. */
1290 union
1291 {
1292 /** 64-bit view */
1293 uint64_t au64[4];
1294 /** 32-bit view */
1295 uint32_t au32[8];
1296 /** 16-bit view */
1297 uint16_t au16[16];
1298 /** 8-bit view */
1299 uint8_t au8[32];
1300 } Args;
1301
1302 /** Pointer to the next frame.
1303 * Might not be used in some cases, so consider it internal. */
1304 PCDBGFSTACKFRAME pNextInternal;
1305 /** Pointer to the first frame.
1306 * Might not be used in some cases, so consider it internal. */
1307 PCDBGFSTACKFRAME pFirstInternal;
1308} DBGFSTACKFRAME;
1309
1310/** @name DBGFSTACKFRAME Flags.
1311 * @{ */
1312/** Set if the content of the frame is filled in by DBGFR3StackWalk() and can be used
1313 * to construct the next frame. */
1314# define DBGFSTACKFRAME_FLAGS_ALL_VALID RT_BIT(0)
1315/** This is the last stack frame we can read.
1316 * This flag is not set if the walk stop because of max dept or recursion. */
1317# define DBGFSTACKFRAME_FLAGS_LAST RT_BIT(1)
1318/** This is the last record because we detected a loop. */
1319# define DBGFSTACKFRAME_FLAGS_LOOP RT_BIT(2)
1320/** This is the last record because we reached the maximum depth. */
1321# define DBGFSTACKFRAME_FLAGS_MAX_DEPTH RT_BIT(3)
1322/** 16-bit frame. */
1323# define DBGFSTACKFRAME_FLAGS_16BIT RT_BIT(4)
1324/** 32-bit frame. */
1325# define DBGFSTACKFRAME_FLAGS_32BIT RT_BIT(5)
1326/** 64-bit frame. */
1327# define DBGFSTACKFRAME_FLAGS_64BIT RT_BIT(6)
1328/** Used Odd/even heuristics for far/near return. */
1329# define DBGFSTACKFRAME_FLAGS_USED_ODD_EVEN RT_BIT(7)
1330/** @} */
1331
1332/** @name DBGFCODETYPE
1333 * @{ */
1334typedef enum DBGFCODETYPE
1335{
1336 /** The usual invalid 0 value. */
1337 DBGFCODETYPE_INVALID = 0,
1338 /** Stack walk for guest code. */
1339 DBGFCODETYPE_GUEST,
1340 /** Stack walk for hypervisor code. */
1341 DBGFCODETYPE_HYPER,
1342 /** Stack walk for ring 0 code. */
1343 DBGFCODETYPE_RING0,
1344 /** The usual 32-bit blowup. */
1345 DBGFCODETYPE_32BIT_HACK = 0x7fffffff
1346} DBGFCODETYPE;
1347/** @} */
1348
1349VMMR3DECL(int) DBGFR3StackWalkBegin(PUVM pUVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType,
1350 PCDBGFSTACKFRAME *ppFirstFrame);
1351VMMR3DECL(int) DBGFR3StackWalkBeginEx(PUVM pUVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType, PCDBGFADDRESS pAddrFrame,
1352 PCDBGFADDRESS pAddrStack,PCDBGFADDRESS pAddrPC,
1353 DBGFRETURNTYPE enmReturnType, PCDBGFSTACKFRAME *ppFirstFrame);
1354VMMR3DECL(PCDBGFSTACKFRAME) DBGFR3StackWalkNext(PCDBGFSTACKFRAME pCurrent);
1355VMMR3DECL(void) DBGFR3StackWalkEnd(PCDBGFSTACKFRAME pFirstFrame);
1356
1357#endif /* IN_RING3 */
1358
1359
1360#ifdef IN_RING3 /* The disassembly API only works in ring-3. */
1361
1362/** @name Flags to pass to DBGFR3DisasInstrEx().
1363 * @{ */
1364/** Disassemble the current guest instruction, with annotations. */
1365#define DBGF_DISAS_FLAGS_CURRENT_GUEST RT_BIT(0)
1366/** Disassemble the current hypervisor instruction, with annotations. */
1367#define DBGF_DISAS_FLAGS_CURRENT_HYPER RT_BIT(1)
1368/** No annotations for current context. */
1369#define DBGF_DISAS_FLAGS_NO_ANNOTATION RT_BIT(2)
1370/** No symbol lookup. */
1371#define DBGF_DISAS_FLAGS_NO_SYMBOLS RT_BIT(3)
1372/** No instruction bytes. */
1373#define DBGF_DISAS_FLAGS_NO_BYTES RT_BIT(4)
1374/** No address in the output. */
1375#define DBGF_DISAS_FLAGS_NO_ADDRESS RT_BIT(5)
1376/** Probably a hypervisor instruction. */
1377#define DBGF_DISAS_FLAGS_HYPER RT_BIT(6)
1378/** Disassemble original unpatched bytes (PATM). */
1379#define DBGF_DISAS_FLAGS_UNPATCHED_BYTES RT_BIT(7)
1380/** Annotate patched instructions. */
1381#define DBGF_DISAS_FLAGS_ANNOTATE_PATCHED RT_BIT(8)
1382/** Disassemble in the default mode of the specific context. */
1383#define DBGF_DISAS_FLAGS_DEFAULT_MODE UINT32_C(0x00000000)
1384/** Disassemble in 16-bit mode. */
1385#define DBGF_DISAS_FLAGS_16BIT_MODE UINT32_C(0x10000000)
1386/** Disassemble in 16-bit mode with real mode address translation. */
1387#define DBGF_DISAS_FLAGS_16BIT_REAL_MODE UINT32_C(0x20000000)
1388/** Disassemble in 32-bit mode. */
1389#define DBGF_DISAS_FLAGS_32BIT_MODE UINT32_C(0x30000000)
1390/** Disassemble in 64-bit mode. */
1391#define DBGF_DISAS_FLAGS_64BIT_MODE UINT32_C(0x40000000)
1392/** The disassembly mode mask. */
1393#define DBGF_DISAS_FLAGS_MODE_MASK UINT32_C(0x70000000)
1394/** Mask containing the valid flags. */
1395#define DBGF_DISAS_FLAGS_VALID_MASK UINT32_C(0x700001ff)
1396/** @} */
1397
1398/** Special flat selector. */
1399#define DBGF_SEL_FLAT 1
1400
1401VMMR3DECL(int) DBGFR3DisasInstrEx(PUVM pUVM, VMCPUID idCpu, RTSEL Sel, RTGCPTR GCPtr, uint32_t fFlags,
1402 char *pszOutput, uint32_t cbOutput, uint32_t *pcbInstr);
1403VMMR3_INT_DECL(int) DBGFR3DisasInstrCurrent(PVMCPU pVCpu, char *pszOutput, uint32_t cbOutput);
1404VMMR3DECL(int) DBGFR3DisasInstrCurrentLogInternal(PVMCPU pVCpu, const char *pszPrefix);
1405
1406/** @def DBGFR3_DISAS_INSTR_CUR_LOG
1407 * Disassembles the current guest context instruction and writes it to the log.
1408 * All registers and data will be displayed. Addresses will be attempted resolved to symbols.
1409 */
1410#ifdef LOG_ENABLED
1411# define DBGFR3_DISAS_INSTR_CUR_LOG(pVCpu, pszPrefix) \
1412 do { \
1413 if (LogIsEnabled()) \
1414 DBGFR3DisasInstrCurrentLogInternal(pVCpu, pszPrefix); \
1415 } while (0)
1416#else
1417# define DBGFR3_DISAS_INSTR_CUR_LOG(pVCpu, pszPrefix) do { } while (0)
1418#endif
1419
1420VMMR3DECL(int) DBGFR3DisasInstrLogInternal(PVMCPU pVCpu, RTSEL Sel, RTGCPTR GCPtr, const char *pszPrefix);
1421
1422/** @def DBGFR3_DISAS_INSTR_LOG
1423 * Disassembles the specified guest context instruction and writes it to the log.
1424 * Addresses will be attempted resolved to symbols.
1425 * @thread Any EMT.
1426 */
1427# ifdef LOG_ENABLED
1428# define DBGFR3_DISAS_INSTR_LOG(pVCpu, Sel, GCPtr, pszPrefix) \
1429 do { \
1430 if (LogIsEnabled()) \
1431 DBGFR3DisasInstrLogInternal(pVCpu, Sel, GCPtr, pszPrefix); \
1432 } while (0)
1433# else
1434# define DBGFR3_DISAS_INSTR_LOG(pVCpu, Sel, GCPtr, pszPrefix) do { } while (0)
1435# endif
1436#endif
1437
1438
1439#ifdef IN_RING3
1440VMMR3DECL(int) DBGFR3MemScan(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, RTGCUINTPTR uAlign,
1441 const void *pvNeedle, size_t cbNeedle, PDBGFADDRESS pHitAddress);
1442VMMR3DECL(int) DBGFR3MemRead(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void *pvBuf, size_t cbRead);
1443VMMR3DECL(int) DBGFR3MemReadString(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, char *pszBuf, size_t cbBuf);
1444VMMR3DECL(int) DBGFR3MemWrite(PUVM pUVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void const *pvBuf, size_t cbRead);
1445#endif
1446
1447
1448/** @name Flags for DBGFR3PagingDumpEx, PGMR3DumpHierarchyHCEx and
1449 * PGMR3DumpHierarchyGCEx
1450 * @{ */
1451/** The CR3 from the current CPU state. */
1452#define DBGFPGDMP_FLAGS_CURRENT_CR3 RT_BIT_32(0)
1453/** The current CPU paging mode (PSE, PAE, LM, EPT, NX). */
1454#define DBGFPGDMP_FLAGS_CURRENT_MODE RT_BIT_32(1)
1455/** Whether PSE is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
1456 * Same value as X86_CR4_PSE. */
1457#define DBGFPGDMP_FLAGS_PSE RT_BIT_32(4) /* */
1458/** Whether PAE is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
1459 * Same value as X86_CR4_PAE. */
1460#define DBGFPGDMP_FLAGS_PAE RT_BIT_32(5) /* */
1461/** Whether LME is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
1462 * Same value as MSR_K6_EFER_LME. */
1463#define DBGFPGDMP_FLAGS_LME RT_BIT_32(8)
1464/** Whether nested paging is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE). */
1465#define DBGFPGDMP_FLAGS_NP RT_BIT_32(9)
1466/** Whether extended nested page tables are enabled
1467 * (!DBGFPGDMP_FLAGS_CURRENT_STATE). */
1468#define DBGFPGDMP_FLAGS_EPT RT_BIT_32(10)
1469/** Whether no-execution is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
1470 * Same value as MSR_K6_EFER_NXE. */
1471#define DBGFPGDMP_FLAGS_NXE RT_BIT_32(11)
1472/** Whether to print the CR3. */
1473#define DBGFPGDMP_FLAGS_PRINT_CR3 RT_BIT_32(27)
1474/** Whether to print the header. */
1475#define DBGFPGDMP_FLAGS_HEADER RT_BIT_32(28)
1476/** Whether to dump additional page information. */
1477#define DBGFPGDMP_FLAGS_PAGE_INFO RT_BIT_32(29)
1478/** Dump the shadow tables if set.
1479 * Cannot be used together with DBGFPGDMP_FLAGS_GUEST. */
1480#define DBGFPGDMP_FLAGS_SHADOW RT_BIT_32(30)
1481/** Dump the guest tables if set.
1482 * Cannot be used together with DBGFPGDMP_FLAGS_SHADOW. */
1483#define DBGFPGDMP_FLAGS_GUEST RT_BIT_32(31)
1484/** Mask of valid bits. */
1485#define DBGFPGDMP_FLAGS_VALID_MASK UINT32_C(0xf8000f33)
1486/** The mask of bits controlling the paging mode. */
1487#define DBGFPGDMP_FLAGS_MODE_MASK UINT32_C(0x00000f32)
1488/** @} */
1489VMMDECL(int) DBGFR3PagingDumpEx(PUVM pUVM, VMCPUID idCpu, uint32_t fFlags, uint64_t cr3, uint64_t u64FirstAddr,
1490 uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
1491
1492
1493/** @name DBGFR3SelQueryInfo flags.
1494 * @{ */
1495/** Get the info from the guest descriptor table. */
1496#define DBGFSELQI_FLAGS_DT_GUEST UINT32_C(0)
1497/** Get the info from the shadow descriptor table.
1498 * Only works in raw-mode. */
1499#define DBGFSELQI_FLAGS_DT_SHADOW UINT32_C(1)
1500/** If currently executing in in 64-bit mode, blow up data selectors. */
1501#define DBGFSELQI_FLAGS_DT_ADJ_64BIT_MODE UINT32_C(2)
1502/** @} */
1503VMMR3DECL(int) DBGFR3SelQueryInfo(PUVM pUVM, VMCPUID idCpu, RTSEL Sel, uint32_t fFlags, PDBGFSELINFO pSelInfo);
1504
1505
1506/**
1507 * Register identifiers.
1508 */
1509typedef enum DBGFREG
1510{
1511 /* General purpose registers: */
1512 DBGFREG_AL = 0,
1513 DBGFREG_AX = DBGFREG_AL,
1514 DBGFREG_EAX = DBGFREG_AL,
1515 DBGFREG_RAX = DBGFREG_AL,
1516
1517 DBGFREG_CL,
1518 DBGFREG_CX = DBGFREG_CL,
1519 DBGFREG_ECX = DBGFREG_CL,
1520 DBGFREG_RCX = DBGFREG_CL,
1521
1522 DBGFREG_DL,
1523 DBGFREG_DX = DBGFREG_DL,
1524 DBGFREG_EDX = DBGFREG_DL,
1525 DBGFREG_RDX = DBGFREG_DL,
1526
1527 DBGFREG_BL,
1528 DBGFREG_BX = DBGFREG_BL,
1529 DBGFREG_EBX = DBGFREG_BL,
1530 DBGFREG_RBX = DBGFREG_BL,
1531
1532 DBGFREG_SPL,
1533 DBGFREG_SP = DBGFREG_SPL,
1534 DBGFREG_ESP = DBGFREG_SPL,
1535 DBGFREG_RSP = DBGFREG_SPL,
1536
1537 DBGFREG_BPL,
1538 DBGFREG_BP = DBGFREG_BPL,
1539 DBGFREG_EBP = DBGFREG_BPL,
1540 DBGFREG_RBP = DBGFREG_BPL,
1541
1542 DBGFREG_SIL,
1543 DBGFREG_SI = DBGFREG_SIL,
1544 DBGFREG_ESI = DBGFREG_SIL,
1545 DBGFREG_RSI = DBGFREG_SIL,
1546
1547 DBGFREG_DIL,
1548 DBGFREG_DI = DBGFREG_DIL,
1549 DBGFREG_EDI = DBGFREG_DIL,
1550 DBGFREG_RDI = DBGFREG_DIL,
1551
1552 DBGFREG_R8,
1553 DBGFREG_R8B = DBGFREG_R8,
1554 DBGFREG_R8W = DBGFREG_R8,
1555 DBGFREG_R8D = DBGFREG_R8,
1556
1557 DBGFREG_R9,
1558 DBGFREG_R9B = DBGFREG_R9,
1559 DBGFREG_R9W = DBGFREG_R9,
1560 DBGFREG_R9D = DBGFREG_R9,
1561
1562 DBGFREG_R10,
1563 DBGFREG_R10B = DBGFREG_R10,
1564 DBGFREG_R10W = DBGFREG_R10,
1565 DBGFREG_R10D = DBGFREG_R10,
1566
1567 DBGFREG_R11,
1568 DBGFREG_R11B = DBGFREG_R11,
1569 DBGFREG_R11W = DBGFREG_R11,
1570 DBGFREG_R11D = DBGFREG_R11,
1571
1572 DBGFREG_R12,
1573 DBGFREG_R12B = DBGFREG_R12,
1574 DBGFREG_R12W = DBGFREG_R12,
1575 DBGFREG_R12D = DBGFREG_R12,
1576
1577 DBGFREG_R13,
1578 DBGFREG_R13B = DBGFREG_R13,
1579 DBGFREG_R13W = DBGFREG_R13,
1580 DBGFREG_R13D = DBGFREG_R13,
1581
1582 DBGFREG_R14,
1583 DBGFREG_R14B = DBGFREG_R14,
1584 DBGFREG_R14W = DBGFREG_R14,
1585 DBGFREG_R14D = DBGFREG_R14,
1586
1587 DBGFREG_R15,
1588 DBGFREG_R15B = DBGFREG_R15,
1589 DBGFREG_R15W = DBGFREG_R15,
1590 DBGFREG_R15D = DBGFREG_R15,
1591
1592 /* Segments and other special registers: */
1593 DBGFREG_CS,
1594 DBGFREG_CS_ATTR,
1595 DBGFREG_CS_BASE,
1596 DBGFREG_CS_LIMIT,
1597
1598 DBGFREG_DS,
1599 DBGFREG_DS_ATTR,
1600 DBGFREG_DS_BASE,
1601 DBGFREG_DS_LIMIT,
1602
1603 DBGFREG_ES,
1604 DBGFREG_ES_ATTR,
1605 DBGFREG_ES_BASE,
1606 DBGFREG_ES_LIMIT,
1607
1608 DBGFREG_FS,
1609 DBGFREG_FS_ATTR,
1610 DBGFREG_FS_BASE,
1611 DBGFREG_FS_LIMIT,
1612
1613 DBGFREG_GS,
1614 DBGFREG_GS_ATTR,
1615 DBGFREG_GS_BASE,
1616 DBGFREG_GS_LIMIT,
1617
1618 DBGFREG_SS,
1619 DBGFREG_SS_ATTR,
1620 DBGFREG_SS_BASE,
1621 DBGFREG_SS_LIMIT,
1622
1623 DBGFREG_IP,
1624 DBGFREG_EIP = DBGFREG_IP,
1625 DBGFREG_RIP = DBGFREG_IP,
1626
1627 DBGFREG_FLAGS,
1628 DBGFREG_EFLAGS = DBGFREG_FLAGS,
1629 DBGFREG_RFLAGS = DBGFREG_FLAGS,
1630
1631 /* FPU: */
1632 DBGFREG_FCW,
1633 DBGFREG_FSW,
1634 DBGFREG_FTW,
1635 DBGFREG_FOP,
1636 DBGFREG_FPUIP,
1637 DBGFREG_FPUCS,
1638 DBGFREG_FPUDP,
1639 DBGFREG_FPUDS,
1640 DBGFREG_MXCSR,
1641 DBGFREG_MXCSR_MASK,
1642
1643 DBGFREG_ST0,
1644 DBGFREG_ST1,
1645 DBGFREG_ST2,
1646 DBGFREG_ST3,
1647 DBGFREG_ST4,
1648 DBGFREG_ST5,
1649 DBGFREG_ST6,
1650 DBGFREG_ST7,
1651
1652 DBGFREG_MM0,
1653 DBGFREG_MM1,
1654 DBGFREG_MM2,
1655 DBGFREG_MM3,
1656 DBGFREG_MM4,
1657 DBGFREG_MM5,
1658 DBGFREG_MM6,
1659 DBGFREG_MM7,
1660
1661 /* SSE: */
1662 DBGFREG_XMM0,
1663 DBGFREG_XMM1,
1664 DBGFREG_XMM2,
1665 DBGFREG_XMM3,
1666 DBGFREG_XMM4,
1667 DBGFREG_XMM5,
1668 DBGFREG_XMM6,
1669 DBGFREG_XMM7,
1670 DBGFREG_XMM8,
1671 DBGFREG_XMM9,
1672 DBGFREG_XMM10,
1673 DBGFREG_XMM11,
1674 DBGFREG_XMM12,
1675 DBGFREG_XMM13,
1676 DBGFREG_XMM14,
1677 DBGFREG_XMM15,
1678 /** @todo add XMM aliases. */
1679
1680 /* System registers: */
1681 DBGFREG_GDTR_BASE,
1682 DBGFREG_GDTR_LIMIT,
1683 DBGFREG_IDTR_BASE,
1684 DBGFREG_IDTR_LIMIT,
1685 DBGFREG_LDTR,
1686 DBGFREG_LDTR_ATTR,
1687 DBGFREG_LDTR_BASE,
1688 DBGFREG_LDTR_LIMIT,
1689 DBGFREG_TR,
1690 DBGFREG_TR_ATTR,
1691 DBGFREG_TR_BASE,
1692 DBGFREG_TR_LIMIT,
1693
1694 DBGFREG_CR0,
1695 DBGFREG_CR2,
1696 DBGFREG_CR3,
1697 DBGFREG_CR4,
1698 DBGFREG_CR8,
1699
1700 DBGFREG_DR0,
1701 DBGFREG_DR1,
1702 DBGFREG_DR2,
1703 DBGFREG_DR3,
1704 DBGFREG_DR6,
1705 DBGFREG_DR7,
1706
1707 /* MSRs: */
1708 DBGFREG_MSR_IA32_APICBASE,
1709 DBGFREG_MSR_IA32_CR_PAT,
1710 DBGFREG_MSR_IA32_PERF_STATUS,
1711 DBGFREG_MSR_IA32_SYSENTER_CS,
1712 DBGFREG_MSR_IA32_SYSENTER_EIP,
1713 DBGFREG_MSR_IA32_SYSENTER_ESP,
1714 DBGFREG_MSR_IA32_TSC,
1715 DBGFREG_MSR_K6_EFER,
1716 DBGFREG_MSR_K6_STAR,
1717 DBGFREG_MSR_K8_CSTAR,
1718 DBGFREG_MSR_K8_FS_BASE,
1719 DBGFREG_MSR_K8_GS_BASE,
1720 DBGFREG_MSR_K8_KERNEL_GS_BASE,
1721 DBGFREG_MSR_K8_LSTAR,
1722 DBGFREG_MSR_K8_SF_MASK,
1723 DBGFREG_MSR_K8_TSC_AUX,
1724
1725 /** The number of registers to pass to DBGFR3RegQueryAll. */
1726 DBGFREG_ALL_COUNT,
1727
1728 /* Misc aliases that doesn't need be part of the 'all' query: */
1729 DBGFREG_AH = DBGFREG_ALL_COUNT,
1730 DBGFREG_CH,
1731 DBGFREG_DH,
1732 DBGFREG_BH,
1733 DBGFREG_GDTR,
1734 DBGFREG_IDTR,
1735
1736 /** The end of the registers. */
1737 DBGFREG_END,
1738 /** The usual 32-bit type hack. */
1739 DBGFREG_32BIT_HACK = 0x7fffffff
1740} DBGFREG;
1741/** Pointer to a register identifier. */
1742typedef DBGFREG *PDBGFREG;
1743/** Pointer to a const register identifier. */
1744typedef DBGFREG const *PCDBGFREG;
1745
1746/**
1747 * Register value type.
1748 */
1749typedef enum DBGFREGVALTYPE
1750{
1751 DBGFREGVALTYPE_INVALID = 0,
1752 /** Unsigned 8-bit register value. */
1753 DBGFREGVALTYPE_U8,
1754 /** Unsigned 16-bit register value. */
1755 DBGFREGVALTYPE_U16,
1756 /** Unsigned 32-bit register value. */
1757 DBGFREGVALTYPE_U32,
1758 /** Unsigned 64-bit register value. */
1759 DBGFREGVALTYPE_U64,
1760 /** Unsigned 128-bit register value. */
1761 DBGFREGVALTYPE_U128,
1762 /** Long double register value. */
1763 DBGFREGVALTYPE_R80,
1764 /** Descriptor table register value. */
1765 DBGFREGVALTYPE_DTR,
1766 /** End of the valid register value types. */
1767 DBGFREGVALTYPE_END,
1768 /** The usual 32-bit type hack. */
1769 DBGFREGVALTYPE_32BIT_HACK = 0x7fffffff
1770} DBGFREGVALTYPE;
1771/** Pointer to a register value type. */
1772typedef DBGFREGVALTYPE *PDBGFREGVALTYPE;
1773
1774/**
1775 * A generic register value type.
1776 */
1777typedef union DBGFREGVAL
1778{
1779 uint64_t au64[2]; /**< The 64-bit array view. First because of the initializer. */
1780 uint32_t au32[4]; /**< The 32-bit array view. */
1781 uint16_t au16[8]; /**< The 16-bit array view. */
1782 uint8_t au8[16]; /**< The 8-bit array view. */
1783
1784 uint8_t u8; /**< The 8-bit view. */
1785 uint16_t u16; /**< The 16-bit view. */
1786 uint32_t u32; /**< The 32-bit view. */
1787 uint64_t u64; /**< The 64-bit view. */
1788 RTUINT128U u128; /**< The 128-bit view. */
1789 RTFLOAT80U r80; /**< The 80-bit floating point view. */
1790 RTFLOAT80U2 r80Ex; /**< The 80-bit floating point view v2. */
1791 /** GDTR or LDTR (DBGFREGVALTYPE_DTR). */
1792 struct
1793 {
1794 /** The table address. */
1795 uint64_t u64Base;
1796 /** The table limit (length minus 1). */
1797 uint32_t u32Limit;
1798 } dtr;
1799
1800 RTUINT128U u;
1801} DBGFREGVAL;
1802/** Pointer to a generic register value type. */
1803typedef DBGFREGVAL *PDBGFREGVAL;
1804/** Pointer to a const generic register value type. */
1805typedef DBGFREGVAL const *PCDBGFREGVAL;
1806
1807/** Initialize a DBGFREGVAL variable to all zeros. */
1808#define DBGFREGVAL_INITIALIZE_ZERO { { 0, 0 } }
1809/** Initialize a DBGFREGVAL variable to all bits set . */
1810#define DBGFREGVAL_INITIALIZE_FFFF { { UINT64_MAX, UINT64_MAX } }
1811
1812
1813VMMDECL(ssize_t) DBGFR3RegFormatValue(char *pszBuf, size_t cbBuf, PCDBGFREGVAL pValue, DBGFREGVALTYPE enmType, bool fSpecial);
1814VMMDECL(ssize_t) DBGFR3RegFormatValueEx(char *pszBuf, size_t cbBuf, PCDBGFREGVAL pValue, DBGFREGVALTYPE enmType,
1815 unsigned uBase, signed int cchWidth, signed int cchPrecision, uint32_t fFlags);
1816
1817/**
1818 * Register sub-field descriptor.
1819 */
1820typedef struct DBGFREGSUBFIELD
1821{
1822 /** The name of the sub-field. NULL is used to terminate the array. */
1823 const char *pszName;
1824 /** The index of the first bit. Ignored if pfnGet is set. */
1825 uint8_t iFirstBit;
1826 /** The number of bits. Mandatory. */
1827 uint8_t cBits;
1828 /** The shift count. Not applied when pfnGet is set, but used to
1829 * calculate the minimum type. */
1830 int8_t cShift;
1831 /** Sub-field flags, DBGFREGSUBFIELD_FLAGS_XXX. */
1832 uint8_t fFlags;
1833 /** Getter (optional).
1834 * @remarks Does not take the device lock or anything like that.
1835 */
1836 DECLCALLBACKMEMBER(int, pfnGet)(void *pvUser, struct DBGFREGSUBFIELD const *pSubField, PRTUINT128U puValue);
1837 /** Setter (optional).
1838 * @remarks Does not take the device lock or anything like that.
1839 */
1840 DECLCALLBACKMEMBER(int, pfnSet)(void *pvUser, struct DBGFREGSUBFIELD const *pSubField, RTUINT128U uValue, RTUINT128U fMask);
1841} DBGFREGSUBFIELD;
1842/** Pointer to a const register sub-field descriptor. */
1843typedef DBGFREGSUBFIELD const *PCDBGFREGSUBFIELD;
1844
1845/** @name DBGFREGSUBFIELD_FLAGS_XXX
1846 * @{ */
1847/** The sub-field is read-only. */
1848#define DBGFREGSUBFIELD_FLAGS_READ_ONLY UINT8_C(0x01)
1849/** @} */
1850
1851/** Macro for creating a read-write sub-field entry without getters. */
1852#define DBGFREGSUBFIELD_RW(a_szName, a_iFirstBit, a_cBits, a_cShift) \
1853 { a_szName, a_iFirstBit, a_cBits, a_cShift, 0 /*fFlags*/, NULL /*pfnGet*/, NULL /*pfnSet*/ }
1854/** Macro for creating a read-write sub-field entry with getters. */
1855#define DBGFREGSUBFIELD_RW_SG(a_szName, a_cBits, a_cShift, a_pfnGet, a_pfnSet) \
1856 { a_szName, 0 /*iFirstBit*/, a_cBits, a_cShift, 0 /*fFlags*/, a_pfnGet, a_pfnSet }
1857/** Macro for creating a read-only sub-field entry without getters. */
1858#define DBGFREGSUBFIELD_RO(a_szName, a_iFirstBit, a_cBits, a_cShift) \
1859 { a_szName, a_iFirstBit, a_cBits, a_cShift, DBGFREGSUBFIELD_FLAGS_READ_ONLY, NULL /*pfnGet*/, NULL /*pfnSet*/ }
1860/** Macro for creating a terminator sub-field entry. */
1861#define DBGFREGSUBFIELD_TERMINATOR() \
1862 { NULL, 0, 0, 0, 0, NULL, NULL }
1863
1864/**
1865 * Register alias descriptor.
1866 */
1867typedef struct DBGFREGALIAS
1868{
1869 /** The alias name. NULL is used to terminate the array. */
1870 const char *pszName;
1871 /** Set to a valid type if the alias has a different type. */
1872 DBGFREGVALTYPE enmType;
1873} DBGFREGALIAS;
1874/** Pointer to a const register alias descriptor. */
1875typedef DBGFREGALIAS const *PCDBGFREGALIAS;
1876
1877/**
1878 * Register descriptor.
1879 */
1880typedef struct DBGFREGDESC
1881{
1882 /** The normal register name. */
1883 const char *pszName;
1884 /** The register identifier if this is a CPU register. */
1885 DBGFREG enmReg;
1886 /** The default register type. */
1887 DBGFREGVALTYPE enmType;
1888 /** Flags, see DBGFREG_FLAGS_XXX. */
1889 uint32_t fFlags;
1890 /** The internal register indicator.
1891 * For CPU registers this is the offset into the CPUMCTX structure,
1892 * thuse the 'off' prefix. */
1893 uint32_t offRegister;
1894 /** Getter.
1895 * @remarks Does not take the device lock or anything like that.
1896 */
1897 DECLCALLBACKMEMBER(int, pfnGet)(void *pvUser, struct DBGFREGDESC const *pDesc, PDBGFREGVAL pValue);
1898 /** Setter.
1899 * @remarks Does not take the device lock or anything like that.
1900 */
1901 DECLCALLBACKMEMBER(int, pfnSet)(void *pvUser, struct DBGFREGDESC const *pDesc, PCDBGFREGVAL pValue, PCDBGFREGVAL pfMask);
1902 /** Aliases (optional). */
1903 PCDBGFREGALIAS paAliases;
1904 /** Sub fields (optional). */
1905 PCDBGFREGSUBFIELD paSubFields;
1906} DBGFREGDESC;
1907
1908/** @name Macros for constructing DBGFREGDESC arrays.
1909 * @{ */
1910#define DBGFREGDESC_RW(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet) \
1911 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, 0 /*fFlags*/, a_offRegister, a_pfnGet, a_pfnSet, NULL /*paAlises*/, NULL /*paSubFields*/ }
1912#define DBGFREGDESC_RO(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet) \
1913 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, DBGFREG_FLAGS_READ_ONLY, a_offRegister, a_pfnGet, a_pfnSet, NULL /*paAlises*/, NULL /*paSubFields*/ }
1914#define DBGFREGDESC_RW_A(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases) \
1915 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, 0 /*fFlags*/, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, NULL /*paSubFields*/ }
1916#define DBGFREGDESC_RO_A(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases) \
1917 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, DBGFREG_FLAGS_READ_ONLY, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, NULL /*paSubFields*/ }
1918#define DBGFREGDESC_RW_S(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paSubFields) \
1919 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, 0 /*fFlags*/, a_offRegister, a_pfnGet, a_pfnSet, /*paAliases*/, a_paSubFields }
1920#define DBGFREGDESC_RO_S(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paSubFields) \
1921 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, DBGFREG_FLAGS_READ_ONLY, a_offRegister, a_pfnGet, a_pfnSet, /*paAliases*/, a_paSubFields }
1922#define DBGFREGDESC_RW_AS(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, a_paSubFields) \
1923 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, 0 /*fFlags*/, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, a_paSubFields }
1924#define DBGFREGDESC_RO_AS(a_szName, a_TypeSuff, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, a_paSubFields) \
1925 { a_szName, DBGFREG_END, DBGFREGVALTYPE_##a_TypeSuff, DBGFREG_FLAGS_READ_ONLY, a_offRegister, a_pfnGet, a_pfnSet, a_paAliases, a_paSubFields }
1926#define DBGFREGDESC_TERMINATOR() \
1927 { NULL, DBGFREG_END, DBGFREGVALTYPE_INVALID, 0, 0, NULL, NULL, NULL, NULL }
1928/** @} */
1929
1930
1931/** @name DBGFREG_FLAGS_XXX
1932 * @{ */
1933/** The register is read-only. */
1934#define DBGFREG_FLAGS_READ_ONLY RT_BIT_32(0)
1935/** @} */
1936
1937/**
1938 * Entry in a batch query or set operation.
1939 */
1940typedef struct DBGFREGENTRY
1941{
1942 /** The register identifier. */
1943 DBGFREG enmReg;
1944 /** The size of the value in bytes. */
1945 DBGFREGVALTYPE enmType;
1946 /** The register value. The valid view is indicated by enmType. */
1947 DBGFREGVAL Val;
1948} DBGFREGENTRY;
1949/** Pointer to a register entry in a batch operation. */
1950typedef DBGFREGENTRY *PDBGFREGENTRY;
1951/** Pointer to a const register entry in a batch operation. */
1952typedef DBGFREGENTRY const *PCDBGFREGENTRY;
1953
1954/** Used with DBGFR3Reg* to indicate the hypervisor register set instead of the
1955 * guest. */
1956#define DBGFREG_HYPER_VMCPUID UINT32_C(0x01000000)
1957
1958VMMR3DECL(int) DBGFR3RegCpuQueryU8( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint8_t *pu8);
1959VMMR3DECL(int) DBGFR3RegCpuQueryU16( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint16_t *pu16);
1960VMMR3DECL(int) DBGFR3RegCpuQueryU32( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint32_t *pu32);
1961VMMR3DECL(int) DBGFR3RegCpuQueryU64( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t *pu64);
1962VMMR3DECL(int) DBGFR3RegCpuQueryU128(PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint128_t *pu128);
1963VMMR3DECL(int) DBGFR3RegCpuQueryLrd( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, long double *plrd);
1964VMMR3DECL(int) DBGFR3RegCpuQueryXdtr(PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t *pu64Base, uint16_t *pu16Limit);
1965#if 0
1966VMMR3DECL(int) DBGFR3RegCpuQueryBatch(PUVM pUVM,VMCPUID idCpu, PDBGFREGENTRY paRegs, size_t cRegs);
1967VMMR3DECL(int) DBGFR3RegCpuQueryAll( PUVM pUVM, VMCPUID idCpu, PDBGFREGENTRY paRegs, size_t cRegs);
1968
1969VMMR3DECL(int) DBGFR3RegCpuSetU8( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint8_t u8);
1970VMMR3DECL(int) DBGFR3RegCpuSetU16( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint16_t u16);
1971VMMR3DECL(int) DBGFR3RegCpuSetU32( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint32_t u32);
1972VMMR3DECL(int) DBGFR3RegCpuSetU64( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t u64);
1973VMMR3DECL(int) DBGFR3RegCpuSetU128( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, uint128_t u128);
1974VMMR3DECL(int) DBGFR3RegCpuSetLrd( PUVM pUVM, VMCPUID idCpu, DBGFREG enmReg, long double lrd);
1975VMMR3DECL(int) DBGFR3RegCpuSetBatch( PUVM pUVM, VMCPUID idCpu, PCDBGFREGENTRY paRegs, size_t cRegs);
1976#endif
1977
1978VMMR3DECL(const char *) DBGFR3RegCpuName(PUVM pUVM, DBGFREG enmReg, DBGFREGVALTYPE enmType);
1979
1980VMMR3_INT_DECL(int) DBGFR3RegRegisterCpu(PVM pVM, PVMCPU pVCpu, PCDBGFREGDESC paRegisters, bool fGuestRegs);
1981VMMR3_INT_DECL(int) DBGFR3RegRegisterDevice(PVM pVM, PCDBGFREGDESC paRegisters, PPDMDEVINS pDevIns,
1982 const char *pszPrefix, uint32_t iInstance);
1983
1984/**
1985 * Entry in a named batch query or set operation.
1986 */
1987typedef struct DBGFREGENTRYNM
1988{
1989 /** The register name. */
1990 const char *pszName;
1991 /** The size of the value in bytes. */
1992 DBGFREGVALTYPE enmType;
1993 /** The register value. The valid view is indicated by enmType. */
1994 DBGFREGVAL Val;
1995} DBGFREGENTRYNM;
1996/** Pointer to a named register entry in a batch operation. */
1997typedef DBGFREGENTRYNM *PDBGFREGENTRYNM;
1998/** Pointer to a const named register entry in a batch operation. */
1999typedef DBGFREGENTRYNM const *PCDBGFREGENTRYNM;
2000
2001VMMR3DECL(int) DBGFR3RegNmValidate( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg);
2002
2003VMMR3DECL(int) DBGFR3RegNmQuery( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, PDBGFREGVAL pValue, PDBGFREGVALTYPE penmType);
2004VMMR3DECL(int) DBGFR3RegNmQueryU8( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint8_t *pu8);
2005VMMR3DECL(int) DBGFR3RegNmQueryU16( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint16_t *pu16);
2006VMMR3DECL(int) DBGFR3RegNmQueryU32( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint32_t *pu32);
2007VMMR3DECL(int) DBGFR3RegNmQueryU64( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint64_t *pu64);
2008VMMR3DECL(int) DBGFR3RegNmQueryU128(PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, PRTUINT128U pu128);
2009/*VMMR3DECL(int) DBGFR3RegNmQueryLrd( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, long double *plrd);*/
2010VMMR3DECL(int) DBGFR3RegNmQueryXdtr(PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint64_t *pu64Base, uint16_t *pu16Limit);
2011VMMR3DECL(int) DBGFR3RegNmQueryBatch(PUVM pUVM,VMCPUID idDefCpu, PDBGFREGENTRYNM paRegs, size_t cRegs);
2012VMMR3DECL(int) DBGFR3RegNmQueryAllCount(PUVM pUVM, size_t *pcRegs);
2013VMMR3DECL(int) DBGFR3RegNmQueryAll( PUVM pUVM, PDBGFREGENTRYNM paRegs, size_t cRegs);
2014
2015VMMR3DECL(int) DBGFR3RegNmSet( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, PCDBGFREGVAL pValue, DBGFREGVALTYPE enmType);
2016VMMR3DECL(int) DBGFR3RegNmSetU8( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint8_t u8);
2017VMMR3DECL(int) DBGFR3RegNmSetU16( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint16_t u16);
2018VMMR3DECL(int) DBGFR3RegNmSetU32( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint32_t u32);
2019VMMR3DECL(int) DBGFR3RegNmSetU64( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, uint64_t u64);
2020VMMR3DECL(int) DBGFR3RegNmSetU128( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, RTUINT128U u128);
2021VMMR3DECL(int) DBGFR3RegNmSetLrd( PUVM pUVM, VMCPUID idDefCpu, const char *pszReg, long double lrd);
2022VMMR3DECL(int) DBGFR3RegNmSetBatch( PUVM pUVM, VMCPUID idDefCpu, PCDBGFREGENTRYNM paRegs, size_t cRegs);
2023
2024/** @todo add enumeration methods. */
2025
2026VMMR3DECL(int) DBGFR3RegPrintf( PUVM pUVM, VMCPUID idDefCpu, char *pszBuf, size_t cbBuf, const char *pszFormat, ...);
2027VMMR3DECL(int) DBGFR3RegPrintfV(PUVM pUVM, VMCPUID idDefCpu, char *pszBuf, size_t cbBuf, const char *pszFormat, va_list va);
2028
2029
2030/**
2031 * Guest OS digger interface identifier.
2032 *
2033 * This is for use together with PDBGFR3QueryInterface and is used to
2034 * obtain access to optional interfaces.
2035 */
2036typedef enum DBGFOSINTERFACE
2037{
2038 /** The usual invalid entry. */
2039 DBGFOSINTERFACE_INVALID = 0,
2040 /** Process info. */
2041 DBGFOSINTERFACE_PROCESS,
2042 /** Thread info. */
2043 DBGFOSINTERFACE_THREAD,
2044 /** Kernel message log - DBGFOSIDMESG. */
2045 DBGFOSINTERFACE_DMESG,
2046 /** The end of the valid entries. */
2047 DBGFOSINTERFACE_END,
2048 /** The usual 32-bit type blowup. */
2049 DBGFOSINTERFACE_32BIT_HACK = 0x7fffffff
2050} DBGFOSINTERFACE;
2051/** Pointer to a Guest OS digger interface identifier. */
2052typedef DBGFOSINTERFACE *PDBGFOSINTERFACE;
2053/** Pointer to a const Guest OS digger interface identifier. */
2054typedef DBGFOSINTERFACE const *PCDBGFOSINTERFACE;
2055
2056
2057/**
2058 * Guest OS Digger Registration Record.
2059 *
2060 * This is used with the DBGFR3OSRegister() API.
2061 */
2062typedef struct DBGFOSREG
2063{
2064 /** Magic value (DBGFOSREG_MAGIC). */
2065 uint32_t u32Magic;
2066 /** Flags. Reserved. */
2067 uint32_t fFlags;
2068 /** The size of the instance data. */
2069 uint32_t cbData;
2070 /** Operative System name. */
2071 char szName[24];
2072
2073 /**
2074 * Constructs the instance.
2075 *
2076 * @returns VBox status code.
2077 * @param pUVM The user mode VM handle.
2078 * @param pvData Pointer to the instance data.
2079 */
2080 DECLCALLBACKMEMBER(int, pfnConstruct)(PUVM pUVM, void *pvData);
2081
2082 /**
2083 * Destroys the instance.
2084 *
2085 * @param pUVM The user mode VM handle.
2086 * @param pvData Pointer to the instance data.
2087 */
2088 DECLCALLBACKMEMBER(void, pfnDestruct)(PUVM pUVM, void *pvData);
2089
2090 /**
2091 * Probes the guest memory for OS finger prints.
2092 *
2093 * No setup or so is performed, it will be followed by a call to pfnInit
2094 * or pfnRefresh that should take care of that.
2095 *
2096 * @returns true if is an OS handled by this module, otherwise false.
2097 * @param pUVM The user mode VM handle.
2098 * @param pvData Pointer to the instance data.
2099 */
2100 DECLCALLBACKMEMBER(bool, pfnProbe)(PUVM pUVM, void *pvData);
2101
2102 /**
2103 * Initializes a fresly detected guest, loading symbols and such useful stuff.
2104 *
2105 * This is called after pfnProbe.
2106 *
2107 * @returns VBox status code.
2108 * @param pUVM The user mode VM handle.
2109 * @param pvData Pointer to the instance data.
2110 */
2111 DECLCALLBACKMEMBER(int, pfnInit)(PUVM pUVM, void *pvData);
2112
2113 /**
2114 * Refreshes symbols and stuff following a redetection of the same OS.
2115 *
2116 * This is called after pfnProbe.
2117 *
2118 * @returns VBox status code.
2119 * @param pUVM The user mode VM handle.
2120 * @param pvData Pointer to the instance data.
2121 */
2122 DECLCALLBACKMEMBER(int, pfnRefresh)(PUVM pUVM, void *pvData);
2123
2124 /**
2125 * Terminates an OS when a new (or none) OS has been detected,
2126 * and before destruction.
2127 *
2128 * This is called after pfnProbe and if needed before pfnDestruct.
2129 *
2130 * @param pUVM The user mode VM handle.
2131 * @param pvData Pointer to the instance data.
2132 */
2133 DECLCALLBACKMEMBER(void, pfnTerm)(PUVM pUVM, void *pvData);
2134
2135 /**
2136 * Queries the version of the running OS.
2137 *
2138 * This is only called after pfnInit().
2139 *
2140 * @returns VBox status code.
2141 * @param pUVM The user mode VM handle.
2142 * @param pvData Pointer to the instance data.
2143 * @param pszVersion Where to store the version string.
2144 * @param cchVersion The size of the version string buffer.
2145 */
2146 DECLCALLBACKMEMBER(int, pfnQueryVersion)(PUVM pUVM, void *pvData, char *pszVersion, size_t cchVersion);
2147
2148 /**
2149 * Queries the pointer to a interface.
2150 *
2151 * This is called after pfnProbe.
2152 *
2153 * The returned interface must be valid until pfnDestruct is called. Two calls
2154 * to this method with the same @a enmIf value must return the same pointer.
2155 *
2156 * @returns Pointer to the interface if available, NULL if not available.
2157 * @param pUVM The user mode VM handle.
2158 * @param pvData Pointer to the instance data.
2159 * @param enmIf The interface identifier.
2160 */
2161 DECLCALLBACKMEMBER(void *, pfnQueryInterface)(PUVM pUVM, void *pvData, DBGFOSINTERFACE enmIf);
2162
2163 /** Trailing magic (DBGFOSREG_MAGIC). */
2164 uint32_t u32EndMagic;
2165} DBGFOSREG;
2166/** Pointer to a Guest OS digger registration record. */
2167typedef DBGFOSREG *PDBGFOSREG;
2168/** Pointer to a const Guest OS digger registration record. */
2169typedef DBGFOSREG const *PCDBGFOSREG;
2170
2171/** Magic value for DBGFOSREG::u32Magic and DBGFOSREG::u32EndMagic. (Hitomi Kanehara) */
2172#define DBGFOSREG_MAGIC 0x19830808
2173
2174
2175/**
2176 * Interface for querying kernel log messages (DBGFOSINTERFACE_DMESG).
2177 */
2178typedef struct DBGFOSIDMESG
2179{
2180 /** Trailing magic (DBGFOSIDMESG_MAGIC). */
2181 uint32_t u32Magic;
2182
2183 /**
2184 * Query the kernel log.
2185 *
2186 * @returns VBox status code.
2187 * @retval VERR_NOT_FOUND if the messages could not be located.
2188 * @retval VERR_INVALID_STATE if the messages was found to have unknown/invalid
2189 * format.
2190 * @retval VERR_BUFFER_OVERFLOW if the buffer isn't large enough, pcbActual
2191 * will be set to the required buffer size. The buffer, however, will
2192 * be filled with as much data as it can hold (properly zero terminated
2193 * of course).
2194 *
2195 * @param pThis Pointer to the interface structure.
2196 * @param pUVM The user mode VM handle.
2197 * @param fFlags Flags reserved for future use, MBZ.
2198 * @param cMessages The number of messages to retrieve, counting from the
2199 * end of the log (i.e. like tail), use UINT32_MAX for all.
2200 * @param pszBuf The output buffer.
2201 * @param cbBuf The buffer size.
2202 * @param pcbActual Where to store the number of bytes actually returned,
2203 * including zero terminator. On VERR_BUFFER_OVERFLOW this
2204 * holds the necessary buffer size. Optional.
2205 */
2206 DECLCALLBACKMEMBER(int, pfnQueryKernelLog)(struct DBGFOSIDMESG *pThis, PUVM pUVM, uint32_t fFlags, uint32_t cMessages,
2207 char *pszBuf, size_t cbBuf, size_t *pcbActual);
2208 /** Trailing magic (DBGFOSIDMESG_MAGIC). */
2209 uint32_t u32EndMagic;
2210} DBGFOSIDMESG;
2211/** Pointer to the interface for query kernel log messages (DBGFOSINTERFACE_DMESG). */
2212typedef DBGFOSIDMESG *PDBGFOSIDMESG;
2213/** Magic value for DBGFOSIDMESG::32Magic and DBGFOSIDMESG::u32EndMagic. (Kenazburo Oe) */
2214#define DBGFOSIDMESG_MAGIC UINT32_C(0x19350131)
2215
2216
2217VMMR3DECL(int) DBGFR3OSRegister(PUVM pUVM, PCDBGFOSREG pReg);
2218VMMR3DECL(int) DBGFR3OSDeregister(PUVM pUVM, PCDBGFOSREG pReg);
2219VMMR3DECL(int) DBGFR3OSDetect(PUVM pUVM, char *pszName, size_t cchName);
2220VMMR3DECL(int) DBGFR3OSQueryNameAndVersion(PUVM pUVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion);
2221VMMR3DECL(void *) DBGFR3OSQueryInterface(PUVM pUVM, DBGFOSINTERFACE enmIf);
2222
2223
2224VMMR3DECL(int) DBGFR3CoreWrite(PUVM pUVM, const char *pszFilename, bool fReplaceFile);
2225
2226
2227#ifdef IN_RING3
2228
2229/** @defgroup grp_dbgf_plug_in The DBGF Plug-in Interface
2230 * @{
2231 */
2232
2233/** The plug-in module name prefix. */
2234# define DBGF_PLUG_IN_PREFIX "DbgPlugIn"
2235
2236/** The name of the plug-in entry point (FNDBGFPLUGIN) */
2237# define DBGF_PLUG_IN_ENTRYPOINT "DbgPlugInEntry"
2238
2239/**
2240 * DBGF plug-in operations.
2241 */
2242typedef enum DBGFPLUGINOP
2243{
2244 /** The usual invalid first value. */
2245 DBGFPLUGINOP_INVALID,
2246 /** Initialize the plug-in for a VM, register all the stuff.
2247 * The plug-in will be unloaded on failure.
2248 * uArg: The full VirtualBox version, see VBox/version.h. */
2249 DBGFPLUGINOP_INIT,
2250 /** Terminate the plug-ing for a VM, deregister all the stuff.
2251 * The plug-in will be unloaded after this call regardless of the return
2252 * code. */
2253 DBGFPLUGINOP_TERM,
2254 /** The usual 32-bit hack. */
2255 DBGFPLUGINOP_32BIT_HACK = 0x7fffffff
2256} DBGFPLUGINOP;
2257
2258/**
2259 * DBGF plug-in main entry point.
2260 *
2261 * @returns VBox status code.
2262 *
2263 * @param enmOperation The operation.
2264 * @param pUVM The user mode VM handle. This may be NULL.
2265 * @param uArg Extra argument.
2266 */
2267typedef DECLCALLBACK(int) FNDBGFPLUGIN(DBGFPLUGINOP enmOperation, PUVM pUVM, uintptr_t uArg);
2268/** Pointer to a FNDBGFPLUGIN. */
2269typedef FNDBGFPLUGIN *PFNDBGFPLUGIN;
2270
2271/** @copydoc FNDBGFPLUGIN */
2272DECLEXPORT(int) DbgPlugInEntry(DBGFPLUGINOP enmOperation, PUVM pUVM, uintptr_t uArg);
2273
2274VMMR3DECL(int) DBGFR3PlugInLoad(PUVM pUVM, const char *pszPlugIn, char *pszActual, size_t cbActual, PRTERRINFO pErrInfo);
2275VMMR3DECL(int) DBGFR3PlugInUnload(PUVM pUVM, const char *pszName);
2276VMMR3DECL(void) DBGFR3PlugInLoadAll(PUVM pUVM);
2277VMMR3DECL(void) DBGFR3PlugInUnloadAll(PUVM pUVM);
2278
2279/** @} */
2280
2281
2282/** @defgroup grp_dbgf_types The DBGF type system Interface.
2283 * @{
2284 */
2285
2286/** A few forward declarations. */
2287/** Pointer to a type registration structure. */
2288typedef struct DBGFTYPEREG *PDBGFTYPEREG;
2289/** Pointer to a const type registration structure. */
2290typedef const struct DBGFTYPEREG *PCDBGFTYPEREG;
2291/** Pointer to a typed buffer. */
2292typedef struct DBGFTYPEVAL *PDBGFTYPEVAL;
2293
2294/**
2295 * DBGF built-in types.
2296 */
2297typedef enum DBGFTYPEBUILTIN
2298{
2299 /** The usual invalid first value. */
2300 DBGFTYPEBUILTIN_INVALID,
2301 /** Unsigned 8bit integer. */
2302 DBGFTYPEBUILTIN_UINT8,
2303 /** Signed 8bit integer. */
2304 DBGFTYPEBUILTIN_INT8,
2305 /** Unsigned 16bit integer. */
2306 DBGFTYPEBUILTIN_UINT16,
2307 /** Signed 16bit integer. */
2308 DBGFTYPEBUILTIN_INT16,
2309 /** Unsigned 32bit integer. */
2310 DBGFTYPEBUILTIN_UINT32,
2311 /** Signed 32bit integer. */
2312 DBGFTYPEBUILTIN_INT32,
2313 /** Unsigned 64bit integer. */
2314 DBGFTYPEBUILTIN_UINT64,
2315 /** Signed 64bit integer. */
2316 DBGFTYPEBUILTIN_INT64,
2317 /** 32bit Guest pointer */
2318 DBGFTYPEBUILTIN_PTR32,
2319 /** 64bit Guest pointer */
2320 DBGFTYPEBUILTIN_PTR64,
2321 /** Guest pointer - size depends on the guest bitness */
2322 DBGFTYPEBUILTIN_PTR,
2323 /** Type indicating a size, like size_t this can have different sizes
2324 * on 32bit and 64bit systems */
2325 DBGFTYPEBUILTIN_SIZE,
2326 /** 32bit float. */
2327 DBGFTYPEBUILTIN_FLOAT32,
2328 /** 64bit float (also known as double). */
2329 DBGFTYPEBUILTIN_FLOAT64,
2330 /** Compund types like structs and unions. */
2331 DBGFTYPEBUILTIN_COMPOUND,
2332 /** The usual 32-bit hack. */
2333 DBGFTYPEBUILTIN_32BIT_HACK = 0x7fffffff
2334} DBGFTYPEBUILTIN;
2335/** Pointer to a built-in type. */
2336typedef DBGFTYPEBUILTIN *PDBGFTYPEBUILTIN;
2337/** Pointer to a const built-in type. */
2338typedef const DBGFTYPEBUILTIN *PCDBGFTYPEBUILTIN;
2339
2340/**
2341 * DBGF type value buffer.
2342 */
2343typedef union DBGFTYPEVALBUF
2344{
2345 uint8_t u8;
2346 int8_t i8;
2347 uint16_t u16;
2348 int16_t i16;
2349 uint32_t u32;
2350 int32_t i32;
2351 uint64_t u64;
2352 int64_t i64;
2353 float f32;
2354 double f64;
2355 uint64_t size; /* For the built-in size_t which can be either 32-bit or 64-bit. */
2356 RTGCPTR GCPtr;
2357 /** For embedded structs. */
2358 PDBGFTYPEVAL pVal;
2359} DBGFTYPEVALBUF;
2360/** Pointer to a value. */
2361typedef DBGFTYPEVALBUF *PDBGFTYPEVALBUF;
2362
2363/**
2364 * DBGF type value entry.
2365 */
2366typedef struct DBGFTYPEVALENTRY
2367{
2368 /** DBGF built-in type. */
2369 DBGFTYPEBUILTIN enmType;
2370 /** Size of the type. */
2371 size_t cbType;
2372 /** Number of entries, for arrays this can be > 1. */
2373 uint32_t cEntries;
2374 /** Value buffer, depends on whether this is an array. */
2375 union
2376 {
2377 /** Single value. */
2378 DBGFTYPEVALBUF Val;
2379 /** Pointer to the array of values. */
2380 PDBGFTYPEVALBUF pVal;
2381 } Buf;
2382} DBGFTYPEVALENTRY;
2383/** Pointer to a type value entry. */
2384typedef DBGFTYPEVALENTRY *PDBGFTYPEVALENTRY;
2385/** Pointer to a const type value entry. */
2386typedef const DBGFTYPEVALENTRY *PCDBGFTYPEVALENTRY;
2387
2388/**
2389 * DBGF typed value.
2390 */
2391typedef struct DBGFTYPEVAL
2392{
2393 /** Pointer to the registration structure for this type. */
2394 PCDBGFTYPEREG pTypeReg;
2395 /** Number of value entries. */
2396 uint32_t cEntries;
2397 /** Variable sized array of value entries. */
2398 DBGFTYPEVALENTRY aEntries[1];
2399} DBGFTYPEVAL;
2400
2401/**
2402 * DBGF type variant.
2403 */
2404typedef enum DBGFTYPEVARIANT
2405{
2406 /** The usual invalid first value. */
2407 DBGFTYPEVARIANT_INVALID,
2408 /** A struct. */
2409 DBGFTYPEVARIANT_STRUCT,
2410 /** Union. */
2411 DBGFTYPEVARIANT_UNION,
2412 /** Alias for an existing type. */
2413 DBGFTYPEVARIANT_ALIAS,
2414 /** The usual 32-bit hack. */
2415 DBGFTYPEVARIANT_32BIT_HACK = 0x7fffffff
2416} DBGFTYPEVARIANT;
2417
2418/** @name DBGFTYPEREGMEMBER Flags.
2419 * @{ */
2420/** The member is an array with a fixed size. */
2421# define DBGFTYPEREGMEMBER_F_ARRAY RT_BIT_32(0)
2422/** The member denotes a pointer. */
2423# define DBGFTYPEREGMEMBER_F_POINTER RT_BIT_32(1)
2424/** @} */
2425
2426/**
2427 * DBGF type member.
2428 */
2429typedef struct DBGFTYPEREGMEMBER
2430{
2431 /** Name of the member. */
2432 const char *pszName;
2433 /** Flags for this member, see DBGFTYPEREGMEMBER_F_XXX. */
2434 uint32_t fFlags;
2435 /** Type identifier. */
2436 const char *pszType;
2437 /** The number of elements in the array, only valid for arrays. */
2438 uint32_t cElements;
2439} DBGFTYPEREGMEMBER;
2440/** Pointer to a member. */
2441typedef DBGFTYPEREGMEMBER *PDBGFTYPEREGMEMBER;
2442/** Pointer to a const member. */
2443typedef const DBGFTYPEREGMEMBER *PCDBGFTYPEREGMEMBER;
2444
2445/** @name DBGFTYPEREG Flags.
2446 * @{ */
2447/** The type is a packed structure. */
2448# define DBGFTYPEREG_F_PACKED RT_BIT_32(0)
2449/** @} */
2450
2451/**
2452 * New type registration structure.
2453 */
2454typedef struct DBGFTYPEREG
2455{
2456 /** Name of the type. */
2457 const char *pszType;
2458 /** The type variant. */
2459 DBGFTYPEVARIANT enmVariant;
2460 /** Some registration flags, see DBGFTYPEREG_F_XXX. */
2461 uint32_t fFlags;
2462 /** Number of members this type has, only valid for structs or unions. */
2463 uint32_t cMembers;
2464 /** Pointer to the member fields, only valid for structs or unions. */
2465 PCDBGFTYPEREGMEMBER paMembers;
2466 /** Name of the aliased type for aliases. */
2467 const char *pszAliasedType;
2468} DBGFTYPEREG;
2469
2470/**
2471 * DBGF typed value dumper callback.
2472 *
2473 * @returns VBox status code. Any non VINF_SUCCESS status code will abort the dumping.
2474 *
2475 * @param off The byte offset of the entry from the start of the type.
2476 * @param pszField The name of the field for the value.
2477 * @param iLvl The current level.
2478 * @param enmType The type enum.
2479 * @param cbType Size of the type.
2480 * @param pValBuf Pointer to the value buffer.
2481 * @param cValBufs Number of value buffers (for arrays).
2482 * @param pvUser Opaque user data.
2483 */
2484typedef DECLCALLBACK(int) FNDBGFR3TYPEVALDUMP(uint32_t off, const char *pszField, uint32_t iLvl,
2485 DBGFTYPEBUILTIN enmType, size_t cbType,
2486 PDBGFTYPEVALBUF pValBuf, uint32_t cValBufs,
2487 void *pvUser);
2488/** Pointer to a FNDBGFR3TYPEVALDUMP. */
2489typedef FNDBGFR3TYPEVALDUMP *PFNDBGFR3TYPEVALDUMP;
2490
2491/**
2492 * DBGF type information dumper callback.
2493 *
2494 * @returns VBox status code. Any non VINF_SUCCESS status code will abort the dumping.
2495 *
2496 * @param off The byte offset of the entry from the start of the type.
2497 * @param pszField The name of the field for the value.
2498 * @param iLvl The current level.
2499 * @param pszType The type of the field.
2500 * @param fTypeFlags Flags for this type, see DBGFTYPEREGMEMBER_F_XXX.
2501 * @param cElements Number of for the field ( > 0 for arrays).
2502 * @param pvUser Opaque user data.
2503 */
2504typedef DECLCALLBACK(int) FNDBGFR3TYPEDUMP(uint32_t off, const char *pszField, uint32_t iLvl,
2505 const char *pszType, uint32_t fTypeFlags,
2506 uint32_t cElements, void *pvUser);
2507/** Pointer to a FNDBGFR3TYPEDUMP. */
2508typedef FNDBGFR3TYPEDUMP *PFNDBGFR3TYPEDUMP;
2509
2510VMMR3DECL(int) DBGFR3TypeRegister( PUVM pUVM, uint32_t cTypes, PCDBGFTYPEREG paTypes);
2511VMMR3DECL(int) DBGFR3TypeDeregister(PUVM pUVM, const char *pszType);
2512VMMR3DECL(int) DBGFR3TypeQueryReg( PUVM pUVM, const char *pszType, PCDBGFTYPEREG *ppTypeReg);
2513
2514VMMR3DECL(int) DBGFR3TypeQuerySize( PUVM pUVM, const char *pszType, size_t *pcbType);
2515VMMR3DECL(int) DBGFR3TypeSetSize( PUVM pUVM, const char *pszType, size_t cbType);
2516VMMR3DECL(int) DBGFR3TypeDumpEx( PUVM pUVM, const char *pszType, uint32_t fFlags,
2517 uint32_t cLvlMax, PFNDBGFR3TYPEDUMP pfnDump, void *pvUser);
2518VMMR3DECL(int) DBGFR3TypeQueryValByType(PUVM pUVM, PCDBGFADDRESS pAddress, const char *pszType,
2519 PDBGFTYPEVAL *ppVal);
2520VMMR3DECL(void) DBGFR3TypeValFree(PDBGFTYPEVAL pVal);
2521VMMR3DECL(int) DBGFR3TypeValDumpEx(PUVM pUVM, PCDBGFADDRESS pAddress, const char *pszType, uint32_t fFlags,
2522 uint32_t cLvlMax, FNDBGFR3TYPEVALDUMP pfnDump, void *pvUser);
2523
2524/** @} */
2525
2526
2527/** @defgroup grp_dbgf_flow The DBGF control flow graph Interface.
2528 * @{
2529 */
2530
2531/** A DBGF control flow graph handle. */
2532typedef struct DBGFFLOWINT *DBGFFLOW;
2533/** Pointer to a DBGF control flow graph handle. */
2534typedef DBGFFLOW *PDBGFFLOW;
2535/** A DBGF control flow graph basic block handle. */
2536typedef struct DBGFFLOWBBINT *DBGFFLOWBB;
2537/** Pointer to a DBGF control flow graph basic block handle. */
2538typedef DBGFFLOWBB *PDBGFFLOWBB;
2539/** A DBGF control flow graph branch table handle. */
2540typedef struct DBGFFLOWBRANCHTBLINT *DBGFFLOWBRANCHTBL;
2541/** Pointer to a DBGF flow control graph branch table handle. */
2542typedef DBGFFLOWBRANCHTBL *PDBGFFLOWBRANCHTBL;
2543/** A DBGF control flow graph iterator. */
2544typedef struct DBGFFLOWITINT *DBGFFLOWIT;
2545/** Pointer to a control flow graph iterator. */
2546typedef DBGFFLOWIT *PDBGFFLOWIT;
2547/** A DBGF control flow graph branch table iterator. */
2548typedef struct DBGFFLOWBRANCHTBLITINT *DBGFFLOWBRANCHTBLIT;
2549/** Pointer to a control flow graph branch table iterator. */
2550typedef DBGFFLOWBRANCHTBLIT *PDBGFFLOWBRANCHTBLIT;
2551
2552/** @name DBGFFLOWBB Flags.
2553 * @{ */
2554/** The basic block is the entry into the owning control flow graph. */
2555#define DBGF_FLOW_BB_F_ENTRY RT_BIT_32(0)
2556/** The basic block was not populated because the limit was reached. */
2557#define DBGF_FLOW_BB_F_EMPTY RT_BIT_32(1)
2558/** The basic block is not complete because an error happened during disassembly. */
2559#define DBGF_FLOW_BB_F_INCOMPLETE_ERR RT_BIT_32(2)
2560/** The basic block is reached through a branch table. */
2561#define DBGF_FLOW_BB_F_BRANCH_TABLE RT_BIT_32(3)
2562/** @} */
2563
2564/** @name Flags controlling the creating of a control flow graph.
2565 * @{ */
2566/** Default options. */
2567#define DBGF_FLOW_CREATE_F_DEFAULT 0
2568/** Tries to resolve indirect branches, useful for code using
2569 * jump tables generated for large switch statements by some compilers. */
2570#define DBGF_FLOW_CREATE_F_TRY_RESOLVE_INDIRECT_BRANCHES RT_BIT_32(0)
2571/** @} */
2572
2573/**
2574 * DBGF control graph basic block end type.
2575 */
2576typedef enum DBGFFLOWBBENDTYPE
2577{
2578 /** Invalid type. */
2579 DBGFFLOWBBENDTYPE_INVALID = 0,
2580 /** Basic block is the exit block and has no successor. */
2581 DBGFFLOWBBENDTYPE_EXIT,
2582 /** Basic block is the last disassembled block because the
2583 * maximum amount to disassemble was reached but is not an
2584 * exit block - no successors.
2585 */
2586 DBGFFLOWBBENDTYPE_LAST_DISASSEMBLED,
2587 /** Unconditional control flow change because the successor is referenced by multiple
2588 * basic blocks. - 1 successor. */
2589 DBGFFLOWBBENDTYPE_UNCOND,
2590 /** Unconditional control flow change because of an direct branch - 1 successor. */
2591 DBGFFLOWBBENDTYPE_UNCOND_JMP,
2592 /** Unconditional control flow change because of an indirect branch - n successors. */
2593 DBGFFLOWBBENDTYPE_UNCOND_INDIRECT_JMP,
2594 /** Conditional control flow change - 2 successors. */
2595 DBGFFLOWBBENDTYPE_COND,
2596 /** 32bit hack. */
2597 DBGFFLOWBBENDTYPE_32BIT_HACK = 0x7fffffff
2598} DBGFFLOWBBENDTYPE;
2599
2600/**
2601 * DBGF control flow graph iteration order.
2602 */
2603typedef enum DBGFFLOWITORDER
2604{
2605 /** Invalid order. */
2606 DBGFFLOWITORDER_INVALID = 0,
2607 /** From lowest to highest basic block start address. */
2608 DBGFFLOWITORDER_BY_ADDR_LOWEST_FIRST,
2609 /** From highest to lowest basic block start address. */
2610 DBGFFLOWITORDER_BY_ADDR_HIGHEST_FIRST,
2611 /** Depth first traversing starting from the entry block. */
2612 DBGFFLOWITORDER_DEPTH_FRIST,
2613 /** Breadth first traversing starting from the entry block. */
2614 DBGFFLOWITORDER_BREADTH_FIRST,
2615 /** Usual 32bit hack. */
2616 DBGFFLOWITORDER_32BIT_HACK = 0x7fffffff
2617} DBGFFLOWITORDER;
2618/** Pointer to a iteration order enum. */
2619typedef DBGFFLOWITORDER *PDBGFFLOWITORDER;
2620
2621
2622VMMR3DECL(int) DBGFR3FlowCreate(PUVM pUVM, VMCPUID idCpu, PDBGFADDRESS pAddressStart, uint32_t cbDisasmMax,
2623 uint32_t fFlagsFlow, uint32_t fFlagsDisasm, PDBGFFLOW phFlow);
2624VMMR3DECL(uint32_t) DBGFR3FlowRetain(DBGFFLOW hFlow);
2625VMMR3DECL(uint32_t) DBGFR3FlowRelease(DBGFFLOW hFlow);
2626VMMR3DECL(int) DBGFR3FlowQueryStartBb(DBGFFLOW hFlow, PDBGFFLOWBB phFlowBb);
2627VMMR3DECL(int) DBGFR3FlowQueryBbByAddress(DBGFFLOW hFlow, PDBGFADDRESS pAddr, PDBGFFLOWBB phFlowBb);
2628VMMR3DECL(int) DBGFR3FlowQueryBranchTblByAddress(DBGFFLOW hFlow, PDBGFADDRESS pAddr, PDBGFFLOWBRANCHTBL phFlowBranchTbl);
2629VMMR3DECL(uint32_t) DBGFR3FlowGetBbCount(DBGFFLOW hFlow);
2630VMMR3DECL(uint32_t) DBGFR3FlowGetBranchTblCount(DBGFFLOW hFlow);
2631
2632VMMR3DECL(uint32_t) DBGFR3FlowBbRetain(DBGFFLOWBB hFlowBb);
2633VMMR3DECL(uint32_t) DBGFR3FlowBbRelease(DBGFFLOWBB hFlowBb);
2634VMMR3DECL(PDBGFADDRESS) DBGFR3FlowBbGetStartAddress(DBGFFLOWBB hFlowBb, PDBGFADDRESS pAddrStart);
2635VMMR3DECL(PDBGFADDRESS) DBGFR3FlowBbGetEndAddress(DBGFFLOWBB hFlowBb, PDBGFADDRESS pAddrEnd);
2636VMMR3DECL(PDBGFADDRESS) DBGFR3FlowBbGetBranchAddress(DBGFFLOWBB hFlowBb, PDBGFADDRESS pAddrTarget);
2637VMMR3DECL(PDBGFADDRESS) DBGFR3FlowBbGetFollowingAddress(DBGFFLOWBB hFlowBb, PDBGFADDRESS pAddrFollow);
2638VMMR3DECL(DBGFFLOWBBENDTYPE) DBGFR3FlowBbGetType(DBGFFLOWBB hFlowBb);
2639VMMR3DECL(uint32_t) DBGFR3FlowBbGetInstrCount(DBGFFLOWBB hFlowBb);
2640VMMR3DECL(uint32_t) DBGFR3FlowBbGetFlags(DBGFFLOWBB hFlowBb);
2641VMMR3DECL(int) DBGFR3FlowBbQueryBranchTbl(DBGFFLOWBB hFlowBb, PDBGFFLOWBRANCHTBL phBranchTbl);
2642VMMR3DECL(int) DBGFR3FlowBbQueryError(DBGFFLOWBB hFlowBb, const char **ppszErr);
2643VMMR3DECL(int) DBGFR3FlowBbQueryInstr(DBGFFLOWBB hFlowBb, uint32_t idxInstr, PDBGFADDRESS pAddrInstr,
2644 uint32_t *pcbInstr, const char **ppszInstr);
2645VMMR3DECL(int) DBGFR3FlowBbQuerySuccessors(DBGFFLOWBB hFlowBb, PDBGFFLOWBB phFlowBbFollow,
2646 PDBGFFLOWBB phFlowBbTarget);
2647VMMR3DECL(uint32_t) DBGFR3FlowBbGetRefBbCount(DBGFFLOWBB hFlowBb);
2648VMMR3DECL(int) DBGFR3FlowBbGetRefBb(DBGFFLOWBB hFlowBb, PDBGFFLOWBB pahFlowBbRef, uint32_t cRef);
2649
2650VMMR3DECL(uint32_t) DBGFR3FlowBranchTblRetain(DBGFFLOWBRANCHTBL hFlowBranchTbl);
2651VMMR3DECL(uint32_t) DBGFR3FlowBranchTblRelease(DBGFFLOWBRANCHTBL hFlowBranchTbl);
2652VMMR3DECL(uint32_t) DBGFR3FlowBranchTblGetSlots(DBGFFLOWBRANCHTBL hFlowBranchTbl);
2653VMMR3DECL(PDBGFADDRESS) DBGFR3FlowBranchTblGetStartAddress(DBGFFLOWBRANCHTBL hFlowBranchTbl, PDBGFADDRESS pAddrStart);
2654VMMR3DECL(PDBGFADDRESS) DBGFR3FlowBranchTblGetAddrAtSlot(DBGFFLOWBRANCHTBL hFlowBranchTbl, uint32_t idxSlot, PDBGFADDRESS pAddrSlot);
2655VMMR3DECL(int) DBGFR3FlowBranchTblQueryAddresses(DBGFFLOWBRANCHTBL hFlowBranchTbl, PDBGFADDRESS paAddrs, uint32_t cAddrs);
2656
2657VMMR3DECL(int) DBGFR3FlowItCreate(DBGFFLOW hFlow, DBGFFLOWITORDER enmOrder, PDBGFFLOWIT phFlowIt);
2658VMMR3DECL(void) DBGFR3FlowItDestroy(DBGFFLOWIT hFlowIt);
2659VMMR3DECL(DBGFFLOWBB) DBGFR3FlowItNext(DBGFFLOWIT hFlowIt);
2660VMMR3DECL(int) DBGFR3FlowItReset(DBGFFLOWIT hFlowIt);
2661
2662VMMR3DECL(int) DBGFR3FlowBranchTblItCreate(DBGFFLOW hFlow, DBGFFLOWITORDER enmOrder, PDBGFFLOWBRANCHTBLIT phFlowBranchTblIt);
2663VMMR3DECL(void) DBGFR3FlowBranchTblItDestroy(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt);
2664VMMR3DECL(DBGFFLOWBRANCHTBL) DBGFR3FlowBranchTblItNext(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt);
2665VMMR3DECL(int) DBGFR3FlowBranchTblItReset(DBGFFLOWBRANCHTBLIT hFlowBranchTblIt);
2666
2667/** @} */
2668
2669#endif /* IN_RING3 */
2670
2671/** @} */
2672
2673
2674RT_C_DECLS_END
2675
2676#endif
2677
Note: See TracBrowser for help on using the repository browser.

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