VirtualBox

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

Last change on this file since 61628 was 61628, checked in by vboxsync, 9 years ago

DBGF: Added bsod_msr event, stubbed bsod_efi event. Since we cannot return VINF_EM_DBG_EVENT from an MSR handler, VMCPU_FF_DBGF was introduced as an alternative.

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