dbgf.h revision 6a8887b42d3f7ff79c8ecec145b64c6447835a0d
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** @file
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * DBGF - Debugger Facility. (VMM)
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/*
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * Copyright (C) 2006-2007 Oracle Corporation
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn *
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * This file is part of VirtualBox Open Source Edition (OSE), as
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * available from http://www.virtualbox.org. This file is free software;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * you can redistribute it and/or modify it under the terms of the GNU
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * General Public License (GPL) as published by the Free Software
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * Foundation, in version 2 as it comes in the "COPYING" file of the
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac *
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * The contents of this file may alternatively be used under the terms
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * of the Common Development and Distribution License Version 1.0
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * VirtualBox OSE distribution, in which case the provisions of the
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * CDDL are applicable instead of those of the GPL.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn *
3e8ebc69e18e02f0935b37e8f5837aab18557f50ludovicp * You may elect to license modified versions of this file under the
65faf58a723c5e70638f0a3fb4239f7042301ddeludo * terms and conditions of either the GPL or the CDDL or both.
d5af1880773b35da2da505be54be517b746e7410ludovicp */
d5af1880773b35da2da505be54be517b746e7410ludovicp
d5af1880773b35da2da505be54be517b746e7410ludovicp#ifndef ___VBox_dbgf_h
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#define ___VBox_dbgf_h
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#include <VBox/cdefs.h>
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#include <VBox/types.h>
d5af1880773b35da2da505be54be517b746e7410ludovicp#include <VBox/vmm.h>
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#include <VBox/log.h> /* LOG_ENABLED */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#include <VBox/dbgfsel.h>
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#include <iprt/stdarg.h>
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#include <iprt/dbg.h>
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbnRT_C_DECLS_BEGIN
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** @defgroup grp_dbgf The Debugger Facility API
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * @{
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#if defined(IN_RC)|| defined(IN_RING0)
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** @addgroup grp_dbgf_rz The RZ DBGF API
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * @ingroup grp_dbgf
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * @{
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
d5af1880773b35da2da505be54be517b746e7410ludovicpVMMRZDECL(int) DBGFRZTrap01Handler(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCUINTREG uDr6);
d5af1880773b35da2da505be54be517b746e7410ludovicpVMMRZDECL(int) DBGFRZTrap03Handler(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
d5af1880773b35da2da505be54be517b746e7410ludovicp/** @} */
d5af1880773b35da2da505be54be517b746e7410ludovicp#endif
d5af1880773b35da2da505be54be517b746e7410ludovicp
d5af1880773b35da2da505be54be517b746e7410ludovicp
d5af1880773b35da2da505be54be517b746e7410ludovicp
d5af1880773b35da2da505be54be517b746e7410ludovicp/**
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * Mixed address.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbntypedef struct DBGFADDRESS
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn{
d5af1880773b35da2da505be54be517b746e7410ludovicp /** The flat address. */
d5af1880773b35da2da505be54be517b746e7410ludovicp RTGCUINTPTR FlatPtr;
a9bdd643112af44da28ffc614f51413c2ab09669ludo /** The selector offset address. */
a9bdd643112af44da28ffc614f51413c2ab09669ludo RTGCUINTPTR off;
a9bdd643112af44da28ffc614f51413c2ab09669ludo /** The selector. DBGF_SEL_FLAT is a legal value. */
a9bdd643112af44da28ffc614f51413c2ab09669ludo RTSEL Sel;
a9bdd643112af44da28ffc614f51413c2ab09669ludo /** Flags describing further details about the address. */
a9bdd643112af44da28ffc614f51413c2ab09669ludo uint16_t fFlags;
d5af1880773b35da2da505be54be517b746e7410ludovicp} DBGFADDRESS;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** Pointer to a mixed address. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbntypedef DBGFADDRESS *PDBGFADDRESS;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** Pointer to a const mixed address. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbntypedef const DBGFADDRESS *PCDBGFADDRESS;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** @name DBGFADDRESS Flags.
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swift * @{ */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** A 16:16 far address. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#define DBGFADDRESS_FLAGS_FAR16 0
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** A 16:32 far address. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#define DBGFADDRESS_FLAGS_FAR32 1
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** A 16:64 far address. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#define DBGFADDRESS_FLAGS_FAR64 2
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** A flat address. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#define DBGFADDRESS_FLAGS_FLAT 3
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** A physical address. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#define DBGFADDRESS_FLAGS_PHYS 4
d5af1880773b35da2da505be54be517b746e7410ludovicp/** A physical address. */
d5af1880773b35da2da505be54be517b746e7410ludovicp#define DBGFADDRESS_FLAGS_RING0 5
d5af1880773b35da2da505be54be517b746e7410ludovicp/** The address type mask. */
d5af1880773b35da2da505be54be517b746e7410ludovicp#define DBGFADDRESS_FLAGS_TYPE_MASK 7
d5af1880773b35da2da505be54be517b746e7410ludovicp
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** Set if the address is valid. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#define DBGFADDRESS_FLAGS_VALID RT_BIT(3)
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** The address is within the hypervisor memoary area (HMA).
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * If not set, the address can be assumed to be a guest address. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#define DBGFADDRESS_FLAGS_HMA RT_BIT(4)
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** Checks if the mixed address is flat or not. */
d5af1880773b35da2da505be54be517b746e7410ludovicp#define DBGFADDRESS_IS_FLAT(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_FLAT )
d5af1880773b35da2da505be54be517b746e7410ludovicp/** Checks if the mixed address is flat or not. */
d5af1880773b35da2da505be54be517b746e7410ludovicp#define DBGFADDRESS_IS_PHYS(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_PHYS )
d5af1880773b35da2da505be54be517b746e7410ludovicp/** Checks if the mixed address is far 16:16 or not. */
d5af1880773b35da2da505be54be517b746e7410ludovicp#define DBGFADDRESS_IS_FAR16(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_FAR16 )
d5af1880773b35da2da505be54be517b746e7410ludovicp/** Checks if the mixed address is far 16:32 or not. */
d5af1880773b35da2da505be54be517b746e7410ludovicp#define DBGFADDRESS_IS_FAR32(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_FAR32 )
d5af1880773b35da2da505be54be517b746e7410ludovicp/** Checks if the mixed address is far 16:64 or not. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#define DBGFADDRESS_IS_FAR64(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_FAR64 )
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** Checks if the mixed address is valid. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#define DBGFADDRESS_IS_VALID(pAddress) ( !!((pAddress)->fFlags & DBGFADDRESS_FLAGS_VALID) )
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** Checks if the address is flagged as within the HMA. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#define DBGFADDRESS_IS_HMA(pAddress) ( !!((pAddress)->fFlags & DBGFADDRESS_FLAGS_HMA) )
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/** @} */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbnVMMR3DECL(int) DBGFR3AddrFromSelOff(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, RTSEL Sel, RTUINTPTR off);
d5af1880773b35da2da505be54be517b746e7410ludovicpVMMR3DECL(int) DBGFR3AddrFromSelInfoOff(PVM pVM, PDBGFADDRESS pAddress, PCDBGFSELINFO pSelInfo, RTUINTPTR off);
d5af1880773b35da2da505be54be517b746e7410ludovicpVMMR3DECL(PDBGFADDRESS) DBGFR3AddrFromFlat(PVM pVM, PDBGFADDRESS pAddress, RTGCUINTPTR FlatPtr);
d5af1880773b35da2da505be54be517b746e7410ludovicpVMMR3DECL(PDBGFADDRESS) DBGFR3AddrFromPhys(PVM pVM, PDBGFADDRESS pAddress, RTGCPHYS PhysAddr);
d5af1880773b35da2da505be54be517b746e7410ludovicpVMMR3DECL(bool) DBGFR3AddrIsValid(PVM pVM, PCDBGFADDRESS pAddress);
d5af1880773b35da2da505be54be517b746e7410ludovicpVMMR3DECL(int) DBGFR3AddrToPhys(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, PRTGCPHYS pGCPhys);
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbnVMMR3DECL(int) DBGFR3AddrToHostPhys(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, PRTHCPHYS pHCPhys);
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbnVMMR3DECL(int) DBGFR3AddrToVolatileR3Ptr(PVM pVM, VMCPUID idCpu, PDBGFADDRESS pAddress, bool fReadOnly, void **ppvR3Ptr);
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbnVMMR3DECL(PDBGFADDRESS) DBGFR3AddrAdd(PDBGFADDRESS pAddress, RTGCUINTPTR uAddend);
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbnVMMR3DECL(PDBGFADDRESS) DBGFR3AddrSub(PDBGFADDRESS pAddress, RTGCUINTPTR uSubtrahend);
d5af1880773b35da2da505be54be517b746e7410ludovicp
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
d5af1880773b35da2da505be54be517b746e7410ludovicp
d5af1880773b35da2da505be54be517b746e7410ludovicp
d5af1880773b35da2da505be54be517b746e7410ludovicp/**
d5af1880773b35da2da505be54be517b746e7410ludovicp * VMM Debug Event Type.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbntypedef enum DBGFEVENTTYPE
a9bdd643112af44da28ffc614f51413c2ab09669ludo{
a9bdd643112af44da28ffc614f51413c2ab09669ludo /** Halt completed.
a9bdd643112af44da28ffc614f51413c2ab09669ludo * This notifies that a halt command have been successfully completed.
a9bdd643112af44da28ffc614f51413c2ab09669ludo */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENT_HALT_DONE = 0,
a9bdd643112af44da28ffc614f51413c2ab09669ludo /** Detach completed.
a9bdd643112af44da28ffc614f51413c2ab09669ludo * This notifies that the detach command have been successfully completed.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENT_DETACH_DONE,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** The command from the debugger is not recognized.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * This means internal error or half implemented features.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENT_INVALID_COMMAND,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Fatal error.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * This notifies a fatal error in the VMM and that the debugger get's a
6df86604699d401d24863654538c078d3750963ashankar_mbn * chance to first hand information about the the problem.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENT_FATAL_ERROR = 100,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Breakpoint Hit.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * This notifies that a breakpoint installed by the debugger was hit. The
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * identifier of the breakpoint can be found in the DBGFEVENT::u::Bp::iBp member.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENT_BREAKPOINT,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Breakpoint Hit in the Hypervisor.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * This notifies that a breakpoint installed by the debugger was hit. The
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * identifier of the breakpoint can be found in the DBGFEVENT::u::Bp::iBp member.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENT_BREAKPOINT_HYPER,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Assertion in the Hypervisor (breakpoint instruction).
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * This notifies that a breakpoint instruction was hit in the hypervisor context.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
6df86604699d401d24863654538c078d3750963ashankar_mbn DBGFEVENT_ASSERTION_HYPER,
2c8454e288252bcfa5e77ea3d35bfed05266b869hajma /** Single Stepped.
2c8454e288252bcfa5e77ea3d35bfed05266b869hajma * This notifies that a single step operation was completed.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENT_STEPPED,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Single Stepped.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * This notifies that a hypervisor single step operation was completed.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENT_STEPPED_HYPER,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** The developer have used the DBGFSTOP macro or the PDMDeviceDBGFSTOP function
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * to bring up the debugger at a specific place.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENT_DEV_STOP,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** The VM is terminating.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * When this notification is received, the debugger thread should detach ASAP.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENT_TERMINATING,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** The usual 32-bit hack. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENT_32BIT_HACK = 0x7fffffff
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn} DBGFEVENTTYPE;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/**
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * The context of an event.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbntypedef enum DBGFEVENTCTX
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn{
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** The usual invalid entry. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENTCTX_INVALID = 0,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Raw mode. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENTCTX_RAW,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Recompiled mode. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENTCTX_REM,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** VMX / AVT mode. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENTCTX_HWACCL,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Hypervisor context. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENTCTX_HYPER,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Other mode */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENTCTX_OTHER,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** The usual 32-bit hack */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENTCTX_32BIT_HACK = 0x7fffffff
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn} DBGFEVENTCTX;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/**
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * VMM Debug Event.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbntypedef struct DBGFEVENT
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn{
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Type. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENTTYPE enmType;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Context */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn DBGFEVENTCTX enmCtx;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Type specific data. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn union
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn {
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Fatal error details. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn struct
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn {
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** The GC return code. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn int rc;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn } FatalError;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Source location. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn struct
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn {
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** File name. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn R3PTRTYPE(const char *) pszFile;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Function name. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn R3PTRTYPE(const char *) pszFunction;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Message. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn R3PTRTYPE(const char *) pszMessage;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /** Line number. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn unsigned uLine;
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn } Src;
d5af1880773b35da2da505be54be517b746e7410ludovicp
d5af1880773b35da2da505be54be517b746e7410ludovicp /** Assertion messages. */
d5af1880773b35da2da505be54be517b746e7410ludovicp struct
d5af1880773b35da2da505be54be517b746e7410ludovicp {
d5af1880773b35da2da505be54be517b746e7410ludovicp /** The first message. */
d5af1880773b35da2da505be54be517b746e7410ludovicp R3PTRTYPE(const char *) pszMsg1;
d5af1880773b35da2da505be54be517b746e7410ludovicp /** The second message. */
d5af1880773b35da2da505be54be517b746e7410ludovicp R3PTRTYPE(const char *) pszMsg2;
d5af1880773b35da2da505be54be517b746e7410ludovicp } Assert;
d5af1880773b35da2da505be54be517b746e7410ludovicp
d5af1880773b35da2da505be54be517b746e7410ludovicp /** Breakpoint. */
d5af1880773b35da2da505be54be517b746e7410ludovicp struct DBGFEVENTBP
d5af1880773b35da2da505be54be517b746e7410ludovicp {
d5af1880773b35da2da505be54be517b746e7410ludovicp /** The identifier of the breakpoint which was hit. */
d5af1880773b35da2da505be54be517b746e7410ludovicp RTUINT iBp;
d5af1880773b35da2da505be54be517b746e7410ludovicp } Bp;
d5af1880773b35da2da505be54be517b746e7410ludovicp /** Padding for ensuring that the structure is 8 byte aligned. */
d5af1880773b35da2da505be54be517b746e7410ludovicp uint64_t au64Padding[4];
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn } u;
d5af1880773b35da2da505be54be517b746e7410ludovicp} DBGFEVENT;
d5af1880773b35da2da505be54be517b746e7410ludovicp/** Pointer to VMM Debug Event. */
d5af1880773b35da2da505be54be517b746e7410ludovicptypedef DBGFEVENT *PDBGFEVENT;
d5af1880773b35da2da505be54be517b746e7410ludovicp/** Pointer to const VMM Debug Event. */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbntypedef const DBGFEVENT *PCDBGFEVENT;
d5af1880773b35da2da505be54be517b746e7410ludovicp
d5af1880773b35da2da505be54be517b746e7410ludovicp
d5af1880773b35da2da505be54be517b746e7410ludovicp/** @def DBGFSTOP
3e8ebc69e18e02f0935b37e8f5837aab18557f50ludovicp * Stops the debugger raising a DBGFEVENT_DEVELOPER_STOP event.
d5af1880773b35da2da505be54be517b746e7410ludovicp *
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * @returns VBox status code which must be propagated up to EM if not VINF_SUCCESS.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * @param pVM VM Handle.
d5af1880773b35da2da505be54be517b746e7410ludovicp */
d5af1880773b35da2da505be54be517b746e7410ludovicp#ifdef VBOX_STRICT
d5af1880773b35da2da505be54be517b746e7410ludovicp# define DBGFSTOP(pVM) DBGFR3EventSrc(pVM, DBGFEVENT_DEV_STOP, __FILE__, __LINE__, __PRETTY_FUNCTION__, NULL)
d5af1880773b35da2da505be54be517b746e7410ludovicp#else
d5af1880773b35da2da505be54be517b746e7410ludovicp# define DBGFSTOP(pVM) VINF_SUCCESS
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn#endif
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swift
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swiftVMMR3DECL(int) DBGFR3Init(PVM pVM);
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swiftVMMR3DECL(int) DBGFR3Term(PVM pVM);
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swiftVMMR3DECL(void) DBGFR3Relocate(PVM pVM, RTGCINTPTR offDelta);
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swiftVMMR3DECL(int) DBGFR3VMMForcedAction(PVM pVM);
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swiftVMMR3DECL(int) DBGFR3Event(PVM pVM, DBGFEVENTTYPE enmEvent);
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swiftVMMR3DECL(int) DBGFR3EventSrc(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszFile, unsigned uLine, const char *pszFunction, const char *pszFormat, ...);
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swiftVMMR3DECL(int) DBGFR3EventSrcV(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszFile, unsigned uLine, const char *pszFunction, const char *pszFormat, va_list args);
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swiftVMMR3DECL(int) DBGFR3EventAssertion(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszMsg1, const char *pszMsg2);
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swiftVMMR3DECL(int) DBGFR3EventBreakpoint(PVM pVM, DBGFEVENTTYPE enmEvent);
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swiftVMMR3DECL(int) DBGFR3Attach(PVM pVM);
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swiftVMMR3DECL(int) DBGFR3Detach(PVM pVM);
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swiftVMMR3DECL(int) DBGFR3EventWait(PVM pVM, RTMSINTERVAL cMillies, PCDBGFEVENT *ppEvent);
074f2520bc04a7a93b4123bc58fb40055c9174d2hajmaVMMR3DECL(int) DBGFR3Halt(PVM pVM);
e89b8e1cf5e7165e6453cd4fe8e57359f6ee2d01hajmaVMMR3DECL(bool) DBGFR3IsHalted(PVM pVM);
d5af1880773b35da2da505be54be517b746e7410ludovicpVMMR3DECL(bool) DBGFR3CanWait(PVM pVM);
074f2520bc04a7a93b4123bc58fb40055c9174d2hajmaVMMR3DECL(int) DBGFR3Resume(PVM pVM);
074f2520bc04a7a93b4123bc58fb40055c9174d2hajmaVMMR3DECL(int) DBGFR3Step(PVM pVM, VMCPUID idCpu);
074f2520bc04a7a93b4123bc58fb40055c9174d2hajmaVMMR3DECL(int) DBGFR3PrgStep(PVMCPU pVCpu);
074f2520bc04a7a93b4123bc58fb40055c9174d2hajma
074f2520bc04a7a93b4123bc58fb40055c9174d2hajma
074f2520bc04a7a93b4123bc58fb40055c9174d2hajma/** Breakpoint type. */
074f2520bc04a7a93b4123bc58fb40055c9174d2hajmatypedef enum DBGFBPTYPE
65faf58a723c5e70638f0a3fb4239f7042301ddeludo{
074f2520bc04a7a93b4123bc58fb40055c9174d2hajma /** Free breakpoint entry. */
074f2520bc04a7a93b4123bc58fb40055c9174d2hajma DBGFBPTYPE_FREE = 0,
074f2520bc04a7a93b4123bc58fb40055c9174d2hajma /** Debug register. */
074f2520bc04a7a93b4123bc58fb40055c9174d2hajma DBGFBPTYPE_REG,
074f2520bc04a7a93b4123bc58fb40055c9174d2hajma /** INT 3 instruction. */
d5af1880773b35da2da505be54be517b746e7410ludovicp DBGFBPTYPE_INT3,
d5af1880773b35da2da505be54be517b746e7410ludovicp /** Recompiler. */
d5af1880773b35da2da505be54be517b746e7410ludovicp DBGFBPTYPE_REM,
d5af1880773b35da2da505be54be517b746e7410ludovicp /** ensure 32-bit size. */
65faf58a723c5e70638f0a3fb4239f7042301ddeludo DBGFBPTYPE_32BIT_HACK = 0x7fffffff
fc2dab2c4a694677a94470b728850adada8e4369matthew} DBGFBPTYPE;
fc2dab2c4a694677a94470b728850adada8e4369matthew
fc2dab2c4a694677a94470b728850adada8e4369matthew
/**
* A Breakpoint.
*/
typedef struct DBGFBP
{
/** The number of breakpoint hits. */
uint64_t cHits;
/** The hit number which starts to trigger the breakpoint. */
uint64_t iHitTrigger;
/** The hit number which stops triggering the breakpoint (disables it).
* Use ~(uint64_t)0 if it should never stop. */
uint64_t iHitDisable;
/** The Flat GC address of the breakpoint.
* (PC register value if REM type?) */
RTGCUINTPTR GCPtr;
/** The breakpoint id. */
RTUINT iBp;
/** The breakpoint status - enabled or disabled. */
bool fEnabled;
/** The breakpoint type. */
DBGFBPTYPE enmType;
#if GC_ARCH_BITS == 64
uint32_t u32Padding;
#endif
/** Union of type specific data. */
union
{
/** Debug register data. */
struct DBGFBPREG
{
/** The debug register number. */
uint8_t iReg;
/** The access type (one of the X86_DR7_RW_* value). */
uint8_t fType;
/** The access size. */
uint8_t cb;
} Reg;
/** Recompiler breakpoint data. */
struct DBGFBPINT3
{
/** The byte value we replaced by the INT 3 instruction. */
uint8_t bOrg;
} Int3;
/** Recompiler breakpoint data. */
struct DBGFBPREM
{
/** nothing yet */
uint8_t fDummy;
} Rem;
/** Paddind to ensure that the size is identical on win32 and linux. */
uint64_t u64Padding;
} u;
} DBGFBP;
/** Pointer to a breakpoint. */
typedef DBGFBP *PDBGFBP;
/** Pointer to a const breakpoint. */
typedef const DBGFBP *PCDBGFBP;
VMMR3DECL(int) DBGFR3BpSet(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp);
VMMR3DECL(int) DBGFR3BpSetReg(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable,
uint8_t fType, uint8_t cb, PRTUINT piBp);
VMMR3DECL(int) DBGFR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp);
VMMR3DECL(int) DBGFR3BpClear(PVM pVM, RTUINT iBp);
VMMR3DECL(int) DBGFR3BpEnable(PVM pVM, RTUINT iBp);
VMMR3DECL(int) DBGFR3BpDisable(PVM pVM, RTUINT iBp);
/**
* Breakpoint enumeration callback function.
*
* @returns VBox status code. Any failure will stop the enumeration.
* @param pVM The VM handle.
* @param pvUser The user argument.
* @param pBp Pointer to the breakpoint information. (readonly)
*/
typedef DECLCALLBACK(int) FNDBGFBPENUM(PVM pVM, void *pvUser, PCDBGFBP pBp);
/** Pointer to a breakpoint enumeration callback function. */
typedef FNDBGFBPENUM *PFNDBGFBPENUM;
VMMR3DECL(int) DBGFR3BpEnum(PVM pVM, PFNDBGFBPENUM pfnCallback, void *pvUser);
VMMDECL(RTGCUINTREG) DBGFBpGetDR7(PVM pVM);
VMMDECL(RTGCUINTREG) DBGFBpGetDR0(PVM pVM);
VMMDECL(RTGCUINTREG) DBGFBpGetDR1(PVM pVM);
VMMDECL(RTGCUINTREG) DBGFBpGetDR2(PVM pVM);
VMMDECL(RTGCUINTREG) DBGFBpGetDR3(PVM pVM);
VMMDECL(bool) DBGFIsStepping(PVMCPU pVCpu);
VMMR3DECL(CPUMMODE) DBGFR3CpuGetMode(PVM pVM, VMCPUID idCpu);
/**
* Info helper callback structure.
*/
typedef struct DBGFINFOHLP
{
/**
* Print formatted string.
*
* @param pHlp Pointer to this structure.
* @param pszFormat The format string.
* @param ... Arguments.
*/
DECLCALLBACKMEMBER(void, pfnPrintf)(PCDBGFINFOHLP pHlp, const char *pszFormat, ...);
/**
* Print formatted string.
*
* @param pHlp Pointer to this structure.
* @param pszFormat The format string.
* @param args Argument list.
*/
DECLCALLBACKMEMBER(void, pfnPrintfV)(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args);
} DBGFINFOHLP;
/**
* Info handler, device version.
*
* @param pDevIns The device instance which registered the info.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
typedef DECLCALLBACK(void) FNDBGFHANDLERDEV(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
/** Pointer to a FNDBGFHANDLERDEV function. */
typedef FNDBGFHANDLERDEV *PFNDBGFHANDLERDEV;
/**
* Info handler, USB device version.
*
* @param pUsbIns The USB device instance which registered the info.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
typedef DECLCALLBACK(void) FNDBGFHANDLERUSB(PPDMUSBINS pUsbIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
/** Pointer to a FNDBGFHANDLERUSB function. */
typedef FNDBGFHANDLERUSB *PFNDBGFHANDLERUSB;
/**
* Info handler, driver version.
*
* @param pDrvIns The driver instance which registered the info.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
typedef DECLCALLBACK(void) FNDBGFHANDLERDRV(PPDMDRVINS pDrvIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
/** Pointer to a FNDBGFHANDLERDRV function. */
typedef FNDBGFHANDLERDRV *PFNDBGFHANDLERDRV;
/**
* Info handler, internal version.
*
* @param pVM The VM handle.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
typedef DECLCALLBACK(void) FNDBGFHANDLERINT(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
/** Pointer to a FNDBGFHANDLERINT function. */
typedef FNDBGFHANDLERINT *PFNDBGFHANDLERINT;
/**
* Info handler, external version.
*
* @param pvUser User argument.
* @param pHlp Callback functions for doing output.
* @param pszArgs Argument string. Optional and specific to the handler.
*/
typedef DECLCALLBACK(void) FNDBGFHANDLEREXT(void *pvUser, PCDBGFINFOHLP pHlp, const char *pszArgs);
/** Pointer to a FNDBGFHANDLEREXT function. */
typedef FNDBGFHANDLEREXT *PFNDBGFHANDLEREXT;
/** @name Flags for the info registration functions.
* @{ */
/** The handler must run on the EMT. */
#define DBGFINFO_FLAGS_RUN_ON_EMT RT_BIT(0)
/** @} */
VMMR3DECL(int) DBGFR3InfoRegisterDevice(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler, PPDMDEVINS pDevIns);
VMMR3DECL(int) DBGFR3InfoRegisterDriver(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler, PPDMDRVINS pDrvIns);
VMMR3DECL(int) DBGFR3InfoRegisterInternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler);
VMMR3DECL(int) DBGFR3InfoRegisterInternalEx(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler, uint32_t fFlags);
VMMR3DECL(int) DBGFR3InfoRegisterExternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLEREXT pfnHandler, void *pvUser);
VMMR3DECL(int) DBGFR3InfoDeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName);
VMMR3DECL(int) DBGFR3InfoDeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName);
VMMR3DECL(int) DBGFR3InfoDeregisterInternal(PVM pVM, const char *pszName);
VMMR3DECL(int) DBGFR3InfoDeregisterExternal(PVM pVM, const char *pszName);
VMMR3DECL(int) DBGFR3Info(PVM pVM, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp);
VMMR3DECL(int) DBGFR3InfoLogRel(PVM pVM, const char *pszName, const char *pszArgs);
VMMR3DECL(int) DBGFR3InfoStdErr(PVM pVM, const char *pszName, const char *pszArgs);
VMMR3DECL(int) DBGFR3InfoMulti(PVM pVM, const char *pszIncludePat, const char *pszExcludePat,
const char *pszSepFmt, PCDBGFINFOHLP pHlp);
/** @def DBGFR3InfoLog
* Display a piece of info writing to the log if enabled.
*
* @param pVM VM handle.
* @param pszName The identifier of the info to display.
* @param pszArgs Arguments to the info handler.
*/
#ifdef LOG_ENABLED
#define DBGFR3InfoLog(pVM, pszName, pszArgs) \
do { \
if (LogIsEnabled()) \
DBGFR3Info(pVM, pszName, pszArgs, NULL); \
} while (0)
#else
#define DBGFR3InfoLog(pVM, pszName, pszArgs) do { } while (0)
#endif
/**
* Enumeration callback for use with DBGFR3InfoEnum.
*
* @returns VBox status code.
* A status code indicating failure will end the enumeration
* and DBGFR3InfoEnum will return with that status code.
* @param pVM VM handle.
* @param pszName Info identifier name.
* @param pszDesc The description.
*/
typedef DECLCALLBACK(int) FNDBGFINFOENUM(PVM pVM, const char *pszName, const char *pszDesc, void *pvUser);
/** Pointer to a FNDBGFINFOENUM function. */
typedef FNDBGFINFOENUM *PFNDBGFINFOENUM;
VMMR3DECL(int) DBGFR3InfoEnum(PVM pVM, PFNDBGFINFOENUM pfnCallback, void *pvUser);
VMMR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogHlp(void);
VMMR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogRelHlp(void);
VMMR3DECL(int) DBGFR3LogModifyGroups(PVM pVM, const char *pszGroupSettings);
VMMR3DECL(int) DBGFR3LogModifyFlags(PVM pVM, const char *pszFlagSettings);
VMMR3DECL(int) DBGFR3LogModifyDestinations(PVM pVM, const char *pszDestSettings);
/** Max length (including '\\0') of a symbol name. */
#define DBGF_SYMBOL_NAME_LENGTH 512
/**
* Debug symbol.
*/
typedef struct DBGFSYMBOL
{
/** Symbol value (address). */
RTGCUINTPTR Value;
/** Symbol size. */
uint32_t cb;
/** Symbol Flags. (reserved). */
uint32_t fFlags;
/** Symbol name. */
char szName[DBGF_SYMBOL_NAME_LENGTH];
} DBGFSYMBOL;
/** Pointer to debug symbol. */
typedef DBGFSYMBOL *PDBGFSYMBOL;
/** Pointer to const debug symbol. */
typedef const DBGFSYMBOL *PCDBGFSYMBOL;
/**
* Debug line number information.
*/
typedef struct DBGFLINE
{
/** Address. */
RTGCUINTPTR Address;
/** Line number. */
uint32_t uLineNo;
/** Filename. */
char szFilename[260];
} DBGFLINE;
/** Pointer to debug line number. */
typedef DBGFLINE *PDBGFLINE;
/** Pointer to const debug line number. */
typedef const DBGFLINE *PCDBGFLINE;
/** @name Address spaces aliases.
* @{ */
/** The guest global address space. */
#define DBGF_AS_GLOBAL ((RTDBGAS)-1)
/** The guest kernel address space.
* This is usually resolves to the same as DBGF_AS_GLOBAL. */
#define DBGF_AS_KERNEL ((RTDBGAS)-2)
/** The physical address space. */
#define DBGF_AS_PHYS ((RTDBGAS)-3)
/** Raw-mode context. */
#define DBGF_AS_RC ((RTDBGAS)-4)
/** Ring-0 context. */
#define DBGF_AS_R0 ((RTDBGAS)-5)
/** Raw-mode context and then global guest context.
* When used for looking up information, it works as if the call was first made
* with DBGF_AS_RC and then on failure with DBGF_AS_GLOBAL. When called for
* making address space changes, it works as if DBGF_AS_RC was used. */
#define DBGF_AS_RC_AND_GC_GLOBAL ((RTDBGAS)-6)
/** The first special one. */
#define DBGF_AS_FIRST DBGF_AS_RC_AND_GC_GLOBAL
/** The last special one. */
#define DBGF_AS_LAST DBGF_AS_GLOBAL
/** The number of special address space handles. */
#define DBGF_AS_COUNT (6U)
/** Converts an alias handle to an array index. */
#define DBGF_AS_ALIAS_2_INDEX(hAlias) \
( (uintptr_t)(hAlias) - (uintptr_t)DBGF_AS_FIRST )
/** Predicat macro that check if the specified handle is an alias. */
#define DBGF_AS_IS_ALIAS(hAlias) \
( DBGF_AS_ALIAS_2_INDEX(hAlias) < DBGF_AS_COUNT )
/** Predicat macro that check if the specified alias is a fixed one or not. */
#define DBGF_AS_IS_FIXED_ALIAS(hAlias) \
( DBGF_AS_ALIAS_2_INDEX(hAlias) < (uintptr_t)DBGF_AS_PHYS - (uintptr_t)DBGF_AS_FIRST + 1U )
/** @} */
VMMR3DECL(int) DBGFR3AsAdd(PVM pVM, RTDBGAS hDbgAs, RTPROCESS ProcId);
VMMR3DECL(int) DBGFR3AsDelete(PVM pVM, RTDBGAS hDbgAs);
VMMR3DECL(int) DBGFR3AsSetAlias(PVM pVM, RTDBGAS hAlias, RTDBGAS hAliasFor);
VMMR3DECL(RTDBGAS) DBGFR3AsResolve(PVM pVM, RTDBGAS hAlias);
VMMR3DECL(RTDBGAS) DBGFR3AsResolveAndRetain(PVM pVM, RTDBGAS hAlias);
VMMR3DECL(RTDBGAS) DBGFR3AsQueryByName(PVM pVM, const char *pszName);
VMMR3DECL(RTDBGAS) DBGFR3AsQueryByPid(PVM pVM, RTPROCESS ProcId);
VMMR3DECL(int) DBGFR3AsLoadImage(PVM pVM, RTDBGAS hDbgAs, const char *pszFilename, const char *pszModName, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, uint32_t fFlags);
VMMR3DECL(int) DBGFR3AsLoadMap(PVM pVM, RTDBGAS hDbgAs, const char *pszFilename, const char *pszModName, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, RTGCUINTPTR uSubtrahend, uint32_t fFlags);
VMMR3DECL(int) DBGFR3AsLinkModule(PVM pVM, RTDBGAS hDbgAs, RTDBGMOD hMod, PCDBGFADDRESS pModAddress, RTDBGSEGIDX iModSeg, uint32_t fFlags);
VMMR3DECL(int) DBGFR3AsSymbolByAddr(PVM pVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, PRTGCINTPTR poffDisp, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
VMMR3DECL(PRTDBGSYMBOL) DBGFR3AsSymbolByAddrA(PVM pVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress, PRTGCINTPTR poffDisp, PRTDBGMOD phMod);
VMMR3DECL(int) DBGFR3AsSymbolByName(PVM pVM, RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
/* The following are soon to be obsoleted: */
VMMR3DECL(int) DBGFR3ModuleLoad(PVM pVM, const char *pszFilename, RTGCUINTPTR AddressDelta, const char *pszName, RTGCUINTPTR ModuleAddress, unsigned cbImage);
VMMR3DECL(void) DBGFR3ModuleRelocate(PVM pVM, RTGCUINTPTR OldImageBase, RTGCUINTPTR NewImageBase, RTGCUINTPTR cbImage,
const char *pszFilename, const char *pszName);
VMMR3DECL(int) DBGFR3SymbolAdd(PVM pVM, RTGCUINTPTR ModuleAddress, RTGCUINTPTR SymbolAddress, RTUINT cbSymbol, const char *pszSymbol);
VMMR3DECL(int) DBGFR3SymbolByAddr(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFSYMBOL pSymbol);
VMMR3DECL(int) DBGFR3SymbolByName(PVM pVM, const char *pszSymbol, PDBGFSYMBOL pSymbol);
VMMR3DECL(int) DBGFR3LineByAddr(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFLINE pLine);
VMMR3DECL(PDBGFLINE) DBGFR3LineByAddrAlloc(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement);
VMMR3DECL(void) DBGFR3LineFree(PDBGFLINE pLine);
/**
* Return type.
*/
typedef enum DBGFRETRUNTYPE
{
/** The usual invalid 0 value. */
DBGFRETURNTYPE_INVALID = 0,
/** Near 16-bit return. */
DBGFRETURNTYPE_NEAR16,
/** Near 32-bit return. */
DBGFRETURNTYPE_NEAR32,
/** Near 64-bit return. */
DBGFRETURNTYPE_NEAR64,
/** Far 16:16 return. */
DBGFRETURNTYPE_FAR16,
/** Far 16:32 return. */
DBGFRETURNTYPE_FAR32,
/** Far 16:64 return. */
DBGFRETURNTYPE_FAR64,
/** 16-bit iret return (e.g. real or 286 protect mode). */
DBGFRETURNTYPE_IRET16,
/** 32-bit iret return. */
DBGFRETURNTYPE_IRET32,
/** 32-bit iret return. */
DBGFRETURNTYPE_IRET32_PRIV,
/** 32-bit iret return to V86 mode. */
DBGFRETURNTYPE_IRET32_V86,
/** @todo 64-bit iret return. */
DBGFRETURNTYPE_IRET64,
/** The end of the valid return types. */
DBGFRETURNTYPE_END,
/** The usual 32-bit blowup. */
DBGFRETURNTYPE_32BIT_HACK = 0x7fffffff
} DBGFRETURNTYPE;
/**
* Figures the size of the return state on the stack.
*
* @returns number of bytes. 0 if invalid parameter.
* @param enmRetType The type of return.
*/
DECLINLINE(unsigned) DBGFReturnTypeSize(DBGFRETURNTYPE enmRetType)
{
switch (enmRetType)
{
case DBGFRETURNTYPE_NEAR16: return 2;
case DBGFRETURNTYPE_NEAR32: return 4;
case DBGFRETURNTYPE_NEAR64: return 8;
case DBGFRETURNTYPE_FAR16: return 4;
case DBGFRETURNTYPE_FAR32: return 4;
case DBGFRETURNTYPE_FAR64: return 8;
case DBGFRETURNTYPE_IRET16: return 6;
case DBGFRETURNTYPE_IRET32: return 4*3;
case DBGFRETURNTYPE_IRET32_PRIV: return 4*5;
case DBGFRETURNTYPE_IRET32_V86: return 4*9;
case DBGFRETURNTYPE_IRET64:
default:
return 0;
}
}
/** Pointer to stack frame info. */
typedef struct DBGFSTACKFRAME *PDBGFSTACKFRAME;
/** Pointer to const stack frame info. */
typedef struct DBGFSTACKFRAME const *PCDBGFSTACKFRAME;
/**
* Info about a stack frame.
*/
typedef struct DBGFSTACKFRAME
{
/** Frame number. */
uint32_t iFrame;
/** Frame flags. */
uint32_t fFlags;
/** The frame address.
* The off member is [e|r]bp and the Sel member is ss. */
DBGFADDRESS AddrFrame;
/** The stack address of the frame.
* The off member is [e|r]sp and the Sel member is ss. */
DBGFADDRESS AddrStack;
/** The program counter (PC) address of the frame.
* The off member is [e|r]ip and the Sel member is cs. */
DBGFADDRESS AddrPC;
/** Pointer to the symbol nearest the program counter (PC). NULL if not found. */
PRTDBGSYMBOL pSymPC;
/** Pointer to the linnumber nearest the program counter (PC). NULL if not found. */
PDBGFLINE pLinePC;
/** The return frame address.
* The off member is [e|r]bp and the Sel member is ss. */
DBGFADDRESS AddrReturnFrame;
/** The return stack address.
* The off member is [e|r]sp and the Sel member is ss. */
DBGFADDRESS AddrReturnStack;
/** The way this frame returns to the next one. */
DBGFRETURNTYPE enmReturnType;
/** The program counter (PC) address which the frame returns to.
* The off member is [e|r]ip and the Sel member is cs. */
DBGFADDRESS AddrReturnPC;
/** Pointer to the symbol nearest the return PC. NULL if not found. */
PRTDBGSYMBOL pSymReturnPC;
/** Pointer to the linnumber nearest the return PC. NULL if not found. */
PDBGFLINE pLineReturnPC;
/** 32-bytes of stack arguments. */
union
{
/** 64-bit view */
uint64_t au64[4];
/** 32-bit view */
uint32_t au32[8];
/** 16-bit view */
uint16_t au16[16];
/** 8-bit view */
uint8_t au8[32];
} Args;
/** Pointer to the next frame.
* Might not be used in some cases, so consider it internal. */
PCDBGFSTACKFRAME pNextInternal;
/** Pointer to the first frame.
* Might not be used in some cases, so consider it internal. */
PCDBGFSTACKFRAME pFirstInternal;
} DBGFSTACKFRAME;
/** @name DBGFSTACKFRAME Flags.
* @{ */
/** Set if the content of the frame is filled in by DBGFR3StackWalk() and can be used
* to construct the next frame. */
#define DBGFSTACKFRAME_FLAGS_ALL_VALID RT_BIT(0)
/** This is the last stack frame we can read.
* This flag is not set if the walk stop because of max dept or recursion. */
#define DBGFSTACKFRAME_FLAGS_LAST RT_BIT(1)
/** This is the last record because we detected a loop. */
#define DBGFSTACKFRAME_FLAGS_LOOP RT_BIT(2)
/** This is the last record because we reached the maximum depth. */
#define DBGFSTACKFRAME_FLAGS_MAX_DEPTH RT_BIT(3)
/** 16-bit frame. */
#define DBGFSTACKFRAME_FLAGS_16BIT RT_BIT(4)
/** 32-bit frame. */
#define DBGFSTACKFRAME_FLAGS_32BIT RT_BIT(5)
/** 64-bit frame. */
#define DBGFSTACKFRAME_FLAGS_64BIT RT_BIT(6)
/** @} */
/** @name DBGFCODETYPE
* @{ */
typedef enum DBGFCODETYPE
{
/** The usual invalid 0 value. */
DBGFCODETYPE_INVALID = 0,
/** Stack walk for guest code. */
DBGFCODETYPE_GUEST,
/** Stack walk for hypervisor code. */
DBGFCODETYPE_HYPER,
/** Stack walk for ring 0 code. */
DBGFCODETYPE_RING0,
/** The usual 32-bit blowup. */
DBGFCODETYPE_32BIT_HACK = 0x7fffffff
} DBGFCODETYPE;
/** @} */
VMMR3DECL(int) DBGFR3StackWalkBegin(PVM pVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType, PCDBGFSTACKFRAME *ppFirstFrame);
VMMR3DECL(int) DBGFR3StackWalkBeginEx(PVM pVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType, PCDBGFADDRESS pAddrFrame,
PCDBGFADDRESS pAddrStack,PCDBGFADDRESS pAddrPC,
DBGFRETURNTYPE enmReturnType, PCDBGFSTACKFRAME *ppFirstFrame);
VMMR3DECL(PCDBGFSTACKFRAME) DBGFR3StackWalkNext(PCDBGFSTACKFRAME pCurrent);
VMMR3DECL(void) DBGFR3StackWalkEnd(PCDBGFSTACKFRAME pFirstFrame);
/** Flags to pass to DBGFR3DisasInstrEx().
* @{ */
/** Disassemble the current guest instruction, with annotations. */
#define DBGF_DISAS_FLAGS_CURRENT_GUEST RT_BIT(0)
/** Disassemble the current hypervisor instruction, with annotations. */
#define DBGF_DISAS_FLAGS_CURRENT_HYPER RT_BIT(1)
/** No annotations for current context. */
#define DBGF_DISAS_FLAGS_NO_ANNOTATION RT_BIT(2)
/** No symbol lookup. */
#define DBGF_DISAS_FLAGS_NO_SYMBOLS RT_BIT(3)
/** No instruction bytes. */
#define DBGF_DISAS_FLAGS_NO_BYTES RT_BIT(4)
/** No address in the output. */
#define DBGF_DISAS_FLAGS_NO_ADDRESS RT_BIT(5)
/** Set if the hidden selector registers are known to be valid. (REM hack to
* avoid assertions.) */
#define DBGF_DISAS_FLAGS_HID_SEL_REGS_VALID RT_BIT(6)
/** Disassemble in the default mode of the specific context. */
#define DBGF_DISAS_FLAGS_DEFAULT_MODE UINT32_C(0x00000000)
/** Disassemble in 16-bit mode. */
#define DBGF_DISAS_FLAGS_16BIT_MODE UINT32_C(0x10000000)
/** Disassemble in 16-bit mode with real mode address translation. */
#define DBGF_DISAS_FLAGS_16BIT_REAL_MODE UINT32_C(0x20000000)
/** Disassemble in 32-bit mode. */
#define DBGF_DISAS_FLAGS_32BIT_MODE UINT32_C(0x30000000)
/** Disassemble in 64-bit mode. */
#define DBGF_DISAS_FLAGS_64BIT_MODE UINT32_C(0x40000000)
/** The dissassembly mode mask. */
#define DBGF_DISAS_FLAGS_MODE_MASK UINT32_C(0x70000000)
/** Mask containing the valid flags. */
#define DBGF_DISAS_FLAGS_VALID_MASK UINT32_C(0x7000007f)
/** @} */
/** Special flat selector. */
#define DBGF_SEL_FLAT 1
VMMR3DECL(int) DBGFR3DisasInstrEx(PVM pVM, VMCPUID idCpu, RTSEL Sel, RTGCPTR GCPtr, uint32_t fFlags,
char *pszOutput, uint32_t cbOutput, uint32_t *pcbInstr);
VMMR3DECL(int) DBGFR3DisasInstrCurrent(PVMCPU pVCpu, char *pszOutput, uint32_t cbOutput);
VMMR3DECL(int) DBGFR3DisasInstrCurrentLogInternal(PVMCPU pVCpu, const char *pszPrefix);
/** @def DBGFR3DisasInstrCurrentLog
* Disassembles the current guest context instruction and writes it to the log.
* All registers and data will be displayed. Addresses will be attempted resolved to symbols.
*/
#ifdef LOG_ENABLED
# define DBGFR3DisasInstrCurrentLog(pVCpu, pszPrefix) \
do { \
if (LogIsEnabled()) \
DBGFR3DisasInstrCurrentLogInternal(pVCpu, pszPrefix); \
} while (0)
#else
# define DBGFR3DisasInstrCurrentLog(pVCpu, pszPrefix) do { } while (0)
#endif
VMMR3DECL(int) DBGFR3DisasInstrLogInternal(PVMCPU pVCpu, RTSEL Sel, RTGCPTR GCPtr);
/** @def DBGFR3DisasInstrLog
* Disassembles the specified guest context instruction and writes it to the log.
* Addresses will be attempted resolved to symbols.
* @thread Any EMT.
*/
#ifdef LOG_ENABLED
# define DBGFR3DisasInstrLog(pVCpu, Sel, GCPtr) \
do { \
if (LogIsEnabled()) \
DBGFR3DisasInstrLogInternal(pVCpu, Sel, GCPtr); \
} while (0)
#else
# define DBGFR3DisasInstrLog(pVCpu, Sel, GCPtr) do { } while (0)
#endif
VMMR3DECL(int) DBGFR3MemScan(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, RTGCUINTPTR uAlign,
const void *pvNeedle, size_t cbNeedle, PDBGFADDRESS pHitAddress);
VMMR3DECL(int) DBGFR3MemRead(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void *pvBuf, size_t cbRead);
VMMR3DECL(int) DBGFR3MemReadString(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, char *pszBuf, size_t cbBuf);
VMMR3DECL(int) DBGFR3MemWrite(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void const *pvBuf, size_t cbRead);
/** @name Flags for DBGFR3PagingDumpEx, PGMR3DumpHierarchyHCEx and
* PGMR3DumpHierarchyGCEx
* @{ */
/** The CR3 from the current CPU state. */
#define DBGFPGDMP_FLAGS_CURRENT_CR3 RT_BIT_32(0)
/** The current CPU paging mode (PSE, PAE, LM, EPT, NX). */
#define DBGFPGDMP_FLAGS_CURRENT_MODE RT_BIT_32(1)
/** Whether PSE is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
* Same value as X86_CR4_PSE. */
#define DBGFPGDMP_FLAGS_PSE RT_BIT_32(4) /* */
/** Whether PAE is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
* Same value as X86_CR4_PAE. */
#define DBGFPGDMP_FLAGS_PAE RT_BIT_32(5) /* */
/** Whether LME is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
* Same value as MSR_K6_EFER_LME. */
#define DBGFPGDMP_FLAGS_LME RT_BIT_32(8)
/** Whether nested paging is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE). */
#define DBGFPGDMP_FLAGS_NP RT_BIT_32(9)
/** Whether extended nested page tables are enabled
* (!DBGFPGDMP_FLAGS_CURRENT_STATE). */
#define DBGFPGDMP_FLAGS_EPT RT_BIT_32(10)
/** Whether no-execution is enabled (!DBGFPGDMP_FLAGS_CURRENT_STATE).
* Same value as MSR_K6_EFER_NXE. */
#define DBGFPGDMP_FLAGS_NXE RT_BIT_32(11)
/** Whether to print the CR3. */
#define DBGFPGDMP_FLAGS_PRINT_CR3 RT_BIT_32(27)
/** Whether to print the header. */
#define DBGFPGDMP_FLAGS_HEADER RT_BIT_32(28)
/** Whether to dump additional page information. */
#define DBGFPGDMP_FLAGS_PAGE_INFO RT_BIT_32(29)
/** Dump the shadow tables if set.
* Cannot be used together with DBGFPGDMP_FLAGS_GUEST. */
#define DBGFPGDMP_FLAGS_SHADOW RT_BIT_32(30)
/** Dump the guest tables if set.
* Cannot be used together with DBGFPGDMP_FLAGS_SHADOW. */
#define DBGFPGDMP_FLAGS_GUEST RT_BIT_32(31)
/** Mask of valid bits. */
#define DBGFPGDMP_FLAGS_VALID_MASK UINT32_C(0xf8000f33)
/** The mask of bits controlling the paging mode. */
#define DBGFPGDMP_FLAGS_MODE_MASK UINT32_C(0x00000f32)
/** @} */
VMMDECL(int) DBGFR3PagingDumpEx(PVM pVM, VMCPUID idCpu, uint32_t fFlags, uint64_t cr3, uint64_t u64FirstAddr,
uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
/** @name DBGFR3SelQueryInfo flags.
* @{ */
/** Get the info from the guest descriptor table. */
#define DBGFSELQI_FLAGS_DT_GUEST UINT32_C(0)
/** Get the info from the shadow descriptor table.
* Only works in raw-mode. */
#define DBGFSELQI_FLAGS_DT_SHADOW UINT32_C(1)
/** If currently executing in in 64-bit mode, blow up data selectors. */
#define DBGFSELQI_FLAGS_DT_ADJ_64BIT_MODE UINT32_C(2)
/** @} */
VMMR3DECL(int) DBGFR3SelQueryInfo(PVM pVM, VMCPUID idCpu, RTSEL Sel, uint32_t fFlags, PDBGFSELINFO pSelInfo);
/**
* Register identifiers.
*/
typedef enum DBGFREG
{
/* General purpose registers: */
DBGFREG_AL = 0,
DBGFREG_AX = DBGFREG_AL,
DBGFREG_EAX = DBGFREG_AL,
DBGFREG_RAX = DBGFREG_AL,
DBGFREG_CL,
DBGFREG_CX = DBGFREG_CL,
DBGFREG_ECX = DBGFREG_CL,
DBGFREG_RCX = DBGFREG_CL,
DBGFREG_DL,
DBGFREG_DX = DBGFREG_DL,
DBGFREG_EDX = DBGFREG_DL,
DBGFREG_RDX = DBGFREG_DL,
DBGFREG_BL,
DBGFREG_BX = DBGFREG_BL,
DBGFREG_EBX = DBGFREG_BL,
DBGFREG_RBX = DBGFREG_BL,
DBGFREG_SPL,
DBGFREG_SP = DBGFREG_SPL,
DBGFREG_ESP = DBGFREG_SPL,
DBGFREG_RSP = DBGFREG_SPL,
DBGFREG_BPL,
DBGFREG_BP = DBGFREG_BPL,
DBGFREG_EBP = DBGFREG_BPL,
DBGFREG_RBP = DBGFREG_BPL,
DBGFREG_SIL,
DBGFREG_SI = DBGFREG_SIL,
DBGFREG_ESI = DBGFREG_SIL,
DBGFREG_RSI = DBGFREG_SIL,
DBGFREG_DIL,
DBGFREG_DI = DBGFREG_DIL,
DBGFREG_EDI = DBGFREG_DIL,
DBGFREG_RDI = DBGFREG_DIL,
DBGFREG_R8,
DBGFREG_R8B = DBGFREG_R8,
DBGFREG_R8W = DBGFREG_R8,
DBGFREG_R8D = DBGFREG_R8,
DBGFREG_R9,
DBGFREG_R9B = DBGFREG_R9,
DBGFREG_R9W = DBGFREG_R9,
DBGFREG_R9D = DBGFREG_R9,
DBGFREG_R10,
DBGFREG_R10B = DBGFREG_R10,
DBGFREG_R10W = DBGFREG_R10,
DBGFREG_R10D = DBGFREG_R10,
DBGFREG_R11,
DBGFREG_R11B = DBGFREG_R11,
DBGFREG_R11W = DBGFREG_R11,
DBGFREG_R11D = DBGFREG_R11,
DBGFREG_R12,
DBGFREG_R12B = DBGFREG_R12,
DBGFREG_R12W = DBGFREG_R12,
DBGFREG_R12D = DBGFREG_R12,
DBGFREG_R13,
DBGFREG_R13B = DBGFREG_R13,
DBGFREG_R13W = DBGFREG_R13,
DBGFREG_R13D = DBGFREG_R13,
DBGFREG_R14,
DBGFREG_R14B = DBGFREG_R14,
DBGFREG_R14W = DBGFREG_R14,
DBGFREG_R14D = DBGFREG_R14,
DBGFREG_R15,
DBGFREG_R15B = DBGFREG_R15,
DBGFREG_R15W = DBGFREG_R15,
DBGFREG_R15D = DBGFREG_R15,
DBGFREG_AH,
DBGFREG_CH,
DBGFREG_DH,
DBGFREG_BH,
/* Segments and other special registers: */
DBGFREG_CS,
DBGFREG_DS,
DBGFREG_ES,
DBGFREG_FS,
DBGFREG_GS,
DBGFREG_SS,
DBGFREG_CS_ATTR,
DBGFREG_DS_ATTR,
DBGFREG_ES_ATTR,
DBGFREG_FS_ATTR,
DBGFREG_GS_ATTR,
DBGFREG_SS_ATTR,
DBGFREG_CS_BASE,
DBGFREG_DS_BASE,
DBGFREG_ES_BASE,
DBGFREG_FS_BASE,
DBGFREG_GS_BASE,
DBGFREG_SS_BASE,
DBGFREG_CS_LIMIT,
DBGFREG_DS_LIMIT,
DBGFREG_ES_LIMIT,
DBGFREG_FS_LIMIT,
DBGFREG_GS_LIMIT,
DBGFREG_SS_LIMIT,
DBGFREG_IP,
DBGFREG_EIP = DBGFREG_IP,
DBGFREG_RIP = DBGFREG_IP,
DBGFREG_FLAGS,
DBGFREG_EFLAGS = DBGFREG_FLAGS,
DBGFREG_RFLAGS = DBGFREG_FLAGS,
/* FPU: */
DBGFREG_ST0,
DBGFREG_ST1,
DBGFREG_ST2,
DBGFREG_ST3,
DBGFREG_ST4,
DBGFREG_ST5,
DBGFREG_ST6,
DBGFREG_ST7,
DBGFREG_MM0,
DBGFREG_MM1,
DBGFREG_MM2,
DBGFREG_MM3,
DBGFREG_MM4,
DBGFREG_MM5,
DBGFREG_MM6,
DBGFREG_MM7,
DBGFREG_FCW,
DBGFREG_FSW,
DBGFREG_FTW,
DBGFREG_FOP,
DBGFREG_FPUIP,
DBGFREG_FPUCS,
DBGFREG_FPUDP,
DBGFREG_FPUDS,
DBGFREG_MXCSR,
DBGFREG_MXCSR_MASK,
/* SSE: */
DBGFREG_XMM0,
DBGFREG_XMM1,
DBGFREG_XMM2,
DBGFREG_XMM3,
DBGFREG_XMM4,
DBGFREG_XMM5,
DBGFREG_XMM6,
DBGFREG_XMM7,
DBGFREG_XMM8,
DBGFREG_XMM9,
DBGFREG_XMM10,
DBGFREG_XMM11,
DBGFREG_XMM12,
DBGFREG_XMM13,
DBGFREG_XMM14,
DBGFREG_XMM15,
/** @todo add XMM aliases. */
/* System registers: */
DBGFREG_GDTR,
DBGFREG_GDTR_BASE,
DBGFREG_GDTR_LIMIT,
DBGFREG_IDTR,
DBGFREG_IDTR_BASE,
DBGFREG_IDTR_LIMIT,
DBGFREG_LDTR,
DBGFREG_LDTR_ATTR,
DBGFREG_LDTR_BASE,
DBGFREG_LDTR_LIMIT,
DBGFREG_TR,
DBGFREG_TR_ATTR,
DBGFREG_TR_BASE,
DBGFREG_TR_LIMIT,
DBGFREG_CR0,
DBGFREG_CR2,
DBGFREG_CR3,
DBGFREG_CR4,
DBGFREG_CR8,
DBGFREG_DR0,
DBGFREG_DR1,
DBGFREG_DR2,
DBGFREG_DR3,
DBGFREG_DR6,
DBGFREG_DR7,
/* MSRs: */
DBGFREG_MSR_IA32_APICBASE,
DBGFREG_MSR_IA32_CR_PAT,
DBGFREG_MSR_IA32_PERF_STATUS,
DBGFREG_MSR_IA32_SYSENTER_CS,
DBGFREG_MSR_IA32_SYSENTER_EIP,
DBGFREG_MSR_IA32_SYSENTER_ESP,
DBGFREG_MSR_IA32_TSC,
DBGFREG_MSR_K6_EFER,
DBGFREG_MSR_K6_STAR,
DBGFREG_MSR_K8_CSTAR,
DBGFREG_MSR_K8_FS_BASE,
DBGFREG_MSR_K8_GS_BASE,
DBGFREG_MSR_K8_KERNEL_GS_BASE,
DBGFREG_MSR_K8_LSTAR,
DBGFREG_MSR_K8_SF_MASK,
DBGFREG_MSR_K8_TSC_AUX,
/** The end of the registers. */
DBGFREG_END,
/** The usual 32-bit type hack. */
DBGFREG_32BIT_HACK = 0x7fffffff
} DBGFREG;
VMMR3DECL(int) DBGFR3RegQueryU8( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint8_t *pu8);
VMMR3DECL(int) DBGFR3RegQueryU16( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint16_t *pu16);
VMMR3DECL(int) DBGFR3RegQueryU32( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint32_t *pu32);
VMMR3DECL(int) DBGFR3RegQueryU64( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t *pu64);
VMMR3DECL(int) DBGFR3RegQueryU128(PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint128_t *pu128);
VMMR3DECL(int) DBGFR3RegQueryLrd( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, long double *plrd);
VMMR3DECL(int) DBGFR3RegQueryXdtr( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t *pu64Base, uint16_t *pu16Limit);
VMMR3DECL(int) DBGFR3RegSetU8( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint8_t u8);
VMMR3DECL(int) DBGFR3RegSetU16( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint16_t u16);
VMMR3DECL(int) DBGFR3RegSetU32( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint32_t u32);
VMMR3DECL(int) DBGFR3RegSetU64( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint64_t u64);
VMMR3DECL(int) DBGFR3RegSetU128(PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint128_t u128);
VMMR3DECL(int) DBGFR3RegSetLrd( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, long double lrd);
/**
* Guest OS digger interface identifier.
*
* This is for use together with PDBGFR3QueryInterface and is used to
* obtain access to optional interfaces.
*/
typedef enum DBGFOSINTERFACE
{
/** The usual invalid entry. */
DBGFOSINTERFACE_INVALID = 0,
/** Process info. */
DBGFOSINTERFACE_PROCESS,
/** Thread info. */
DBGFOSINTERFACE_THREAD,
/** The end of the valid entries. */
DBGFOSINTERFACE_END,
/** The usual 32-bit type blowup. */
DBGFOSINTERFACE_32BIT_HACK = 0x7fffffff
} DBGFOSINTERFACE;
/** Pointer to a Guest OS digger interface identifier. */
typedef DBGFOSINTERFACE *PDBGFOSINTERFACE;
/** Pointer to a const Guest OS digger interface identifier. */
typedef DBGFOSINTERFACE const *PCDBGFOSINTERFACE;
/**
* Guest OS Digger Registration Record.
*
* This is used with the DBGFR3OSRegister() API.
*/
typedef struct DBGFOSREG
{
/** Magic value (DBGFOSREG_MAGIC). */
uint32_t u32Magic;
/** Flags. Reserved. */
uint32_t fFlags;
/** The size of the instance data. */
uint32_t cbData;
/** Operative System name. */
char szName[24];
/**
* Constructs the instance.
*
* @returns VBox status code.
* @param pVM Pointer to the shared VM structure.
* @param pvData Pointer to the instance data.
*/
DECLCALLBACKMEMBER(int, pfnConstruct)(PVM pVM, void *pvData);
/**
* Destroys the instance.
*
* @param pVM Pointer to the shared VM structure.
* @param pvData Pointer to the instance data.
*/
DECLCALLBACKMEMBER(void, pfnDestruct)(PVM pVM, void *pvData);
/**
* Probes the guest memory for OS finger prints.
*
* No setup or so is performed, it will be followed by a call to pfnInit
* or pfnRefresh that should take care of that.
*
* @returns true if is an OS handled by this module, otherwise false.
* @param pVM Pointer to the shared VM structure.
* @param pvData Pointer to the instance data.
*/
DECLCALLBACKMEMBER(bool, pfnProbe)(PVM pVM, void *pvData);
/**
* Initializes a fresly detected guest, loading symbols and such useful stuff.
*
* This is called after pfnProbe.
*
* @returns VBox status code.
* @param pVM Pointer to the shared VM structure.
* @param pvData Pointer to the instance data.
*/
DECLCALLBACKMEMBER(int, pfnInit)(PVM pVM, void *pvData);
/**
* Refreshes symbols and stuff following a redetection of the same OS.
*
* This is called after pfnProbe.
*
* @returns VBox status code.
* @param pVM Pointer to the shared VM structure.
* @param pvData Pointer to the instance data.
*/
DECLCALLBACKMEMBER(int, pfnRefresh)(PVM pVM, void *pvData);
/**
* Terminates an OS when a new (or none) OS has been detected,
* and before destruction.
*
* This is called after pfnProbe and if needed before pfnDestruct.
*
* @param pVM Pointer to the shared VM structure.
* @param pvData Pointer to the instance data.
*/
DECLCALLBACKMEMBER(void, pfnTerm)(PVM pVM, void *pvData);
/**
* Queries the version of the running OS.
*
* This is only called after pfnInit().
*
* @returns VBox status code.
* @param pVM Pointer to the shared VM structure.
* @param pvData Pointer to the instance data.
* @param pszVersion Where to store the version string.
* @param cchVersion The size of the version string buffer.
*/
DECLCALLBACKMEMBER(int, pfnQueryVersion)(PVM pVM, void *pvData, char *pszVersion, size_t cchVersion);
/**
* Queries the pointer to a interface.
*
* This is called after pfnProbe.
*
* @returns Pointer to the interface if available, NULL if not available.
* @param pVM Pointer to the shared VM structure.
* @param pvData Pointer to the instance data.
* @param enmIf The interface identifier.
*/
DECLCALLBACKMEMBER(void *, pfnQueryInterface)(PVM pVM, void *pvData, DBGFOSINTERFACE enmIf);
/** Trailing magic (DBGFOSREG_MAGIC). */
uint32_t u32EndMagic;
} DBGFOSREG;
/** Pointer to a Guest OS digger registration record. */
typedef DBGFOSREG *PDBGFOSREG;
/** Pointer to a const Guest OS digger registration record. */
typedef DBGFOSREG const *PCDBGFOSREG;
/** Magic value for DBGFOSREG::u32Magic and DBGFOSREG::u32EndMagic. (Hitomi Kanehara) */
#define DBGFOSREG_MAGIC 0x19830808
VMMR3DECL(int) DBGFR3OSRegister(PVM pVM, PCDBGFOSREG pReg);
VMMR3DECL(int) DBGFR3OSDeregister(PVM pVM, PCDBGFOSREG pReg);
VMMR3DECL(int) DBGFR3OSDetect(PVM pVM, char *pszName, size_t cchName);
VMMR3DECL(int) DBGFR3OSQueryNameAndVersion(PVM pVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion);
VMMR3DECL(void *) DBGFR3OSQueryInterface(PVM pVM, DBGFOSINTERFACE enmIf);
VMMR3DECL(int) DBGFR3CoreWrite(PVM pVM, VMCPUID idCpu, const char *pszDumpPath);
/** @} */
RT_C_DECLS_END
#endif