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