<div dir="ltr">I think this error might be more general: CU contains no DIEs. This check doesn't verify that the root DIE Is actually a unit DIE (type_unit, compile_unit, or partial_unit).<br><br>Dunno about the best phrasing "unit is empty, does not contain a root unit DIE" or somesuch. That doesn't seem the best phrasing - open to ideas.<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 28, 2017 at 8:16 AM Jonas Devlieghere via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">JDevlieghere created this revision.<br>
<br>
This patch adds a check to the DWARF verifier to detect CUs without a<br>
unit DIE.<br>
<br>
<br>
Repository:<br>
rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D38363" rel="noreferrer" target="_blank">https://reviews.llvm.org/D38363</a><br>
<br>
Files:<br>
lib/DebugInfo/DWARF/DWARFVerifier.cpp<br>
test/tools/llvm-dwarfdump/X86/empty-CU.s<br>
<br>
<br>
Index: test/tools/llvm-dwarfdump/X86/empty-CU.s<br>
===================================================================<br>
--- /dev/null<br>
+++ test/tools/llvm-dwarfdump/X86/empty-CU.s<br>
@@ -0,0 +1,21 @@<br>
+# RUN: llvm-mc %s -filetype obj -triple x86_64-apple-darwin -o - \<br>
+# RUN: | not llvm-dwarfdump --verify --debug-info - \<br>
+# RUN: | FileCheck %s<br>
+# CHECK: Error: Compilation unit without unit DIE.<br>
+<br>
+ .section __DWARF,__debug_info,regular,debug<br>
+.long 8 # CU length<br>
+.short 3 # Version<br>
+.long 0 # Abbrev offset<br>
+.byte 4 # AddrSize<br>
+.byte 1 # Abbrev 1<br>
+.long 7 # Unit lengthh...<br>
+.short 3<br>
+.long 0<br>
+.byte 4<br>
+ .section __DWARF,__debug_abbrev,regular,debug<br>
+.byte 1 # Abbrev code<br>
+.byte 0x11 # TAG_compile_unit<br>
+.byte 0 # no children<br>
+.byte 0 # no attributes<br>
+.byte 0<br>
Index: lib/DebugInfo/DWARF/DWARFVerifier.cpp<br>
===================================================================<br>
--- lib/DebugInfo/DWARF/DWARFVerifier.cpp<br>
+++ lib/DebugInfo/DWARF/DWARFVerifier.cpp<br>
@@ -179,9 +179,14 @@<br>
}<br>
}<br>
<br>
- DieRangeInfo RI;<br>
- DWARFDie Die = Unit.getUnitDIE(/* ExtractUnitDIEOnly = */ false);<br>
- NumUnitErrors += verifyDieRanges(Die, RI);<br>
+ if (DWARFDie Die = Unit.getUnitDIE(/* ExtractUnitDIEOnly = */ false)) {<br>
+ DieRangeInfo RI;<br>
+ NumUnitErrors += verifyDieRanges(Die, RI);<br>
+ } else {<br>
+ OS << "Error: Compilation unit without unit DIE.\n";<br>
+ NumUnitErrors++;<br>
+ }<br>
+<br>
return NumUnitErrors == 0;<br>
}<br>
<br>
<br>
<br>
</blockquote></div></div>