[PATCH] D49815: [DWARF v5] Don't report an error when the .debug_rnglists section is empty or non-existent (PR 38297)

Wolfgang Pieb via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 25 18:12:56 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL337993: [DWARF v5] Don't report an error when the .debug_rnglists section is empty or… (authored by wolfgangp, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49815?vs=157330&id=157414#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49815

Files:
  llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets.s


Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
===================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -314,22 +314,24 @@
       else
         setRangesSection(&Context.getDWARFObj().getRnglistsSection(),
                          toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0));
-      // Parse the range list table header. Individual range lists are
-      // extracted lazily.
-      DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
-                                  isLittleEndian, 0);
-      if (auto TableOrError =
-              parseRngListTableHeader(RangesDA, RangeSectionBase))
-        RngListTable = TableOrError.get();
-      else
-        WithColor::error() << "parsing a range list table: "
-                           << toString(TableOrError.takeError())
-                           << '\n';
-
-      // In a split dwarf unit, there is no DW_AT_rnglists_base attribute.
-      // Adjust RangeSectionBase to point past the table header.
-      if (isDWO && RngListTable)
-        RangeSectionBase = RngListTable->getHeaderSize();
+      if (RangeSection->Data.size()) {
+        // Parse the range list table header. Individual range lists are
+        // extracted lazily.
+        DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
+                                    isLittleEndian, 0);
+        if (auto TableOrError =
+                parseRngListTableHeader(RangesDA, RangeSectionBase))
+          RngListTable = TableOrError.get();
+        else
+          WithColor::error() << "parsing a range list table: "
+                             << toString(TableOrError.takeError())
+                             << '\n';
+
+        // In a split dwarf unit, there is no DW_AT_rnglists_base attribute.
+        // Adjust RangeSectionBase to point past the table header.
+        if (isDWO && RngListTable)
+          RangeSectionBase = RngListTable->getHeaderSize();
+      }
     }
 
     // Don't fall back to DW_AT_GNU_ranges_base: it should be ignored for
Index: llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets.s
===================================================================
--- llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets.s
+++ llvm/trunk/test/DebugInfo/X86/dwarfdump-str-offsets.s
@@ -1,5 +1,8 @@
 # RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
-# RUN: llvm-dwarfdump -v %t.o | FileCheck --check-prefix=COMMON --check-prefix=SPLIT %s
+# RUN: llvm-dwarfdump -v %t.o 2> %t.err | FileCheck --check-prefix=COMMON --check-prefix=SPLIT %s
+# 
+# Check that we don't report an error on a non-existent range list table.
+# RUN: FileCheck -allow-empty --check-prefix ERR %s < %t.err
 
 # Test object to verify dwarfdump handles v5 string offset tables.
 # We have 2 v5 CUs, a v5 TU, and a split v5 CU and TU.
@@ -382,3 +385,5 @@
 # SPLIT-NEXT:  0x00000010: 00000034 "/home/test/splitCU"
 # SPLIT-NEXT:  0x00000014: 00000047 "V5_split_type_unit"
 # SPLIT-NEXT:  0x00000018: 0000005a "V5_split_Mystruct"
+
+# ERR-NOT: parsing a range list table:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49815.157414.patch
Type: text/x-patch
Size: 3159 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180726/3afd82a0/attachment.bin>


More information about the llvm-commits mailing list