#include "llvm/DebugInfo/Symbolize/Symbolize.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/DebugInfo/BTF/BTFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/PDB/PDB.h"
#include "llvm/DebugInfo/PDB/PDBContext.h"
#include "llvm/DebugInfo/Symbolize/SymbolizableObjectFile.h"
#include "llvm/Demangle/Demangle.h"
#include "llvm/Object/BuildID.h"
#include "llvm/Object/COFF.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/MachO.h"
#include "llvm/Object/MachOUniversal.h"
#include "llvm/Support/CRC.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include <algorithm>
#include <cassert>
#include <cstring>
namespace llvm {
namespace codeview {
DebugInfo;
}
namespace symbolize {
LLVMSymbolizer::LLVMSymbolizer() = default;
LLVMSymbolizer::LLVMSymbolizer(const Options &Opts)
: … { … }
LLVMSymbolizer::~LLVMSymbolizer() = default;
template <typename T>
Expected<DILineInfo>
LLVMSymbolizer::symbolizeCodeCommon(const T &ModuleSpecifier,
object::SectionedAddress ModuleOffset) { … }
Expected<DILineInfo>
LLVMSymbolizer::symbolizeCode(const ObjectFile &Obj,
object::SectionedAddress ModuleOffset) { … }
Expected<DILineInfo>
LLVMSymbolizer::symbolizeCode(StringRef ModuleName,
object::SectionedAddress ModuleOffset) { … }
Expected<DILineInfo>
LLVMSymbolizer::symbolizeCode(ArrayRef<uint8_t> BuildID,
object::SectionedAddress ModuleOffset) { … }
template <typename T>
Expected<DIInliningInfo> LLVMSymbolizer::symbolizeInlinedCodeCommon(
const T &ModuleSpecifier, object::SectionedAddress ModuleOffset) { … }
Expected<DIInliningInfo>
LLVMSymbolizer::symbolizeInlinedCode(const ObjectFile &Obj,
object::SectionedAddress ModuleOffset) { … }
Expected<DIInliningInfo>
LLVMSymbolizer::symbolizeInlinedCode(StringRef ModuleName,
object::SectionedAddress ModuleOffset) { … }
Expected<DIInliningInfo>
LLVMSymbolizer::symbolizeInlinedCode(ArrayRef<uint8_t> BuildID,
object::SectionedAddress ModuleOffset) { … }
template <typename T>
Expected<DIGlobal>
LLVMSymbolizer::symbolizeDataCommon(const T &ModuleSpecifier,
object::SectionedAddress ModuleOffset) { … }
Expected<DIGlobal>
LLVMSymbolizer::symbolizeData(const ObjectFile &Obj,
object::SectionedAddress ModuleOffset) { … }
Expected<DIGlobal>
LLVMSymbolizer::symbolizeData(StringRef ModuleName,
object::SectionedAddress ModuleOffset) { … }
Expected<DIGlobal>
LLVMSymbolizer::symbolizeData(ArrayRef<uint8_t> BuildID,
object::SectionedAddress ModuleOffset) { … }
template <typename T>
Expected<std::vector<DILocal>>
LLVMSymbolizer::symbolizeFrameCommon(const T &ModuleSpecifier,
object::SectionedAddress ModuleOffset) { … }
Expected<std::vector<DILocal>>
LLVMSymbolizer::symbolizeFrame(const ObjectFile &Obj,
object::SectionedAddress ModuleOffset) { … }
Expected<std::vector<DILocal>>
LLVMSymbolizer::symbolizeFrame(StringRef ModuleName,
object::SectionedAddress ModuleOffset) { … }
Expected<std::vector<DILocal>>
LLVMSymbolizer::symbolizeFrame(ArrayRef<uint8_t> BuildID,
object::SectionedAddress ModuleOffset) { … }
template <typename T>
Expected<std::vector<DILineInfo>>
LLVMSymbolizer::findSymbolCommon(const T &ModuleSpecifier, StringRef Symbol,
uint64_t Offset) { … }
Expected<std::vector<DILineInfo>>
LLVMSymbolizer::findSymbol(const ObjectFile &Obj, StringRef Symbol,
uint64_t Offset) { … }
Expected<std::vector<DILineInfo>>
LLVMSymbolizer::findSymbol(StringRef ModuleName, StringRef Symbol,
uint64_t Offset) { … }
Expected<std::vector<DILineInfo>>
LLVMSymbolizer::findSymbol(ArrayRef<uint8_t> BuildID, StringRef Symbol,
uint64_t Offset) { … }
void LLVMSymbolizer::flush() { … }
namespace {
std::string getDarwinDWARFResourceForPath(const std::string &Path,
const std::string &Basename) { … }
bool checkFileCRC(StringRef Path, uint32_t CRCHash) { … }
bool getGNUDebuglinkContents(const ObjectFile *Obj, std::string &DebugName,
uint32_t &CRCHash) { … }
bool darwinDsymMatchesBinary(const MachOObjectFile *DbgObj,
const MachOObjectFile *Obj) { … }
}
ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath,
const MachOObjectFile *MachExeObj,
const std::string &ArchName) { … }
ObjectFile *LLVMSymbolizer::lookUpDebuglinkObject(const std::string &Path,
const ObjectFile *Obj,
const std::string &ArchName) { … }
ObjectFile *LLVMSymbolizer::lookUpBuildIDObject(const std::string &Path,
const ELFObjectFileBase *Obj,
const std::string &ArchName) { … }
bool LLVMSymbolizer::findDebugBinary(const std::string &OrigPath,
const std::string &DebuglinkName,
uint32_t CRCHash, std::string &Result) { … }
static StringRef getBuildIDStr(ArrayRef<uint8_t> BuildID) { … }
bool LLVMSymbolizer::getOrFindDebugBinary(const ArrayRef<uint8_t> BuildID,
std::string &Result) { … }
Expected<LLVMSymbolizer::ObjectPair>
LLVMSymbolizer::getOrCreateObjectPair(const std::string &Path,
const std::string &ArchName) { … }
Expected<ObjectFile *>
LLVMSymbolizer::getOrCreateObject(const std::string &Path,
const std::string &ArchName) { … }
Expected<SymbolizableModule *>
LLVMSymbolizer::createModuleInfo(const ObjectFile *Obj,
std::unique_ptr<DIContext> Context,
StringRef ModuleName) { … }
Expected<SymbolizableModule *>
LLVMSymbolizer::getOrCreateModuleInfo(StringRef ModuleName) { … }
static bool useBTFContext(const ObjectFile &Obj) { … }
Expected<SymbolizableModule *>
LLVMSymbolizer::getOrCreateModuleInfo(const ObjectFile &Obj) { … }
Expected<SymbolizableModule *>
LLVMSymbolizer::getOrCreateModuleInfo(ArrayRef<uint8_t> BuildID) { … }
namespace {
StringRef demanglePE32ExternCFunc(StringRef SymbolName) { … }
}
std::string
LLVMSymbolizer::DemangleName(const std::string &Name,
const SymbolizableModule *DbiModuleDescriptor) { … }
void LLVMSymbolizer::recordAccess(CachedBinary &Bin) { … }
void LLVMSymbolizer::pruneCache() { … }
void CachedBinary::pushEvictor(std::function<void()> NewEvictor) { … }
}
}