jankratochvil updated this revision to Diff 333693.
jankratochvil added a comment.
testcases: -fdebug-types-section is unsupported on OSX, Repro was crashing with
SymbolFileDWZTests.cpp so it is excluded.
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/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/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
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits