1 | /* $Id: VMMTracing.h 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxVMM - Trace point macros for the VMM.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2022 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef VMM_INCLUDED_SRC_include_VMMTracing_h
|
---|
29 | #define VMM_INCLUDED_SRC_include_VMMTracing_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 |
|
---|
35 | /*******************************************************************************
|
---|
36 | * Header Files *
|
---|
37 | *******************************************************************************/
|
---|
38 | #ifdef DOXYGEN_RUNNING
|
---|
39 | # undef VBOX_WITH_DTRACE
|
---|
40 | # undef VBOX_WITH_DTRACE_R3
|
---|
41 | # undef VBOX_WITH_DTRACE_R0
|
---|
42 | # undef VBOX_WITH_DTRACE_RC
|
---|
43 | # define DBGFTRACE_ENABLED
|
---|
44 | #endif
|
---|
45 | #include <VBox/vmm/dbgftrace.h>
|
---|
46 |
|
---|
47 |
|
---|
48 | /*******************************************************************************
|
---|
49 | * Defined Constants And Macros *
|
---|
50 | *******************************************************************************/
|
---|
51 | /** Gets the trace buffer handle from a VMCPU pointer. */
|
---|
52 | #define VMCPU_TO_HTB(a_pVCpu) ((a_pVCpu)->CTX_SUFF(pVM)->CTX_SUFF(hTraceBuf))
|
---|
53 |
|
---|
54 | /** Gets the trace buffer handle from a VMCPU pointer. */
|
---|
55 | #define VM_TO_HTB(a_pVM) ((a_pVM)->CTX_SUFF(hTraceBuf))
|
---|
56 |
|
---|
57 | /** Macro wrapper for trace points that are disabled by default. */
|
---|
58 | #define TP_COND_VMCPU(a_pVCpu, a_GrpSuff, a_TraceStmt) \
|
---|
59 | do { \
|
---|
60 | if (RT_UNLIKELY( (a_pVCpu)->fTraceGroups & VMMTPGROUP_##a_GrpSuff )) \
|
---|
61 | { \
|
---|
62 | RTTRACEBUF const hTB = (a_pVCpu)->CTX_SUFF(pVM)->CTX_SUFF(hTraceBuf); \
|
---|
63 | a_TraceStmt; \
|
---|
64 | } \
|
---|
65 | } while (0)
|
---|
66 |
|
---|
67 | /** @name VMM Trace Point Groups.
|
---|
68 | * @{ */
|
---|
69 | #define VMMTPGROUP_EM RT_BIT(0)
|
---|
70 | #define VMMTPGROUP_HM RT_BIT(1)
|
---|
71 | #define VMMTPGROUP_TM RT_BIT(2)
|
---|
72 | /** @} */
|
---|
73 |
|
---|
74 |
|
---|
75 |
|
---|
76 | /** @name Ring-3 trace points.
|
---|
77 | * @{
|
---|
78 | */
|
---|
79 | #ifdef IN_RING3
|
---|
80 | # ifdef VBOX_WITH_DTRACE_R3
|
---|
81 | # include "dtrace/VBoxVMM.h"
|
---|
82 |
|
---|
83 | # elif defined(DBGFTRACE_ENABLED)
|
---|
84 | # define VBOXVMM_EM_STATE_CHANGED(a_pVCpu, a_enmOldState, a_enmNewState, a_rc) \
|
---|
85 | TP_COND_VMCPU(a_pVCpu, EM, RTTraceBufAddMsgF(hTB, "em-state-changed %d -> %d (rc=%d)", a_enmOldState, a_enmNewState, a_rc))
|
---|
86 | # define VBOXVMM_EM_STATE_UNCHANGED(a_pVCpu, a_enmState, a_rc) \
|
---|
87 | TP_COND_VMCPU(a_pVCpu, EM, RTTraceBufAddMsgF(hTB, "em-state-unchanged %d (rc=%d)", a_enmState, a_rc))
|
---|
88 | # define VBOXVMM_EM_RAW_RUN_PRE(a_pVCpu, a_pCtx) \
|
---|
89 | TP_COND_VMCPU(a_pVCpu, EM, RTTraceBufAddMsgF(hTB, "em-raw-pre %04x:%08llx", (a_pCtx)->cs, (a_pCtx)->rip))
|
---|
90 | # define VBOXVMM_EM_RAW_RUN_RET(a_pVCpu, a_pCtx, a_rc) \
|
---|
91 | TP_COND_VMCPU(a_pVCpu, EM, RTTraceBufAddMsgF(hTB, "em-raw-ret %04x:%08llx rc=%d", (a_pCtx)->cs, (a_pCtx)->rip, (a_rc)))
|
---|
92 | # define VBOXVMM_EM_FF_HIGH(a_pVCpu, a_fGlobal, a_fLocal, a_rc) \
|
---|
93 | TP_COND_VMCPU(a_pVCpu, EM, RTTraceBufAddMsgF(hTB, "em-ff-high vm=%#x cpu=%#x rc=%d", (a_fGlobal), (a_fLocal), (a_rc)))
|
---|
94 | # define VBOXVMM_EM_FF_ALL(a_pVCpu, a_fGlobal, a_fLocal, a_rc) \
|
---|
95 | TP_COND_VMCPU(a_pVCpu, EM, RTTraceBufAddMsgF(hTB, "em-ff-all vm=%#x cpu=%#x rc=%d", (a_fGlobal), (a_fLocal), (a_rc)))
|
---|
96 | # define VBOXVMM_EM_FF_ALL_RET(a_pVCpu, a_rc) \
|
---|
97 | TP_COND_VMCPU(a_pVCpu, EM, RTTraceBufAddMsgF(hTB, "em-ff-all-ret %d", (a_rc)))
|
---|
98 | # define VBOXVMM_EM_FF_RAW(a_pVCpu, a_fGlobal, a_fLocal) \
|
---|
99 | TP_COND_VMCPU(a_pVCpu, EM, RTTraceBufAddMsgF(hTB, "em-ff-raw vm=%#x cpu=%#x", (a_fGlobal), (a_fLocal)))
|
---|
100 | # define VBOXVMM_EM_FF_RAW_RET(a_pVCpu, a_rc) \
|
---|
101 | TP_COND_VMCPU(a_pVCpu, EM, RTTraceBufAddMsgF(hTB, "em-ff-raw-ret %d", (a_rc)))
|
---|
102 |
|
---|
103 | # else
|
---|
104 | # define VBOXVMM_EM_STATE_CHANGED(a_pVCpu, a_enmOldState, a_enmNewState, a_rc) do { } while (0)
|
---|
105 | # define VBOXVMM_EM_STATE_UNCHANGED(a_pVCpu, a_enmState, a_rc) do { } while (0)
|
---|
106 | # define VBOXVMM_EM_RAW_RUN_PRE(a_pVCpu, a_pCtx) do { } while (0)
|
---|
107 | # define VBOXVMM_EM_RAW_RUN_RET(a_pVCpu, a_pCtx, a_rc) do { } while (0)
|
---|
108 | # define VBOXVMM_EM_FF_HIGH(a_pVCpu, a_fGlobal, a_fLocal, a_rc) do { } while (0)
|
---|
109 | # define VBOXVMM_EM_FF_ALL(a_pVCpu, a_fGlobal, a_fLocal, a_rc) do { } while (0)
|
---|
110 | # define VBOXVMM_EM_FF_ALL_RET(a_pVCpu, a_rc) do { } while (0)
|
---|
111 | # define VBOXVMM_EM_FF_RAW(a_pVCpu, a_fGlobal, a_fLocal) do { } while (0)
|
---|
112 | # define VBOXVMM_EM_FF_RAW_RET(a_pVCpu, a_rc) do { } while (0)
|
---|
113 |
|
---|
114 | # endif
|
---|
115 | #endif /* IN_RING3 */
|
---|
116 | /** @} */
|
---|
117 |
|
---|
118 |
|
---|
119 | /** @name Ring-0 trace points.
|
---|
120 | * @{
|
---|
121 | */
|
---|
122 | #ifdef IN_RING0
|
---|
123 | # ifdef VBOX_WITH_DTRACE_R0
|
---|
124 | # include "VBoxVMMR0-dtrace.h"
|
---|
125 |
|
---|
126 | # elif defined(DBGFTRACE_ENABLED)
|
---|
127 |
|
---|
128 | # else
|
---|
129 |
|
---|
130 | # endif
|
---|
131 | #endif /* IN_RING0 */
|
---|
132 | /** @} */
|
---|
133 |
|
---|
134 |
|
---|
135 | #endif /* !VMM_INCLUDED_SRC_include_VMMTracing_h */
|
---|
136 |
|
---|