VirtualBox

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

Last change on this file since 78415 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

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