[llvm] r306042 - Add IDs and clone methods to NativeRawSymbol

Adrian McCarthy via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 22 11:43:18 PDT 2017


Author: amccarth
Date: Thu Jun 22 13:43:18 2017
New Revision: 306042

URL: http://llvm.org/viewvc/llvm-project?rev=306042&view=rev
Log:
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.

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

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h?rev=306042&r1=306041&r2=306042&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h Thu Jun 22 13:43:18 2017
@@ -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;

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h?rev=306042&r1=306041&r2=306042&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h Thu Jun 22 13:43:18 2017
@@ -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;

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h?rev=306042&r1=306041&r2=306042&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h Thu Jun 22 13:43:18 2017
@@ -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;
 };
 
 }

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp?rev=306042&r1=306041&r2=306042&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp Thu Jun 22 13:43:18 2017
@@ -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();
 }

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp?rev=306042&r1=306041&r2=306042&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp Thu Jun 22 13:43:18 2017
@@ -34,7 +34,7 @@ NativeEnumModules::getChildAtIndex(uint3
     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() {

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp?rev=306042&r1=306041&r2=306042&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp Thu Jun 22 13:43:18 2017
@@ -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<NativeRawSymbol> NativeExeSymbol::clone() const {
+  return std::make_unique<NativeExeSymbol>(Session, SymbolId);
+}
 
 std::unique_ptr<IPDBEnumSymbols>
 NativeExeSymbol::findChildren(PDB_SymType Type) const {

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp?rev=306042&r1=306041&r2=306042&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp Thu Jun 22 13:43:18 2017
@@ -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()
 
 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;

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp?rev=306042&r1=306041&r2=306042&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp Thu Jun 22 13:43:18 2017
@@ -71,7 +71,7 @@ uint64_t NativeSession::getLoadAddress()
 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()));




More information about the llvm-commits mailing list