1 | /* $Id: VBoxTpG.h 41130 2012-05-03 11:35:25Z 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 | * 32-bit probe location.
|
---|
38 | */
|
---|
39 | typedef struct VTGPROBELOC32
|
---|
40 | {
|
---|
41 | uint32_t uLine : 31;
|
---|
42 | uint32_t fEnabled : 1;
|
---|
43 | uint32_t idProbe;
|
---|
44 | uint32_t pszFunction;
|
---|
45 | uint32_t pProbe;
|
---|
46 | } VTGPROBELOC32;
|
---|
47 | AssertCompileSize(VTGPROBELOC32, 16);
|
---|
48 | /** Pointer to a 32-bit probe location. */
|
---|
49 | typedef VTGPROBELOC32 *PVTGPROBELOC32;
|
---|
50 | /** Pointer to a const 32-bit probe location. */
|
---|
51 | typedef VTGPROBELOC32 const *PCVTGPROBELOC32;
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * 64-bit probe location.
|
---|
55 | */
|
---|
56 | typedef struct VTGPROBELOC64
|
---|
57 | {
|
---|
58 | uint32_t uLine : 31;
|
---|
59 | uint32_t fEnabled : 1;
|
---|
60 | uint32_t idProbe;
|
---|
61 | uint64_t pszFunction;
|
---|
62 | uint64_t pProbe;
|
---|
63 | uint64_t uAlignment;
|
---|
64 | } VTGPROBELOC64;
|
---|
65 | AssertCompileSize(VTGPROBELOC64, 32);
|
---|
66 | /** Pointer to a 64-bit probe location. */
|
---|
67 | typedef VTGPROBELOC64 *PVTGPROBELOC64;
|
---|
68 | /** Pointer to a const 64-bit probe location. */
|
---|
69 | typedef VTGPROBELOC64 const *PCVTGPROBELOC64;
|
---|
70 |
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * Probe location.
|
---|
74 | */
|
---|
75 | typedef struct VTGPROBELOC
|
---|
76 | {
|
---|
77 | uint32_t uLine : 31;
|
---|
78 | uint32_t fEnabled : 1;
|
---|
79 | uint32_t idProbe;
|
---|
80 | const char *pszFunction;
|
---|
81 | struct VTGDESCPROBE *pProbe;
|
---|
82 | #if ARCH_BITS == 64
|
---|
83 | uintptr_t uAlignment;
|
---|
84 | #endif
|
---|
85 | } VTGPROBELOC;
|
---|
86 | AssertCompileSizeAlignment(VTGPROBELOC, 16);
|
---|
87 | /** Pointer to a probe location. */
|
---|
88 | typedef VTGPROBELOC *PVTGPROBELOC;
|
---|
89 | /** Pointer to a const probe location. */
|
---|
90 | typedef VTGPROBELOC const *PCVTGPROBELOC;
|
---|
91 |
|
---|
92 | /** @def VTG_OBJ_SECT
|
---|
93 | * The name of the section containing the other probe data provided by the
|
---|
94 | * assembly / object generated by VBoxTpG. */
|
---|
95 | /** @def VTG_LOC_SECT
|
---|
96 | * The name of the section containing the VTGPROBELOC structures. This is
|
---|
97 | * filled by the probe macros, @see VTG_DECL_VTGPROBELOC. */
|
---|
98 | /** @def VTG_DECL_VTGPROBELOC
|
---|
99 | * Declares a static variable, @a a_VarName, of type VTGPROBELOC in the section
|
---|
100 | * indicated by VTG_LOC_SECT. */
|
---|
101 | #if defined(RT_OS_WINDOWS)
|
---|
102 | # define VTG_OBJ_SECT "VTGObj"
|
---|
103 | # define VTG_LOC_SECT "VTGPrLc.Data"
|
---|
104 | # ifdef _MSC_VER
|
---|
105 | # define VTG_DECL_VTGPROBELOC(a_VarName) \
|
---|
106 | __declspec(allocate(VTG_LOC_SECT)) static VTGPROBELOC a_VarName
|
---|
107 | # elif defined(__GNUC__)
|
---|
108 | # define VTG_DECL_VTGPROBELOC(a_VarName) \
|
---|
109 | static VTGPROBELOC __attribute__((section(VTG_LOC_SECT))) a_VarName
|
---|
110 | # else
|
---|
111 | # error "Unsupported Windows compiler!"
|
---|
112 | # endif
|
---|
113 |
|
---|
114 | #elif defined(RT_OS_DARWIN)
|
---|
115 | # define VTG_OBJ_SECT "__VTGObj"
|
---|
116 | # define VTG_LOC_SECT "__VTGPrLc"
|
---|
117 | # define VTG_LOC_SEG "__VTG"
|
---|
118 | # ifdef __GNUC__
|
---|
119 | # define VTG_DECL_VTGPROBELOC(a_VarName) \
|
---|
120 | static VTGPROBELOC __attribute__((section(VTG_LOC_SEG "," VTG_LOC_SECT ",regular")/*, aligned(16)*/)) a_VarName
|
---|
121 | # else
|
---|
122 | # error "Unsupported Darwin compiler!"
|
---|
123 | # endif
|
---|
124 |
|
---|
125 | #elif defined(RT_OS_OS2)
|
---|
126 | # error "OS/2 is not supported"
|
---|
127 |
|
---|
128 | #else /* Assume the rest uses ELF. */
|
---|
129 | # define VTG_OBJ_SECT ".VTGObj"
|
---|
130 | # define VTG_LOC_SECT ".VTGPrLc"
|
---|
131 | # ifdef __GNUC__
|
---|
132 | # define VTG_DECL_VTGPROBELOC(a_VarName) \
|
---|
133 | static VTGPROBELOC __attribute__((section(VTG_LOC_SECT))) a_VarName
|
---|
134 | # else
|
---|
135 | # error "Unsupported compiler!"
|
---|
136 | # endif
|
---|
137 | #endif
|
---|
138 |
|
---|
139 | /** VTG string table offset. */
|
---|
140 | typedef uint32_t VTGSTROFF;
|
---|
141 |
|
---|
142 |
|
---|
143 | /** @name VTG type flags
|
---|
144 | * @{ */
|
---|
145 | /** Masking out the fixed size if given. */
|
---|
146 | #define VTG_TYPE_SIZE_MASK UINT32_C(0x000000ff)
|
---|
147 | /** Indicates that VTG_TYPE_SIZE_MASK can be applied, UNSIGNED or SIGNED is
|
---|
148 | * usually set as well, so may PHYS. */
|
---|
149 | #define VTG_TYPE_FIXED_SIZED RT_BIT_32(8)
|
---|
150 | /** It's a pointer type, the size is given by the context the probe fired in. */
|
---|
151 | #define VTG_TYPE_POINTER RT_BIT_32(9)
|
---|
152 | /** A context specfic pointer or address, consult VTG_TYPE_CTX_XXX. */
|
---|
153 | #define VTG_TYPE_CTX_POINTER RT_BIT_32(10)
|
---|
154 | /** The type has the same size as the host architecture. */
|
---|
155 | #define VTG_TYPE_HC_ARCH_SIZED RT_BIT_32(11)
|
---|
156 | /** The type applies to ring-3 context. */
|
---|
157 | #define VTG_TYPE_CTX_R3 RT_BIT_32(24)
|
---|
158 | /** The type applies to ring-0 context. */
|
---|
159 | #define VTG_TYPE_CTX_R0 RT_BIT_32(25)
|
---|
160 | /** The type applies to raw-mode context. */
|
---|
161 | #define VTG_TYPE_CTX_RC RT_BIT_32(26)
|
---|
162 | /** The type applies to guest context. */
|
---|
163 | #define VTG_TYPE_CTX_GST RT_BIT_32(27)
|
---|
164 | /** The type context mask. */
|
---|
165 | #define VTG_TYPE_CTX_MASK UINT32_C(0x0f000000)
|
---|
166 | /** The type is a physical address. */
|
---|
167 | #define VTG_TYPE_PHYS RT_BIT_32(29)
|
---|
168 | /** The type is unsigned. */
|
---|
169 | #define VTG_TYPE_UNSIGNED RT_BIT_32(30)
|
---|
170 | /** The type is signed. */
|
---|
171 | #define VTG_TYPE_SIGNED RT_BIT_32(31)
|
---|
172 | /** Mask of valid bits (for simple validation). */
|
---|
173 | #define VTG_TYPE_VALID_MASK UINT32_C(0xef000fff)
|
---|
174 | /** @} */
|
---|
175 |
|
---|
176 | /**
|
---|
177 | * Checks if the VTG type flags indicates a large fixed size argument.
|
---|
178 | */
|
---|
179 | #define VTG_TYPE_IS_LARGE(a_fType) \
|
---|
180 | ( ((a_fType) & VTG_TYPE_SIZE_MASK) > 4 && ((a_fType) & VTG_TYPE_FIXED_SIZED) )
|
---|
181 |
|
---|
182 |
|
---|
183 | /**
|
---|
184 | * VTG argument descriptor.
|
---|
185 | */
|
---|
186 | typedef struct VTGDESCARG
|
---|
187 | {
|
---|
188 | VTGSTROFF offType;
|
---|
189 | uint32_t fType;
|
---|
190 | } VTGDESCARG;
|
---|
191 | /** Pointer to an argument descriptor. */
|
---|
192 | typedef VTGDESCARG *PVTGDESCARG;
|
---|
193 | /** Pointer to a const argument descriptor. */
|
---|
194 | typedef VTGDESCARG const *PCVTGDESCARG;
|
---|
195 |
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * VTG argument list descriptor.
|
---|
199 | */
|
---|
200 | typedef struct VTGDESCARGLIST
|
---|
201 | {
|
---|
202 | uint8_t cArgs;
|
---|
203 | uint8_t fHaveLargeArgs;
|
---|
204 | uint8_t abReserved[2];
|
---|
205 | VTGDESCARG aArgs[1];
|
---|
206 | } VTGDESCARGLIST;
|
---|
207 | /** Pointer to a VTG argument list descriptor. */
|
---|
208 | typedef VTGDESCARGLIST *PVTGDESCARGLIST;
|
---|
209 | /** Pointer to a const VTG argument list descriptor. */
|
---|
210 | typedef VTGDESCARGLIST const *PCVTGDESCARGLIST;
|
---|
211 |
|
---|
212 |
|
---|
213 | /**
|
---|
214 | * VTG probe descriptor.
|
---|
215 | */
|
---|
216 | typedef struct VTGDESCPROBE
|
---|
217 | {
|
---|
218 | VTGSTROFF offName;
|
---|
219 | uint32_t offArgList;
|
---|
220 | uint16_t idxEnabled;
|
---|
221 | uint16_t idxProvider;
|
---|
222 | /** The distance from this structure to the VTG object header. */
|
---|
223 | int32_t offObjHdr;
|
---|
224 | } VTGDESCPROBE;
|
---|
225 | AssertCompileSize(VTGDESCPROBE, 16);
|
---|
226 | /** Pointer to a VTG probe descriptor. */
|
---|
227 | typedef VTGDESCPROBE *PVTGDESCPROBE;
|
---|
228 | /** Pointer to a const VTG probe descriptor. */
|
---|
229 | typedef VTGDESCPROBE const *PCVTGDESCPROBE;
|
---|
230 |
|
---|
231 |
|
---|
232 | /**
|
---|
233 | * Code/data stability.
|
---|
234 | */
|
---|
235 | typedef enum kVTGStability
|
---|
236 | {
|
---|
237 | kVTGStability_Invalid = 0,
|
---|
238 | kVTGStability_Internal,
|
---|
239 | kVTGStability_Private,
|
---|
240 | kVTGStability_Obsolete,
|
---|
241 | kVTGStability_External,
|
---|
242 | kVTGStability_Unstable,
|
---|
243 | kVTGStability_Evolving,
|
---|
244 | kVTGStability_Stable,
|
---|
245 | kVTGStability_Standard,
|
---|
246 | kVTGStability_End
|
---|
247 | } kVTGStability;
|
---|
248 |
|
---|
249 | /**
|
---|
250 | * Data dependency.
|
---|
251 | */
|
---|
252 | typedef enum kVTGClass
|
---|
253 | {
|
---|
254 | kVTGClass_Invalid = 0,
|
---|
255 | kVTGClass_Unknown,
|
---|
256 | kVTGClass_Cpu,
|
---|
257 | kVTGClass_Platform,
|
---|
258 | kVTGClass_Group,
|
---|
259 | kVTGClass_Isa,
|
---|
260 | kVTGClass_Common,
|
---|
261 | kVTGClass_End
|
---|
262 | } kVTGClass;
|
---|
263 |
|
---|
264 |
|
---|
265 | /**
|
---|
266 | * VTG attributes.
|
---|
267 | */
|
---|
268 | typedef struct VTGDESCATTR
|
---|
269 | {
|
---|
270 | uint8_t u8Code;
|
---|
271 | uint8_t u8Data;
|
---|
272 | uint8_t u8DataDep;
|
---|
273 | } VTGDESCATTR;
|
---|
274 | AssertCompileSize(VTGDESCATTR, 3);
|
---|
275 | /** Pointer to a const VTG attribute. */
|
---|
276 | typedef VTGDESCATTR const *PCVTGDESCATTR;
|
---|
277 |
|
---|
278 |
|
---|
279 | /**
|
---|
280 | * VTG provider descriptor.
|
---|
281 | */
|
---|
282 | typedef struct VTGDESCPROVIDER
|
---|
283 | {
|
---|
284 | VTGSTROFF offName;
|
---|
285 | uint16_t iFirstProbe;
|
---|
286 | uint16_t cProbes;
|
---|
287 | VTGDESCATTR AttrSelf;
|
---|
288 | VTGDESCATTR AttrModules;
|
---|
289 | VTGDESCATTR AttrFunctions;
|
---|
290 | VTGDESCATTR AttrNames;
|
---|
291 | VTGDESCATTR AttrArguments;
|
---|
292 | uint8_t bReserved;
|
---|
293 | } VTGDESCPROVIDER;
|
---|
294 | /** Pointer to a VTG provider descriptor. */
|
---|
295 | typedef VTGDESCPROVIDER *PVTGDESCPROVIDER;
|
---|
296 | /** Pointer to a const VTG provider descriptor. */
|
---|
297 | typedef VTGDESCPROVIDER const *PCVTGDESCPROVIDER;
|
---|
298 |
|
---|
299 |
|
---|
300 | /**
|
---|
301 | * VTG data object header.
|
---|
302 | */
|
---|
303 | typedef struct VTGOBJHDR
|
---|
304 | {
|
---|
305 | /** Magic value (VTGOBJHDR_MAGIC). */
|
---|
306 | char szMagic[24];
|
---|
307 | /** The bitness of the structures.
|
---|
308 | * This only affects the probe location pointers and structures. */
|
---|
309 | uint32_t cBits;
|
---|
310 | /** The size of the VTG object. This excludes the probe locations. */
|
---|
311 | uint32_t cbObj;
|
---|
312 |
|
---|
313 | /** @name Area Descriptors
|
---|
314 | * @remarks The offsets are relative to the header. The members are
|
---|
315 | * ordered by ascending offset (maybe with the exception of the
|
---|
316 | * probe locations). No overlaps, though there might be zero
|
---|
317 | * filled gaps between them due to alignment.
|
---|
318 | * @{ */
|
---|
319 | /* 32: */
|
---|
320 | /** Offset of the string table (char) relative to this header. */
|
---|
321 | uint32_t offStrTab;
|
---|
322 | /** The size of the string table, in bytes. */
|
---|
323 | uint32_t cbStrTab;
|
---|
324 | /** Offset of the argument lists (VTGDESCARGLIST - variable size) relative
|
---|
325 | * to this header. */
|
---|
326 | uint32_t offArgLists;
|
---|
327 | /** The size of the argument lists, in bytes. */
|
---|
328 | uint32_t cbArgLists;
|
---|
329 | /* 48: */
|
---|
330 | /** Offset of the probe array (VTGDESCPROBE) relative to this header. */
|
---|
331 | uint32_t offProbes;
|
---|
332 | /** The size of the probe array, in bytes. */
|
---|
333 | uint32_t cbProbes;
|
---|
334 | /** Offset of the provider array (VTGDESCPROVIDER) relative to this
|
---|
335 | * header. */
|
---|
336 | uint32_t offProviders;
|
---|
337 | /** The size of the provider array, in bytes. */
|
---|
338 | uint32_t cbProviders;
|
---|
339 | /* 64: */
|
---|
340 | /** Offset of the probe-enabled array (uint32_t) relative to this
|
---|
341 | * header. */
|
---|
342 | uint32_t offProbeEnabled;
|
---|
343 | /** The size of the probe-enabled array, in bytes. */
|
---|
344 | uint32_t cbProbeEnabled;
|
---|
345 | /** Offset of the probe location array (VTGPROBELOC) relative to this
|
---|
346 | * header.
|
---|
347 | * @remarks This is filled in by the first VTG user using uProbeLocs. */
|
---|
348 | int32_t offProbeLocs;
|
---|
349 | /** The size of the probe location array, in bytes.
|
---|
350 | * @remarks This is filled in by the first VTG user using uProbeLocs. */
|
---|
351 | uint32_t cbProbeLocs;
|
---|
352 | /** @} */
|
---|
353 | /* 80: */
|
---|
354 | /**
|
---|
355 | * The probe location array is generated by C code and lives in a
|
---|
356 | * different section/subsection/segment than the rest of the data.
|
---|
357 | *
|
---|
358 | * The assembler cannot generate offsets across sections for most (if not
|
---|
359 | * all) object formats, so we have to store pointers here. The first user
|
---|
360 | * of the data will convert these two members into offset and size and fill
|
---|
361 | * in the offProbeLocs and cbProbeLocs members above.
|
---|
362 | *
|
---|
363 | * @remarks Converting these members to offset+size and reusing the members
|
---|
364 | * to store the converted values isn't possible because of
|
---|
365 | * raw-mode context modules having relocations associated with the
|
---|
366 | * fields.
|
---|
367 | */
|
---|
368 | union
|
---|
369 | {
|
---|
370 | PVTGPROBELOC p;
|
---|
371 | uintptr_t uPtr;
|
---|
372 | uint32_t u32;
|
---|
373 | uint64_t u64;
|
---|
374 | }
|
---|
375 | /** Pointer to the probe location array. */
|
---|
376 | uProbeLocs,
|
---|
377 | /** Pointer to the end of the probe location array. */
|
---|
378 | uProbeLocsEnd;
|
---|
379 | /** UUID for making sharing ring-0 structures for the same ring-3
|
---|
380 | * modules easier. */
|
---|
381 | RTUUID Uuid;
|
---|
382 | /** Reserved / alignment. */
|
---|
383 | uint32_t au32Reserved1[4];
|
---|
384 | } VTGOBJHDR;
|
---|
385 | AssertCompileSize(VTGOBJHDR, 128);
|
---|
386 | AssertCompileMemberAlignment(VTGOBJHDR, uProbeLocs, 8);
|
---|
387 | AssertCompileMemberAlignment(VTGOBJHDR, uProbeLocsEnd, 8);
|
---|
388 | /** Pointer to a VTG data object header. */
|
---|
389 | typedef VTGOBJHDR *PVTGOBJHDR;
|
---|
390 | /** Pointer to a const VTG data object header. */
|
---|
391 | typedef VTGOBJHDR const *PCVTGOBJHDR;
|
---|
392 |
|
---|
393 | /** The current VTGOBJHDR::szMagic value. */
|
---|
394 | #define VTGOBJHDR_MAGIC "VTG Object Header v1.5\0"
|
---|
395 |
|
---|
396 | /** The name of the VTG data object header symbol in the object file. */
|
---|
397 | extern VTGOBJHDR g_VTGObjHeader;
|
---|
398 |
|
---|
399 | RT_C_DECLS_END
|
---|
400 |
|
---|
401 | #endif
|
---|
402 |
|
---|