[Lldb-commits] [lldb] 5978912 - [lldb] Add a dwarf unit test for null unit dies
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 29 23:48:08 PDT 2021
Author: Pavel Labath
Date: 2021-03-30T08:46:36+02:00
New Revision: 5978912da00acc610e4e1379bde815b28252944c
URL: https://github.com/llvm/llvm-project/commit/5978912da00acc610e4e1379bde815b28252944c
DIFF: https://github.com/llvm/llvm-project/commit/5978912da00acc610e4e1379bde815b28252944c.diff
LOG: [lldb] Add a dwarf unit test for null unit dies
This is the test I mentioned in the previous commit (1b96e133), but
forgot to add.
Added:
lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
Modified:
lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
Removed:
################################################################################
diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index 30620a61dc5f..982ac935794f 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -1,5 +1,6 @@
add_lldb_unittest(SymbolFileDWARFTests
DWARFASTParserClangTests.cpp
+ DWARFUnitTest.cpp
SymbolFileDWARFTests.cpp
XcodeSDKModuleTests.cpp
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
new file mode 100644
index 000000000000..3a4b1cfd8ba7
--- /dev/null
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
@@ -0,0 +1,49 @@
+//===-- DWARFUnitTest.cpp -------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Plugins/SymbolFile/DWARF/DWARFUnit.h"
+#include "TestingSupport/Symbol/YAMLModuleTester.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+TEST(DWARFUnitTest, NullUnitDie) {
+ // Make sure we don't crash parsing a null unit DIE.
+ const char *yamldata = R"(
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_386
+DWARF:
+ debug_abbrev:
+ - Table:
+ - Code: 0x00000001
+ Tag: DW_TAG_compile_unit
+ Children: DW_CHILDREN_yes
+ Attributes:
+ - Attribute: DW_AT_language
+ Form: DW_FORM_data2
+ debug_info:
+ - Version: 4
+ AddrSize: 8
+ Entries:
+ - AbbrCode: 0x00000000
+)";
+
+ YAMLModuleTester t(yamldata);
+ ASSERT_TRUE((bool)t.GetDwarfUnit());
+
+ DWARFUnit *unit = t.GetDwarfUnit();
+ const DWARFDebugInfoEntry *die_first = unit->DIE().GetDIE();
+ ASSERT_NE(die_first, nullptr);
+ EXPECT_TRUE(die_first->IsNULL());
+}
More information about the lldb-commits
mailing list