VirtualBox

source: vbox/trunk/include/VBox/VBoxTpG.h@ 44510

Last change on this file since 44510 was 44424, checked in by vboxsync, 12 years ago

VBoxTpG.h: OS/2 cheats.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.9 KB
Line 
1/* $Id: VBoxTpG.h 44424 2013-01-28 13:54:47Z 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
34RT_C_DECLS_BEGIN
35
36/**
37 * 32-bit probe location.
38 */
39typedef 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;
47AssertCompileSize(VTGPROBELOC32, 16);
48/** Pointer to a 32-bit probe location. */
49typedef VTGPROBELOC32 *PVTGPROBELOC32;
50/** Pointer to a const 32-bit probe location. */
51typedef VTGPROBELOC32 const *PCVTGPROBELOC32;
52
53/**
54 * 64-bit probe location.
55 */
56typedef 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;
65AssertCompileSize(VTGPROBELOC64, 32);
66/** Pointer to a 64-bit probe location. */
67typedef VTGPROBELOC64 *PVTGPROBELOC64;
68/** Pointer to a const 64-bit probe location. */
69typedef VTGPROBELOC64 const *PCVTGPROBELOC64;
70
71
72/**
73 * Probe location.
74 */
75typedef 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;
86AssertCompileSizeAlignment(VTGPROBELOC, 16);
87/** Pointer to a probe location. */
88typedef VTGPROBELOC *PVTGPROBELOC;
89/** Pointer to a const probe location. */
90typedef 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) /** @todo This doesn't actually work, but it makes the code compile. */
126# define VTG_OBJ_SECT "__DATA"
127# define VTG_LOC_SECT "__VTGPrLc"
128# define VTG_LOC_SET "__VTGPrLcSet"
129# ifdef __GNUC__
130# define VTG_DECL_VTGPROBELOC(a_VarName) \
131 static VTGPROBELOC a_VarName; \
132 __asm__ (".stabs \"__VTGPrLcSet\", 23, 0, 0, _" #a_VarName );
133
134# else
135# error "Unsupported Darwin compiler!"
136# endif
137
138#else /* Assume the rest uses ELF. */
139# define VTG_OBJ_SECT ".VTGObj"
140# define VTG_LOC_SECT ".VTGPrLc"
141# ifdef __GNUC__
142# define VTG_DECL_VTGPROBELOC(a_VarName) \
143 static VTGPROBELOC __attribute__((section(VTG_LOC_SECT))) a_VarName
144# else
145# error "Unsupported compiler!"
146# endif
147#endif
148
149/** VTG string table offset. */
150typedef uint32_t VTGSTROFF;
151
152
153/** @name VTG type flags
154 * @{ */
155/** Masking out the fixed size if given. */
156#define VTG_TYPE_SIZE_MASK UINT32_C(0x000000ff)
157/** Indicates that VTG_TYPE_SIZE_MASK can be applied, UNSIGNED or SIGNED is
158 * usually set as well, so may PHYS. */
159#define VTG_TYPE_FIXED_SIZED RT_BIT_32(8)
160/** It's a pointer type, the size is given by the context the probe fired in. */
161#define VTG_TYPE_POINTER RT_BIT_32(9)
162/** A context specfic pointer or address, consult VTG_TYPE_CTX_XXX. */
163#define VTG_TYPE_CTX_POINTER RT_BIT_32(10)
164/** The type has the same size as the host architecture. */
165#define VTG_TYPE_HC_ARCH_SIZED RT_BIT_32(11)
166/** The type applies to ring-3 context. */
167#define VTG_TYPE_CTX_R3 RT_BIT_32(24)
168/** The type applies to ring-0 context. */
169#define VTG_TYPE_CTX_R0 RT_BIT_32(25)
170/** The type applies to raw-mode context. */
171#define VTG_TYPE_CTX_RC RT_BIT_32(26)
172/** The type applies to guest context. */
173#define VTG_TYPE_CTX_GST RT_BIT_32(27)
174/** The type context mask. */
175#define VTG_TYPE_CTX_MASK UINT32_C(0x0f000000)
176/** The type is automatically converted to a ring-0 pointer. */
177#define VTG_TYPE_AUTO_CONV_PTR RT_BIT_32(28)
178/** The type is a physical address. */
179#define VTG_TYPE_PHYS RT_BIT_32(29)
180/** The type is unsigned. */
181#define VTG_TYPE_UNSIGNED RT_BIT_32(30)
182/** The type is signed. */
183#define VTG_TYPE_SIGNED RT_BIT_32(31)
184/** Mask of valid bits (for simple validation). */
185#define VTG_TYPE_VALID_MASK UINT32_C(0xff000fff)
186/** @} */
187
188/**
189 * Checks if the VTG type flags indicates a large fixed size argument.
190 */
191#define VTG_TYPE_IS_LARGE(a_fType) \
192 ( ((a_fType) & VTG_TYPE_SIZE_MASK) > 4 && ((a_fType) & VTG_TYPE_FIXED_SIZED) )
193
194
195/**
196 * VTG argument descriptor.
197 */
198typedef struct VTGDESCARG
199{
200 VTGSTROFF offType;
201 uint32_t fType;
202} VTGDESCARG;
203/** Pointer to an argument descriptor. */
204typedef VTGDESCARG *PVTGDESCARG;
205/** Pointer to a const argument descriptor. */
206typedef VTGDESCARG const *PCVTGDESCARG;
207
208
209/**
210 * VTG argument list descriptor.
211 */
212typedef struct VTGDESCARGLIST
213{
214 uint8_t cArgs;
215 uint8_t fHaveLargeArgs;
216 uint8_t abReserved[2];
217 VTGDESCARG aArgs[1];
218} VTGDESCARGLIST;
219/** Pointer to a VTG argument list descriptor. */
220typedef VTGDESCARGLIST *PVTGDESCARGLIST;
221/** Pointer to a const VTG argument list descriptor. */
222typedef VTGDESCARGLIST const *PCVTGDESCARGLIST;
223
224
225/**
226 * VTG probe descriptor.
227 */
228typedef struct VTGDESCPROBE
229{
230 VTGSTROFF offName;
231 uint32_t offArgList;
232 uint16_t idxEnabled;
233 uint16_t idxProvider;
234 /** The distance from this structure to the VTG object header. */
235 int32_t offObjHdr;
236} VTGDESCPROBE;
237AssertCompileSize(VTGDESCPROBE, 16);
238/** Pointer to a VTG probe descriptor. */
239typedef VTGDESCPROBE *PVTGDESCPROBE;
240/** Pointer to a const VTG probe descriptor. */
241typedef VTGDESCPROBE const *PCVTGDESCPROBE;
242
243
244/**
245 * Code/data stability.
246 */
247typedef enum kVTGStability
248{
249 kVTGStability_Invalid = 0,
250 kVTGStability_Internal,
251 kVTGStability_Private,
252 kVTGStability_Obsolete,
253 kVTGStability_External,
254 kVTGStability_Unstable,
255 kVTGStability_Evolving,
256 kVTGStability_Stable,
257 kVTGStability_Standard,
258 kVTGStability_End
259} kVTGStability;
260
261/**
262 * Data dependency.
263 */
264typedef enum kVTGClass
265{
266 kVTGClass_Invalid = 0,
267 kVTGClass_Unknown,
268 kVTGClass_Cpu,
269 kVTGClass_Platform,
270 kVTGClass_Group,
271 kVTGClass_Isa,
272 kVTGClass_Common,
273 kVTGClass_End
274} kVTGClass;
275
276
277/**
278 * VTG attributes.
279 */
280typedef struct VTGDESCATTR
281{
282 uint8_t u8Code;
283 uint8_t u8Data;
284 uint8_t u8DataDep;
285} VTGDESCATTR;
286AssertCompileSize(VTGDESCATTR, 3);
287/** Pointer to a const VTG attribute. */
288typedef VTGDESCATTR const *PCVTGDESCATTR;
289
290
291/**
292 * VTG provider descriptor.
293 */
294typedef struct VTGDESCPROVIDER
295{
296 VTGSTROFF offName;
297 uint16_t iFirstProbe;
298 uint16_t cProbes;
299 VTGDESCATTR AttrSelf;
300 VTGDESCATTR AttrModules;
301 VTGDESCATTR AttrFunctions;
302 VTGDESCATTR AttrNames;
303 VTGDESCATTR AttrArguments;
304 uint8_t bReserved;
305} VTGDESCPROVIDER;
306/** Pointer to a VTG provider descriptor. */
307typedef VTGDESCPROVIDER *PVTGDESCPROVIDER;
308/** Pointer to a const VTG provider descriptor. */
309typedef VTGDESCPROVIDER const *PCVTGDESCPROVIDER;
310
311
312/**
313 * VTG data object header.
314 */
315typedef struct VTGOBJHDR
316{
317 /** Magic value (VTGOBJHDR_MAGIC). */
318 char szMagic[24];
319 /** The bitness of the structures.
320 * This only affects the probe location pointers and structures. */
321 uint32_t cBits;
322 /** The size of the VTG object. This excludes the probe locations. */
323 uint32_t cbObj;
324
325 /** @name Area Descriptors
326 * @remarks The offsets are relative to the header. The members are
327 * ordered by ascending offset (maybe with the exception of the
328 * probe locations). No overlaps, though there might be zero
329 * filled gaps between them due to alignment.
330 * @{ */
331 /* 32: */
332 /** Offset of the string table (char) relative to this header. */
333 uint32_t offStrTab;
334 /** The size of the string table, in bytes. */
335 uint32_t cbStrTab;
336 /** Offset of the argument lists (VTGDESCARGLIST - variable size) relative
337 * to this header. */
338 uint32_t offArgLists;
339 /** The size of the argument lists, in bytes. */
340 uint32_t cbArgLists;
341 /* 48: */
342 /** Offset of the probe array (VTGDESCPROBE) relative to this header. */
343 uint32_t offProbes;
344 /** The size of the probe array, in bytes. */
345 uint32_t cbProbes;
346 /** Offset of the provider array (VTGDESCPROVIDER) relative to this
347 * header. */
348 uint32_t offProviders;
349 /** The size of the provider array, in bytes. */
350 uint32_t cbProviders;
351 /* 64: */
352 /** Offset of the probe-enabled array (uint32_t) relative to this
353 * header. */
354 uint32_t offProbeEnabled;
355 /** The size of the probe-enabled array, in bytes. */
356 uint32_t cbProbeEnabled;
357 /** Offset of the probe location array (VTGPROBELOC) relative to this
358 * header.
359 * @remarks This is filled in by the first VTG user using uProbeLocs. */
360 int32_t offProbeLocs;
361 /** The size of the probe location array, in bytes.
362 * @remarks This is filled in by the first VTG user using uProbeLocs. */
363 uint32_t cbProbeLocs;
364 /** @} */
365 /* 80: */
366 /**
367 * The probe location array is generated by C code and lives in a
368 * different section/subsection/segment than the rest of the data.
369 *
370 * The assembler cannot generate offsets across sections for most (if not
371 * all) object formats, so we have to store pointers here. The first user
372 * of the data will convert these two members into offset and size and fill
373 * in the offProbeLocs and cbProbeLocs members above.
374 *
375 * @remarks Converting these members to offset+size and reusing the members
376 * to store the converted values isn't possible because of
377 * raw-mode context modules having relocations associated with the
378 * fields.
379 */
380 union
381 {
382 PVTGPROBELOC p;
383 uintptr_t uPtr;
384 uint32_t u32;
385 uint64_t u64;
386 }
387 /** Pointer to the probe location array. */
388 uProbeLocs,
389 /** Pointer to the end of the probe location array. */
390 uProbeLocsEnd;
391 /** UUID for making sharing ring-0 structures for the same ring-3
392 * modules easier. */
393 RTUUID Uuid;
394 /** Mac 10.6.x load workaround.
395 * The linker or/and load messes up the uProbeLocs and uProbeLocsEnd fields
396 * so that they will be link addresses instead of load addresses. To be
397 * able to work around it we store the start address of the __VTGObj section
398 * here and uses it to validate the probe location addresses. */
399 uint64_t u64VtgObjSectionStart;
400 /** Reserved / alignment. */
401 uint32_t au32Reserved1[2];
402} VTGOBJHDR;
403AssertCompileSize(VTGOBJHDR, 128);
404AssertCompileMemberAlignment(VTGOBJHDR, uProbeLocs, 8);
405AssertCompileMemberAlignment(VTGOBJHDR, uProbeLocsEnd, 8);
406/** Pointer to a VTG data object header. */
407typedef VTGOBJHDR *PVTGOBJHDR;
408/** Pointer to a const VTG data object header. */
409typedef VTGOBJHDR const *PCVTGOBJHDR;
410
411/** The current VTGOBJHDR::szMagic value. */
412#define VTGOBJHDR_MAGIC "VTG Object Header v1.5\0"
413
414/** The name of the VTG data object header symbol in the object file. */
415extern VTGOBJHDR g_VTGObjHeader;
416
417
418/** @name Macros for converting typical pointer arguments to ring-0 pointers.
419 * @{ */
420#ifdef IN_RING0
421# define VTG_VM_TO_R0(a_pVM) (a_pVM)
422# define VTG_VMCPU_TO_R0(a_pVCpu) (a_pVCpu)
423# define VTG_CPUMCTX_TO_R0(a_pVCpu, a_pCtx) (a_pCtx)
424#else
425# define VTG_VM_TO_R0(a_pVM) ((a_pVM) ? (a_pVM)->pVMR0 : NIL_RTR0PTR)
426# define VTG_VMCPU_TO_R0(a_pVCpu) ((a_pVCpu) ? VM_R0_ADDR((a_pVCpu)->CTX_SUFF(pVM), a_pVCpu) : NIL_RTR0PTR)
427# define VTG_CPUMCTX_TO_R0(a_pVCpu, a_pCtx) ((a_pVCpu) ? VM_R0_ADDR((a_pVCpu)->CTX_SUFF(pVM), a_pCtx) : NIL_RTR0PTR)
428#endif
429/** @} */
430
431
432RT_C_DECLS_END
433
434#endif
435
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette