diff options
| author | Zachary Turner <zturner@google.com> | 2015-02-08 20:58:09 +0000 | 
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2015-02-08 20:58:09 +0000 | 
| commit | bae16b3f5355e50bb4a0d5265f5304142a6afc0b (patch) | |
| tree | d84c7496b24b21ae5cba39e1af6adbdcbf88af07 /llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp | |
| parent | 9be09a36172701e9e906cced96b022fd41f52c2e (diff) | |
| download | llvm-bae16b3f5355e50bb4a0d5265f5304142a6afc0b.zip llvm-bae16b3f5355e50bb4a0d5265f5304142a6afc0b.tar.gz llvm-bae16b3f5355e50bb4a0d5265f5304142a6afc0b.tar.bz2 | |
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
Diffstat (limited to 'llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp')
| -rw-r--r-- | llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp | 37 | 
1 files changed, 29 insertions, 8 deletions
| diff --git a/llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp b/llvm/unittests/DebugInfo/PDB/PDBApiTest.cpp index 5a86d4c..4f838a0 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<PDBSymbolExe> getGlobalScope() const override { +    return nullptr; +  } +  std::unique_ptr<PDBSymbol> getSymbolById() const override { return nullptr; } +  std::unique_ptr<IPDBSourceFile> getSourceFileById() const override { +    return nullptr; +  } +  std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override { +    return nullptr; +  } +}; +  class MockRawSymbol : public IPDBRawSymbol {  public:    MockRawSymbol(PDB_SymType SymType) : Type(SymType) {} @@ -257,6 +275,8 @@ public:    std::unordered_map<PDB_SymType, std::unique_ptr<PDBSymbol>> 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<IPDBRawSymbol>(new MockRawSymbol(Tag)); -    auto Symbol = PDBSymbol::create(std::move(RawSymbol)); -    SymbolMap.insert(std::make_pair(Tag, std::move(Symbol))); -  } - -public:    template <class ExpectedType> void VerifyDyncast(PDB_SymType Tag) {      for (auto item = SymbolMap.begin(); item != SymbolMap.end(); ++item) {        EXPECT_EQ(item->first == Tag, llvm::isa<ExpectedType>(*item->second)); @@ -314,6 +326,15 @@ public:        EXPECT_EQ(should_match, llvm::isa<PDBSymbolUnknown>(*item->second));      }    } + +private: +  std::unique_ptr<IPDBSession> Session; + +  void InsertItemWithTag(PDB_SymType Tag) { +    auto RawSymbol = std::unique_ptr<IPDBRawSymbol>(new MockRawSymbol(Tag)); +    auto Symbol = PDBSymbol::create(*Session, std::move(RawSymbol)); +    SymbolMap.insert(std::make_pair(Tag, std::move(Symbol))); +  }  };  TEST_F(PDBApiTest, Dyncast) { | 
