]> granicus.if.org Git - llvm/commitdiff
Add IDs and clone methods to NativeRawSymbol
authorAdrian McCarthy <amccarth@google.com>
Thu, 22 Jun 2017 18:43:18 +0000 (18:43 +0000)
committerAdrian McCarthy <amccarth@google.com>
Thu, 22 Jun 2017 18:43:18 +0000 (18:43 +0000)
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

include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h
include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h
include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp
lib/DebugInfo/PDB/Native/NativeEnumModules.cpp
lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp
lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp
lib/DebugInfo/PDB/Native/NativeSession.cpp

index 22ed61910d94a6f2584696ed0363b38aa8deebf7..1687737f0e7f9c01df92e0bebc2e8be8af117f7b 100644 (file)
@@ -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<NativeRawSymbol> clone() const override;
+
   PDB_SymType getSymTag() const override;
   bool isEditAndContinueEnabled() const override;
   uint32_t getLexicalParentId() const override;
index 9516810539b6b617ddedf54ec01fb8fddf931f0d..15bac78df191b6b06b40f8a70f0820742c8ceed2 100644 (file)
@@ -18,7 +18,9 @@ namespace pdb {
 
 class NativeExeSymbol : public NativeRawSymbol {
 public:
-  NativeExeSymbol(NativeSession &Session);
+  NativeExeSymbol(NativeSession &Session, uint32_t SymbolId);
+
+  std::unique_ptr<NativeRawSymbol> clone() const override;
 
   std::unique_ptr<IPDBEnumSymbols>
   findChildren(PDB_SymType Type) const override;
index e1e78035ff38953967cd463ecbd20aa5157a78de..5e4aaafff1a902b574568bb6c2532807c47f95ee 100644 (file)
@@ -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<NativeRawSymbol> clone() const = 0;
 
   void dump(raw_ostream &OS, int Indent) const override;
 
@@ -201,6 +203,7 @@ public:
 
 protected:
   NativeSession &Session;
+  uint32_t SymbolId;
 };
 
 }
index 77f832582f82404de2fd12783542a4396f68aff2..bd5cdd4691e4150af3924fe3201b79d8b7f5e7bb 100644 (file)
@@ -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<NativeRawSymbol> NativeCompilandSymbol::clone() const {
+  return std::make_unique<NativeCompilandSymbol>(Session, SymbolId, Module);
+}
+
 bool NativeCompilandSymbol::isEditAndContinueEnabled() const {
   return Module.hasECInfo();
 }
index 97319fd77d117522ca94017b4d82bc39faf6d263..c23120041164a6967b09f12f10e53557d25df5a3 100644 (file)
@@ -34,7 +34,7 @@ NativeEnumModules::getChildAtIndex(uint32_t Index) const {
     return nullptr;
   return std::unique_ptr<PDBSymbol>(new PDBSymbolCompiland(
       Session, std::unique_ptr<IPDBRawSymbol>(new NativeCompilandSymbol(
-                   Session, Modules.getModuleDescriptor(Index)))));
+                   Session, 0, Modules.getModuleDescriptor(Index)))));
 }
 
 std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
index bb52560be167a84c5e83e152f1760dc8a55ebd05..36731f586d2f141413ff0637ba976d295aef491c 100644 (file)
 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<NativeRawSymbol> NativeExeSymbol::clone() const {
+  return std::make_unique<NativeExeSymbol>(Session, SymbolId);
+}
 
 std::unique_ptr<IPDBEnumSymbols>
 NativeExeSymbol::findChildren(PDB_SymType Type) const {
index 70968d4330b07e28515f211379abfd383adb04ca..ed6db63edbabf9fe6ba5f9070795f018946e6423 100644 (file)
@@ -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;
index c59cf866d1cd4b2f9d20a80d40ed334e0977dbad..3ab381e76e628e6f3c99c5d00337e56ec66e992f 100644 (file)
@@ -71,7 +71,7 @@ uint64_t NativeSession::getLoadAddress() const { return 0; }
 void NativeSession::setLoadAddress(uint64_t Address) {}
 
 std::unique_ptr<PDBSymbolExe> NativeSession::getGlobalScope() {
-  auto RawSymbol = llvm::make_unique<NativeExeSymbol>(*this);
+  auto RawSymbol = llvm::make_unique<NativeExeSymbol>(*this, 0);
   auto PdbSymbol(PDBSymbol::create(*this, std::move(RawSymbol)));
   std::unique_ptr<PDBSymbolExe> ExeSymbol(
       static_cast<PDBSymbolExe *>(PdbSymbol.release()));