Index: lldb/trunk/unittests/SymbolFile/CMakeLists.txt =================================================================== --- lldb/trunk/unittests/SymbolFile/CMakeLists.txt +++ lldb/trunk/unittests/SymbolFile/CMakeLists.txt @@ -1 +1,4 @@ -add_subdirectory(PDB) +add_subdirectory(DWARF) +if (LLVM_ENABLE_DIA_SDK) + add_subdirectory(PDB) +endif() Index: lldb/trunk/unittests/SymbolFile/DWARF/CMakeLists.txt =================================================================== --- lldb/trunk/unittests/SymbolFile/DWARF/CMakeLists.txt +++ lldb/trunk/unittests/SymbolFile/DWARF/CMakeLists.txt @@ -0,0 +1,8 @@ +add_lldb_unittest(SymbolFileDWARFTests + SymbolFileDWARFTests.cpp + ) + +set(test_inputs + test-dwarf.exe) + +add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}") Index: lldb/trunk/unittests/SymbolFile/DWARF/Inputs/test-dwarf.cpp =================================================================== --- lldb/trunk/unittests/SymbolFile/DWARF/Inputs/test-dwarf.cpp +++ lldb/trunk/unittests/SymbolFile/DWARF/Inputs/test-dwarf.cpp @@ -0,0 +1,6 @@ +// Compile with "cl /c /Zi /GR- test.cpp" +// Link with "link test.obj /debug /nodefaultlib /entry:main /out:test.exe" + +int __cdecl _purecall(void) { return 0; } + +int main(int argc, char **argv) { return 0; } Index: lldb/trunk/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp =================================================================== --- lldb/trunk/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp +++ lldb/trunk/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp @@ -0,0 +1,83 @@ +//===-- PythonDataObjectsTests.cpp ------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "gtest/gtest.h" + +#include "llvm/ADT/STLExtras.h" +#include "llvm/DebugInfo/PDB/PDBSymbolData.h" +#include "llvm/DebugInfo/PDB/PDBSymbolExe.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" + +#include "lldb/Core/Address.h" +#include "lldb/Core/ArchSpec.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/ModuleSpec.h" +#include "lldb/Host/FileSpec.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Symbol/LineTable.h" +#include "lldb/Symbol/SymbolVendor.h" + +#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" +#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" +#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h" + +extern const char *TestMainArgv0; + +using namespace lldb_private; + +class SymbolFileDWARFTests : public testing::Test { +public: + void SetUp() override { +// Initialize and TearDown the plugin every time, so we get a brand new +// AST every time so that modifications to the AST from each test don't +// leak into the next test. + HostInfo::Initialize(); + ObjectFilePECOFF::Initialize(); + SymbolFileDWARF::Initialize(); + ClangASTContext::Initialize(); + SymbolFilePDB::Initialize(); + + llvm::StringRef exe_folder = llvm::sys::path::parent_path(TestMainArgv0); + llvm::SmallString<128> inputs_folder = exe_folder; + llvm::sys::path::append(inputs_folder, "Inputs"); + + m_dwarf_test_exe = inputs_folder; + llvm::sys::path::append(m_dwarf_test_exe, "test-dwarf.exe"); + } + + void TearDown() override { + SymbolFilePDB::Terminate(); + ClangASTContext::Initialize(); + SymbolFileDWARF::Terminate(); + ObjectFilePECOFF::Terminate(); + HostInfo::Terminate(); + } + +protected: + llvm::SmallString<128> m_dwarf_test_exe; +}; + +TEST_F(SymbolFileDWARFTests, TestAbilitiesForDWARF) { + // Test that when we have Dwarf debug info, SymbolFileDWARF is used. + FileSpec fspec(m_dwarf_test_exe.c_str(), false); + ArchSpec aspec("i686-pc-windows"); + lldb::ModuleSP module = std::make_shared(fspec, aspec); + + SymbolVendor *plugin = module->GetSymbolVendor(); + EXPECT_NE(nullptr, plugin); + SymbolFile *symfile = plugin->GetSymbolFile(); + EXPECT_NE(nullptr, symfile); + EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic()); + + uint32_t expected_abilities = SymbolFile::kAllAbilities; + EXPECT_EQ(expected_abilities, symfile->CalculateAbilities()); +} Index: lldb/trunk/unittests/SymbolFile/PDB/CMakeLists.txt =================================================================== --- lldb/trunk/unittests/SymbolFile/PDB/CMakeLists.txt +++ lldb/trunk/unittests/SymbolFile/PDB/CMakeLists.txt @@ -5,8 +5,7 @@ set(test_inputs test-pdb.exe test-pdb.pdb - test-dwarf.exe test-pdb-types.exe test-pdb-types.pdb) -add_unittest_inputs(SymbolFilePDBTests "${test_inputs}") +add_unittest_inputs(SymbolFilePDBTests "${test_inputs}") Index: lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp =================================================================== --- lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp +++ lldb/trunk/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp @@ -1,6 +0,0 @@ -// Compile with "cl /c /Zi /GR- test.cpp" -// Link with "link test.obj /debug /nodefaultlib /entry:main /out:test.exe" - -int __cdecl _purecall(void) { return 0; } - -int main(int argc, char **argv) { return 0; } Index: lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp =================================================================== --- lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp +++ lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp @@ -10,7 +10,6 @@ #include "gtest/gtest.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/Config/config.h" #include "llvm/DebugInfo/PDB/PDBSymbolData.h" #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" #include "llvm/Support/FileSystem.h" @@ -63,10 +62,8 @@ llvm::sys::path::append(inputs_folder, "Inputs"); m_pdb_test_exe = inputs_folder; - m_dwarf_test_exe = inputs_folder; m_types_test_exe = inputs_folder; llvm::sys::path::append(m_pdb_test_exe, "test-pdb.exe"); - llvm::sys::path::append(m_dwarf_test_exe, "test-dwarf.exe"); llvm::sys::path::append(m_types_test_exe, "test-pdb-types.exe"); } @@ -84,7 +81,6 @@ protected: llvm::SmallString<128> m_pdb_test_exe; - llvm::SmallString<128> m_dwarf_test_exe; llvm::SmallString<128> m_types_test_exe; bool FileSpecMatchesAsBaseOrFull(const FileSpec &left, @@ -154,29 +150,7 @@ } }; -#if HAVE_DIA_SDK -#define REQUIRES_DIA_SDK(TestName) TestName -#else -#define REQUIRES_DIA_SDK(TestName) DISABLED_##TestName -#endif - -TEST_F(SymbolFilePDBTests, TestAbilitiesForDWARF) { - // Test that when we have Dwarf debug info, SymbolFileDWARF is used. - FileSpec fspec(m_dwarf_test_exe.c_str(), false); - ArchSpec aspec("i686-pc-windows"); - lldb::ModuleSP module = std::make_shared(fspec, aspec); - - SymbolVendor *plugin = module->GetSymbolVendor(); - EXPECT_NE(nullptr, plugin); - SymbolFile *symfile = plugin->GetSymbolFile(); - EXPECT_NE(nullptr, symfile); - EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic()); - - uint32_t expected_abilities = SymbolFile::kAllAbilities; - EXPECT_EQ(expected_abilities, symfile->CalculateAbilities()); -} - -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestAbilitiesForPDB)) { +TEST_F(SymbolFilePDBTests, TestAbilitiesForPDB) { // Test that when we have PDB debug info, SymbolFilePDB is used. FileSpec fspec(m_pdb_test_exe.c_str(), false); ArchSpec aspec("i686-pc-windows"); @@ -193,7 +167,7 @@ EXPECT_EQ(expected_abilities, symfile->CalculateAbilities()); } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestResolveSymbolContextBasename)) { +TEST_F(SymbolFilePDBTests, TestResolveSymbolContextBasename) { // Test that attempting to call ResolveSymbolContext with only a basename // finds all full paths // with the same basename @@ -213,7 +187,7 @@ EXPECT_TRUE(ContainsCompileUnit(sc_list, header_spec)); } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestResolveSymbolContextFullPath)) { +TEST_F(SymbolFilePDBTests, TestResolveSymbolContextFullPath) { // Test that attempting to call ResolveSymbolContext with a full path only // finds the one source // file that matches the full path. @@ -236,7 +210,7 @@ } TEST_F(SymbolFilePDBTests, - REQUIRES_DIA_SDK(TestLookupOfHeaderFileWithInlines)) { + TestLookupOfHeaderFileWithInlines) { // Test that when looking up a header file via ResolveSymbolContext (i.e. a // file that was not by itself // compiled, but only contributes to the combined code of other source files), @@ -264,8 +238,7 @@ } } -TEST_F(SymbolFilePDBTests, - REQUIRES_DIA_SDK(TestLookupOfHeaderFileWithNoInlines)) { +TEST_F(SymbolFilePDBTests, TestLookupOfHeaderFileWithNoInlines) { // Test that when looking up a header file via ResolveSymbolContext (i.e. a // file that was not by itself // compiled, but only contributes to the combined code of other source files), @@ -289,7 +262,7 @@ } } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchAll)) { +TEST_F(SymbolFilePDBTests, TestLineTablesMatchAll) { // Test that when calling ResolveSymbolContext with a line number of 0, all // line entries from // the specified files are returned. @@ -338,7 +311,7 @@ VerifyLineEntry(module, sc, header2, *lt, 7, 0x401089); } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchSpecific)) { +TEST_F(SymbolFilePDBTests, TestLineTablesMatchSpecific) { // Test that when calling ResolveSymbolContext with a specific line number, // only line entries // which match the requested line are returned. @@ -390,7 +363,7 @@ VerifyLineEntry(module, sc, header1, *lt, 9, 0x401090); } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestSimpleClassTypes)) { +TEST_F(SymbolFilePDBTests, TestSimpleClassTypes) { FileSpec fspec(m_types_test_exe.c_str(), false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -413,7 +386,7 @@ udt_type->GetByteSize()); } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNestedClassTypes)) { +TEST_F(SymbolFilePDBTests, TestNestedClassTypes) { FileSpec fspec(m_types_test_exe.c_str(), false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -436,7 +409,7 @@ udt_type->GetByteSize()); } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestClassInNamespace)) { +TEST_F(SymbolFilePDBTests, TestClassInNamespace) { FileSpec fspec(m_types_test_exe.c_str(), false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -459,7 +432,7 @@ udt_type->GetByteSize()); } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestEnumTypes)) { +TEST_F(SymbolFilePDBTests, TestEnumTypes) { FileSpec fspec(m_types_test_exe.c_str(), false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -492,21 +465,21 @@ } } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestArrayTypes)) { +TEST_F(SymbolFilePDBTests, TestArrayTypes) { // In order to get this test working, we need to support lookup by symbol // name. Because array // types themselves do not have names, only the symbols have names (i.e. the // name of the array). } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestFunctionTypes)) { +TEST_F(SymbolFilePDBTests, TestFunctionTypes) { // In order to get this test working, we need to support lookup by symbol // name. Because array // types themselves do not have names, only the symbols have names (i.e. the // name of the array). } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestTypedefs)) { +TEST_F(SymbolFilePDBTests, TestTypedefs) { FileSpec fspec(m_types_test_exe.c_str(), false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -540,7 +513,7 @@ } } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestRegexNameMatch)) { +TEST_F(SymbolFilePDBTests, TestRegexNameMatch) { FileSpec fspec(m_types_test_exe.c_str(), false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -557,7 +530,7 @@ EXPECT_EQ(num_results, results.GetSize()); } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestMaxMatches)) { +TEST_F(SymbolFilePDBTests, TestMaxMatches) { FileSpec fspec(m_types_test_exe.c_str(), false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -584,7 +557,7 @@ } } -TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNullName)) { +TEST_F(SymbolFilePDBTests, TestNullName) { FileSpec fspec(m_types_test_exe.c_str(), false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec);