OSDN Git Service

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 22ed619..1687737 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 9516810..15bac78 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 e1e7803..5e4aaaf 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 77f8325..bd5cdd4 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 97319fd..c231200 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 bb52560..36731f5 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 70968d4..ed6db63 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 c59cf86..3ab381e 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()));