VirtualBox

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

Last change on this file since 107288 was 107227, checked in by vboxsync, 3 months ago

VMM: Cleaning up ARMv8 / x86 split. jiraref:VBP-1470

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