jankratochvil updated this revision to Diff 374779. jankratochvil retitled this revision from "[lldb] DWZ 8/9: New testcases" to "[lldb] DWZ 16/17: New testcases". jankratochvil edited the summary of this revision. jankratochvil added a comment.
My question about upstreaming of this patchset. <https://reviews.llvm.org/D96236#3020116> Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D96242/new/ https://reviews.llvm.org/D96242 Files: lldb/test/Shell/SymbolFile/DWARF/dump-debug-types.cpp lldb/test/Shell/SymbolFile/DWARF/dwz-global-variable.c lldb/unittests/SymbolFile/CMakeLists.txt lldb/unittests/SymbolFile/DWZ/CMakeLists.txt lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.c lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.debug lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.debug.dwz lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.out lldb/unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
Index: lldb/unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp =================================================================== --- /dev/null +++ lldb/unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp @@ -0,0 +1,92 @@ +//===-- SymbolFileDWZTests.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 "TestingSupport/TestUtilities.h" + +#include "Plugins/ObjectFile/ELF/ObjectFileELF.h" +#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" +#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h" +#include "Plugins/TypeSystem/Clang/TypeSystemClang.h" +#include "lldb/Core/Module.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/SymbolVendor.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Reproducer.h" + +#if defined(_MSC_VER) +#include "lldb/Host/windows/windows.h" +#include <objbase.h> +#endif + +#include <algorithm> + +using namespace lldb_private; +using namespace lldb_private::repro; + +class SymbolFileDWZTests : 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. +#if defined(_MSC_VER) + ::CoInitializeEx(nullptr, COINIT_MULTITHREADED); +#endif + + llvm::cantFail(Reproducer::Initialize(ReproducerMode::Off, llvm::None)); + FileSystem::Initialize(); + HostInfo::Initialize(); + SymbolFileDWARF::Initialize(); + TypeSystemClang::Initialize(); + ObjectFileELF::Initialize(); + SymbolVendorELF::Initialize(); + + m_dwztest_out = GetInputFilePath("dwztest.out"); + } + + void TearDown() override { + SymbolVendorELF::Terminate(); + ObjectFileELF::Terminate(); + TypeSystemClang::Terminate(); + SymbolFileDWARF::Terminate(); + HostInfo::Terminate(); + FileSystem::Terminate(); + Reproducer::Terminate(); + +#if defined(_MSC_VER) + ::CoUninitialize(); +#endif + } + +protected: + std::string m_dwztest_out; +}; + +TEST_F(SymbolFileDWZTests, TestSimpleClassTypes) { + FileSpec fspec(m_dwztest_out); + ArchSpec aspec("x86_64-pc-linux"); + lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec); + + SymbolFile *symfile = module->GetSymbolFile(); + EXPECT_NE(nullptr, symfile); + EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic()); + SymbolContext sc; + llvm::DenseSet<SymbolFile *> searched_files; + TypeMap results; + symfile->FindTypes(ConstString("StructMovedToDWZCommonFile"), + CompilerDeclContext(), 0, searched_files, results); + EXPECT_EQ(1u, results.GetSize()); + lldb::TypeSP udt_type = results.GetTypeAtIndex(0); + EXPECT_EQ(ConstString("StructMovedToDWZCommonFile"), udt_type->GetName()); + CompilerType compiler_type = udt_type->GetForwardCompilerType(); + EXPECT_TRUE(TypeSystemClang::IsClassType(compiler_type.GetOpaqueQualType())); +} Index: lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.c =================================================================== --- /dev/null +++ lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.c @@ -0,0 +1,11 @@ +// gcc -Wall -g -o dwztest.out dwztest.c; eu-strip --remove-comment -f +// dwztest.debug dwztest.out; cp -p dwztest.debug dwztest.debug.dup; dwz -m +// dwztest.debug.dwz dwztest.debug dwztest.debug.dup;rm dwztest.debug.dup; +// /usr/lib/rpm/sepdebugcrcfix . dwztest.out + +struct StructMovedToDWZCommonFile { + int i1, i2, i3, i4, i5, i6, i7, i8, i9; +} VarWithStructMovedToDWZCommonFile; +static const int sizeof_StructMovedToDWZCommonFile = + sizeof(struct StructMovedToDWZCommonFile); +int main() { return sizeof_StructMovedToDWZCommonFile; } Index: lldb/unittests/SymbolFile/DWZ/CMakeLists.txt =================================================================== --- /dev/null +++ lldb/unittests/SymbolFile/DWZ/CMakeLists.txt @@ -0,0 +1,21 @@ +add_lldb_unittest(SymbolFileDWZTests + SymbolFileDWZTests.cpp + + LINK_LIBS + lldbCore + lldbHost + lldbSymbol + lldbPluginSymbolFileDWARF + lldbUtilityHelpers + lldbPluginObjectFileELF + lldbPluginSymbolVendorELF + LINK_COMPONENTS + Support + ) + +set(test_inputs + dwztest.out + dwztest.debug + dwztest.debug.dwz) + +add_unittest_inputs(SymbolFileDWZTests "${test_inputs}") Index: lldb/unittests/SymbolFile/CMakeLists.txt =================================================================== --- lldb/unittests/SymbolFile/CMakeLists.txt +++ lldb/unittests/SymbolFile/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(DWARF) add_subdirectory(NativePDB) +add_subdirectory(DWZ) if (LLVM_ENABLE_DIA_SDK) add_subdirectory(PDB) endif() Index: lldb/test/Shell/SymbolFile/DWARF/dwz-global-variable.c =================================================================== --- /dev/null +++ lldb/test/Shell/SymbolFile/DWARF/dwz-global-variable.c @@ -0,0 +1,24 @@ +// Test listing global variables when dwz -m is not in use. + +// REQUIRES: target-x86_64, system-linux, native + +// RUN: %clang_host -Wall -g -O2 -c -o %t-1.o %s -DMAIN +// RUN: %clang_host -Wall -g -O2 -c -o %t-2.o %s +// RUN: %clang_host -Wall -o %t %t-1.o %t-2.o +// RUN: (! which eu-strip dwz) || (! test -x /usr/lib/rpm/sepdebugcrcfix) || \ +// RUN: (eu-strip --remove-comment -f %t.debug %t && dwz %t.debug && \ +// RUN: /usr/lib/rpm/sepdebugcrcfix . "$(realpath --relative-to=$PWD %t)") +// RUN: %lldb %t -o 'b main' -o r -o 'target variable -c' \ +// RUN: -o exit | FileCheck %s + +// CHECK-LABEL: (lldb) target variable -c +// CHECK: `dwz-global-variable.c:{{[0-9]*}}: (const int) file_static_variable = 42 + +static const int file_static_variable = 42; +static const int make_it_dwz_worth = 42; +#ifdef MAIN +int func(void); +int main(void) { return func() + file_static_variable + make_it_dwz_worth; } +#else +int func(void) { return file_static_variable + make_it_dwz_worth; } +#endif Index: lldb/test/Shell/SymbolFile/DWARF/dump-debug-types.cpp =================================================================== --- /dev/null +++ lldb/test/Shell/SymbolFile/DWARF/dump-debug-types.cpp @@ -0,0 +1,12 @@ +// Test dumping types does work even for -fdebug-types-section. + +// error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin20.1.0' +// UNSUPPORTED: system-darwin + +// RUN: %clangxx_host -g -fdebug-types-section -c -o %t.o %s +// RUN: lldb-test symbols -dump-clang-ast %t.o | FileCheck %s + +struct StructName { +} a; + +// CHECK: StructName
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits