[llvm] e1ef718 - [dwarfdump] Warn for tags with DW_CHILDREN_yes but no children.
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 22:12:59 PDT 2020
Author: Jonas Devlieghere
Date: 2020-09-23T22:12:04-07:00
New Revision: e1ef7183c6f008fa13cbe273500b020c4fad1252
URL: https://github.com/llvm/llvm-project/commit/e1ef7183c6f008fa13cbe273500b020c4fad1252
DIFF: https://github.com/llvm/llvm-project/commit/e1ef7183c6f008fa13cbe273500b020c4fad1252.diff
LOG: [dwarfdump] Warn for tags with DW_CHILDREN_yes but no children.
Flag DIEs that have DW_CHILDREN_yes set in their abbreviation but don't
actually have any children.
rdar://59809554
Differential revision: https://reviews.llvm.org/D88048
Added:
llvm/test/tools/llvm-dwarfdump/X86/no-children.yaml
Modified:
llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
llvm/test/DebugInfo/X86/skeleton-unit-verify.s
llvm/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s
Removed:
################################################################################
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index 00d94e90eafc..ac624ec8b80f 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -172,6 +172,15 @@ unsigned DWARFVerifier::verifyUnitContents(DWARFUnit &Unit) {
NumUnitErrors += verifyDebugInfoForm(Die, AttrValue);
}
+ if (Die.hasChildren()) {
+ if (Die.getFirstChild().isValid() &&
+ Die.getFirstChild().getTag() == DW_TAG_null) {
+ warn() << dwarf::TagString(Die.getTag())
+ << " has DW_CHILDREN_yes but DIE has no children: ";
+ Die.dump(OS);
+ }
+ }
+
NumUnitErrors += verifyDebugInfoCallSite(Die);
}
diff --git a/llvm/test/DebugInfo/X86/skeleton-unit-verify.s b/llvm/test/DebugInfo/X86/skeleton-unit-verify.s
index d990d918cef6..95fbd113942a 100644
--- a/llvm/test/DebugInfo/X86/skeleton-unit-verify.s
+++ b/llvm/test/DebugInfo/X86/skeleton-unit-verify.s
@@ -3,6 +3,8 @@
# CHECK: Verifying .debug_abbrev...
# CHECK-NEXT: Verifying .debug_info Unit Header Chain...
+# CHECK-NEXT: warning: DW_TAG_skeleton_unit has DW_CHILDREN_yes but DIE has no children
+# CHECK-NEXT: DW_TAG_skeleton_unit
# CHECK-NEXT: error: Skeleton compilation unit has children.
# CHECK-NEXT: Verifying .debug_info references...
# CHECK-NEXT: Verifying .debug_types Unit Header Chain...
@@ -30,7 +32,7 @@
.byte 8 # Address Size (in bytes)
.long .debug_abbrev # Offset Into Abbrev. Section
.quad -6573227469967412476
- .byte 1 # Abbrev [1]
+ .byte 1 # Abbrev [1]
.byte 0
.Lcu_end0:
.long .Lcu_end1-.Lcu_start1 # Length of Unit
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/no-children.yaml b/llvm/test/tools/llvm-dwarfdump/X86/no-children.yaml
new file mode 100644
index 000000000000..1417ab2bdc3f
--- /dev/null
+++ b/llvm/test/tools/llvm-dwarfdump/X86/no-children.yaml
@@ -0,0 +1,23 @@
+# RUN: yaml2obj %s | llvm-dwarfdump -verify - | FileCheck %s
+# CHECK: warning: DW_TAG_compile_unit has DW_CHILDREN_yes but DIE has no children
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+DWARF:
+ debug_abbrev:
+ - Table:
+ - Tag: DW_TAG_compile_unit
+ Children: DW_CHILDREN_yes
+ Attributes:
+ - Attribute: DW_AT_low_pc
+ Form: DW_FORM_data4
+ debug_info:
+ - Version: 4
+ Entries:
+ - AbbrCode: 1
+ Values:
+ - Value: 0x1234
+ - AbbrCode: 0 ## Terminator for the current DIE.
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s b/llvm/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s
index ea357b728897..ea461b27e3e7 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s
@@ -3,7 +3,8 @@
# RUN: | FileCheck %s
# CHECK: Verifying .debug_info Unit Header Chain...
-# CHECK-NEXT: error: Invalid address range [0x0000000000000007, 0x0000000000000006)
+# CHECK: warning: DW_TAG_compile_unit has DW_CHILDREN_yes but DIE has no children:
+# CHECK: error: Invalid address range [0x0000000000000007, 0x0000000000000006)
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 12
More information about the llvm-commits
mailing list