|
LLVM 22.0.0git
|
#include "llvm/XRay/Trace.h"#include "llvm/ADT/STLExtras.h"#include "llvm/Support/DataExtractor.h"#include "llvm/Support/Error.h"#include "llvm/Support/FileSystem.h"#include "llvm/XRay/BlockIndexer.h"#include "llvm/XRay/BlockVerifier.h"#include "llvm/XRay/FDRRecordConsumer.h"#include "llvm/XRay/FDRRecordProducer.h"#include "llvm/XRay/FDRRecords.h"#include "llvm/XRay/FDRTraceExpander.h"#include "llvm/XRay/FileHeaderReader.h"#include "llvm/XRay/YAMLXRayRecord.h"#include <memory>#include <vector>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) |
|
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().
|
static |
Definition at line 32 of file Trace.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::createStringError(), llvm::Data, llvm::divideCeil(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::xray::ENTER, llvm::xray::ENTER_ARG, llvm::xray::EXIT, llvm::DataExtractor::getSigned(), llvm::DataExtractor::getU16(), llvm::DataExtractor::getU32(), llvm::DataExtractor::getU64(), llvm::DataExtractor::getU8(), llvm::DataExtractor::isValidOffset(), llvm::DataExtractor::isValidOffsetForDataOfSize(), llvm::make_error(), llvm::xray::readBinaryFormatHeader(), llvm::SmallVectorImpl< T >::reserve(), llvm::DataExtractor::size(), llvm::Error::success(), llvm::xray::TAIL_EXIT, and llvm::xray::XRayFileHeader::Version.
Referenced by llvm::xray::loadTrace().
|
static |
Definition at line 350 of file Trace.cpp.
References llvm::Trace::begin(), llvm::SmallVectorImpl< T >::clear(), llvm::xray::XRayFileHeader::ConstantTSC, llvm::xray::XRayFileHeader::CycleFrequency, llvm::Data, llvm::Trace::end(), llvm::make_error(), llvm::xray::XRayFileHeader::NonstopTSC, llvm::xray::XRayFileHeader::Type, and llvm::xray::XRayFileHeader::Version.
Referenced by llvm::xray::loadTrace().