LLVM  14.0.0git
YAMLXRayRecord.h
Go to the documentation of this file.
1 //===- YAMLXRayRecord.h - XRay Record YAML Support Definitions ------------===//
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 // Types and traits specialisations for YAML I/O of XRay log entries.
10 //
11 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_XRAY_YAMLXRAYRECORD_H
13 #define LLVM_XRAY_YAMLXRAYRECORD_H
14 
15 #include <type_traits>
16 
18 #include "llvm/XRay/XRayRecord.h"
19 
20 namespace llvm {
21 namespace xray {
22 
27  bool NonstopTSC;
29 };
30 
35  int32_t FuncId;
36  std::string Function;
40  std::vector<uint64_t> CallArgs;
41  std::string Data;
42 };
43 
44 struct YAMLXRayTrace {
46  std::vector<YAMLXRayRecord> Records;
47 };
48 
49 } // namespace xray
50 
51 namespace yaml {
52 
53 // YAML Traits
54 // -----------
55 template <> struct ScalarEnumerationTraits<xray::RecordTypes> {
56  static void enumeration(IO &IO, xray::RecordTypes &Type) {
57  IO.enumCase(Type, "function-enter", xray::RecordTypes::ENTER);
58  IO.enumCase(Type, "function-exit", xray::RecordTypes::EXIT);
59  IO.enumCase(Type, "function-tail-exit", xray::RecordTypes::TAIL_EXIT);
60  IO.enumCase(Type, "function-enter-arg", xray::RecordTypes::ENTER_ARG);
61  IO.enumCase(Type, "custom-event", xray::RecordTypes::CUSTOM_EVENT);
62  IO.enumCase(Type, "typed-event", xray::RecordTypes::TYPED_EVENT);
63  }
64 };
65 
66 template <> struct MappingTraits<xray::YAMLXRayFileHeader> {
67  static void mapping(IO &IO, xray::YAMLXRayFileHeader &Header) {
68  IO.mapRequired("version", Header.Version);
69  IO.mapRequired("type", Header.Type);
70  IO.mapRequired("constant-tsc", Header.ConstantTSC);
71  IO.mapRequired("nonstop-tsc", Header.NonstopTSC);
72  IO.mapRequired("cycle-frequency", Header.CycleFrequency);
73  }
74 };
75 
76 template <> struct MappingTraits<xray::YAMLXRayRecord> {
77  static void mapping(IO &IO, xray::YAMLXRayRecord &Record) {
78  IO.mapRequired("type", Record.RecordType);
79  IO.mapOptional("func-id", Record.FuncId);
80  IO.mapOptional("function", Record.Function);
81  IO.mapOptional("args", Record.CallArgs);
82  IO.mapRequired("cpu", Record.CPU);
83  IO.mapOptional("thread", Record.TId, 0U);
84  IO.mapOptional("process", Record.PId, 0U);
85  IO.mapRequired("kind", Record.Type);
86  IO.mapRequired("tsc", Record.TSC);
87  IO.mapOptional("data", Record.Data);
88  }
89 
90  static constexpr bool flow = true;
91 };
92 
93 template <> struct MappingTraits<xray::YAMLXRayTrace> {
94  static void mapping(IO &IO, xray::YAMLXRayTrace &Trace) {
95  // A trace file contains two parts, the header and the list of all the
96  // trace records.
97  IO.mapRequired("header", Trace.Header);
98  IO.mapRequired("records", Trace.Records);
99  }
100 };
101 
102 } // namespace yaml
103 } // namespace llvm
104 
105 LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRayRecord)
106 
107 #endif // LLVM_XRAY_YAMLXRAYRECORD_H
llvm::xray::YAMLXRayFileHeader
Definition: YAMLXRayRecord.h:23
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::xray::YAMLXRayFileHeader::NonstopTSC
bool NonstopTSC
Definition: YAMLXRayRecord.h:27
llvm::xray::YAMLXRayRecord::Type
RecordTypes Type
Definition: YAMLXRayRecord.h:34
llvm::xray::YAMLXRayRecord::FuncId
int32_t FuncId
Definition: YAMLXRayRecord.h:35
llvm::xray::RecordTypes::EXIT
@ EXIT
LLVM_YAML_IS_SEQUENCE_VECTOR
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::yaml::MappingTraits
Definition: ModuleSummaryIndex.h:52
llvm::xray::YAMLXRayTrace::Header
YAMLXRayFileHeader Header
Definition: YAMLXRayRecord.h:45
llvm::xray::YAMLXRayRecord::Data
std::string Data
Definition: YAMLXRayRecord.h:41
llvm::yaml::ScalarEnumerationTraits< xray::RecordTypes >::enumeration
static void enumeration(IO &IO, xray::RecordTypes &Type)
Definition: YAMLXRayRecord.h:56
llvm::xray::RecordTypes::TAIL_EXIT
@ TAIL_EXIT
llvm::xray::RecordTypes::TYPED_EVENT
@ TYPED_EVENT
llvm::xray::YAMLXRayFileHeader::Type
uint16_t Type
Definition: YAMLXRayRecord.h:25
llvm::xray::YAMLXRayTrace
Definition: YAMLXRayRecord.h:44
llvm::xray::YAMLXRayRecord::CPU
uint16_t CPU
Definition: YAMLXRayRecord.h:33
llvm::xray::RecordTypes
RecordTypes
Determines the supported types of records that could be seen in XRay traces.
Definition: XRayRecord.h:57
llvm::yaml::MappingTraits< xray::YAMLXRayRecord >::mapping
static void mapping(IO &IO, xray::YAMLXRayRecord &Record)
Definition: YAMLXRayRecord.h:77
llvm::xray::YAMLXRayRecord::Function
std::string Function
Definition: YAMLXRayRecord.h:36
llvm::yaml::MappingTraits< xray::YAMLXRayTrace >::mapping
static void mapping(IO &IO, xray::YAMLXRayTrace &Trace)
Definition: YAMLXRayRecord.h:94
llvm::xray::YAMLXRayFileHeader::Version
uint16_t Version
Definition: YAMLXRayRecord.h:24
llvm::xray::RecordTypes::CUSTOM_EVENT
@ CUSTOM_EVENT
llvm::xray::YAMLXRayRecord::PId
uint32_t PId
Definition: YAMLXRayRecord.h:39
uint64_t
llvm::xray::YAMLXRayRecord
Definition: YAMLXRayRecord.h:31
llvm::xray::RecordTypes::ENTER
@ ENTER
llvm::xray::YAMLXRayRecord::TId
uint32_t TId
Definition: YAMLXRayRecord.h:38
llvm::xray::YAMLXRayFileHeader::ConstantTSC
bool ConstantTSC
Definition: YAMLXRayRecord.h:26
llvm::Record
Definition: Record.h:1472
llvm::xray::YAMLXRayRecord::TSC
uint64_t TSC
Definition: YAMLXRayRecord.h:37
YAMLTraits.h
llvm::xray::YAMLXRayRecord::RecordType
uint16_t RecordType
Definition: YAMLXRayRecord.h:32
uint32_t
llvm::Trace
Definition: Trace.h:30
llvm::xray::YAMLXRayTrace::Records
std::vector< YAMLXRayRecord > Records
Definition: YAMLXRayRecord.h:46
uint16_t
llvm::xray::YAMLXRayFileHeader::CycleFrequency
uint64_t CycleFrequency
Definition: YAMLXRayRecord.h:28
llvm::xray::RecordTypes::ENTER_ARG
@ ENTER_ARG
llvm::yaml::MappingTraits< xray::YAMLXRayFileHeader >::mapping
static void mapping(IO &IO, xray::YAMLXRayFileHeader &Header)
Definition: YAMLXRayRecord.h:67
XRayRecord.h
llvm::xray::YAMLXRayRecord::CallArgs
std::vector< uint64_t > CallArgs
Definition: YAMLXRayRecord.h:40