LLVM 22.0.0git
Trace.cpp File Reference

Go to the source code of this file.

Classes

class  Input
 The Input class is used to parse a yaml document into in-memory structs and vectors. More...

Functions

static Error loadNaiveFormatLog (StringRef Data, bool IsLittleEndian, XRayFileHeader &FileHeader, std::vector< XRayRecord > &Records)
static Error loadFDRLog (StringRef Data, bool IsLittleEndian, XRayFileHeader &FileHeader, std::vector< XRayRecord > &Records)
 Reads a log in FDR mode for version 1 of this binary format.
static Error loadYAMLLog (StringRef Data, XRayFileHeader &FileHeader, std::vector< XRayRecord > &Records)

Function Documentation

◆ loadFDRLog()

Error loadFDRLog ( StringRef Data,
bool IsLittleEndian,
XRayFileHeader & FileHeader,
std::vector< XRayRecord > & Records )
static

Reads a log in FDR mode for version 1 of this binary format.

FDR mode is defined as part of the compiler-rt project in xray_fdr_logging.h, and such a log consists of the familiar 32 bit XRayHeader, followed by sequences of of interspersed 16 byte Metadata Records and 8 byte Function Records.

The following is an attempt to document the grammar of the format, which is parsed by this function for little-endian machines. Since the format makes use of BitFields, when we support big-endian architectures, we will need to adjust not only the endianness parameter to llvm's RecordExtractor, but also the bit twiddling logic, which is consistent with the little-endian convention that BitFields within a struct will first be packed into the least significant bits the address they belong to.

We expect a format complying with the grammar in the following pseudo-EBNF in Version 1 of the FDR log.

FDRLog: XRayFileHeader ThreadBuffer* XRayFileHeader: 32 bytes to identify the log as FDR with machine metadata. Includes BufferSize ThreadBuffer: NewBuffer WallClockTime NewCPUId FunctionSequence EOB BufSize: 8 byte unsigned integer indicating how large the buffer is. NewBuffer: 16 byte metadata record with Thread Id. WallClockTime: 16 byte metadata record with human readable time. Pid: 16 byte metadata record with Pid NewCPUId: 16 byte metadata record with CPUId and a 64 bit TSC reading. EOB: 16 byte record in a thread buffer plus mem garbage to fill BufSize. FunctionSequence: NewCPUId | TSCWrap | FunctionRecord TSCWrap: 16 byte metadata record with a full 64 bit TSC reading. FunctionRecord: 8 byte record with FunctionId, entry/exit, and TSC delta.

In Version 2, we make the following changes:

ThreadBuffer: BufferExtents NewBuffer WallClockTime NewCPUId FunctionSequence BufferExtents: 16 byte metdata record describing how many usable bytes are in the buffer. This is measured from the start of the buffer and must always be at least 48 (bytes).

In Version 3, we make the following changes:

ThreadBuffer: BufferExtents NewBuffer WallClockTime Pid NewCPUId FunctionSequence EOB: deprecated

In Version 4, we make the following changes:

CustomEventRecord now includes the CPU data.

In Version 5, we make the following changes:

CustomEventRecord and TypedEventRecord now use TSC delta encoding similar to what FunctionRecord instances use, and we no longer need to include the CPU id in the CustomEventRecord.

Definition at line 266 of file Trace.cpp.

References B(), llvm::CallingConv::C, llvm::createStringError(), llvm::Data, E(), llvm::xray::BlockIndexer::flush(), llvm::xray::TraceExpander::flush(), llvm::DataExtractor::isValidOffsetForDataOfSize(), P, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::xray::readBinaryFormatHeader(), llvm::sort(), llvm::Error::success(), and llvm::xray::XRayFileHeader::Version.

Referenced by llvm::xray::loadTrace().

◆ loadNaiveFormatLog()

◆ loadYAMLLog()