]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/include/xray/xray_records.h
Update ELF Tool Chain to upstream r3520
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / include / xray / xray_records.h
1 //===-- xray_records.h ------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of XRay, a dynamic runtime instrumentation system.
11 //
12 // This header exposes some record types useful for the XRay in-memory logging
13 // implementation.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef XRAY_XRAY_RECORDS_H
18 #define XRAY_XRAY_RECORDS_H
19
20 namespace __xray {
21
22 enum FileTypes {
23   NAIVE_LOG = 0,
24 };
25
26 // This data structure is used to describe the contents of the file. We use this
27 // for versioning the supported XRay file formats.
28 struct alignas(32) XRayFileHeader {
29   uint16_t Version = 0;
30
31   // The type of file we're writing out. See the FileTypes enum for more
32   // information. This allows different implementations of the XRay logging to
33   // have different files for different information being stored.
34   uint16_t Type = 0;
35
36   // What follows are a set of flags that indicate useful things for when
37   // reading the data in the file.
38   bool ConstantTSC : 1;
39   bool NonstopTSC : 1;
40
41   // The frequency by which TSC increases per-second.
42   alignas(8) uint64_t CycleFrequency = 0;
43 } __attribute__((packed));
44
45 static_assert(sizeof(XRayFileHeader) == 32, "XRayFileHeader != 32 bytes");
46
47 enum RecordTypes {
48   NORMAL = 0,
49 };
50
51 struct alignas(32) XRayRecord {
52   // This is the type of the record being written. We use 16 bits to allow us to
53   // treat this as a discriminant, and so that the first 4 bytes get packed
54   // properly. See RecordTypes for more supported types.
55   uint16_t RecordType = 0;
56
57   // The CPU where the thread is running. We assume number of CPUs <= 256.
58   uint8_t CPU = 0;
59
60   // The type of the event. Usually either ENTER = 0 or EXIT = 1.
61   uint8_t Type = 0;
62
63   // The function ID for the record.
64   int32_t FuncId = 0;
65
66   // Get the full 8 bytes of the TSC when we get the log record.
67   uint64_t TSC = 0;
68
69   // The thread ID for the currently running thread.
70   uint32_t TId = 0;
71
72   // Use some bytes in the end of the record for buffers.
73   char Buffer[4] = {};
74 } __attribute__((packed));
75
76 static_assert(sizeof(XRayRecord) == 32, "XRayRecord != 32 bytes");
77
78 } // namespace __xray
79
80 #endif // XRAY_XRAY_RECORDS_H