diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSession.cpp | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSession.cpp')
-rw-r--r-- | contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSession.cpp | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSession.cpp b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSession.cpp index 5d7946cdc2..6a7e7ee4d8 100644 --- a/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSession.cpp +++ b/contrib/libs/llvm12/lib/DebugInfo/PDB/Native/NativeSession.cpp @@ -13,7 +13,7 @@ #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBSourceFile.h" #include "llvm/DebugInfo/PDB/Native/DbiStream.h" -#include "llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h" +#include "llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h" #include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h" #include "llvm/DebugInfo/PDB/Native/NativeEnumInjectedSources.h" #include "llvm/DebugInfo/PDB/Native/NativeEnumTypes.h" @@ -57,7 +57,7 @@ static DbiStream *getDbiStreamPtr(PDBFile &File) { NativeSession::NativeSession(std::unique_ptr<PDBFile> PdbFile, std::unique_ptr<BumpPtrAllocator> Allocator) : Pdb(std::move(PdbFile)), Allocator(std::move(Allocator)), - Cache(*this, getDbiStreamPtr(*Pdb)), AddrToModuleIndex(IMapAllocator) {} + Cache(*this, getDbiStreamPtr(*Pdb)), AddrToModuleIndex(IMapAllocator) {} NativeSession::~NativeSession() = default; @@ -256,9 +256,9 @@ std::unique_ptr<PDBSymbol> NativeSession::findSymbolByRVA(uint32_t RVA, std::unique_ptr<PDBSymbol> NativeSession::findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, PDB_SymType Type) { - if (AddrToModuleIndex.empty()) - parseSectionContribs(); - + if (AddrToModuleIndex.empty()) + parseSectionContribs(); + return Cache.findSymbolBySectOffset(Sect, Offset, Type); } @@ -276,14 +276,14 @@ NativeSession::findLineNumbersByAddress(uint64_t Address, std::unique_ptr<IPDBEnumLineNumbers> NativeSession::findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const { - return Cache.findLineNumbersByVA(getLoadAddress() + RVA, Length); + return Cache.findLineNumbersByVA(getLoadAddress() + RVA, Length); } std::unique_ptr<IPDBEnumLineNumbers> NativeSession::findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, uint32_t Length) const { uint64_t VA = getVAFromSectOffset(Section, Offset); - return Cache.findLineNumbersByVA(VA, Length); + return Cache.findLineNumbersByVA(VA, Length); } std::unique_ptr<IPDBEnumSourceFiles> @@ -390,74 +390,74 @@ uint64_t NativeSession::getVAFromSectOffset(uint32_t Section, uint32_t Offset) const { return LoadAddress + getRVAFromSectOffset(Section, Offset); } - -bool NativeSession::moduleIndexForVA(uint64_t VA, uint16_t &ModuleIndex) const { - ModuleIndex = 0; - auto Iter = AddrToModuleIndex.find(VA); - if (Iter == AddrToModuleIndex.end()) - return false; - ModuleIndex = Iter.value(); - return true; -} - -bool NativeSession::moduleIndexForSectOffset(uint32_t Sect, uint32_t Offset, - uint16_t &ModuleIndex) const { - ModuleIndex = 0; - auto Iter = AddrToModuleIndex.find(getVAFromSectOffset(Sect, Offset)); - if (Iter == AddrToModuleIndex.end()) - return false; - ModuleIndex = Iter.value(); - return true; -} - -void NativeSession::parseSectionContribs() { - auto Dbi = Pdb->getPDBDbiStream(); - if (!Dbi) - return; - - class Visitor : public ISectionContribVisitor { - NativeSession &Session; - IMap &AddrMap; - - public: - Visitor(NativeSession &Session, IMap &AddrMap) - : Session(Session), AddrMap(AddrMap) {} - void visit(const SectionContrib &C) override { - if (C.Size == 0) - return; - - uint64_t VA = Session.getVAFromSectOffset(C.ISect, C.Off); - uint64_t End = VA + C.Size; - - // Ignore overlapping sections based on the assumption that a valid - // PDB file should not have overlaps. - if (!AddrMap.overlaps(VA, End)) - AddrMap.insert(VA, End, C.Imod); - } - void visit(const SectionContrib2 &C) override { visit(C.Base); } - }; - - Visitor V(*this, AddrToModuleIndex); - Dbi->visitSectionContributions(V); -} - -Expected<ModuleDebugStreamRef> -NativeSession::getModuleDebugStream(uint32_t Index) const { - auto *Dbi = getDbiStreamPtr(*Pdb); - assert(Dbi && "Dbi stream not present"); - - DbiModuleDescriptor Modi = Dbi->modules().getModuleDescriptor(Index); - - uint16_t ModiStream = Modi.getModuleStreamIndex(); - if (ModiStream == kInvalidStreamIndex) - return make_error<RawError>("Module stream not present"); - - std::unique_ptr<msf::MappedBlockStream> ModStreamData = - Pdb->createIndexedStream(ModiStream); - - ModuleDebugStreamRef ModS(Modi, std::move(ModStreamData)); - if (auto EC = ModS.reload()) - return std::move(EC); - - return std::move(ModS); -} + +bool NativeSession::moduleIndexForVA(uint64_t VA, uint16_t &ModuleIndex) const { + ModuleIndex = 0; + auto Iter = AddrToModuleIndex.find(VA); + if (Iter == AddrToModuleIndex.end()) + return false; + ModuleIndex = Iter.value(); + return true; +} + +bool NativeSession::moduleIndexForSectOffset(uint32_t Sect, uint32_t Offset, + uint16_t &ModuleIndex) const { + ModuleIndex = 0; + auto Iter = AddrToModuleIndex.find(getVAFromSectOffset(Sect, Offset)); + if (Iter == AddrToModuleIndex.end()) + return false; + ModuleIndex = Iter.value(); + return true; +} + +void NativeSession::parseSectionContribs() { + auto Dbi = Pdb->getPDBDbiStream(); + if (!Dbi) + return; + + class Visitor : public ISectionContribVisitor { + NativeSession &Session; + IMap &AddrMap; + + public: + Visitor(NativeSession &Session, IMap &AddrMap) + : Session(Session), AddrMap(AddrMap) {} + void visit(const SectionContrib &C) override { + if (C.Size == 0) + return; + + uint64_t VA = Session.getVAFromSectOffset(C.ISect, C.Off); + uint64_t End = VA + C.Size; + + // Ignore overlapping sections based on the assumption that a valid + // PDB file should not have overlaps. + if (!AddrMap.overlaps(VA, End)) + AddrMap.insert(VA, End, C.Imod); + } + void visit(const SectionContrib2 &C) override { visit(C.Base); } + }; + + Visitor V(*this, AddrToModuleIndex); + Dbi->visitSectionContributions(V); +} + +Expected<ModuleDebugStreamRef> +NativeSession::getModuleDebugStream(uint32_t Index) const { + auto *Dbi = getDbiStreamPtr(*Pdb); + assert(Dbi && "Dbi stream not present"); + + DbiModuleDescriptor Modi = Dbi->modules().getModuleDescriptor(Index); + + uint16_t ModiStream = Modi.getModuleStreamIndex(); + if (ModiStream == kInvalidStreamIndex) + return make_error<RawError>("Module stream not present"); + + std::unique_ptr<msf::MappedBlockStream> ModStreamData = + Pdb->createIndexedStream(ModiStream); + + ModuleDebugStreamRef ModS(Modi, std::move(ModStreamData)); + if (auto EC = ModS.reload()) + return std::move(EC); + + return std::move(ModS); +} |