1 | /* $Id: VBoxTpG.h 40986 2012-04-19 10:32:03Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Tracepoint Generator Structures.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | #ifndef ___VBox_VTG_h___
|
---|
29 | #define ___VBox_VTG_h___
|
---|
30 |
|
---|
31 | #include <iprt/types.h>
|
---|
32 | #include <iprt/assert.h>
|
---|
33 |
|
---|
34 | RT_C_DECLS_BEGIN
|
---|
35 |
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Probe location.
|
---|
39 | */
|
---|
40 | typedef struct VTGPROBELOC
|
---|
41 | {
|
---|
42 | uint32_t uLine : 31;
|
---|
43 | uint32_t fEnabled : 1;
|
---|
44 | uint32_t idProbe;
|
---|
45 | const char *pszFunction;
|
---|
46 | uint8_t *pbProbe;
|
---|
47 | #if ARCH_BITS == 64
|
---|
48 | uintptr_t uAlignment;
|
---|
49 | #endif
|
---|
50 | } VTGPROBELOC;
|
---|
51 | AssertCompileSizeAlignment(VTGPROBELOC, 16);
|
---|
52 | /** Pointer to a probe location. */
|
---|
53 | typedef VTGPROBELOC *PVTGPROBELOC;
|
---|
54 |
|
---|
55 | /** @def VTG_OBJ_SECT
|
---|
56 | * The name of the section containing the other probe data provided by the
|
---|
57 | * assembly / object generated by VBoxTpG. */
|
---|
58 | /** @def VTG_LOC_SECT
|
---|
59 | * The name of the section containing the VTGPROBELOC structures. This is
|
---|
60 | * filled by the probe macros, @see VTG_DECL_VTGPROBELOC. */
|
---|
61 | /** @def VTG_DECL_VTGPROBELOC
|
---|
62 | * Declares a static variable, @a a_VarName, of type VTGPROBELOC in the section
|
---|
63 | * indicated by VTG_LOC_SECT. */
|
---|
64 | #if defined(RT_OS_WINDOWS)
|
---|
65 | # define VTG_OBJ_SECT "VTGObj"
|
---|
66 | # define VTG_LOC_SECT "VTGPrLc.Data"
|
---|
67 | # ifdef _MSC_VER
|
---|
68 | # define VTG_DECL_VTGPROBELOC(a_VarName) \
|
---|
69 | __declspec(allocate(VTG_LOC_SECT)) static VTGPROBELOC a_VarName
|
---|
70 | # elif defined(__GNUC__)
|
---|
71 | # define VTG_DECL_VTGPROBELOC(a_VarName) \
|
---|
72 | static VTGPROBELOC __attribute__((section(VTG_LOC_SECT))) a_VarName
|
---|
73 | # else
|
---|
74 | # error "Unsupported Windows compiler!"
|
---|
75 | # endif
|
---|
76 |
|
---|
77 | #elif defined(RT_OS_DARWIN)
|
---|
78 | # define VTG_OBJ_SECT "__VTGObj"
|
---|
79 | # define VTG_LOC_SECT "__VTGPrLc"
|
---|
80 | # define VTG_LOC_SEG "__VTG"
|
---|
81 | # ifdef __GNUC__
|
---|
82 | # define VTG_DECL_VTGPROBELOC(a_VarName) \
|
---|
83 | static VTGPROBELOC __attribute__((section(VTG_LOC_SEG "," VTG_LOC_SECT ",regular")/*, aligned(16)*/)) a_VarName
|
---|
84 | # else
|
---|
85 | # error "Unsupported Darwin compiler!"
|
---|
86 | # endif
|
---|
87 |
|
---|
88 | #elif defined(RT_OS_OS2)
|
---|
89 | # error "OS/2 is not supported"
|
---|
90 |
|
---|
91 | #else /* Assume the rest uses ELF. */
|
---|
92 | # define VTG_OBJ_SECT ".VTGObj"
|
---|
93 | # define VTG_LOC_SECT ".VTGPrLc"
|
---|
94 | # ifdef __GNUC__
|
---|
95 | # define VTG_DECL_VTGPROBELOC(a_VarName) \
|
---|
96 | static VTGPROBELOC __attribute__((section(VTG_LOC_SECT))) a_VarName
|
---|
97 | # else
|
---|
98 | # error "Unsupported compiler!"
|
---|
99 | # endif
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | /** VTG string table offset. */
|
---|
103 | typedef uint32_t VTGSTROFF;
|
---|
104 |
|
---|
105 |
|
---|
106 | /** @name VTG type flags
|
---|
107 | * @{ */
|
---|
108 | /** Masking out the fixed size if given. */
|
---|
109 | #define VTG_TYPE_SIZE_MASK UINT32_C(0x000000ff)
|
---|
110 | /** Indicates that VTG_TYPE_SIZE_MASK can be applied, UNSIGNED or SIGNED is
|
---|
111 | * usually set as well, so may PHYS. */
|
---|
112 | #define VTG_TYPE_FIXED_SIZED RT_BIT_32(8)
|
---|
113 | /** It's a pointer type, the size is given by the context the probe fired in. */
|
---|
114 | #define VTG_TYPE_POINTER RT_BIT_32(9)
|
---|
115 | /** A context specfic pointer or address, consult VTG_TYPE_CTX_XXX. */
|
---|
116 | #define VTG_TYPE_CTX_POINTER RT_BIT_32(10)
|
---|
117 | /** The type has the same size as the host architecture. */
|
---|
118 | #define VTG_TYPE_HC_ARCH_SIZED RT_BIT_32(11)
|
---|
119 | /** The type applies to ring-3 context. */
|
---|
120 | #define VTG_TYPE_CTX_R3 RT_BIT_32(24)
|
---|
121 | /** The type applies to ring-0 context. */
|
---|
122 | #define VTG_TYPE_CTX_R0 RT_BIT_32(25)
|
---|
123 | /** The type applies to raw-mode context. */
|
---|
124 | #define VTG_TYPE_CTX_RC RT_BIT_32(26)
|
---|
125 | /** The type applies to guest context. */
|
---|
126 | #define VTG_TYPE_CTX_GST RT_BIT_32(27)
|
---|
127 | /** The type context mask. */
|
---|
128 | #define VTG_TYPE_CTX_MASK UINT32_C(0x0f000000)
|
---|
129 | /** The type is a physical address. */
|
---|
130 | #define VTG_TYPE_PHYS RT_BIT_32(29)
|
---|
131 | /** The type is unsigned. */
|
---|
132 | #define VTG_TYPE_UNSIGNED RT_BIT_32(30)
|
---|
133 | /** The type is signed. */
|
---|
134 | #define VTG_TYPE_SIGNED RT_BIT_32(31)
|
---|
135 | /** Mask of valid bits (for simple validation). */
|
---|
136 | #define VTG_TYPE_VALID_MASK UINT32_C(0xef000fff)
|
---|
137 | /** @} */
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * Checks if the VTG type flags indicates a large fixed size argument.
|
---|
141 | */
|
---|
142 | #define VTG_TYPE_IS_LARGE(a_fType) \
|
---|
143 | ( ((a_fType) & VTG_TYPE_SIZE_MASK) > 4 && ((a_fType) & VTG_TYPE_FIXED_SIZED) )
|
---|
144 |
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * VTG argument descriptor.
|
---|
148 | */
|
---|
149 | typedef struct VTGDESCARG
|
---|
150 | {
|
---|
151 | VTGSTROFF offType;
|
---|
152 | uint32_t fType;
|
---|
153 | } VTGDESCARG;
|
---|
154 | /** Pointer to an argument descriptor. */
|
---|
155 | typedef VTGDESCARG *PVTGDESCARG;
|
---|
156 |
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * VTG argument list descriptor.
|
---|
160 | */
|
---|
161 | typedef struct VTGDESCARGLIST
|
---|
162 | {
|
---|
163 | uint8_t cArgs;
|
---|
164 | uint8_t fHaveLargeArgs;
|
---|
165 | uint8_t abReserved[2];
|
---|
166 | VTGDESCARG aArgs[1];
|
---|
167 | } VTGDESCARGLIST;
|
---|
168 | /** Pointer to a VTG argument list descriptor. */
|
---|
169 | typedef VTGDESCARGLIST *PVTGDESCARGLIST;
|
---|
170 |
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * VTG probe descriptor.
|
---|
174 | */
|
---|
175 | typedef struct VTGDESCPROBE
|
---|
176 | {
|
---|
177 | VTGSTROFF offName;
|
---|
178 | uint32_t offArgList;
|
---|
179 | uint16_t idxEnabled;
|
---|
180 | uint16_t idxProvider;
|
---|
181 | /** The distance from this structure to the VTG object header. */
|
---|
182 | int32_t offObjHdr;
|
---|
183 | uint32_t u32User;
|
---|
184 | uint32_t u32User2;
|
---|
185 | } VTGDESCPROBE;
|
---|
186 | AssertCompileSize(VTGDESCPROBE, 24);
|
---|
187 | /** Pointer to a VTG probe descriptor. */
|
---|
188 | typedef VTGDESCPROBE *PVTGDESCPROBE;
|
---|
189 |
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * Code/data stability.
|
---|
193 | */
|
---|
194 | typedef enum kVTGStability
|
---|
195 | {
|
---|
196 | kVTGStability_Invalid = 0,
|
---|
197 | kVTGStability_Internal,
|
---|
198 | kVTGStability_Private,
|
---|
199 | kVTGStability_Obsolete,
|
---|
200 | kVTGStability_External,
|
---|
201 | kVTGStability_Unstable,
|
---|
202 | kVTGStability_Evolving,
|
---|
203 | kVTGStability_Stable,
|
---|
204 | kVTGStability_Standard,
|
---|
205 | kVTGStability_End
|
---|
206 | } kVTGStability;
|
---|
207 |
|
---|
208 | /**
|
---|
209 | * Data dependency.
|
---|
210 | */
|
---|
211 | typedef enum kVTGClass
|
---|
212 | {
|
---|
213 | kVTGClass_Invalid = 0,
|
---|
214 | kVTGClass_Unknown,
|
---|
215 | kVTGClass_Cpu,
|
---|
216 | kVTGClass_Platform,
|
---|
217 | kVTGClass_Group,
|
---|
218 | kVTGClass_Isa,
|
---|
219 | kVTGClass_Common,
|
---|
220 | kVTGClass_End
|
---|
221 | } kVTGClass;
|
---|
222 |
|
---|
223 |
|
---|
224 | /**
|
---|
225 | * VTG attributes.
|
---|
226 | */
|
---|
227 | typedef struct VTGDESCATTR
|
---|
228 | {
|
---|
229 | uint8_t u8Code;
|
---|
230 | uint8_t u8Data;
|
---|
231 | uint8_t u8DataDep;
|
---|
232 | } VTGDESCATTR;
|
---|
233 | AssertCompileSize(VTGDESCATTR, 3);
|
---|
234 | /** Pointer to a const VTG attribute. */
|
---|
235 | typedef VTGDESCATTR const *PCVTGDESCATTR;
|
---|
236 |
|
---|
237 |
|
---|
238 | /**
|
---|
239 | * VTG provider descriptor.
|
---|
240 | */
|
---|
241 | typedef struct VTGDESCPROVIDER
|
---|
242 | {
|
---|
243 | VTGSTROFF offName;
|
---|
244 | uint16_t iFirstProbe;
|
---|
245 | uint16_t cProbes;
|
---|
246 | VTGDESCATTR AttrSelf;
|
---|
247 | VTGDESCATTR AttrModules;
|
---|
248 | VTGDESCATTR AttrFunctions;
|
---|
249 | VTGDESCATTR AttrNames;
|
---|
250 | VTGDESCATTR AttrArguments;
|
---|
251 | uint8_t bReserved;
|
---|
252 | } VTGDESCPROVIDER;
|
---|
253 | /** Pointer to a VTG provider descriptor. */
|
---|
254 | typedef VTGDESCPROVIDER *PVTGDESCPROVIDER;
|
---|
255 |
|
---|
256 |
|
---|
257 | /**
|
---|
258 | * VTG data object header.
|
---|
259 | */
|
---|
260 | typedef struct VTGOBJHDR
|
---|
261 | {
|
---|
262 | char szMagic[24];
|
---|
263 | uint32_t cBits;
|
---|
264 | uint32_t u32Reserved0;
|
---|
265 | PVTGDESCPROVIDER paProviders;
|
---|
266 | uintptr_t cbProviders;
|
---|
267 | PVTGDESCPROBE paProbes;
|
---|
268 | uintptr_t cbProbes;
|
---|
269 | bool *pafProbeEnabled;
|
---|
270 | uintptr_t cbProbeEnabled;
|
---|
271 | char *pachStrTab;
|
---|
272 | uintptr_t cbStrTab;
|
---|
273 | PVTGDESCARGLIST paArgLists;
|
---|
274 | uintptr_t cbArgLists;
|
---|
275 | PVTGPROBELOC paProbLocs;
|
---|
276 | PVTGPROBELOC paProbLocsEnd;
|
---|
277 | uintptr_t auReserved1[4];
|
---|
278 | } VTGOBJHDR;
|
---|
279 | /** Pointer to a VTG data object header. */
|
---|
280 | typedef VTGOBJHDR *PVTGOBJHDR;
|
---|
281 |
|
---|
282 | /** The current VTGOBJHDR::szMagic value. */
|
---|
283 | #define VTGOBJHDR_MAGIC "VTG Object Header v1.4\0"
|
---|
284 |
|
---|
285 | /** The name of the VTG data object header symbol in the object file. */
|
---|
286 | extern VTGOBJHDR g_VTGObjHeader;
|
---|
287 |
|
---|
288 | RT_C_DECLS_END
|
---|
289 |
|
---|
290 | #endif
|
---|
291 |
|
---|