[PATCH] D88048: [dwarfdump] Add verifier check to find DIEs with DW_CHILDREN_yes but without children.

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 22:13:02 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGe1ef7183c6f0: [dwarfdump] Warn for tags with DW_CHILDREN_yes but no children. (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D88048?vs=293298&id=293939#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88048/new/

https://reviews.llvm.org/D88048

Files:
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/test/DebugInfo/X86/skeleton-unit-verify.s
  llvm/test/tools/llvm-dwarfdump/X86/no-children.yaml
  llvm/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s


Index: llvm/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s
===================================================================
--- llvm/test/tools/llvm-dwarfdump/X86/verify_die_ranges.s
+++ 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
Index: llvm/test/tools/llvm-dwarfdump/X86/no-children.yaml
===================================================================
--- /dev/null
+++ 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.
Index: llvm/test/DebugInfo/X86/skeleton-unit-verify.s
===================================================================
--- llvm/test/DebugInfo/X86/skeleton-unit-verify.s
+++ 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
Index: llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -172,6 +172,15 @@
       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);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88048.293939.patch
Type: text/x-patch
Size: 3195 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200924/47b42dd3/attachment.bin>


More information about the llvm-commits mailing list