VirtualBox

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

Last change on this file since 73417 was 73417, checked in by vboxsync, 7 years ago

VMM/DBGF: Implemented DBGFR3RegNmQueryXdtr and fixed exports, including DBGFR3ModInMem which is needed by previous commit.

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

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