|
LLVM
5.0.0
|
#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/YAMLXRayRecord.h"Go to the source code of this file.
Classes | |
| struct | FDRState |
| When reading from a Flight Data Recorder mode log, metadata records are sparse compared to packed function records, so we must maintain state as we read through the sequence of entries. More... | |
Typedefs | |
| using | XRayRecordStorage = std::aligned_storage< sizeof(XRayRecord), alignof(XRayRecord)>::type |
Functions | |
| Error | readBinaryFormatHeader (StringRef Data, XRayFileHeader &FileHeader) |
| Error | loadNaiveFormatLog (StringRef Data, XRayFileHeader &FileHeader, std::vector< XRayRecord > &Records) |
| Twine | fdrStateToTwine (const FDRState::Token &state) |
| Error | processFDRNewBufferRecord (FDRState &State, uint8_t RecordFirstByte, DataExtractor &RecordExtractor) |
| State transition when a NewBufferRecord is encountered. More... | |
| Error | processFDREndOfBufferRecord (FDRState &State, uint8_t RecordFirstByte, DataExtractor &RecordExtractor) |
| State transition when an EndOfBufferRecord is encountered. More... | |
| Error | processFDRNewCPUIdRecord (FDRState &State, uint8_t RecordFirstByte, DataExtractor &RecordExtractor) |
| State transition when a NewCPUIdRecord is encountered. More... | |
| Error | processFDRTSCWrapRecord (FDRState &State, uint8_t RecordFirstByte, DataExtractor &RecordExtractor) |
| State transition when a TSCWrapRecord (overflow detection) is encountered. More... | |
| Error | processFDRWallTimeRecord (FDRState &State, uint8_t RecordFirstByte, DataExtractor &RecordExtractor) |
| State transition when a WallTimeMarkerRecord is encountered. More... | |
| Error | processCustomEventMarker (FDRState &State, uint8_t RecordFirstByte, DataExtractor &RecordExtractor, size_t &RecordSize) |
| State transition when a CustomEventMarker is encountered. More... | |
| Error | processFDRMetadataRecord (FDRState &State, uint8_t RecordFirstByte, DataExtractor &RecordExtractor, size_t &RecordSize) |
| Advances the state machine for reading the FDR record type by reading one Metadata Record and updating the State appropriately based on the kind of record encountered. More... | |
| Error | processFDRFunctionRecord (FDRState &State, uint8_t RecordFirstByte, DataExtractor &RecordExtractor, std::vector< XRayRecord > &Records) |
| Reads a function record from an FDR format log, appending a new XRayRecord to the vector being populated and updating the State with a new value reference value to interpret TSC deltas. More... | |
| Error | loadFDRLog (StringRef Data, XRayFileHeader &FileHeader, std::vector< XRayRecord > &Records) |
| Reads a log in FDR mode for version 1 of this binary format. More... | |
| Error | loadYAMLLog (StringRef Data, XRayFileHeader &FileHeader, std::vector< XRayRecord > &Records) |
| using XRayRecordStorage = std::aligned_storage<sizeof(XRayRecord), alignof(XRayRecord)>::type |
| Twine fdrStateToTwine | ( | const FDRState::Token & | state | ) |
Definition at line 137 of file Trace.cpp.
References FDRState::CUSTOM_EVENT_DATA, FDRState::FUNCTION_SEQUENCE, FDRState::NEW_BUFFER_RECORD_OR_EOF, FDRState::NEW_CPU_ID_RECORD, FDRState::SCAN_TO_END_OF_THREAD_BUF, and FDRState::WALLCLOCK_RECORD.
Referenced by loadFDRLog().
| Error loadFDRLog | ( | StringRef | Data, |
| XRayFileHeader & | FileHeader, | ||
| std::vector< XRayRecord > & | Records | ||
| ) |
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.
FDRLog: XRayFileHeader ThreadBuffer* XRayFileHeader: 32 bits to identify the log as FDR with machine metadata. ThreadBuffer: BufSize 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. 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.
Definition at line 382 of file Trace.cpp.
References llvm::StringRef::drop_front(), E, llvm::StringRef::empty(), fdrStateToTwine(), llvm::xray::XRayFileHeader::FreeFormData, llvm::DataExtractor::getU64(), llvm::DataExtractor::getU8(), llvm::make_error_code(), FDRState::NEW_BUFFER_RECORD_OR_EOF, processFDRFunctionRecord(), processFDRMetadataRecord(), readBinaryFormatHeader(), FDRState::SCAN_TO_END_OF_THREAD_BUF, llvm::StringRef::size(), and llvm::Error::success().
Referenced by llvm::xray::loadTraceFile().
| Error loadNaiveFormatLog | ( | StringRef | Data, |
| XRayFileHeader & | FileHeader, | ||
| std::vector< XRayRecord > & | Records | ||
| ) |
Definition at line 57 of file Trace.cpp.
References llvm::StringRef::drop_front(), E, llvm::StringRef::empty(), llvm::xray::ENTER, llvm::xray::EXIT, llvm::DataExtractor::getSigned(), llvm::DataExtractor::getU16(), llvm::DataExtractor::getU32(), llvm::DataExtractor::getU64(), llvm::DataExtractor::getU8(), llvm::make_error_code(), readBinaryFormatHeader(), llvm::StringRef::size(), and llvm::Error::success().
Referenced by llvm::xray::loadTraceFile().
| Error loadYAMLLog | ( | StringRef | Data, |
| XRayFileHeader & | FileHeader, | ||
| std::vector< XRayRecord > & | Records | ||
| ) |
Definition at line 458 of file Trace.cpp.
References llvm::xray::XRayFileHeader::ConstantTSC, llvm::xray::XRayFileHeader::CycleFrequency, llvm::yaml::Input::error(), llvm::tgtok::In, llvm::make_error_code(), llvm::xray::XRayFileHeader::NonstopTSC, llvm::xray::XRayRecord::RecordType, llvm::Error::success(), llvm::transform(), llvm::xray::XRayFileHeader::Type, and llvm::xray::XRayFileHeader::Version.
Referenced by llvm::xray::loadTraceFile().
| Error processCustomEventMarker | ( | FDRState & | State, |
| uint8_t | RecordFirstByte, | ||
| DataExtractor & | RecordExtractor, | ||
| size_t & | RecordSize | ||
| ) |
State transition when a CustomEventMarker is encountered.
Definition at line 221 of file Trace.cpp.
References llvm::DataExtractor::getU32(), llvm::DataExtractor::getU64(), and llvm::Error::success().
Referenced by processFDRMetadataRecord().
| Error processFDREndOfBufferRecord | ( | FDRState & | State, |
| uint8_t | RecordFirstByte, | ||
| DataExtractor & | RecordExtractor | ||
| ) |
State transition when an EndOfBufferRecord is encountered.
Definition at line 170 of file Trace.cpp.
References FDRState::Expects, llvm::make_error_code(), FDRState::NEW_BUFFER_RECORD_OR_EOF, FDRState::SCAN_TO_END_OF_THREAD_BUF, and llvm::Error::success().
Referenced by processFDRMetadataRecord().
| Error processFDRFunctionRecord | ( | FDRState & | State, |
| uint8_t | RecordFirstByte, | ||
| DataExtractor & | RecordExtractor, | ||
| std::vector< XRayRecord > & | Records | ||
| ) |
Reads a function record from an FDR format log, appending a new XRayRecord to the vector being populated and updating the State with a new value reference value to interpret TSC deltas.
The XRayRecord constructed includes information from the function record processed here as well as Thread ID and CPU ID formerly extracted into State.
Definition at line 296 of file Trace.cpp.
References FDRState::BaseTSC, llvm::Twine::concat(), FDRState::CPUId, llvm::xray::ENTER, llvm::xray::EXIT, FDRState::Expects, llvm::DataExtractor::getU32(), llvm::make_error_code(), FDRState::NEW_BUFFER_RECORD_OR_EOF, FDRState::NEW_CPU_ID_RECORD, llvm::Error::success(), FDRState::ThreadId, and FDRState::WALLCLOCK_RECORD.
Referenced by loadFDRLog().
| Error processFDRMetadataRecord | ( | FDRState & | State, |
| uint8_t | RecordFirstByte, | ||
| DataExtractor & | RecordExtractor, | ||
| size_t & | RecordSize | ||
| ) |
Advances the state machine for reading the FDR record type by reading one Metadata Record and updating the State appropriately based on the kind of record encountered.
The RecordKind is encoded in the first byte of the Record, which the caller should pass in because they have already read it to determine that this is a metadata record as opposed to a function record.
Definition at line 243 of file Trace.cpp.
References llvm::Twine::concat(), E, llvm::make_error_code(), processCustomEventMarker(), processFDREndOfBufferRecord(), processFDRNewBufferRecord(), processFDRNewCPUIdRecord(), processFDRTSCWrapRecord(), processFDRWallTimeRecord(), and llvm::Error::success().
Referenced by loadFDRLog().
| Error processFDRNewBufferRecord | ( | FDRState & | State, |
| uint8_t | RecordFirstByte, | ||
| DataExtractor & | RecordExtractor | ||
| ) |
State transition when a NewBufferRecord is encountered.
Definition at line 156 of file Trace.cpp.
References FDRState::Expects, llvm::DataExtractor::getU16(), llvm::make_error_code(), FDRState::NEW_BUFFER_RECORD_OR_EOF, llvm::Error::success(), FDRState::ThreadId, and FDRState::WALLCLOCK_RECORD.
Referenced by processFDRMetadataRecord().
| Error processFDRNewCPUIdRecord | ( | FDRState & | State, |
| uint8_t | RecordFirstByte, | ||
| DataExtractor & | RecordExtractor | ||
| ) |
State transition when a NewCPUIdRecord is encountered.
Definition at line 181 of file Trace.cpp.
References FDRState::BaseTSC, FDRState::CPUId, FDRState::Expects, FDRState::FUNCTION_SEQUENCE, llvm::DataExtractor::getU16(), llvm::DataExtractor::getU64(), llvm::make_error_code(), FDRState::NEW_CPU_ID_RECORD, and llvm::Error::success().
Referenced by processFDRMetadataRecord().
| Error processFDRTSCWrapRecord | ( | FDRState & | State, |
| uint8_t | RecordFirstByte, | ||
| DataExtractor & | RecordExtractor | ||
| ) |
State transition when a TSCWrapRecord (overflow detection) is encountered.
Definition at line 196 of file Trace.cpp.
References FDRState::BaseTSC, FDRState::Expects, FDRState::FUNCTION_SEQUENCE, llvm::DataExtractor::getU64(), llvm::make_error_code(), and llvm::Error::success().
Referenced by processFDRMetadataRecord().
| Error processFDRWallTimeRecord | ( | FDRState & | State, |
| uint8_t | RecordFirstByte, | ||
| DataExtractor & | RecordExtractor | ||
| ) |
State transition when a WallTimeMarkerRecord is encountered.
Definition at line 208 of file Trace.cpp.
References FDRState::Expects, llvm::make_error_code(), FDRState::NEW_CPU_ID_RECORD, llvm::Error::success(), and FDRState::WALLCLOCK_RECORD.
Referenced by processFDRMetadataRecord().
| Error readBinaryFormatHeader | ( | StringRef | Data, |
| XRayFileHeader & | FileHeader | ||
| ) |
Definition at line 28 of file Trace.cpp.
References llvm::StringRef::bytes_begin(), llvm::xray::XRayFileHeader::ConstantTSC, llvm::xray::XRayFileHeader::CycleFrequency, llvm::xray::XRayFileHeader::FreeFormData, llvm::DataExtractor::getU16(), llvm::DataExtractor::getU32(), llvm::DataExtractor::getU64(), llvm::make_error_code(), llvm::xray::XRayFileHeader::NonstopTSC, llvm::Error::success(), llvm::xray::XRayFileHeader::Type, and llvm::xray::XRayFileHeader::Version.
Referenced by loadFDRLog(), and loadNaiveFormatLog().
1.8.6