VMMTracing.h revision 1f1218115ed7be1a29be1143ef6d8736532af2cc
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync/* $Id$ */
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync/** @file
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync * VBoxVMM - Trace point macros for the VMM.
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync */
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync/*
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync * Copyright (C) 2012 Oracle Corporation
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync *
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync * available from http://www.virtualbox.org. This file is free software;
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync * you can redistribute it and/or modify it under the terms of the GNU
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync * General Public License (GPL) as published by the Free Software
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync */
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync#ifndef ___VMMTracing_h___
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync#define ___VMMTracing_h___
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync/*******************************************************************************
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync* Header Files *
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync*******************************************************************************/
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync#ifdef DOXYGEN_RUNNING
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# undef VBOX_WITH_DTRACE
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# undef VBOX_WITH_DTRACE_R3
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# undef VBOX_WITH_DTRACE_R0
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# undef VBOX_WITH_DTRACE_RC
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# define DBGFTRACE_ENABLED
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync#endif
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync#include <VBox/vmm/dbgftrace.h>
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync/*******************************************************************************
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync* Defined Constants And Macros *
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync*******************************************************************************/
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync/** Gets the trace buffer handle from a VMCPU pointer. */
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync#define VMCPU_TO_HTB(a_pVCpu) ((a_pVCpu)->CTX_SUFF(pVM)->CTX_SUFF(hTraceBuf))
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync/** Gets the trace buffer handle from a VMCPU pointer. */
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync#define VM_TO_HTB(a_pVM) ((a_pVM)->CTX_SUFF(hTraceBuf))
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync/** @name Ring-3 trace points.
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync * @{
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync */
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync#ifdef IN_RING3
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# ifdef VBOX_WITH_DTRACE_R3
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# include "VBoxVMM-dtrace.h"
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# elif defined(DBGFTRACE_ENABLED)
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# error
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_STATE_CHANGED(a_pVCpu, a_enmOldState, a_enmNewState, a_rc) \
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync RTTraceBufAddMsgF(VMCPU_TO_HTB(a_pVCpu), "em-state-changed %d -> %d (rc=%d)", a_enmOldState, a_enmNewState, a_rc)
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_STATE_UNCHANGED(a_pVCpu, a_enmState, a_rc) \
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync RTTraceBufAddMsgF(VMCPU_TO_HTB(a_pVCpu), "em-state-unchanged %d (rc=%d)", a_enmState, a_rc)
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_RAW_RUN_PRE(a_pVCpu, a_pCtx) \
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync RTTraceBufAddMsgF(VMCPU_TO_HTB(a_pVCpu), "em-raw-pre %04x:%08llx", (a_pCtx)->cs, (a_pCtx)->rip)
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_RAW_RUN_RET(a_pVCpu, a_pCtx, a_rc) \
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync RTTraceBufAddMsgF(VMCPU_TO_HTB(a_pVCpu), "em-raw-ret %04x:%08llx rc=%d", (a_pCtx)->cs, (a_pCtx)->rip, (a_rc))
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_FF_HIGH(a_pVCpu, a_fGlobal, a_fLocal, a_rc) \
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync RTTraceBufAddMsgF(VMCPU_TO_HTB(a_pVCpu), "em-ff-high vm=%#x cpu=%#x rc=%d", (a_fGlobal), (a_fLocal), (a_rc))
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_FF_ALL(a_pVCpu, a_fGlobal, a_fLocal, a_rc) \
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync RTTraceBufAddMsgF(VMCPU_TO_HTB(a_pVCpu), "em-ff-all vm=%#x cpu=%#x rc=%d", (a_fGlobal), (a_fLocal), (a_rc))
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_FF_ALL_RET(a_pVCpu, a_rc) \
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync RTTraceBufAddMsgF(VMCPU_TO_HTB(a_pVCpu), "em-ff-all-ret %d", (a_rc))
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_FF_RAW(a_pVCpu, a_fGlobal, a_fLocal) \
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync RTTraceBufAddMsgF(VMCPU_TO_HTB(a_pVCpu), "em-ff-raw vm=%#x cpu=%#x", (a_fGlobal), (a_fLocal))
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_FF_RAW_RET(a_pVCpu, a_rc) \
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync RTTraceBufAddMsgF(VMCPU_TO_HTB(a_pVCpu), "em-ff-raw-ret %d", (a_rc))
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# else
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_STATE_CHANGED(a_pVCpu, a_enmOldState, a_enmNewState, a_rc) do { } while (0)
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_STATE_UNCHANGED(a_pVCpu, a_enmState, a_rc) do { } while (0)
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_RAW_RUN_PRE(a_pVCpu, a_pCtx) do { } while (0)
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_RAW_RUN_RET(a_pVCpu, a_pCtx, a_rc) do { } while (0)
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_FF_HIGH(a_pVCpu, a_fGlobal, a_fLocal, a_rc) do { } while (0)
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_FF_ALL(a_pVCpu, a_fGlobal, a_fLocal, a_rc) do { } while (0)
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_FF_ALL_RET(a_pVCpu, a_rc) do { } while (0)
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_FF_RAW(a_pVCpu, a_fGlobal, a_fLocal) do { } while (0)
1f1218115ed7be1a29be1143ef6d8736532af2ccvboxsync# define VBOXVMM_EM_FF_RAW_RET(a_pVCpu, a_rc) do { } while (0)
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# endif
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync#endif /* IN_RING3 */
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync/** @name Ring-0 trace points.
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync * @{
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync */
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync#ifdef IN_RING0
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# ifdef VBOX_WITH_DTRACE_R0
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# include "VBoxVMMR0-dtrace.h"
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# elif defined(DBGFTRACE_ENABLED)
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# else
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync# endif
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync#endif /* IN_RING0*/
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync/** @} */
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync/** @} */
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync#endif
e132802aac955bd3d8476d42e98c67e323bc29c8vboxsync