LLVM  8.0.1
XRayRecord.h
Go to the documentation of this file.
1 //===- XRayRecord.h - XRay Trace Record -----------------------------------===//
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 replicates the record definition for XRay log entries. This should
11 // follow the evolution of the log record versions supported in the compiler-rt
12 // xray project.
13 //
14 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_XRAY_XRAY_RECORD_H
16 #define LLVM_XRAY_XRAY_RECORD_H
17 
18 #include <cstdint>
19 #include <vector>
20 #include <string>
21 
22 namespace llvm {
23 namespace xray {
24 
25 /// XRay traces all have a header providing some top-matter information useful
26 /// to help tools determine how to interpret the information available in the
27 /// trace.
29  /// Version of the XRay implementation that produced this file.
30  uint16_t Version = 0;
31 
32  /// A numeric identifier for the type of file this is. Best used in
33  /// combination with Version.
34  uint16_t Type = 0;
35 
36  /// Whether the CPU that produced the timestamp counters (TSC) move at a
37  /// constant rate.
39 
40  /// Whether the CPU that produced the timestamp counters (TSC) do not stop.
41  bool NonstopTSC;
42 
43  /// The number of cycles per second for the CPU that produced the timestamp
44  /// counter (TSC) values. Useful for estimating the amount of time that
45  /// elapsed between two TSCs on some platforms.
46  uint64_t CycleFrequency = 0;
47 
48  // This is different depending on the type of xray record. The naive format
49  // stores a Wallclock timespec. FDR logging stores the size of a thread
50  // buffer.
51  char FreeFormData[16];
52 };
53 
54 /// Determines the supported types of records that could be seen in XRay traces.
55 /// This may or may not correspond to actual record types in the raw trace (as
56 /// the loader implementation may synthesize this information in the process of
57 /// of loading).
58 enum class RecordTypes {
59  ENTER,
60  EXIT,
61  TAIL_EXIT,
62  ENTER_ARG,
65 };
66 
67 /// An XRayRecord is the denormalized view of data associated in a trace. These
68 /// records may not correspond to actual entries in the raw traces, but they are
69 /// the logical representation of records in a higher-level event log.
70 struct XRayRecord {
71  /// RecordType values are used as "sub-types" which have meaning in the
72  /// context of the `Type` below. For function call and custom event records,
73  /// the RecordType is always 0, while for typed events we store the type in
74  /// the RecordType field.
75  uint16_t RecordType;
76 
77  /// The CPU where the thread is running. We assume number of CPUs <= 65536.
78  uint16_t CPU;
79 
80  /// Identifies the type of record.
82 
83  /// The function ID for the record, if this is a function call record.
84  int32_t FuncId;
85 
86  /// Get the full 8 bytes of the TSC when we get the log record.
87  uint64_t TSC;
88 
89  /// The thread ID for the currently running thread.
91 
92  /// The process ID for the currently running process.
94 
95  /// The function call arguments.
96  std::vector<uint64_t> CallArgs;
97 
98  /// For custom and typed events, we provide the raw data from the trace.
99  std::string Data;
100 };
101 
102 } // namespace xray
103 } // namespace llvm
104 
105 #endif // LLVM_XRAY_XRAY_RECORD_H
uint16_t RecordType
RecordType values are used as "sub-types" which have meaning in the context of the Type below...
Definition: XRayRecord.h:75
This class represents lattice values for constants.
Definition: AllocatorList.h:24
std::string Data
For custom and typed events, we provide the raw data from the trace.
Definition: XRayRecord.h:99
RecordTypes Type
Identifies the type of record.
Definition: XRayRecord.h:81
uint64_t CycleFrequency
The number of cycles per second for the CPU that produced the timestamp counter (TSC) values...
Definition: XRayRecord.h:46
int32_t FuncId
The function ID for the record, if this is a function call record.
Definition: XRayRecord.h:84
An XRayRecord is the denormalized view of data associated in a trace.
Definition: XRayRecord.h:70
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
RecordTypes
Determines the supported types of records that could be seen in XRay traces.
Definition: XRayRecord.h:58
uint32_t TId
The thread ID for the currently running thread.
Definition: XRayRecord.h:90
bool NonstopTSC
Whether the CPU that produced the timestamp counters (TSC) do not stop.
Definition: XRayRecord.h:41
uint32_t PId
The process ID for the currently running process.
Definition: XRayRecord.h:93
uint64_t TSC
Get the full 8 bytes of the TSC when we get the log record.
Definition: XRayRecord.h:87
std::vector< uint64_t > CallArgs
The function call arguments.
Definition: XRayRecord.h:96
bool ConstantTSC
Whether the CPU that produced the timestamp counters (TSC) move at a constant rate.
Definition: XRayRecord.h:38
uint16_t CPU
The CPU where the thread is running. We assume number of CPUs <= 65536.
Definition: XRayRecord.h:78
XRay traces all have a header providing some top-matter information useful to help tools determine ho...
Definition: XRayRecord.h:28
uint16_t Version
Version of the XRay implementation that produced this file.
Definition: XRayRecord.h:30