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
;
44 struct YAMLXRayTrace
{
45 YAMLXRayFileHeader Header
;
46 std::vector
<YAMLXRayRecord
> Records
;
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
);
64 template <> struct MappingTraits
<xray::YAMLXRayFileHeader
> {
65 static void mapping(IO
&IO
, xray::YAMLXRayFileHeader
&Header
) {
66 IO
.mapRequired("version", Header
.Version
);
67 IO
.mapRequired("type", Header
.Type
);
68 IO
.mapRequired("constant-tsc", Header
.ConstantTSC
);
69 IO
.mapRequired("nonstop-tsc", Header
.NonstopTSC
);
70 IO
.mapRequired("cycle-frequency", Header
.CycleFrequency
);
74 template <> struct MappingTraits
<xray::YAMLXRayRecord
> {
75 static void mapping(IO
&IO
, xray::YAMLXRayRecord
&Record
) {
76 // FIXME: Make this type actually be descriptive
77 IO
.mapRequired("type", Record
.RecordType
);
78 IO
.mapRequired("func-id", Record
.FuncId
);
79 IO
.mapOptional("function", Record
.Function
);
80 IO
.mapOptional("args", Record
.CallArgs
);
81 IO
.mapRequired("cpu", Record
.CPU
);
82 IO
.mapRequired("thread", Record
.TId
);
83 IO
.mapOptional("process", Record
.PId
, 0U);
84 IO
.mapRequired("kind", Record
.Type
);
85 IO
.mapRequired("tsc", Record
.TSC
);
88 static constexpr bool flow
= true;
91 template <> struct MappingTraits
<xray::YAMLXRayTrace
> {
92 static void mapping(IO
&IO
, xray::YAMLXRayTrace
&Trace
) {
93 // A trace file contains two parts, the header and the list of all the
95 IO
.mapRequired("header", Trace
.Header
);
96 IO
.mapRequired("records", Trace
.Records
);
103 LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRayRecord
)
105 #endif // LLVM_XRAY_YAML_XRAY_RECORD_H