VirtualBox

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

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

DBGFStack: Take odd saved BP as a hint of far returns.

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