[llvm] r296049 - Implement some methods for NativeRawSymbol

Adrian McCarthy via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 23 16:10:48 PST 2017


Author: amccarth
Date: Thu Feb 23 18:10:47 2017
New Revision: 296049

URL: http://llvm.org/viewvc/llvm-project?rev=296049&view=rev
Log:
Implement some methods for NativeRawSymbol

This allows the ability to call IPDBSession::getGlobalScope with a NativeSession and
to then query it for some basic fields from the PDB's InfoStream.
Note that the symbols now have non-const references back to the Session so that
NativeRawSymbol can access the PDBFile through the Session.

Differential Revision: https://reviews.llvm.org/D30314

Modified:
    llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h
    llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h
    llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp
    llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h?rev=296049&r1=296048&r2=296049&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h Thu Feb 23 18:10:47 2017
@@ -31,7 +31,7 @@ public:
 
   uint64_t getLoadAddress() const override;
   void setLoadAddress(uint64_t Address) override;
-  std::unique_ptr<PDBSymbolExe> getGlobalScope() const override;
+  std::unique_ptr<PDBSymbolExe> getGlobalScope() override;
   std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override;
 
   std::unique_ptr<PDBSymbol>

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h?rev=296049&r1=296048&r2=296049&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h Thu Feb 23 18:10:47 2017
@@ -28,7 +28,7 @@ public:
 
   virtual uint64_t getLoadAddress() const = 0;
   virtual void setLoadAddress(uint64_t Address) = 0;
-  virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() const = 0;
+  virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() = 0;
   virtual std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const = 0;
 
   template <typename T>

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=296049&r1=296048&r2=296049&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h Thu Feb 23 18:10:47 2017
@@ -19,7 +19,7 @@ class NativeSession;
 
 class NativeRawSymbol : public IPDBRawSymbol {
 public:
-  explicit NativeRawSymbol(const NativeSession &PDBSession);
+  explicit NativeRawSymbol(NativeSession &PDBSession);
 
   void dump(raw_ostream &OS, int Indent) const override;
 
@@ -196,6 +196,9 @@ public:
   bool isVolatileType() const override;
   bool wasInlined() const override;
   std::string getUnused() const override;
+
+private:
+  NativeSession &Session;
 };
 
 }

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h?rev=296049&r1=296048&r2=296049&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h Thu Feb 23 18:10:47 2017
@@ -32,7 +32,7 @@ public:
 
   uint64_t getLoadAddress() const override;
   void setLoadAddress(uint64_t Address) override;
-  std::unique_ptr<PDBSymbolExe> getGlobalScope() const override;
+  std::unique_ptr<PDBSymbolExe> getGlobalScope() override;
   std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override;
 
   std::unique_ptr<PDBSymbol>

Modified: llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp?rev=296049&r1=296048&r2=296049&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp Thu Feb 23 18:10:47 2017
@@ -140,7 +140,7 @@ void DIASession::setLoadAddress(uint64_t
   Session->put_loadAddress(Address);
 }
 
-std::unique_ptr<PDBSymbolExe> DIASession::getGlobalScope() const {
+std::unique_ptr<PDBSymbolExe> DIASession::getGlobalScope() {
   CComPtr<IDiaSymbol> GlobalScope;
   if (S_OK != Session->get_globalScope(&GlobalScope))
     return nullptr;

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=296049&r1=296048&r2=296049&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp Thu Feb 23 18:10:47 2017
@@ -10,7 +10,9 @@
 #include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
+#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
 #include "llvm/DebugInfo/PDB/PDBExtras.h"
 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
 #include "llvm/Support/ConvertUTF.h"
@@ -19,7 +21,8 @@
 using namespace llvm;
 using namespace llvm::pdb;
 
-NativeRawSymbol::NativeRawSymbol(const NativeSession &PDBSession) {}
+NativeRawSymbol::NativeRawSymbol(NativeSession &PDBSession)
+  : Session(PDBSession) {}
 
 void NativeRawSymbol::dump(raw_ostream &OS, int Indent) const {}
 
@@ -62,6 +65,11 @@ uint32_t NativeRawSymbol::getAddressSect
 }
 
 uint32_t NativeRawSymbol::getAge() const {
+  auto &File = Session.getPDBFile();
+  auto IS = File.getPDBInfoStream();
+  if (IS)
+    return IS->getAge();
+  consumeError(IS.takeError());
   return 0;
 }
 
@@ -248,7 +256,7 @@ uint32_t NativeRawSymbol::getSubTypeId()
 }
 
 std::string NativeRawSymbol::getSymbolsFileName() const {
-  return 0;
+  return Session.getPDBFile().getFilePath();
 }
 
 uint32_t NativeRawSymbol::getSymIndexId() const {
@@ -328,7 +336,12 @@ PDB_SymType NativeRawSymbol::getSymTag()
 }
 
 PDB_UniqueId NativeRawSymbol::getGuid() const {
-  return {{0}};
+  auto &File = Session.getPDBFile();
+  auto IS = File.getPDBInfoStream();
+  if (IS)
+    return IS->getGuid();
+  consumeError(IS.takeError());
+  return PDB_UniqueId{{0}};
 }
 
 int32_t NativeRawSymbol::getOffset() const {

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=296049&r1=296048&r2=296049&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp Thu Feb 23 18:10:47 2017
@@ -14,6 +14,7 @@
 #include "llvm/DebugInfo/PDB/GenericError.h"
 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
 #include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
+#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
 #include "llvm/DebugInfo/PDB/Native/RawError.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
@@ -68,8 +69,12 @@ uint64_t NativeSession::getLoadAddress()
 
 void NativeSession::setLoadAddress(uint64_t Address) {}
 
-std::unique_ptr<PDBSymbolExe> NativeSession::getGlobalScope() const {
-  return nullptr;
+std::unique_ptr<PDBSymbolExe> NativeSession::getGlobalScope() {
+  auto RawSymbol = llvm::make_unique<NativeRawSymbol>(*this);
+  auto PdbSymbol(PDBSymbol::create(*this, std::move(RawSymbol)));
+  std::unique_ptr<PDBSymbolExe> ExeSymbol(
+    static_cast<PDBSymbolExe *>(PdbSymbol.release()));
+  return ExeSymbol;
 }
 
 std::unique_ptr<PDBSymbol>




More information about the llvm-commits mailing list