21 using namespace llvm::xray;
25 std::aligned_storage<sizeof(XRayRecord), alignof(XRayRecord)>::type;
28 std::vector<XRayRecord> &Records) {
42 return make_error<StringError>(
43 "Not enough bytes for an XRay log.",
46 if (Data.
size() - 32 == 0 || Data.
size() % 32 != 0)
47 return make_error<StringError>(
48 "Invalid-sized XRay data.",
54 FileHeader.
Type = HeaderExtractor.
getU16(&OffsetPtr);
61 return make_error<StringError>(
77 Records.emplace_back();
78 auto &
Record = Records.back();
81 auto Type = RecordExtractor.
getU8(&OffsetPtr);
90 return make_error<StringError>(
102 std::vector<XRayRecord> &Records) {
109 return make_error<StringError>(
"Failed loading YAML Data.", In.
error());
111 FileHeader.
Version = Trace.Header.Version;
112 FileHeader.
Type = Trace.Header.Type;
114 FileHeader.
NonstopTSC = Trace.Header.NonstopTSC;
118 return make_error<StringError>(
126 R.FuncId, R.TSC, R.TId};
134 return make_error<StringError>(
135 Twine(
"Cannot read log from '") + Filename +
"'", EC);
141 return make_error<StringError>(
142 Twine(
"Cannot read log from '") + Filename +
"'", EC);
145 return make_error<StringError>(
146 Twine(
"File '") + Filename +
"' too small for XRay.",
153 Fd, sys::fs::mapped_file_region::mapmode::readonly, FileSize, 0, EC);
155 return make_error<StringError>(
156 Twine(
"Cannot read log from '") + Filename +
"'", EC);
175 uint16_t
Version = HeaderExtractor.getU16(&OffsetPtr);
176 uint16_t
Type = HeaderExtractor.getU16(&OffsetPtr);
179 if (Version == 1 && (Type == 0 || Type == 1)) {
181 T.FileHeader, T.Records))
185 T.FileHeader, T.Records))
190 std::sort(T.Records.begin(), T.Records.end(),
192 return L.
TSC < R.TSC;
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
uint16_t RecordType
The type of record.
std::error_code openFileForRead(const Twine &Name, int &ResultFD, SmallVectorImpl< char > *RealPath=nullptr)
This class represents a memory mapped file.
Expected< Trace > loadTraceFile(StringRef Filename, bool Sort=false)
This function will attempt to load XRay trace records from the provided |Filename|.
Error YAMLLogLoader(StringRef Data, XRayFileHeader &FileHeader, std::vector< XRayRecord > &Records)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::error_code make_error_code(BitcodeError E)
std::error_code file_size(const Twine &Path, uint64_t &Result)
Get file size.
Tagged union holding either a T or a Error.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
A Trace object represents the records that have been loaded from XRay log files generated by instrume...
The instances of the Type class are immutable: once they are created, they are never changed...
static const char *const Magic
static ErrorSuccess success()
Create a success value.
Error NaiveLogLoader(StringRef Data, XRayFileHeader &FileHeader, std::vector< XRayRecord > &Records)
uint64_t TSC
Get the full 8 bytes of the TSC when we get the log record.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
OutputIt transform(R &&Range, OutputIt d_first, UnaryPredicate P)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere...
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
std::aligned_storage< sizeof(XRayRecord), alignof(XRayRecord)>::type XRayRecordStorage