#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/DebugInfo/MSF/MSFCommon.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
#include "llvm/DebugInfo/PDB/Native/DbiModuleList.h"
#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
#include "llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h"
#include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"
#include "llvm/DebugInfo/PDB/Native/NativeEnumInjectedSources.h"
#include "llvm/DebugInfo/PDB/Native/NativeExeSymbol.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
#include "llvm/DebugInfo/PDB/Native/RawError.h"
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
#include "llvm/DebugInfo/PDB/Native/SymbolCache.h"
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/COFF.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/BinaryByteStream.h"
#include "llvm/Support/BinaryStreamArray.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include <algorithm>
#include <cassert>
#include <memory>
#include <utility>
usingnamespacellvm;
usingnamespacellvm::msf;
usingnamespacellvm::pdb;
namespace llvm {
namespace codeview {
DebugInfo;
}
}
static DbiStream *getDbiStreamPtr(PDBFile &File) { … }
NativeSession::NativeSession(std::unique_ptr<PDBFile> PdbFile,
std::unique_ptr<BumpPtrAllocator> Allocator)
: … { … }
NativeSession::~NativeSession() = default;
Error NativeSession::createFromPdb(std::unique_ptr<MemoryBuffer> Buffer,
std::unique_ptr<IPDBSession> &Session) { … }
static Expected<std::unique_ptr<PDBFile>>
loadPdbFile(StringRef PdbPath, std::unique_ptr<BumpPtrAllocator> &Allocator) { … }
Error NativeSession::createFromPdbPath(StringRef PdbPath,
std::unique_ptr<IPDBSession> &Session) { … }
static Expected<std::string> getPdbPathFromExe(StringRef ExePath) { … }
Error NativeSession::createFromExe(StringRef ExePath,
std::unique_ptr<IPDBSession> &Session) { … }
Expected<std::string>
NativeSession::searchForPdb(const PdbSearchOptions &Opts) { … }
uint64_t NativeSession::getLoadAddress() const { … }
bool NativeSession::setLoadAddress(uint64_t Address) { … }
std::unique_ptr<PDBSymbolExe> NativeSession::getGlobalScope() { … }
std::unique_ptr<PDBSymbol>
NativeSession::getSymbolById(SymIndexId SymbolId) const { … }
bool NativeSession::addressForVA(uint64_t VA, uint32_t &Section,
uint32_t &Offset) const { … }
bool NativeSession::addressForRVA(uint32_t RVA, uint32_t &Section,
uint32_t &Offset) const { … }
std::unique_ptr<PDBSymbol>
NativeSession::findSymbolByAddress(uint64_t Address, PDB_SymType Type) { … }
std::unique_ptr<PDBSymbol> NativeSession::findSymbolByRVA(uint32_t RVA,
PDB_SymType Type) { … }
std::unique_ptr<PDBSymbol>
NativeSession::findSymbolBySectOffset(uint32_t Sect, uint32_t Offset,
PDB_SymType Type) { … }
std::unique_ptr<IPDBEnumLineNumbers>
NativeSession::findLineNumbers(const PDBSymbolCompiland &Compiland,
const IPDBSourceFile &File) const { … }
std::unique_ptr<IPDBEnumLineNumbers>
NativeSession::findLineNumbersByAddress(uint64_t Address,
uint32_t Length) const { … }
std::unique_ptr<IPDBEnumLineNumbers>
NativeSession::findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const { … }
std::unique_ptr<IPDBEnumLineNumbers>
NativeSession::findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset,
uint32_t Length) const { … }
std::unique_ptr<IPDBEnumSourceFiles>
NativeSession::findSourceFiles(const PDBSymbolCompiland *Compiland,
StringRef Pattern,
PDB_NameSearchFlags Flags) const { … }
std::unique_ptr<IPDBSourceFile>
NativeSession::findOneSourceFile(const PDBSymbolCompiland *Compiland,
StringRef Pattern,
PDB_NameSearchFlags Flags) const { … }
std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
NativeSession::findCompilandsForSourceFile(StringRef Pattern,
PDB_NameSearchFlags Flags) const { … }
std::unique_ptr<PDBSymbolCompiland>
NativeSession::findOneCompilandForSourceFile(StringRef Pattern,
PDB_NameSearchFlags Flags) const { … }
std::unique_ptr<IPDBEnumSourceFiles> NativeSession::getAllSourceFiles() const { … }
std::unique_ptr<IPDBEnumSourceFiles> NativeSession::getSourceFilesForCompiland(
const PDBSymbolCompiland &Compiland) const { … }
std::unique_ptr<IPDBSourceFile>
NativeSession::getSourceFileById(uint32_t FileId) const { … }
std::unique_ptr<IPDBEnumDataStreams> NativeSession::getDebugStreams() const { … }
std::unique_ptr<IPDBEnumTables> NativeSession::getEnumTables() const { … }
std::unique_ptr<IPDBEnumInjectedSources>
NativeSession::getInjectedSources() const { … }
std::unique_ptr<IPDBEnumSectionContribs>
NativeSession::getSectionContribs() const { … }
std::unique_ptr<IPDBEnumFrameData>
NativeSession::getFrameData() const { … }
void NativeSession::initializeExeSymbol() { … }
NativeExeSymbol &NativeSession::getNativeGlobalScope() const { … }
uint32_t NativeSession::getRVAFromSectOffset(uint32_t Section,
uint32_t Offset) const { … }
uint64_t NativeSession::getVAFromSectOffset(uint32_t Section,
uint32_t Offset) const { … }
bool NativeSession::moduleIndexForVA(uint64_t VA, uint16_t &ModuleIndex) const { … }
bool NativeSession::moduleIndexForSectOffset(uint32_t Sect, uint32_t Offset,
uint16_t &ModuleIndex) const { … }
void NativeSession::parseSectionContribs() { … }
Expected<ModuleDebugStreamRef>
NativeSession::getModuleDebugStream(uint32_t Index) const { … }