<div dir="ltr">This breaks for me on GCC 4.8:<div><br></div><div><div>../unittests/DebugInfo/PDB/PDBApiTest.cpp:66:33: error: ‘std::unique_ptr<llvm::pdb::PDBSymbolExe> {anonymous}::MockSession::getGlobalScope() const’ marked override, but does not override</div><div>   std::unique_ptr<PDBSymbolExe> getGlobalScope() const override {</div><div>                                 ^</div><div>../unittests/DebugInfo/PDB/PDBApiTest.cpp: In member function ‘virtual void {anonymous}::PDBApiTest::SetUp()’:</div><div>../unittests/DebugInfo/PDB/PDBApiTest.cpp:325:35: error: cannot allocate an object of abstract type ‘{anonymous}::MockSession’</div><div>     Session.reset(new MockSession());</div><div>                                   ^</div><div>../unittests/DebugInfo/PDB/PDBApiTest.cpp:63:7: note:   because the following virtual functions are pure within ‘{anonymous}::MockSession’:</div><div> class MockSession : public IPDBSession {</div><div>       ^</div><div>In file included from ../unittests/DebugInfo/PDB/PDBApiTest.cpp:15:0:</div><div>../include/llvm/DebugInfo/PDB/IPDBSession.h:31:41: note: <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>virtual std::unique_ptr<llvm::pdb::PDBSymbolExe> llvm::pdb::IPDBSession::getGlobalScope()</div><div>   virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() = 0;</div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 23, 2017 at 4:10 PM, Adrian McCarthy via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: amccarth<br>
Date: Thu Feb 23 18:10:47 2017<br>
New Revision: 296049<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=296049&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=296049&view=rev</a><br>
Log:<br>
Implement some methods for NativeRawSymbol<br>
<br>
This allows the ability to call IPDBSession::getGlobalScope with a NativeSession and<br>
to then query it for some basic fields from the PDB's InfoStream.<br>
Note that the symbols now have non-const references back to the Session so that<br>
NativeRawSymbol can access the PDBFile through the Session.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D30314" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D30314</a><br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/DIA/DIASession.h<br>
    llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/IPDBSession.h<br>
    llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/Native/<wbr>NativeRawSymbol.h<br>
    llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/Native/<wbr>NativeSession.h<br>
    llvm/trunk/lib/DebugInfo/PDB/<wbr>DIA/DIASession.cpp<br>
    llvm/trunk/lib/DebugInfo/PDB/<wbr>Native/NativeRawSymbol.cpp<br>
    llvm/trunk/lib/DebugInfo/PDB/<wbr>Native/NativeSession.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/DIA/DIASession.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIASession.h?rev=296049&r1=296048&r2=296049&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/DebugInfo/PDB/DIA/<wbr>DIASession.h?rev=296049&r1=<wbr>296048&r2=296049&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/DIA/DIASession.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/DIA/DIASession.h Thu Feb 23 18:10:47 2017<br>
@@ -31,7 +31,7 @@ public:<br>
<br>
   uint64_t getLoadAddress() const override;<br>
   void setLoadAddress(uint64_t Address) override;<br>
-  std::unique_ptr<PDBSymbolExe> getGlobalScope() const override;<br>
+  std::unique_ptr<PDBSymbolExe> getGlobalScope() override;<br>
   std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override;<br>
<br>
   std::unique_ptr<PDBSymbol><br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/IPDBSession.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/IPDBSession.h?rev=296049&r1=296048&r2=296049&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/DebugInfo/PDB/<wbr>IPDBSession.h?rev=296049&r1=<wbr>296048&r2=296049&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/IPDBSession.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/IPDBSession.h Thu Feb 23 18:10:47 2017<br>
@@ -28,7 +28,7 @@ public:<br>
<br>
   virtual uint64_t getLoadAddress() const = 0;<br>
   virtual void setLoadAddress(uint64_t Address) = 0;<br>
-  virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() const = 0;<br>
+  virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() = 0;<br>
   virtual std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const = 0;<br>
<br>
   template <typename T><br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/Native/<wbr>NativeRawSymbol.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h?rev=296049&r1=296048&r2=296049&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/DebugInfo/PDB/Native/<wbr>NativeRawSymbol.h?rev=296049&<wbr>r1=296048&r2=296049&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/Native/<wbr>NativeRawSymbol.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/Native/<wbr>NativeRawSymbol.h Thu Feb 23 18:10:47 2017<br>
@@ -19,7 +19,7 @@ class NativeSession;<br>
<br>
 class NativeRawSymbol : public IPDBRawSymbol {<br>
 public:<br>
-  explicit NativeRawSymbol(const NativeSession &PDBSession);<br>
+  explicit NativeRawSymbol(NativeSession &PDBSession);<br>
<br>
   void dump(raw_ostream &OS, int Indent) const override;<br>
<br>
@@ -196,6 +196,9 @@ public:<br>
   bool isVolatileType() const override;<br>
   bool wasInlined() const override;<br>
   std::string getUnused() const override;<br>
+<br>
+private:<br>
+  NativeSession &Session;<br>
 };<br>
<br>
 }<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/Native/<wbr>NativeSession.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeSession.h?rev=296049&r1=296048&r2=296049&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/DebugInfo/PDB/Native/<wbr>NativeSession.h?rev=296049&r1=<wbr>296048&r2=296049&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/Native/<wbr>NativeSession.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>DebugInfo/PDB/Native/<wbr>NativeSession.h Thu Feb 23 18:10:47 2017<br>
@@ -32,7 +32,7 @@ public:<br>
<br>
   uint64_t getLoadAddress() const override;<br>
   void setLoadAddress(uint64_t Address) override;<br>
-  std::unique_ptr<PDBSymbolExe> getGlobalScope() const override;<br>
+  std::unique_ptr<PDBSymbolExe> getGlobalScope() override;<br>
   std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override;<br>
<br>
   std::unique_ptr<PDBSymbol><br>
<br>
Modified: llvm/trunk/lib/DebugInfo/PDB/<wbr>DIA/DIASession.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp?rev=296049&r1=296048&r2=296049&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>DebugInfo/PDB/DIA/DIASession.<wbr>cpp?rev=296049&r1=296048&r2=<wbr>296049&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/DebugInfo/PDB/<wbr>DIA/DIASession.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/PDB/<wbr>DIA/DIASession.cpp Thu Feb 23 18:10:47 2017<br>
@@ -140,7 +140,7 @@ void DIASession::setLoadAddress(<wbr>uint64_t<br>
   Session->put_loadAddress(<wbr>Address);<br>
 }<br>
<br>
-std::unique_ptr<PDBSymbolExe> DIASession::getGlobalScope() const {<br>
+std::unique_ptr<PDBSymbolExe> DIASession::getGlobalScope() {<br>
   CComPtr<IDiaSymbol> GlobalScope;<br>
   if (S_OK != Session->get_globalScope(&<wbr>GlobalScope))<br>
     return nullptr;<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/PDB/<wbr>Native/NativeRawSymbol.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp?rev=296049&r1=296048&r2=296049&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>DebugInfo/PDB/Native/<wbr>NativeRawSymbol.cpp?rev=<wbr>296049&r1=296048&r2=296049&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/DebugInfo/PDB/<wbr>Native/NativeRawSymbol.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/PDB/<wbr>Native/NativeRawSymbol.cpp Thu Feb 23 18:10:47 2017<br>
@@ -10,7 +10,9 @@<br>
 #include "llvm/DebugInfo/PDB/Native/<wbr>NativeRawSymbol.h"<br>
 #include "llvm/ADT/ArrayRef.h"<br>
 #include "llvm/ADT/STLExtras.h"<br>
+#include "llvm/DebugInfo/PDB/Native/<wbr>InfoStream.h"<br>
 #include "llvm/DebugInfo/PDB/<wbr>IPDBEnumChildren.h"<br>
+#include "llvm/DebugInfo/PDB/Native/<wbr>PDBFile.h"<br>
 #include "llvm/DebugInfo/PDB/PDBExtras.<wbr>h"<br>
 #include "llvm/DebugInfo/PDB/Native/<wbr>NativeSession.h"<br>
 #include "llvm/Support/ConvertUTF.h"<br>
@@ -19,7 +21,8 @@<br>
 using namespace llvm;<br>
 using namespace llvm::pdb;<br>
<br>
-NativeRawSymbol::<wbr>NativeRawSymbol(const NativeSession &PDBSession) {}<br>
+NativeRawSymbol::<wbr>NativeRawSymbol(NativeSession &PDBSession)<br>
+  : Session(PDBSession) {}<br>
<br>
 void NativeRawSymbol::dump(raw_<wbr>ostream &OS, int Indent) const {}<br>
<br>
@@ -62,6 +65,11 @@ uint32_t NativeRawSymbol::<wbr>getAddressSect<br>
 }<br>
<br>
 uint32_t NativeRawSymbol::getAge() const {<br>
+  auto &File = Session.getPDBFile();<br>
+  auto IS = File.getPDBInfoStream();<br>
+  if (IS)<br>
+    return IS->getAge();<br>
+  consumeError(IS.takeError());<br>
   return 0;<br>
 }<br>
<br>
@@ -248,7 +256,7 @@ uint32_t NativeRawSymbol::getSubTypeId(<wbr>)<br>
 }<br>
<br>
 std::string NativeRawSymbol::<wbr>getSymbolsFileName() const {<br>
-  return 0;<br>
+  return Session.getPDBFile().<wbr>getFilePath();<br>
 }<br>
<br>
 uint32_t NativeRawSymbol::<wbr>getSymIndexId() const {<br>
@@ -328,7 +336,12 @@ PDB_SymType NativeRawSymbol::getSymTag()<br>
 }<br>
<br>
 PDB_UniqueId NativeRawSymbol::getGuid() const {<br>
-  return {{0}};<br>
+  auto &File = Session.getPDBFile();<br>
+  auto IS = File.getPDBInfoStream();<br>
+  if (IS)<br>
+    return IS->getGuid();<br>
+  consumeError(IS.takeError());<br>
+  return PDB_UniqueId{{0}};<br>
 }<br>
<br>
 int32_t NativeRawSymbol::getOffset() const {<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/PDB/<wbr>Native/NativeSession.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NativeSession.cpp?rev=296049&r1=296048&r2=296049&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>DebugInfo/PDB/Native/<wbr>NativeSession.cpp?rev=296049&<wbr>r1=296048&r2=296049&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/DebugInfo/PDB/<wbr>Native/NativeSession.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/PDB/<wbr>Native/NativeSession.cpp Thu Feb 23 18:10:47 2017<br>
@@ -14,6 +14,7 @@<br>
 #include "llvm/DebugInfo/PDB/<wbr>GenericError.h"<br>
 #include "llvm/DebugInfo/PDB/<wbr>IPDBEnumChildren.h"<br>
 #include "llvm/DebugInfo/PDB/<wbr>IPDBSourceFile.h"<br>
+#include "llvm/DebugInfo/PDB/Native/<wbr>NativeRawSymbol.h"<br>
 #include "llvm/DebugInfo/PDB/Native/<wbr>PDBFile.h"<br>
 #include "llvm/DebugInfo/PDB/Native/<wbr>RawError.h"<br>
 #include "llvm/DebugInfo/PDB/<wbr>PDBSymbolCompiland.h"<br>
@@ -68,8 +69,12 @@ uint64_t NativeSession::getLoadAddress(<wbr>)<br>
<br>
 void NativeSession::setLoadAddress(<wbr>uint64_t Address) {}<br>
<br>
-std::unique_ptr<PDBSymbolExe> NativeSession::getGlobalScope(<wbr>) const {<br>
-  return nullptr;<br>
+std::unique_ptr<PDBSymbolExe> NativeSession::getGlobalScope(<wbr>) {<br>
+  auto RawSymbol = llvm::make_unique<<wbr>NativeRawSymbol>(*this);<br>
+  auto PdbSymbol(PDBSymbol::create(*<wbr>this, std::move(RawSymbol)));<br>
+  std::unique_ptr<PDBSymbolExe> ExeSymbol(<br>
+    static_cast<PDBSymbolExe *>(PdbSymbol.release()));<br>
+  return ExeSymbol;<br>
 }<br>
<br>
 std::unique_ptr<PDBSymbol><br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>