#include <algorithm>
#include <cstdint>
#include <memory>
#include <type_traits>
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/Symbolize/SymbolizableModule.h"
#include "llvm/DebugInfo/Symbolize/SymbolizableObjectFile.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/BuildID.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/ProfileData/MemProf.h"
#include "llvm/ProfileData/MemProfData.inc"
#include "llvm/ProfileData/MemProfReader.h"
#include "llvm/ProfileData/SampleProf.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#define DEBUG_TYPE …
namespace llvm {
namespace memprof {
namespace {
template <class T = uint64_t> inline T alignedRead(const char *Ptr) { … }
Error checkBuffer(const MemoryBuffer &Buffer) { … }
llvm::SmallVector<SegmentEntry> readSegmentEntries(const char *Ptr) { … }
llvm::SmallVector<std::pair<uint64_t, MemInfoBlock>>
readMemInfoBlocksV3(const char *Ptr) { … }
llvm::SmallVector<std::pair<uint64_t, MemInfoBlock>>
readMemInfoBlocksV4(const char *Ptr) { … }
CallStackMap readStackInfo(const char *Ptr) { … }
bool mergeStackMap(const CallStackMap &From, CallStackMap &To) { … }
Error report(Error E, const StringRef Context) { … }
bool isRuntimePath(const StringRef Path) { … }
std::string getBuildIdString(const SegmentEntry &Entry) { … }
}
MemProfReader::MemProfReader(
llvm::DenseMap<FrameId, Frame> FrameIdMap,
llvm::MapVector<GlobalValue::GUID, IndexedMemProfRecord> ProfData)
: … { … }
Expected<std::unique_ptr<RawMemProfReader>>
RawMemProfReader::create(const Twine &Path, const StringRef ProfiledBinary,
bool KeepName) { … }
Expected<std::unique_ptr<RawMemProfReader>>
RawMemProfReader::create(std::unique_ptr<MemoryBuffer> Buffer,
const StringRef ProfiledBinary, bool KeepName) { … }
RawMemProfReader::~RawMemProfReader() { … }
bool RawMemProfReader::hasFormat(const StringRef Path) { … }
bool RawMemProfReader::hasFormat(const MemoryBuffer &Buffer) { … }
void RawMemProfReader::printYAML(raw_ostream &OS) { … }
Error RawMemProfReader::initialize(std::unique_ptr<MemoryBuffer> DataBuffer) { … }
Error RawMemProfReader::setupForSymbolization() { … }
Error RawMemProfReader::mapRawProfileToRecords() { … }
Error RawMemProfReader::symbolizeAndFilterStackFrames(
std::unique_ptr<llvm::symbolize::SymbolizableModule> Symbolizer) { … }
std::vector<std::string>
RawMemProfReader::peekBuildIds(MemoryBuffer *DataBuffer) { … }
llvm::SmallVector<std::pair<uint64_t, MemInfoBlock>>
RawMemProfReader::readMemInfoBlocks(const char *Ptr) { … }
Error RawMemProfReader::readRawProfile(
std::unique_ptr<MemoryBuffer> DataBuffer) { … }
object::SectionedAddress
RawMemProfReader::getModuleOffset(const uint64_t VirtualAddress) { … }
Error RawMemProfReader::readNextRecord(
GuidMemProfRecordPair &GuidRecord,
std::function<const Frame(const FrameId)> Callback) { … }
}
}