1 //===- YAMLXRayRecord.h - XRay Record YAML Support Definitions ------------===//
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
7 //===----------------------------------------------------------------------===//
9 // Types and traits specialisations for YAML I/O of XRay log entries.
11 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_XRAY_YAML_XRAY_RECORD_H
13 #define LLVM_XRAY_YAML_XRAY_RECORD_H
15 #include <type_traits>
17 #include "llvm/Support/YAMLTraits.h"
18 #include "llvm/XRay/XRayRecord.h"
23 struct YAMLXRayFileHeader
{
28 uint64_t CycleFrequency
;
31 struct YAMLXRayRecord
{
40 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
);
61 IO
.enumCase(Type
, "custom-event", xray::RecordTypes::CUSTOM_EVENT
);
62 IO
.enumCase(Type
, "typed-event", xray::RecordTypes::TYPED_EVENT
);
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
);
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
);
90 static constexpr bool flow
= true;
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
97 IO
.mapRequired("header", Trace
.Header
);
98 IO
.mapRequired("records", Trace
.Records
);
105 LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRayRecord
)
107 #endif // LLVM_XRAY_YAML_XRAY_RECORD_H