Skip to content

Commit e1ef718

Browse files
committed
[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
1 parent 6b136b1 commit e1ef718

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ unsigned DWARFVerifier::verifyUnitContents(DWARFUnit &Unit) {
172172
NumUnitErrors += verifyDebugInfoForm(Die, AttrValue);
173173
}
174174

175+
if (Die.hasChildren()) {
176+
if (Die.getFirstChild().isValid() &&
177+
Die.getFirstChild().getTag() == DW_TAG_null) {
178+
warn() << dwarf::TagString(Die.getTag())
179+
<< " has DW_CHILDREN_yes but DIE has no children: ";
180+
Die.dump(OS);
181+
}
182+
}
183+
175184
NumUnitErrors += verifyDebugInfoCallSite(Die);
176185
}
177186

llvm/test/DebugInfo/X86/skeleton-unit-verify.s

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
# CHECK: Verifying .debug_abbrev...
55
# CHECK-NEXT: Verifying .debug_info Unit Header Chain...
6+
# CHECK-NEXT: warning: DW_TAG_skeleton_unit has DW_CHILDREN_yes but DIE has no children
7+
# CHECK-NEXT: DW_TAG_skeleton_unit
68
# CHECK-NEXT: error: Skeleton compilation unit has children.
79
# CHECK-NEXT: Verifying .debug_info references...
810
# CHECK-NEXT: Verifying .debug_types Unit Header Chain...
@@ -30,7 +32,7 @@
3032
.byte 8 # Address Size (in bytes)
3133
.long .debug_abbrev # Offset Into Abbrev. Section
3234
.quad -6573227469967412476
33-
.byte 1 # Abbrev [1]
35+
.byte 1 # Abbrev [1]
3436
.byte 0
3537
.Lcu_end0:
3638
.long .Lcu_end1-.Lcu_start1 # Length of Unit
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# RUN: yaml2obj %s | llvm-dwarfdump -verify - | FileCheck %s
2+
# CHECK: warning: DW_TAG_compile_unit has DW_CHILDREN_yes but DIE has no children
3+
4+
--- !ELF
5+
FileHeader:
6+
Class: ELFCLASS64
7+
Data: ELFDATA2LSB
8+
Type: ET_EXEC
9+
DWARF:
10+
debug_abbrev:
11+
- Table:
12+
- Tag: DW_TAG_compile_unit
13+
Children: DW_CHILDREN_yes
14+
Attributes:
15+
- Attribute: DW_AT_low_pc
16+
Form: DW_FORM_data4
17+
debug_info:
18+
- Version: 4
19+
Entries:
20+
- AbbrCode: 1
21+
Values:
22+
- Value: 0x1234
23+
- AbbrCode: 0 ## Terminator for the current DIE.

llvm/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# RUN: | FileCheck %s
44

55
# CHECK: Verifying .debug_info Unit Header Chain...
6-
# CHECK-NEXT: error: Invalid address range [0x0000000000000007, 0x0000000000000006)
6+
# CHECK: warning: DW_TAG_compile_unit has DW_CHILDREN_yes but DIE has no children:
7+
# CHECK: error: Invalid address range [0x0000000000000007, 0x0000000000000006)
78

89
.section __TEXT,__text,regular,pure_instructions
910
.macosx_version_min 10, 12

0 commit comments

Comments
 (0)