From: Adrian McCarthy Date: Thu, 22 Jun 2017 18:43:18 +0000 (+0000) Subject: Add IDs and clone methods to NativeRawSymbol X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dba69154c2c801a880c07faa606591dfd11097d9;p=llvm Add IDs and clone methods to NativeRawSymbol All NativeRawSymbols will have a unique symbol ID (retrievable via getSymIndexId). For now, these are initialized to 0, but soon the NativeSession will be responsible for creating the raw symbols, and it will assign unique IDs. The symbol cache in the NativeSession will also require the ability to clone raw symbols, so I've provided implementations for that as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306042 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h index 22ed61910d9..1687737f0e7 100644 --- a/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h +++ b/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h @@ -18,7 +18,11 @@ namespace pdb { class NativeCompilandSymbol : public NativeRawSymbol { public: - NativeCompilandSymbol(NativeSession &Session, DbiModuleDescriptor MI); + NativeCompilandSymbol(NativeSession &Session, uint32_t SymbolId, + DbiModuleDescriptor MI); + + std::unique_ptr clone() const override; + PDB_SymType getSymTag() const override; bool isEditAndContinueEnabled() const override; uint32_t getLexicalParentId() const override; diff --git a/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h index 9516810539b..15bac78df19 100644 --- a/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h +++ b/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h @@ -18,7 +18,9 @@ namespace pdb { class NativeExeSymbol : public NativeRawSymbol { public: - NativeExeSymbol(NativeSession &Session); + NativeExeSymbol(NativeSession &Session, uint32_t SymbolId); + + std::unique_ptr clone() const override; std::unique_ptr findChildren(PDB_SymType Type) const override; diff --git a/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h index e1e78035ff3..5e4aaafff1a 100644 --- a/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h +++ b/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h @@ -19,7 +19,9 @@ class NativeSession; class NativeRawSymbol : public IPDBRawSymbol { public: - explicit NativeRawSymbol(NativeSession &PDBSession); + NativeRawSymbol(NativeSession &PDBSession, uint32_t SymbolId); + + virtual std::unique_ptr clone() const = 0; void dump(raw_ostream &OS, int Indent) const override; @@ -201,6 +203,7 @@ public: protected: NativeSession &Session; + uint32_t SymbolId; }; } diff --git a/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp b/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp index 77f832582f8..bd5cdd4691e 100644 --- a/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp +++ b/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp @@ -13,13 +13,18 @@ namespace llvm { namespace pdb { NativeCompilandSymbol::NativeCompilandSymbol(NativeSession &Session, + uint32_t SymbolId, DbiModuleDescriptor MI) - : NativeRawSymbol(Session), Module(MI) {} + : NativeRawSymbol(Session, SymbolId), Module(MI) {} PDB_SymType NativeCompilandSymbol::getSymTag() const { return PDB_SymType::Compiland; } +std::unique_ptr NativeCompilandSymbol::clone() const { + return std::make_unique(Session, SymbolId, Module); +} + bool NativeCompilandSymbol::isEditAndContinueEnabled() const { return Module.hasECInfo(); } diff --git a/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp b/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp index 97319fd77d1..c2312004116 100644 --- a/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp +++ b/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp @@ -34,7 +34,7 @@ NativeEnumModules::getChildAtIndex(uint32_t Index) const { return nullptr; return std::unique_ptr(new PDBSymbolCompiland( Session, std::unique_ptr(new NativeCompilandSymbol( - Session, Modules.getModuleDescriptor(Index))))); + Session, 0, Modules.getModuleDescriptor(Index))))); } std::unique_ptr NativeEnumModules::getNext() { diff --git a/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp b/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp index bb52560be16..36731f586d2 100644 --- a/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp +++ b/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp @@ -17,8 +17,12 @@ namespace llvm { namespace pdb { -NativeExeSymbol::NativeExeSymbol(NativeSession &Session) - : NativeRawSymbol(Session), File(Session.getPDBFile()) {} +NativeExeSymbol::NativeExeSymbol(NativeSession &Session, uint32_t SymbolId) + : NativeRawSymbol(Session, SymbolId), File(Session.getPDBFile()) {} + +std::unique_ptr NativeExeSymbol::clone() const { + return std::make_unique(Session, SymbolId); +} std::unique_ptr NativeExeSymbol::findChildren(PDB_SymType Type) const { diff --git a/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp b/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp index 70968d4330b..ed6db63edba 100644 --- a/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp +++ b/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp @@ -22,8 +22,8 @@ using namespace llvm; using namespace llvm::pdb; -NativeRawSymbol::NativeRawSymbol(NativeSession &PDBSession) - : Session(PDBSession) {} +NativeRawSymbol::NativeRawSymbol(NativeSession &PDBSession, uint32_t SymbolId) + : Session(PDBSession), SymbolId(SymbolId) {} void NativeRawSymbol::dump(raw_ostream &OS, int Indent) const {} @@ -253,9 +253,7 @@ uint32_t NativeRawSymbol::getSubTypeId() const { std::string NativeRawSymbol::getSymbolsFileName() const { return ""; } -uint32_t NativeRawSymbol::getSymIndexId() const { - return 0; -} +uint32_t NativeRawSymbol::getSymIndexId() const { return SymbolId; } uint32_t NativeRawSymbol::getTargetOffset() const { return 0; diff --git a/lib/DebugInfo/PDB/Native/NativeSession.cpp b/lib/DebugInfo/PDB/Native/NativeSession.cpp index c59cf866d1c..3ab381e76e6 100644 --- a/lib/DebugInfo/PDB/Native/NativeSession.cpp +++ b/lib/DebugInfo/PDB/Native/NativeSession.cpp @@ -71,7 +71,7 @@ uint64_t NativeSession::getLoadAddress() const { return 0; } void NativeSession::setLoadAddress(uint64_t Address) {} std::unique_ptr NativeSession::getGlobalScope() { - auto RawSymbol = llvm::make_unique(*this); + auto RawSymbol = llvm::make_unique(*this, 0); auto PdbSymbol(PDBSymbol::create(*this, std::move(RawSymbol))); std::unique_ptr ExeSymbol( static_cast(PdbSymbol.release()));