File indexing completed on 2026-05-10 08:44:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef LLVM_XRAY_YAMLXRAYRECORD_H
0013 #define LLVM_XRAY_YAMLXRAYRECORD_H
0014
0015 #include <type_traits>
0016
0017 #include "llvm/Support/YAMLTraits.h"
0018 #include "llvm/XRay/XRayRecord.h"
0019
0020 namespace llvm {
0021 namespace xray {
0022
0023 struct YAMLXRayFileHeader {
0024 uint16_t Version;
0025 uint16_t Type;
0026 bool ConstantTSC;
0027 bool NonstopTSC;
0028 uint64_t CycleFrequency;
0029 };
0030
0031 struct YAMLXRayRecord {
0032 uint16_t RecordType;
0033 uint16_t CPU;
0034 RecordTypes Type;
0035 int32_t FuncId;
0036 std::string Function;
0037 uint64_t TSC;
0038 uint32_t TId;
0039 uint32_t PId;
0040 std::vector<uint64_t> CallArgs;
0041 std::string Data;
0042 };
0043
0044 struct YAMLXRayTrace {
0045 YAMLXRayFileHeader Header;
0046 std::vector<YAMLXRayRecord> Records;
0047 };
0048
0049 }
0050
0051 namespace yaml {
0052
0053
0054
0055 template <> struct ScalarEnumerationTraits<xray::RecordTypes> {
0056 static void enumeration(IO &IO, xray::RecordTypes &Type) {
0057 IO.enumCase(Type, "function-enter", xray::RecordTypes::ENTER);
0058 IO.enumCase(Type, "function-exit", xray::RecordTypes::EXIT);
0059 IO.enumCase(Type, "function-tail-exit", xray::RecordTypes::TAIL_EXIT);
0060 IO.enumCase(Type, "function-enter-arg", xray::RecordTypes::ENTER_ARG);
0061 IO.enumCase(Type, "custom-event", xray::RecordTypes::CUSTOM_EVENT);
0062 IO.enumCase(Type, "typed-event", xray::RecordTypes::TYPED_EVENT);
0063 }
0064 };
0065
0066 template <> struct MappingTraits<xray::YAMLXRayFileHeader> {
0067 static void mapping(IO &IO, xray::YAMLXRayFileHeader &Header) {
0068 IO.mapRequired("version", Header.Version);
0069 IO.mapRequired("type", Header.Type);
0070 IO.mapRequired("constant-tsc", Header.ConstantTSC);
0071 IO.mapRequired("nonstop-tsc", Header.NonstopTSC);
0072 IO.mapRequired("cycle-frequency", Header.CycleFrequency);
0073 }
0074 };
0075
0076 template <> struct MappingTraits<xray::YAMLXRayRecord> {
0077 static void mapping(IO &IO, xray::YAMLXRayRecord &Record) {
0078 IO.mapRequired("type", Record.RecordType);
0079 IO.mapOptional("func-id", Record.FuncId);
0080 IO.mapOptional("function", Record.Function);
0081 IO.mapOptional("args", Record.CallArgs);
0082 IO.mapRequired("cpu", Record.CPU);
0083 IO.mapOptional("thread", Record.TId, 0U);
0084 IO.mapOptional("process", Record.PId, 0U);
0085 IO.mapRequired("kind", Record.Type);
0086 IO.mapRequired("tsc", Record.TSC);
0087 IO.mapOptional("data", Record.Data);
0088 }
0089
0090 static constexpr bool flow = true;
0091 };
0092
0093 template <> struct MappingTraits<xray::YAMLXRayTrace> {
0094 static void mapping(IO &IO, xray::YAMLXRayTrace &Trace) {
0095
0096
0097 IO.mapRequired("header", Trace.Header);
0098 IO.mapRequired("records", Trace.Records);
0099 }
0100 };
0101
0102 }
0103 }
0104
0105 LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRayRecord)
0106
0107 #endif