Index: llvm/include/llvm/DebugInfo/PDB/DIA/DIASession.h =================================================================== --- llvm/include/llvm/DebugInfo/PDB/DIA/DIASession.h +++ llvm/include/llvm/DebugInfo/PDB/DIA/DIASession.h @@ -31,7 +31,7 @@ uint64_t getLoadAddress() const override; void setLoadAddress(uint64_t Address) override; - std::unique_ptr getGlobalScope() const override; + std::unique_ptr getGlobalScope() override; std::unique_ptr getSymbolById(uint32_t SymbolId) const override; std::unique_ptr Index: llvm/include/llvm/DebugInfo/PDB/IPDBSession.h =================================================================== --- llvm/include/llvm/DebugInfo/PDB/IPDBSession.h +++ llvm/include/llvm/DebugInfo/PDB/IPDBSession.h @@ -28,7 +28,7 @@ virtual uint64_t getLoadAddress() const = 0; virtual void setLoadAddress(uint64_t Address) = 0; - virtual std::unique_ptr getGlobalScope() const = 0; + virtual std::unique_ptr getGlobalScope() = 0; virtual std::unique_ptr getSymbolById(uint32_t SymbolId) const = 0; template Index: llvm/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h =================================================================== --- llvm/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h +++ llvm/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h @@ -19,7 +19,7 @@ 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 @@ bool isVolatileType() const override; bool wasInlined() const override; std::string getUnused() const override; + +private: + NativeSession &Session; }; } Index: llvm/include/llvm/DebugInfo/PDB/Native/NativeSession.h =================================================================== --- llvm/include/llvm/DebugInfo/PDB/Native/NativeSession.h +++ llvm/include/llvm/DebugInfo/PDB/Native/NativeSession.h @@ -21,7 +21,8 @@ class NativeSession : public IPDBSession { public: - NativeSession(std::unique_ptr PdbFile, + NativeSession(StringRef Path, + std::unique_ptr PdbFile, std::unique_ptr Allocator); ~NativeSession() override; @@ -32,7 +33,7 @@ uint64_t getLoadAddress() const override; void setLoadAddress(uint64_t Address) override; - std::unique_ptr getGlobalScope() const override; + std::unique_ptr getGlobalScope() override; std::unique_ptr getSymbolById(uint32_t SymbolId) const override; std::unique_ptr @@ -68,7 +69,10 @@ PDBFile &getPDBFile() { return *Pdb; } const PDBFile &getPDBFile() const { return *Pdb; } + StringRef getPDBFileName() const { return Path; } + private: + std::string Path; std::unique_ptr Pdb; std::unique_ptr Allocator; }; Index: llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp =================================================================== --- llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp +++ llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp @@ -140,7 +140,7 @@ Session->put_loadAddress(Address); } -std::unique_ptr DIASession::getGlobalScope() const { +std::unique_ptr DIASession::getGlobalScope() { CComPtr GlobalScope; if (S_OK != Session->get_globalScope(&GlobalScope)) return nullptr; Index: llvm/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp =================================================================== --- llvm/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp +++ llvm/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp @@ -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,7 +65,9 @@ } uint32_t NativeRawSymbol::getAge() const { - return 0; + auto &File = Session.getPDBFile(); + auto IS = File.getPDBInfoStream(); + return IS ? IS.get().getAge() : 0; } uint32_t NativeRawSymbol::getArrayIndexTypeId() const { @@ -248,7 +253,7 @@ } std::string NativeRawSymbol::getSymbolsFileName() const { - return 0; + return Session.getPDBFileName(); } uint32_t NativeRawSymbol::getSymIndexId() const { @@ -328,7 +333,9 @@ } PDB_UniqueId NativeRawSymbol::getGuid() const { - return {{0}}; + auto &File = Session.getPDBFile(); + auto IS = File.getPDBInfoStream(); + return IS ? IS.get().getGuid() : PDB_UniqueId{{0}}; } int32_t NativeRawSymbol::getOffset() const { Index: llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp =================================================================== --- llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp +++ llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp @@ -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" @@ -29,9 +30,10 @@ using namespace llvm::msf; using namespace llvm::pdb; -NativeSession::NativeSession(std::unique_ptr PdbFile, +NativeSession::NativeSession(StringRef Path, + std::unique_ptr PdbFile, std::unique_ptr Allocator) - : Pdb(std::move(PdbFile)), Allocator(std::move(Allocator)) {} + : Path(Path), Pdb(std::move(PdbFile)), Allocator(std::move(Allocator)) {} NativeSession::~NativeSession() = default; @@ -54,7 +56,8 @@ return EC; Session = - llvm::make_unique(std::move(File), std::move(Allocator)); + llvm::make_unique(Path, std::move(File), + std::move(Allocator)); return Error::success(); } @@ -68,8 +71,12 @@ void NativeSession::setLoadAddress(uint64_t Address) {} -std::unique_ptr NativeSession::getGlobalScope() const { - return nullptr; +std::unique_ptr NativeSession::getGlobalScope() { + auto RawSymbol = llvm::make_unique(*this); + auto PdbSymbol(PDBSymbol::create(*this, std::move(RawSymbol))); + std::unique_ptr ExeSymbol( + static_cast(PdbSymbol.release())); + return ExeSymbol; } std::unique_ptr