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/HostInfo.h" 26 #include "lldb/Symbol/ClangASTContext.h" 27 #include "lldb/Symbol/CompileUnit.h" 28 #include "lldb/Symbol/LineTable.h" 29 #include "lldb/Symbol/SymbolVendor.h" 30 #include "lldb/Utility/ArchSpec.h" 31 #include "lldb/Utility/FileSpec.h" 32 33 using namespace lldb_private; 34 35 class SymbolFileDWARFTests : public testing::Test { 36 public: 37 void SetUp() override { 38 // Initialize and TearDown the plugin every time, so we get a brand new 39 // AST every time so that modifications to the AST from each test don't 40 // leak into the next test. 41 HostInfo::Initialize(); 42 ObjectFilePECOFF::Initialize(); 43 SymbolFileDWARF::Initialize(); 44 ClangASTContext::Initialize(); 45 SymbolFilePDB::Initialize(); 46 47 m_dwarf_test_exe = GetInputFilePath("test-dwarf.exe"); 48 } 49 50 void TearDown() override { 51 SymbolFilePDB::Terminate(); 52 ClangASTContext::Initialize(); 53 SymbolFileDWARF::Terminate(); 54 ObjectFilePECOFF::Terminate(); 55 HostInfo::Terminate(); 56 } 57 58 protected: 59 std::string m_dwarf_test_exe; 60 }; 61 62 TEST_F(SymbolFileDWARFTests, TestAbilitiesForDWARF) { 63 // Test that when we have Dwarf debug info, SymbolFileDWARF is used. 64 FileSpec fspec(m_dwarf_test_exe, false); 65 ArchSpec aspec("i686-pc-windows"); 66 lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec); 67 68 SymbolVendor *plugin = module->GetSymbolVendor(); 69 EXPECT_NE(nullptr, plugin); 70 SymbolFile *symfile = plugin->GetSymbolFile(); 71 EXPECT_NE(nullptr, symfile); 72 EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic()); 73 74 uint32_t expected_abilities = SymbolFile::kAllAbilities; 75 EXPECT_EQ(expected_abilities, symfile->CalculateAbilities()); 76 } 77