1 //===-- PythonDataObjectsTests.cpp ------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "gtest/gtest.h" 11 12 #include "llvm/ADT/STLExtras.h" 13 #include "llvm/DebugInfo/PDB/PDBSymbolData.h" 14 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" 15 #include "llvm/Support/FileSystem.h" 16 #include "llvm/Support/Path.h" 17 18 #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" 19 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" 20 #include "Plugins/SymbolFile/PDB/SymbolFilePDB.h" 21 #include "TestingSupport/TestUtilities.h" 22 #include "lldb/Core/Address.h" 23 #include "lldb/Core/Module.h" 24 #include "lldb/Core/ModuleSpec.h" 25 #include "lldb/Host/FileSystem.h" 26 #include "lldb/Host/HostInfo.h" 27 #include "lldb/Symbol/ClangASTContext.h" 28 #include "lldb/Symbol/CompileUnit.h" 29 #include "lldb/Symbol/LineTable.h" 30 #include "lldb/Symbol/SymbolVendor.h" 31 #include "lldb/Utility/ArchSpec.h" 32 #include "lldb/Utility/FileSpec.h" 33 34 using namespace lldb_private; 35 36 class SymbolFileDWARFTests : public testing::Test { 37 public: 38 void SetUp() override { 39 // Initialize and TearDown the plugin every time, so we get a brand new 40 // AST every time so that modifications to the AST from each test don't 41 // leak into the next test. 42 FileSystem::Initialize(); 43 HostInfo::Initialize(); 44 ObjectFilePECOFF::Initialize(); 45 SymbolFileDWARF::Initialize(); 46 ClangASTContext::Initialize(); 47 SymbolFilePDB::Initialize(); 48 49 m_dwarf_test_exe = GetInputFilePath("test-dwarf.exe"); 50 } 51 52 void TearDown() override { 53 SymbolFilePDB::Terminate(); 54 ClangASTContext::Initialize(); 55 SymbolFileDWARF::Terminate(); 56 ObjectFilePECOFF::Terminate(); 57 HostInfo::Terminate(); 58 FileSystem::Terminate(); 59 } 60 61 protected: 62 std::string m_dwarf_test_exe; 63 }; 64 65 TEST_F(SymbolFileDWARFTests, TestAbilitiesForDWARF) { 66 // Test that when we have Dwarf debug info, SymbolFileDWARF is used. 67 FileSpec fspec(m_dwarf_test_exe); 68 ArchSpec aspec("i686-pc-windows"); 69 lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec); 70 71 SymbolVendor *plugin = module->GetSymbolVendor(); 72 EXPECT_NE(nullptr, plugin); 73 SymbolFile *symfile = plugin->GetSymbolFile(); 74 EXPECT_NE(nullptr, symfile); 75 EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic()); 76 77 uint32_t expected_abilities = SymbolFile::kAllAbilities; 78 EXPECT_EQ(expected_abilities, symfile->CalculateAbilities()); 79 } 80