1 //===- YAMLXRayRecord.h - XRay Record YAML Support Definitions ------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Types and traits specialisations for YAML I/O of XRay log entries.
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_XRAY_YAML_XRAY_RECORD_H
14 #define LLVM_XRAY_YAML_XRAY_RECORD_H
16 #include <type_traits>
18 #include "llvm/Support/YAMLTraits.h"
19 #include "llvm/XRay/XRayRecord.h"
24 struct YAMLXRayFileHeader {
29 uint64_t CycleFrequency;
32 struct YAMLXRayRecord {
41 std::vector<uint64_t> CallArgs;
45 struct YAMLXRayTrace {
46 YAMLXRayFileHeader Header;
47 std::vector<YAMLXRayRecord> Records;
56 template <> struct ScalarEnumerationTraits<xray::RecordTypes> {
57 static void enumeration(IO &IO, xray::RecordTypes &Type) {
58 IO.enumCase(Type, "function-enter", xray::RecordTypes::ENTER);
59 IO.enumCase(Type, "function-exit", xray::RecordTypes::EXIT);
60 IO.enumCase(Type, "function-tail-exit", xray::RecordTypes::TAIL_EXIT);
61 IO.enumCase(Type, "function-enter-arg", xray::RecordTypes::ENTER_ARG);
62 IO.enumCase(Type, "custom-event", xray::RecordTypes::CUSTOM_EVENT);
63 IO.enumCase(Type, "typed-event", xray::RecordTypes::TYPED_EVENT);
67 template <> struct MappingTraits<xray::YAMLXRayFileHeader> {
68 static void mapping(IO &IO, xray::YAMLXRayFileHeader &Header) {
69 IO.mapRequired("version", Header.Version);
70 IO.mapRequired("type", Header.Type);
71 IO.mapRequired("constant-tsc", Header.ConstantTSC);
72 IO.mapRequired("nonstop-tsc", Header.NonstopTSC);
73 IO.mapRequired("cycle-frequency", Header.CycleFrequency);
77 template <> struct MappingTraits<xray::YAMLXRayRecord> {
78 static void mapping(IO &IO, xray::YAMLXRayRecord &Record) {
79 IO.mapRequired("type", Record.RecordType);
80 IO.mapOptional("func-id", Record.FuncId);
81 IO.mapOptional("function", Record.Function);
82 IO.mapOptional("args", Record.CallArgs);
83 IO.mapRequired("cpu", Record.CPU);
84 IO.mapOptional("thread", Record.TId, 0U);
85 IO.mapOptional("process", Record.PId, 0U);
86 IO.mapRequired("kind", Record.Type);
87 IO.mapRequired("tsc", Record.TSC);
88 IO.mapOptional("data", Record.Data);
91 static constexpr bool flow = true;
94 template <> struct MappingTraits<xray::YAMLXRayTrace> {
95 static void mapping(IO &IO, xray::YAMLXRayTrace &Trace) {
96 // A trace file contains two parts, the header and the list of all the
98 IO.mapRequired("header", Trace.Header);
99 IO.mapRequired("records", Trace.Records);
106 LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRayRecord)
108 #endif // LLVM_XRAY_YAML_XRAY_RECORD_H