From bae16b3f5355e50bb4a0d5265f5304142a6afc0b Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Sun, 8 Feb 2015 20:58:09 +0000 Subject: DebugInfoPDB: Make the symbol base case hold an IPDBSession ref. Dumping a symbol often requires access to data that isn't inside the symbol hierarchy, but which is only accessible through the top-level session. This patch is a pure interface change to give symbols a reference to the session. llvm-svn: 228542 --- llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp | 37 ++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'llvm/unittests/DebugInfo') diff --git a/llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp b/llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp index 5a86d4ca7a5..4f838a0ded6 100644 --- a/llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp +++ b/llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp @@ -12,6 +12,9 @@ #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" +#include "llvm/DebugInfo/PDB/IPDBSession.h" +#include "llvm/DebugInfo/PDB/IPDBSourceFile.h" + #include "llvm/DebugInfo/PDB/PDBSymbol.h" #include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h" #include "llvm/DebugInfo/PDB/PDBSymbolBlock.h" @@ -66,6 +69,21 @@ namespace { return ReturnType(); \ } +class MockSession : public IPDBSession { + uint64_t getLoadAddress() const override { return 0; } + void setLoadAddress(uint64_t Address) override {} + std::unique_ptr getGlobalScope() const override { + return nullptr; + } + std::unique_ptr getSymbolById() const override { return nullptr; } + std::unique_ptr getSourceFileById() const override { + return nullptr; + } + std::unique_ptr getDebugStreams() const override { + return nullptr; + } +}; + class MockRawSymbol : public IPDBRawSymbol { public: MockRawSymbol(PDB_SymType SymType) : Type(SymType) {} @@ -257,6 +275,8 @@ public: std::unordered_map> SymbolMap; void SetUp() override { + Session.reset(new MockSession()); + InsertItemWithTag(PDB_SymType::None); InsertItemWithTag(PDB_SymType::Exe); InsertItemWithTag(PDB_SymType::Compiland); @@ -291,14 +311,6 @@ public: InsertItemWithTag(PDB_SymType::Max); } -private: - void InsertItemWithTag(PDB_SymType Tag) { - auto RawSymbol = std::unique_ptr(new MockRawSymbol(Tag)); - auto Symbol = PDBSymbol::create(std::move(RawSymbol)); - SymbolMap.insert(std::make_pair(Tag, std::move(Symbol))); - } - -public: template void VerifyDyncast(PDB_SymType Tag) { for (auto item = SymbolMap.begin(); item != SymbolMap.end(); ++item) { EXPECT_EQ(item->first == Tag, llvm::isa(*item->second)); @@ -314,6 +326,15 @@ public: EXPECT_EQ(should_match, llvm::isa(*item->second)); } } + +private: + std::unique_ptr Session; + + void InsertItemWithTag(PDB_SymType Tag) { + auto RawSymbol = std::unique_ptr(new MockRawSymbol(Tag)); + auto Symbol = PDBSymbol::create(*Session, std::move(RawSymbol)); + SymbolMap.insert(std::make_pair(Tag, std::move(Symbol))); + } }; TEST_F(PDBApiTest, Dyncast) { -- cgit v1.2.3