Skip to content

[dwarfdump] Warn for tags with DW_CHILDREN_yes but no children. #1867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 3 additions & 1 deletion llvm/test/DebugInfo/X86/skeleton-unit-verify.s
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion llvm/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down