<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi, I believe your commit is not breaking the buildbot. Sanitizer-buildbot3 seems to be succeeding and Sanitizer-buildbot4 seems to be failing consistently with a CMake error. I'll contact the admin to take a look.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Alexandros</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> llvm-commits <llvm-commits-bounces@lists.llvm.org> on behalf of Wolfgang Pieb via llvm-commits <llvm-commits@lists.llvm.org><br>
<b>Sent:</b> Wednesday, September 12, 2018 3:40:04 PM<br>
<b>To:</b> llvm-commits@lists.llvm.org<br>
<b>Subject:</b> [llvm] r342056 - Reverting r342048, which caused UBSan failures in dsymutil.</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Author: wolfgangp<br>
Date: Wed Sep 12 07:40:04 2018<br>
New Revision: 342056<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=342056&view=rev">http://llvm.org/viewvc/llvm-project?rev=342056&view=rev</a><br>
Log:<br>
Reverting r342048, which caused UBSan failures in dsymutil.<br>
<br>
<br>
Added:<br>
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h<br>
      - copied unchanged from r342047, llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h<br>
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp<br>
      - copied unchanged from r342047, llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp<br>
Modified:<br>
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h<br>
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h<br>
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h<br>
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h<br>
    llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt<br>
    llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp<br>
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp<br>
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp<br>
    llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp<br>
    llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp<br>
    llvm/trunk/test/DebugInfo/Generic/cu-ranges.ll<br>
    llvm/trunk/test/DebugInfo/Inputs/gmlt.ll<br>
    llvm/trunk/test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s<br>
    llvm/trunk/test/DebugInfo/X86/dwarfdump-ranges-unrelocated.s<br>
    llvm/trunk/test/DebugInfo/dwarfdump-ranges.test<br>
    llvm/trunk/test/MC/ARM/dwarf-asm-multiple-sections.s<br>
    llvm/trunk/tools/dsymutil/DwarfLinker.cpp<br>
    llvm/trunk/tools/dsymutil/DwarfStreamer.cpp<br>
    llvm/trunk/tools/dsymutil/DwarfStreamer.h<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h Wed Sep 12 07:40:04 2018<br>
@@ -231,9 +231,7 @@ public:<br>
   /// Get a DIE given an exact offset.<br>
   DWARFDie getDIEForOffset(uint32_t Offset);<br>
 <br>
-  unsigned getMaxVersion(uint16_t DefaultVersion = 0) const {<br>
-    return MaxVersion ? MaxVersion : DefaultVersion;<br>
-  }<br>
+  unsigned getMaxVersion() const { return MaxVersion; }<br>
 <br>
   void setMaxVersionIfGreater(unsigned Version) {<br>
     if (Version > MaxVersion)<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h Wed Sep 12 07:40:04 2018<br>
@@ -12,8 +12,8 @@<br>
 <br>
 #include "llvm/BinaryFormat/Dwarf.h"<br>
 #include "llvm/DebugInfo/DIContext.h"<br>
-#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"<br>
+#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFListTable.h"<br>
 #include <cstdint><br>
 #include <map><br>
@@ -21,8 +21,6 @@<br>
 <br>
 namespace llvm {<br>
 <br>
-struct BaseAddress;<br>
-class DWARFContext;<br>
 class Error;<br>
 class raw_ostream;<br>
 <br>
@@ -35,29 +33,10 @@ struct RangeListEntry : public DWARFList<br>
   uint64_t Value0;<br>
   uint64_t Value1;<br>
 <br>
-  Error extract(DWARFDataExtractor Data, uint32_t End, uint16_t Version,<br>
-                StringRef SectionName, uint32_t *OffsetPtr, bool isDWO = false);<br>
-  bool isEndOfList() const { return EntryKind == dwarf::DW_RLE_end_of_list; }<br>
-  bool isBaseAddressSelectionEntry() const {<br>
-    return EntryKind == dwarf::DW_RLE_base_address;<br>
-  }<br>
-  uint64_t getStartAddress() const {<br>
-    assert((EntryKind == dwarf::DW_RLE_start_end ||<br>
-            EntryKind == dwarf::DW_RLE_offset_pair ||<br>
-            EntryKind == dwarf::DW_RLE_startx_length) &&<br>
-           "Unexpected range list entry kind");<br>
-    return Value0;<br>
-  }<br>
-  uint64_t getEndAddress() const {<br>
-    assert((EntryKind == dwarf::DW_RLE_start_end ||<br>
-            EntryKind == dwarf::DW_RLE_offset_pair) &&<br>
-           "Unexpected range list entry kind");<br>
-    return Value1;<br>
-  }<br>
-  void dump(raw_ostream &OS, DWARFContext *C, uint8_t AddrSize,<br>
-            uint64_t &CurrentBase, unsigned Indent, uint16_t Version,<br>
-            uint8_t MaxEncodingStringLength = 0,<br>
-            DIDumpOptions DumpOpts = {}) const;<br>
+  Error extract(DWARFDataExtractor Data, uint32_t End, uint32_t *OffsetPtr);<br>
+  void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength,<br>
+            uint64_t &CurrentBase, DIDumpOptions DumpOpts) const;<br>
+  bool isSentinel() const { return EntryKind == dwarf::DW_RLE_end_of_list; }<br>
 };<br>
 <br>
 /// A class representing a single rangelist.<br>
@@ -70,12 +49,10 @@ public:<br>
 <br>
 class DWARFDebugRnglistTable : public DWARFListTableBase<DWARFDebugRnglist> {<br>
 public:<br>
-  DWARFDebugRnglistTable(DWARFContext *C, StringRef SectionName,<br>
-                         bool isDWO = false)<br>
-      : DWARFListTableBase(C, SectionName, isDWO,<br>
+  DWARFDebugRnglistTable()<br>
+      : DWARFListTableBase(/* SectionName    = */ ".debug_rnglists",<br>
                            /* HeaderString   = */ "ranges:",<br>
-                           /* ListTypeString = */ "range",<br>
-                           dwarf::RangeListEncodingString) {}<br>
+                           /* ListTypeString = */ "range") {}<br>
 };<br>
 <br>
 } // end namespace llvm<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h Wed Sep 12 07:40:04 2018<br>
@@ -23,8 +23,6 @@<br>
 <br>
 namespace llvm {<br>
 <br>
-class DWARFContext;<br>
-<br>
 /// A base class for DWARF list entries, such as range or location list<br>
 /// entries.<br>
 struct DWARFListEntryBase {<br>
@@ -39,7 +37,6 @@ struct DWARFListEntryBase {<br>
 /// A base class for lists of entries that are extracted from a particular<br>
 /// section, such as range lists or location lists.<br>
 template <typename ListEntryType> class DWARFListType {<br>
-public:<br>
   using EntryType = ListEntryType;<br>
   using ListEntries = std::vector<EntryType>;<br>
 <br>
@@ -48,26 +45,11 @@ protected:<br>
 <br>
 public:<br>
   const ListEntries &getEntries() const { return Entries; }<br>
-  bool empty() const {<br>
-    return Entries.empty() || Entries.begin()->isEndOfList();<br>
-  }<br>
+  bool empty() const { return Entries.empty(); }<br>
   void clear() { Entries.clear(); }<br>
-  uint32_t getOffset() const {<br>
-    if (Entries.empty())<br>
-      return 0;<br>
-    return Entries.begin()->Offset;<br>
-  }<br>
-<br>
-  /// Extract a list. The caller must pass the correct DWARF version.<br>
-  /// The end-of-list entry is retained as the last element of the vector of<br>
-  /// entries.<br>
   Error extract(DWARFDataExtractor Data, uint32_t HeaderOffset, uint32_t End,<br>
-                uint16_t Version, uint32_t *OffsetPtr, StringRef SectionName,<br>
-                StringRef ListStringName, bool isDWO = false);<br>
-  void dump(raw_ostream &OS, DWARFContext *C, uint8_t AddressSize,<br>
-            uint64_t BaseAddress, unsigned Indent, uint16_t Version,<br>
-            size_t MaxEncodingStringLength = 0,<br>
-            DIDumpOptions DumpOpts = {}) const;<br>
+                uint32_t *OffsetPtr, StringRef SectionName,<br>
+                StringRef ListStringName);<br>
 };<br>
 <br>
 /// A class representing the header of a list table such as the range list<br>
@@ -85,9 +67,9 @@ class DWARFListTableHeader {<br>
     uint8_t AddrSize;<br>
     /// The size in bytes of a segment selector on the target architecture.<br>
     /// If the target system uses a flat address space, this value is 0.<br>
-    uint8_t SegSize = 0;<br>
+    uint8_t SegSize;<br>
     /// The number of offsets that follow the header before the range lists.<br>
-    uint32_t OffsetEntryCount = 0;<br>
+    uint32_t OffsetEntryCount;<br>
   };<br>
 <br>
   Header HeaderData;<br>
@@ -96,10 +78,10 @@ class DWARFListTableHeader {<br>
   /// FIXME: Generate the table and use the appropriate forms.<br>
   std::vector<uint32_t> Offsets;<br>
   /// The table's format, either DWARF32 or DWARF64.<br>
-  dwarf::DwarfFormat Format = dwarf::DwarfFormat::DWARF32;<br>
+  dwarf::DwarfFormat Format;<br>
   /// The offset at which the header (and hence the table) is located within<br>
   /// its section.<br>
-  uint32_t HeaderOffset = 0;<br>
+  uint32_t HeaderOffset;<br>
   /// The name of the section the list is located in.<br>
   StringRef SectionName;<br>
   /// A characterization of the list for dumping purposes, e.g. "range" or<br>
@@ -115,19 +97,8 @@ public:<br>
     Offsets.clear();<br>
   }<br>
   uint32_t getHeaderOffset() const { return HeaderOffset; }<br>
-<br>
   uint8_t getAddrSize() const { return HeaderData.AddrSize; }<br>
-  void setAddrSize(uint8_t AddrSize) { HeaderData.AddrSize = AddrSize; }<br>
-<br>
   uint32_t getLength() const { return HeaderData.Length; }<br>
-  void setLength(uint32_t Length) { HeaderData.Length = Length; }<br>
-<br>
-  uint16_t getVersion() const { return HeaderData.Version; }<br>
-  void setVersion(uint16_t Version) { HeaderData.Version = Version; }<br>
-<br>
-  uint8_t getSegSize() const { return HeaderData.SegSize; }<br>
-  uint32_t getOffsetEntryCount() const { return HeaderData.OffsetEntryCount; }<br>
-<br>
   StringRef getSectionName() const { return SectionName; }<br>
   StringRef getListTypeString() const { return ListTypeString; }<br>
   dwarf::DwarfFormat getFormat() const { return Format; }<br>
@@ -144,10 +115,8 @@ public:<br>
 <br>
   /// Returns the length of the table, including the length field, or 0 if the<br>
   /// length has not been determined (e.g. because the table has not yet been<br>
-  /// parsed, or there was a problem in parsing). In fake tables, such as for<br>
-  /// DWARF v4 and earlier, there is no header, so the length simply reflects<br>
-  /// the size of the section.<br>
-  uint32_t getTableLength() const;<br>
+  /// parsed, or there was a problem in parsing).<br>
+  uint32_t length() const;<br>
 };<br>
 <br>
 /// A class representing a table of lists as specified in the DWARF v5<br>
@@ -160,22 +129,14 @@ template <typename DWARFListType> class<br>
   /// A mapping between file offsets and lists. It is used to find a particular<br>
   /// list based on an offset (obtained from DW_AT_ranges, for example).<br>
   std::map<uint32_t, DWARFListType> ListMap;<br>
-  DWARFContext *C;<br>
-  /// True if this list is located in a split-DWARF (dwo or dwp) file.<br>
-  bool isDWO;<br>
   /// This string is displayed as a heading before the list is dumped<br>
   /// (e.g. "ranges:").<br>
   StringRef HeaderString;<br>
-  /// A function returning the encoding string for a given list entry encoding,<br>
-  /// e.g. "DW_RLE_start_end".<br>
-  std::function<StringRef(unsigned)> EncodingString;<br>
 <br>
 protected:<br>
-  DWARFListTableBase(DWARFContext *C, StringRef SectionName, bool isDWO,<br>
-                     StringRef HeaderString, StringRef ListTypeString,<br>
-                     std::function<StringRef(unsigned)> EncodingString)<br>
-      : Header(SectionName, ListTypeString), C(C), isDWO(isDWO),<br>
-        HeaderString(HeaderString), EncodingString(EncodingString) {}<br>
+  DWARFListTableBase(StringRef SectionName, StringRef HeaderString,<br>
+                     StringRef ListTypeString)<br>
+      : Header(SectionName, ListTypeString), HeaderString(HeaderString) {}<br>
 <br>
 public:<br>
   void clear() {<br>
@@ -186,28 +147,14 @@ public:<br>
   Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint32_t *OffsetPtr) {<br>
     return Header.extract(Data, OffsetPtr);<br>
   }<br>
-<br>
-  /// Initialize the table header to explicit values. This is used for DWARF v4<br>
-  /// and earlier since there is no header that can be extracted from a section.<br>
-  void setHeaderData(uint32_t Length, uint16_t Version, uint8_t AddrSize) {<br>
-    assert(Header.getSegSize() == 0 &&<br>
-           "Unexpected segsize in list table header.");<br>
-    assert(Header.getOffsetEntryCount() == 0 &&<br>
-           "Unexpected offset entry count in list table header.");<br>
-    Header.setLength(Length);<br>
-    Header.setVersion(Version);<br>
-    Header.setAddrSize(AddrSize);<br>
-  }<br>
-<br>
   /// Extract an entire table, including all list entries.<br>
-  Error extract(DWARFDataExtractor Data, uint16_t Version, uint32_t *OffsetPtr);<br>
+  Error extract(DWARFDataExtractor Data, uint32_t *OffsetPtr);<br>
   /// Look up a list based on a given offset. Extract it and enter it into the<br>
   /// list map if necessary.<br>
   Expected<DWARFListType> findList(DWARFDataExtractor Data, uint32_t Offset);<br>
 <br>
   uint32_t getHeaderOffset() const { return Header.getHeaderOffset(); }<br>
   uint8_t getAddrSize() const { return Header.getAddrSize(); }<br>
-  StringRef getListTypeString() const { return Header.getListTypeString(); }<br>
 <br>
   void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const;<br>
 <br>
@@ -228,35 +175,25 @@ public:<br>
     llvm_unreachable("Invalid DWARF format (expected DWARF32 or DWARF64");<br>
   }<br>
 <br>
-  uint16_t getVersion() const { return Header.getVersion(); }<br>
-  uint32_t getLength() const { return Header.getTableLength(); }<br>
+  uint32_t length() { return Header.length(); }<br>
 };<br>
 <br>
 template <typename DWARFListType><br>
 Error DWARFListTableBase<DWARFListType>::extract(DWARFDataExtractor Data,<br>
-                                                 uint16_t Version,<br>
                                                  uint32_t *OffsetPtr) {<br>
-  assert(Version > 0 && "DWARF version required and not given.");<br>
   clear();<br>
-  // For DWARF v4 and earlier, we cannot extract a table header, so we<br>
-  // initialize it explicitly.<br>
-  if (Version < 5)<br>
-    setHeaderData(Data.size(), Version, Data.getAddressSize());<br>
-  else if (Error E = extractHeaderAndOffsets(Data, OffsetPtr))<br>
+  if (Error E = extractHeaderAndOffsets(Data, OffsetPtr))<br>
     return E;<br>
 <br>
   Data.setAddressSize(Header.getAddrSize());<br>
-  uint32_t End = getHeaderOffset() + getLength();<br>
-  // Extract all lists.<br>
+  uint32_t End = getHeaderOffset() + Header.length();<br>
   while (*OffsetPtr < End) {<br>
     DWARFListType CurrentList;<br>
     uint32_t Off = *OffsetPtr;<br>
-    if (Error E = CurrentList.extract(<br>
-            Data, getHeaderOffset(), End, Header.getVersion(), OffsetPtr,<br>
-            Header.getSectionName(), Header.getListTypeString(), isDWO)) {<br>
-      *OffsetPtr = End;<br>
+    if (Error E = CurrentList.extract(Data, getHeaderOffset(), End, OffsetPtr,<br>
+                                      Header.getSectionName(),<br>
+                                      Header.getListTypeString()))<br>
       return E;<br>
-    }<br>
     ListMap[Off] = CurrentList;<br>
   }<br>
 <br>
@@ -267,10 +204,11 @@ Error DWARFListTableBase<DWARFListType>:<br>
 }<br>
 <br>
 template <typename ListEntryType><br>
-Error DWARFListType<ListEntryType>::extract(<br>
-    DWARFDataExtractor Data, uint32_t HeaderOffset, uint32_t End,<br>
-    uint16_t Version, uint32_t *OffsetPtr, StringRef SectionName,<br>
-    StringRef ListTypeString, bool isDWO) {<br>
+Error DWARFListType<ListEntryType>::extract(DWARFDataExtractor Data,<br>
+                                            uint32_t HeaderOffset, uint32_t End,<br>
+                                            uint32_t *OffsetPtr,<br>
+                                            StringRef SectionName,<br>
+                                            StringRef ListTypeString) {<br>
   if (*OffsetPtr < HeaderOffset || *OffsetPtr >= End)<br>
     return createStringError(errc::invalid_argument,<br>
                        "invalid %s list offset 0x%" PRIx32,<br>
@@ -278,11 +216,10 @@ Error DWARFListType<ListEntryType>::extr<br>
   Entries.clear();<br>
   while (*OffsetPtr < End) {<br>
     ListEntryType Entry;<br>
-    if (Error E =<br>
-            Entry.extract(Data, End, Version, SectionName, OffsetPtr, isDWO))<br>
+    if (Error E = Entry.extract(Data, End, OffsetPtr))<br>
       return E;<br>
     Entries.push_back(Entry);<br>
-    if (Entry.isEndOfList())<br>
+    if (Entry.isSentinel())<br>
       return Error::success();<br>
   }<br>
   return createStringError(errc::illegal_byte_sequence,<br>
@@ -291,41 +228,28 @@ Error DWARFListType<ListEntryType>::extr<br>
                      SectionName.data(), HeaderOffset);<br>
 }<br>
 <br>
-template <typename ListEntryType><br>
-void DWARFListType<ListEntryType>::dump(raw_ostream &OS, DWARFContext *C,<br>
-                                        uint8_t AddressSize,<br>
-                                        uint64_t BaseAddress, unsigned Indent,<br>
-                                        uint16_t Version,<br>
-                                        size_t MaxEncodingStringLength,<br>
-                                        DIDumpOptions DumpOpts) const {<br>
-  uint64_t CurrentBase = BaseAddress;<br>
-  for (const auto &Entry : Entries)<br>
-    Entry.dump(OS, C, AddressSize, CurrentBase, Indent, Version,<br>
-               MaxEncodingStringLength, DumpOpts);<br>
-}<br>
-<br>
 template <typename DWARFListType><br>
 void DWARFListTableBase<DWARFListType>::dump(raw_ostream &OS,<br>
                                              DIDumpOptions DumpOpts) const {<br>
+  Header.dump(OS, DumpOpts);<br>
+  OS << HeaderString << "\n";<br>
+<br>
+  // Determine the length of the longest encoding string we have in the table,<br>
+  // so we can align the output properly. We only need this in verbose mode.<br>
   size_t MaxEncodingStringLength = 0;<br>
-  // Don't dump the fake table header we create for DWARF v4 and earlier.<br>
-  if (Header.getVersion() > 4) {<br>
-    Header.dump(OS, DumpOpts);<br>
-    OS << HeaderString << '\n';<br>
-    // Determine the length of the longest encoding string we have in the table,<br>
-    // so we can align the output properly. We only need this in verbose mode.<br>
-    if (DumpOpts.Verbose)<br>
-      for (const auto &List : ListMap)<br>
-        for (const auto &Entry : List.second.getEntries())<br>
-          MaxEncodingStringLength = std::max(<br>
-              MaxEncodingStringLength, EncodingString(Entry.EntryKind).size());<br>
+  if (DumpOpts.Verbose) {<br>
+    for (const auto &List : ListMap)<br>
+      for (const auto &Entry : List.second.getEntries())<br>
+        MaxEncodingStringLength =<br>
+            std::max(MaxEncodingStringLength,<br>
+                     dwarf::RangeListEncodingString(Entry.EntryKind).size());<br>
   }<br>
 <br>
   uint64_t CurrentBase = 0;<br>
-  for (const auto &List : ListMap) {<br>
-    List.second.dump(OS, C, getAddrSize(), CurrentBase, 0, Header.getVersion(),<br>
-                     MaxEncodingStringLength, DumpOpts);<br>
-  }<br>
+  for (const auto &List : ListMap)<br>
+    for (const auto &Entry : List.second.getEntries())<br>
+      Entry.dump(OS, getAddrSize(), MaxEncodingStringLength, CurrentBase,<br>
+                 DumpOpts);<br>
 }<br>
 <br>
 template <typename DWARFListType><br>
@@ -338,11 +262,11 @@ DWARFListTableBase<DWARFListType>::findL<br>
 <br>
   // Extract the list from the section and enter it into the list map.<br>
   DWARFListType List;<br>
-  uint32_t End = getHeaderOffset() + getLength();<br>
+  uint32_t End = getHeaderOffset() + Header.length();<br>
   uint32_t StartingOffset = Offset;<br>
-  if (Error E = List.extract(Data, getHeaderOffset(), End, Header.getVersion(),<br>
-                             &Offset, Header.getSectionName(),<br>
-                             Header.getListTypeString(), isDWO))<br>
+  if (Error E =<br>
+          List.extract(Data, getHeaderOffset(), End, &Offset,<br>
+                       Header.getSectionName(), Header.getListTypeString()))<br>
     return std::move(E);<br>
   ListMap[StartingOffset] = List;<br>
   return List;<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h Wed Sep 12 07:40:04 2018<br>
@@ -17,6 +17,7 @@<br>
 #include "llvm/ADT/iterator_range.h"<br>
 #include "llvm/BinaryFormat/Dwarf.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h"<br>
+#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFDie.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"<br>
@@ -305,6 +306,12 @@ public:<br>
     return DataExtractor(StringSection, false, 0);<br>
   }<br>
 <br>
+  /// Extract the range list referenced by this compile unit from the<br>
+  /// .debug_ranges section. If the extraction is unsuccessful, an error<br>
+  /// is returned. Successful extraction requires that the compile unit<br>
+  /// has already been extracted.<br>
+  Error extractRangeList(uint32_t RangeListOffset,<br>
+                         DWARFDebugRangeList &RangeList) const;<br>
   void clear();<br>
 <br>
   const Optional<StrOffsetsContributionDescriptor> &<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/CMakeLists.txt Wed Sep 12 07:40:04 2018<br>
@@ -15,6 +15,7 @@ add_llvm_library(LLVMDebugInfoDWARF<br>
   DWARFDebugLoc.cpp<br>
   DWARFDebugMacro.cpp<br>
   DWARFDebugPubTable.cpp<br>
+  DWARFDebugRangeList.cpp<br>
   DWARFDebugRnglists.cpp<br>
   DWARFDie.cpp<br>
   DWARFExpression.cpp<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Wed Sep 12 07:40:04 2018<br>
@@ -25,6 +25,7 @@<br>
 #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFDebugPubTable.h"<br>
+#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFDie.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"<br>
@@ -266,29 +267,24 @@ static void dumpAddrSection(raw_ostream<br>
   }<br>
 }<br>
 <br>
-// Dump a section that contains a sequence of tables of lists, such as range<br>
-// or location list tables. In DWARF v5 we expect to find properly formatted<br>
-// tables with headers. In DWARF v4 and earlier we simply expect a sequence of<br>
-// lists, which we treat, mutatis mutandis, like DWARF v5 tables.<br>
-template <typename ListTable><br>
-static void dumpListSection(raw_ostream &OS, DWARFContext *C,<br>
-                            StringRef SectionName, uint16_t MaxVersion,<br>
-                            DWARFDataExtractor &ListData,<br>
-                            DIDumpOptions DumpOpts, bool isDWO = false) {<br>
+// Dump the .debug_rnglists or .debug_rnglists.dwo section (DWARF v5).<br>
+static void dumpRnglistsSection(raw_ostream &OS,<br>
+                                DWARFDataExtractor &rnglistData,<br>
+                                DIDumpOptions DumpOpts) {<br>
   uint32_t Offset = 0;<br>
-  while (ListData.isValidOffset(Offset)) {<br>
-    ListTable Table(C, SectionName, isDWO);<br>
-    if (Error Err = Table.extract(ListData, MaxVersion, &Offset)) {<br>
+  while (rnglistData.isValidOffset(Offset)) {<br>
+    llvm::DWARFDebugRnglistTable Rnglists;<br>
+    uint32_t TableOffset = Offset;<br>
+    if (Error Err = Rnglists.extract(rnglistData, &Offset)) {<br>
       WithColor::error() << toString(std::move(Err)) << '\n';<br>
-      // If table extraction set Offset to 0, it indicates that we cannot<br>
-      // continue to read the section.<br>
-      if (Offset == 0)<br>
+      uint64_t Length = Rnglists.length();<br>
+      // Keep going after an error, if we can, assuming that the length field<br>
+      // could be read. If it couldn't, stop reading the section.<br>
+      if (Length == 0)<br>
         break;<br>
-      // In DWARF v4 and earlier, dump as much of the lists as we can.<br>
-      if (MaxVersion < 5)<br>
-        Table.dump(OS, DumpOpts);<br>
+      Offset = TableOffset + Length;<br>
     } else {<br>
-      Table.dump(OS, DumpOpts);<br>
+      Rnglists.dump(OS, DumpOpts);<br>
     }<br>
   }<br>
 }<br>
@@ -488,25 +484,29 @@ void DWARFContext::dump(<br>
     uint8_t savedAddressByteSize = getCUAddrSize();<br>
     DWARFDataExtractor rangesData(*DObj, DObj->getRangeSection(),<br>
                                   isLittleEndian(), savedAddressByteSize);<br>
-    dumpListSection<DWARFDebugRnglistTable>(<br>
-        OS, this, ".debug_ranges", /* MaxVersion = */ 4, rangesData, DumpOpts);<br>
+    uint32_t offset = 0;<br>
+    DWARFDebugRangeList rangeList;<br>
+    while (rangesData.isValidOffset(offset)) {<br>
+      if (Error E = rangeList.extract(rangesData, &offset)) {<br>
+        WithColor::error() << toString(std::move(E)) << '\n';<br>
+        break;<br>
+      }<br>
+      rangeList.dump(OS);<br>
+    }<br>
   }<br>
 <br>
   if (shouldDump(Explicit, ".debug_rnglists", DIDT_ID_DebugRnglists,<br>
                  DObj->getRnglistsSection().Data)) {<br>
     DWARFDataExtractor RnglistData(*DObj, DObj->getRnglistsSection(),<br>
-                                   isLittleEndian(), getCUAddrSize());<br>
-    dumpListSection<DWARFDebugRnglistTable>(<br>
-        OS, this, ".debug_rnglists", getMaxVersion(5), RnglistData, DumpOpts);<br>
+                                   isLittleEndian(), 0);<br>
+    dumpRnglistsSection(OS, RnglistData, DumpOpts);<br>
   }<br>
 <br>
   if (shouldDump(ExplicitDWO, ".debug_rnglists.dwo", DIDT_ID_DebugRnglists,<br>
                  DObj->getRnglistsDWOSection().Data)) {<br>
     DWARFDataExtractor RnglistData(*DObj, DObj->getRnglistsDWOSection(),<br>
-                                   isLittleEndian(), getCUAddrSize());<br>
-    dumpListSection<DWARFDebugRnglistTable>(OS, this, ".debug_rnglists.dwo",<br>
-                                            getMaxVersion(5), RnglistData,<br>
-                                            DumpOpts);<br>
+                                   isLittleEndian(), 0);<br>
+    dumpRnglistsSection(OS, RnglistData, DumpOpts);<br>
   }<br>
 <br>
   if (shouldDump(Explicit, ".debug_pubnames", DIDT_ID_DebugPubnames,<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp Wed Sep 12 07:40:04 2018<br>
@@ -13,30 +13,19 @@<br>
 #include "llvm/Support/Errc.h"<br>
 #include "llvm/Support/Error.h"<br>
 #include "llvm/Support/Format.h"<br>
-#include "llvm/Support/MathExtras.h"<br>
 #include "llvm/Support/raw_ostream.h"<br>
 <br>
 using namespace llvm;<br>
 <br>
 Error RangeListEntry::extract(DWARFDataExtractor Data, uint32_t End,<br>
-                              uint16_t Version, StringRef /* SectionName */,<br>
-                              uint32_t *OffsetPtr, bool /* isDWO */) {<br>
+                              uint32_t *OffsetPtr) {<br>
   Offset = *OffsetPtr;<br>
   SectionIndex = -1ULL;<br>
-<br>
-  assert((Data.getAddressSize() == 4 || Data.getAddressSize() == 8) &&<br>
-         "Unsupported address size");<br>
-<br>
-  // We model a DWARF v4 range list entry like DWARF v5 DW_RLE_offset_pair,<br>
-  // since it is subject to base adjustment.<br>
-  uint8_t Encoding = dwarf::DW_RLE_offset_pair;<br>
-  if (Version > 4) {<br>
-    // The caller should guarantee that we have at least 1 byte available, so<br>
-    // we just assert instead of revalidate.<br>
-    assert(*OffsetPtr < End &&<br>
-           "not enough space to extract a rangelist encoding");<br>
-    Encoding = Data.getU8(OffsetPtr);<br>
-  }<br>
+  // The caller should guarantee that we have at least 1 byte available, so<br>
+  // we just assert instead of revalidate.<br>
+  assert(*OffsetPtr < End &&<br>
+         "not enough space to extract a rangelist encoding");<br>
+  uint8_t Encoding = Data.getU8(OffsetPtr);<br>
 <br>
   switch (Encoding) {<br>
   case dwarf::DW_RLE_end_of_list:<br>
@@ -59,23 +48,6 @@ Error RangeListEntry::extract(DWARFDataE<br>
                        "at offset 0x%" PRIx32,<br>
                        *OffsetPtr - 1);<br>
   case dwarf::DW_RLE_offset_pair: {<br>
-    if (Version < 5) {<br>
-      if ((End - *OffsetPtr) < unsigned(Data.getAddressSize() * 2))<br>
-        return createStringError(<br>
-            errc::illegal_byte_sequence,<br>
-            "invalid range list entry at offset 0x%" PRIx32, *OffsetPtr);<br>
-      Value0 = Data.getRelocatedAddress(OffsetPtr);<br>
-      Value1 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex);<br>
-      // Adjust the EntryKind for end-of-list and base_address based on the<br>
-      // contents.<br>
-      if (Value0 == maxUIntN(Data.getAddressSize() * 8)) {<br>
-        Encoding = dwarf::DW_RLE_base_address;<br>
-        Value0 = Value1;<br>
-        Value1 = 0;<br>
-      } else if (Value0 == 0 && Value1 == 0)<br>
-        Encoding = dwarf::DW_RLE_end_of_list;<br>
-      break;<br>
-    }<br>
     uint32_t PreviousOffset = *OffsetPtr - 1;<br>
     Value0 = Data.getULEB128(OffsetPtr);<br>
     Value1 = Data.getULEB128(OffsetPtr);<br>
@@ -86,7 +58,7 @@ Error RangeListEntry::extract(DWARFDataE<br>
                          PreviousOffset);<br>
     break;<br>
   }<br>
-  case dwarf::DW_RLE_base_address:<br>
+  case dwarf::DW_RLE_base_address: {<br>
     if ((End - *OffsetPtr) < Data.getAddressSize())<br>
       return createStringError(errc::invalid_argument,<br>
                          "insufficient space remaining in table for "<br>
@@ -94,16 +66,18 @@ Error RangeListEntry::extract(DWARFDataE<br>
                          *OffsetPtr - 1);<br>
     Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex);<br>
     break;<br>
-  case dwarf::DW_RLE_start_end:<br>
+  }<br>
+  case dwarf::DW_RLE_start_end: {<br>
     if ((End - *OffsetPtr) < unsigned(Data.getAddressSize() * 2))<br>
       return createStringError(errc::invalid_argument,<br>
                          "insufficient space remaining in table for "<br>
                          "DW_RLE_start_end encoding "<br>
                          "at offset 0x%" PRIx32,<br>
                          *OffsetPtr - 1);<br>
-    Value0 = Data.getRelocatedAddress(OffsetPtr);<br>
-    Value1 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex);<br>
+    Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex);<br>
+    Value1 = Data.getRelocatedAddress(OffsetPtr);<br>
     break;<br>
+  }<br>
   case dwarf::DW_RLE_start_length: {<br>
     uint32_t PreviousOffset = *OffsetPtr - 1;<br>
     Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex);<br>
@@ -169,10 +143,9 @@ DWARFAddressRangesVector DWARFDebugRngli<br>
   return Res;<br>
 }<br>
 <br>
-void RangeListEntry::dump(raw_ostream &OS, DWARFContext *, uint8_t AddrSize,<br>
-                          uint64_t &CurrentBase, unsigned Indent,<br>
-                          uint16_t Version, uint8_t MaxEncodingStringLength,<br>
-                          DIDumpOptions DumpOpts) const {<br>
+void RangeListEntry::dump(raw_ostream &OS, uint8_t AddrSize,<br>
+                          uint8_t MaxEncodingStringLength,<br>
+                          uint64_t &CurrentBase, DIDumpOptions DumpOpts) const {<br>
   auto PrintRawEntry = [](raw_ostream &OS, const RangeListEntry &Entry,<br>
                           uint8_t AddrSize, DIDumpOptions DumpOpts) {<br>
     if (DumpOpts.Verbose) {<br>
@@ -183,49 +156,27 @@ void RangeListEntry::dump(raw_ostream &O<br>
     }<br>
   };<br>
 <br>
-  // Output indentations before we print the actual entry. We only print<br>
-  // anything for DW_RLE_base_address when we are in verbose mode.<br>
-  if (DumpOpts.Verbose || !isBaseAddressSelectionEntry())<br>
-    OS.indent(Indent);<br>
-<br>
   if (DumpOpts.Verbose) {<br>
     // Print the section offset in verbose mode.<br>
     OS << format("0x%8.8" PRIx32 ":", Offset);<br>
-    if (Version > 4) {<br>
-      auto EncodingString = dwarf::RangeListEncodingString(EntryKind);<br>
-      // Unsupported encodings should have been reported during parsing.<br>
-      assert(!EncodingString.empty() && "Unknown range entry encoding");<br>
-      OS << format(" [%s%*c", EncodingString.data(),<br>
-                   MaxEncodingStringLength - EncodingString.size() + 1, ']');<br>
-      if (!isEndOfList())<br>
-        OS << ": ";<br>
-    }<br>
+    auto EncodingString = dwarf::RangeListEncodingString(EntryKind);<br>
+    // Unsupported encodings should have been reported during parsing.<br>
+    assert(!EncodingString.empty() && "Unknown range entry encoding");<br>
+    OS << format(" [%s%*c", EncodingString.data(),<br>
+                 MaxEncodingStringLength - EncodingString.size() + 1, ']');<br>
+    if (EntryKind != dwarf::DW_RLE_end_of_list)<br>
+      OS << ": ";<br>
   }<br>
 <br>
   switch (EntryKind) {<br>
   case dwarf::DW_RLE_end_of_list:<br>
-    if (DumpOpts.Verbose) {<br>
-      // For DWARF v4 and earlier, we print the raw entry, i.e. 2 zeros.<br>
-      if (Version < 5) {<br>
-        OS << format(" 0x%*.*" PRIx64, AddrSize * 2, AddrSize * 2, Value0);<br>
-        OS << format(", 0x%*.*" PRIx64, AddrSize * 2, AddrSize * 2, Value1);<br>
-      }<br>
-      break;<br>
-    }<br>
-    OS << "<End of list>";<br>
+    OS << (DumpOpts.Verbose ? "" : "<End of list>");<br>
     break;<br>
   case dwarf::DW_RLE_base_address:<br>
-    // In non-verbose mode, we do not print anything for this entry.<br>
+    // In non-verbose mode we do not print anything for this entry.<br>
     CurrentBase = Value0;<br>
     if (!DumpOpts.Verbose)<br>
       return;<br>
-    if (Version < 5) {<br>
-      // Dump the entry in pre-DWARF v5 format, i.e. with a -1 as Value0.<br>
-      uint64_t allOnes = maxUIntN(AddrSize * 8);<br>
-      OS << format(" 0x%*.*" PRIx64, AddrSize * 2, AddrSize * 2, allOnes);<br>
-      OS << format(", 0x%*.*" PRIx64, AddrSize * 2, AddrSize * 2, Value0);<br>
-      break;<br>
-    }<br>
     OS << format(" 0x%*.*" PRIx64, AddrSize * 2, AddrSize * 2, Value0);<br>
     break;<br>
   case dwarf::DW_RLE_start_length:<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp Wed Sep 12 07:40:04 2018<br>
@@ -15,6 +15,7 @@<br>
 #include "llvm/BinaryFormat/Dwarf.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"<br>
+#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFExpression.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFUnit.h"<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp Wed Sep 12 07:40:04 2018<br>
@@ -20,43 +20,30 @@ Error DWARFListTableHeader::extract(DWAR<br>
                                     uint32_t *OffsetPtr) {<br>
   HeaderOffset = *OffsetPtr;<br>
   // Read and verify the length field.<br>
-  if (!Data.isValidOffsetForDataOfSize(*OffsetPtr, sizeof(uint32_t))) {<br>
-    // By setting *OffsetPtr to 0, we indicate to the caller that <br>
-    // we could not detemine the length of the table.<br>
-    *OffsetPtr = 0;<br>
+  if (!Data.isValidOffsetForDataOfSize(*OffsetPtr, sizeof(uint32_t)))<br>
     return createStringError(errc::invalid_argument,<br>
                        "section is not large enough to contain a "<br>
                        "%s table length at offset 0x%" PRIx32,<br>
-                       SectionName.data(), HeaderOffset);<br>
-  }<br>
+                       SectionName.data(), *OffsetPtr);<br>
   // TODO: Add support for DWARF64.<br>
   HeaderData.Length = Data.getU32(OffsetPtr);<br>
-  if (HeaderData.Length == 0xffffffffu) {<br>
-    *OffsetPtr = 0;<br>
+  if (HeaderData.Length == 0xffffffffu)<br>
     return createStringError(errc::not_supported,<br>
                        "DWARF64 is not supported in %s at offset 0x%" PRIx32,<br>
                        SectionName.data(), HeaderOffset);<br>
-  }<br>
-<br>
-  uint32_t TableLength = HeaderData.Length + sizeof(uint32_t);<br>
-  uint32_t End = HeaderOffset + TableLength;<br>
   Format = dwarf::DwarfFormat::DWARF32;<br>
-  if (TableLength < sizeof(Header)) {<br>
-    *OffsetPtr = End;<br>
-    return createStringError(<br>
-        errc::invalid_argument,<br>
-        "%s table at offset 0x%" PRIx32 " has too small length (0x%" PRIx32<br>
-        ") to contain a complete header",<br>
-        SectionName.data(), HeaderOffset, TableLength);<br>
-  }<br>
-  if (!Data.isValidOffsetForDataOfSize(HeaderOffset, TableLength)) {<br>
-    *OffsetPtr = 0;   // No recovery if the length exceeds the section size.<br>
-    return createStringError(<br>
-        errc::invalid_argument,<br>
-        "section is not large enough to contain a %s table "<br>
-        "of length 0x%" PRIx32 " at offset 0x%" PRIx32,<br>
-        SectionName.data(), TableLength, HeaderOffset);<br>
-  }<br>
+  if (HeaderData.Length + sizeof(uint32_t) < sizeof(Header))<br>
+    return createStringError(errc::invalid_argument,<br>
+                       "%s table at offset 0x%" PRIx32<br>
+                       " has too small length (0x%" PRIx32<br>
+                       ") to contain a complete header",<br>
+                       SectionName.data(), HeaderOffset, length());<br>
+  uint32_t End = HeaderOffset + length();<br>
+  if (!Data.isValidOffsetForDataOfSize(HeaderOffset, End - HeaderOffset))<br>
+    return createStringError(errc::invalid_argument,<br>
+                       "section is not large enough to contain a %s table "<br>
+                       "of length 0x%" PRIx32 " at offset 0x%" PRIx32,<br>
+                       SectionName.data(), length(), HeaderOffset);<br>
 <br>
   HeaderData.Version = Data.getU16(OffsetPtr);<br>
   HeaderData.AddrSize = Data.getU8(OffsetPtr);<br>
@@ -64,36 +51,27 @@ Error DWARFListTableHeader::extract(DWAR<br>
   HeaderData.OffsetEntryCount = Data.getU32(OffsetPtr);<br>
 <br>
   // Perform basic validation of the remaining header fields.<br>
-  if (HeaderData.Version != 5) {<br>
-    *OffsetPtr = End;<br>
+  if (HeaderData.Version != 5)<br>
     return createStringError(errc::invalid_argument,<br>
-                             "unrecognised %s table version %" PRIu16<br>
-                             " in table at offset 0x%" PRIx32,<br>
-                             SectionName.data(), HeaderData.Version,<br>
-                             HeaderOffset);<br>
-  }<br>
-  if (HeaderData.AddrSize != 4 && HeaderData.AddrSize != 8) {<br>
-    *OffsetPtr = End;<br>
+                       "unrecognised %s table version %" PRIu16<br>
+                       " in table at offset 0x%" PRIx32,<br>
+                       SectionName.data(), HeaderData.Version, HeaderOffset);<br>
+  if (HeaderData.AddrSize != 4 && HeaderData.AddrSize != 8)<br>
     return createStringError(errc::not_supported,<br>
                        "%s table at offset 0x%" PRIx32<br>
                        " has unsupported address size %" PRIu8,<br>
                        SectionName.data(), HeaderOffset, HeaderData.AddrSize);<br>
-  }<br>
-  if (HeaderData.SegSize != 0) {<br>
-    *OffsetPtr = End;<br>
+  if (HeaderData.SegSize != 0)<br>
     return createStringError(errc::not_supported,<br>
                        "%s table at offset 0x%" PRIx32<br>
                        " has unsupported segment selector size %" PRIu8,<br>
                        SectionName.data(), HeaderOffset, HeaderData.SegSize);<br>
-  }<br>
   if (End < HeaderOffset + sizeof(HeaderData) +<br>
-                HeaderData.OffsetEntryCount * sizeof(uint32_t)) {<br>
-    *OffsetPtr = End;<br>
+                HeaderData.OffsetEntryCount * sizeof(uint32_t))<br>
     return createStringError(errc::invalid_argument,<br>
         "%s table at offset 0x%" PRIx32 " has more offset entries (%" PRIu32<br>
         ") than there is space for",<br>
         SectionName.data(), HeaderOffset, HeaderData.OffsetEntryCount);<br>
-  }<br>
   Data.setAddressSize(HeaderData.AddrSize);<br>
   for (uint32_t I = 0; I < HeaderData.OffsetEntryCount; ++I)<br>
     Offsets.push_back(Data.getU32(OffsetPtr));<br>
@@ -123,11 +101,9 @@ void DWARFListTableHeader::dump(raw_ostr<br>
   }<br>
 }<br>
 <br>
-uint32_t DWARFListTableHeader::getTableLength() const {<br>
+uint32_t DWARFListTableHeader::length() const {<br>
   if (HeaderData.Length == 0)<br>
     return 0;<br>
-  assert(HeaderData.Version > 0 &&<br>
-         "No DWARF version in header when using getTableLength()");<br>
   // TODO: DWARF64 support.<br>
-  return HeaderData.Length + (HeaderData.Version > 4) * sizeof(uint32_t);<br>
+  return HeaderData.Length + sizeof(uint32_t);<br>
 }<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Wed Sep 12 07:40:04 2018<br>
@@ -264,16 +264,13 @@ bool DWARFUnitHeader::extract(DWARFConte<br>
   return true;<br>
 }<br>
 <br>
-// Parse a list table header, including the optional array of offsets<br>
+// Parse the rangelist table header, including the optional array of offsets<br>
 // following it (DWARF v5 and later).<br>
-template <typename DWARFListTable><br>
-static Expected<DWARFListTable><br>
-parseListTableHeader(DWARFDataExtractor DA, DWARFContext *C,<br>
-                     StringRef SectionName, uint32_t Offset, bool isDWO) {<br>
+static Expected<DWARFDebugRnglistTable><br>
+parseRngListTableHeader(DWARFDataExtractor &DA, uint32_t Offset) {<br>
   // TODO: Support DWARF64<br>
   // We are expected to be called with Offset 0 or pointing just past the table<br>
   // header, which is 12 bytes long for DWARF32.<br>
-  DWARFListTable Table(C, SectionName, isDWO);<br>
   if (Offset > 0) {<br>
     if (Offset < 12U)<br>
       return createStringError(errc::invalid_argument, "Did not detect a valid"<br>
@@ -281,46 +278,20 @@ parseListTableHeader(DWARFDataExtractor<br>
                                Offset);<br>
     Offset -= 12U;<br>
   }<br>
+  llvm::DWARFDebugRnglistTable Table;<br>
   if (Error E = Table.extractHeaderAndOffsets(DA, &Offset))<br>
     return std::move(E);<br>
   return Table;<br>
 }<br>
 <br>
-// Parse a DWARF v5 list table (e.g. either a rangelist table or a location<br>
-// list table). For DWARF units with version 4 or earlier, we instead create<br>
-// the table artifically by giving it a size that equals the section size.<br>
-template <typename DWARFListTable><br>
-static Optional<DWARFListTable><br>
-setupListTable(DWARFUnit *U, const DWARFSection *Section, StringRef SectionName,<br>
-               uint32_t &Base, bool isDWO, bool isLittleEndian) {<br>
-  if (!Section->Data.size())<br>
-    return None;<br>
-  DWARFContext &Ctx = U->getContext();<br>
-  DWARFListTable Table(&Ctx, SectionName, isDWO);<br>
-  // Parse the list table header. Individual lists are extracted lazily.<br>
-  DWARFDataExtractor DA(Ctx.getDWARFObj(), *Section, isLittleEndian,<br>
-                        U->getAddressByteSize());<br>
-  if (U->getVersion() < 5) {<br>
-    Base = 0;<br>
-    Table.setHeaderData(Section->Data.size(), U->getVersion(),<br>
-                        DA.getAddressSize());<br>
-    return Table;<br>
-  }<br>
-  if (auto TableOrError = parseListTableHeader<DWARFListTable>(<br>
-          DA, &Ctx, SectionName, Base, isDWO))<br>
-    Table = TableOrError.get();<br>
-  else {<br>
-    WithColor::error() << "parsing a " << Table.getListTypeString().data()<br>
-                       << " list table: " << toString(TableOrError.takeError())<br>
-                       << '\n';<br>
-    return None;<br>
-  }<br>
-  // In a split dwarf unit, there are no attributes like DW_AT_rnglists_base or<br>
-  // DW_AT_loclists_base that describe the table base. Adjust Base to point past<br>
-  // the table header which is expected to start at offset 0.<br>
-  if (isDWO)<br>
-    Base = Table.getHeaderSize();<br>
-  return Table;<br>
+Error DWARFUnit::extractRangeList(uint32_t RangeListOffset,<br>
+                                  DWARFDebugRangeList &RangeList) const {<br>
+  // Require that compile unit is extracted.<br>
+  assert(!DieArray.empty());<br>
+  DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection,<br>
+                                isLittleEndian, getAddressByteSize());<br>
+  uint32_t ActualRangeListOffset = RangeSectionBase + RangeListOffset;<br>
+  return RangeList.extract(RangesData, &ActualRangeListOffset);<br>
 }<br>
 <br>
 void DWARFUnit::clear() {<br>
@@ -440,20 +411,31 @@ size_t DWARFUnit::extractDIEsIfNeeded(bo<br>
 <br>
     // DWARF v5 uses the .debug_rnglists and .debug_rnglists.dwo sections to<br>
     // describe address ranges.<br>
-    StringRef RangeSectionName = ".debug_ranges";<br>
     if (getVersion() >= 5) {<br>
-      if (isDWO) {<br>
-        RangeSectionName = ".debug_rnglists.dwo";<br>
+      if (isDWO)<br>
         setRangesSection(&Context.getDWARFObj().getRnglistsDWOSection(), 0);<br>
-      } else {<br>
-        RangeSectionName = ".debug_rnglists";<br>
+      else<br>
         setRangesSection(&Context.getDWARFObj().getRnglistsSection(),<br>
                          toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0));<br>
+      if (RangeSection->Data.size()) {<br>
+        // Parse the range list table header. Individual range lists are<br>
+        // extracted lazily.<br>
+        DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,<br>
+                                    isLittleEndian, 0);<br>
+        if (auto TableOrError =<br>
+                parseRngListTableHeader(RangesDA, RangeSectionBase))<br>
+          RngListTable = TableOrError.get();<br>
+        else<br>
+          WithColor::error() << "parsing a range list table: "<br>
+                             << toString(TableOrError.takeError())<br>
+                             << '\n';<br>
+<br>
+        // In a split dwarf unit, there is no DW_AT_rnglists_base attribute.<br>
+        // Adjust RangeSectionBase to point past the table header.<br>
+        if (isDWO && RngListTable)<br>
+          RangeSectionBase = RngListTable->getHeaderSize();<br>
       }<br>
     }<br>
-    RngListTable = setupListTable<DWARFDebugRnglistTable>(<br>
-        this, RangeSection, RangeSectionName, RangeSectionBase, isDWO,<br>
-        isLittleEndian);<br>
 <br>
     // Don't fall back to DW_AT_GNU_ranges_base: it should be ignored for<br>
     // skeleton CU DIE, so that DWARF users not aware of it are not broken.<br>
@@ -495,9 +477,16 @@ bool DWARFUnit::parseDWO() {<br>
   DWO->setAddrOffsetSection(AddrOffsetSection, AddrOffsetSectionBase);<br>
   if (getVersion() >= 5) {<br>
     DWO->setRangesSection(&Context.getDWARFObj().getRnglistsDWOSection(), 0);<br>
-    DWO->RngListTable = setupListTable<DWARFDebugRnglistTable>(<br>
-        DWOCU, DWO->RangeSection, ".debug_rnglists.dwo", DWO->RangeSectionBase,<br>
-        /* isDWO =*/true, isLittleEndian);<br>
+    DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,<br>
+                                isLittleEndian, 0);<br>
+    if (auto TableOrError = parseRngListTableHeader(RangesDA, RangeSectionBase))<br>
+      DWO->RngListTable = TableOrError.get();<br>
+    else<br>
+      WithColor::error() << "parsing a range list table: "<br>
+                         << toString(TableOrError.takeError())<br>
+                         << '\n';<br>
+    if (DWO->RngListTable)<br>
+      DWO->RangeSectionBase = DWO->RngListTable->getHeaderSize();<br>
   } else {<br>
     auto DWORangesBase = UnitDie.getRangesBaseAttribute();<br>
     DWO->setRangesSection(RangeSection, DWORangesBase ? *DWORangesBase : 0);<br>
@@ -515,6 +504,12 @@ void DWARFUnit::clearDIEs(bool KeepCUDie<br>
 <br>
 Expected<DWARFAddressRangesVector><br>
 DWARFUnit::findRnglistFromOffset(uint32_t Offset) {<br>
+  if (getVersion() <= 4) {<br>
+    DWARFDebugRangeList RangeList;<br>
+    if (Error E = extractRangeList(Offset, RangeList))<br>
+      return std::move(E);<br>
+    return RangeList.getAbsoluteRanges(getBaseAddress());<br>
+  }<br>
   if (RngListTable) {<br>
     DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection,<br>
                                   isLittleEndian, RngListTable->getAddrSize());<br>
<br>
Modified: llvm/trunk/test/DebugInfo/Generic/cu-ranges.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/cu-ranges.ll?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/cu-ranges.ll?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/Generic/cu-ranges.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/Generic/cu-ranges.ll Wed Sep 12 07:40:04 2018<br>
@@ -4,18 +4,18 @@<br>
 <br>
 ; Check that we emit ranges for this which has a non-traditional section and a normal section.<br>
 <br>
-; CHECK:      .debug_info contents:<br>
-; CHECK:      DW_TAG_compile_unit<br>
-; CHECK-NOT:  DW_TAG<br>
-; CHECK:      DW_AT_ranges [DW_FORM_sec_offset] (0x<br>
-; CHECK-NEXT: "__TEXT,__foo"<br>
-; CHECK-NEXT: ".text")<br>
-; CHECK:      DW_TAG_subprogram<br>
-; CHECK:      DW_AT_low_pc<br>
-; CHECK:      DW_AT_high_pc<br>
-; CHECK:      DW_TAG_subprogram<br>
-; CHECK:      DW_AT_low_pc<br>
-; CHECK:      DW_AT_high_pc<br>
+; CHECK: DW_TAG_compile_unit<br>
+; CHECK: DW_AT_ranges<br>
+; CHECK: DW_TAG_subprogram<br>
+; CHECK: DW_AT_low_pc<br>
+; CHECK: DW_AT_high_pc<br>
+; CHECK: DW_TAG_subprogram<br>
+; CHECK: DW_AT_low_pc<br>
+; CHECK: DW_AT_high_pc<br>
+<br>
+; CHECK: .debug_ranges contents:<br>
+; FIXME: When we get better dumping facilities we'll want to elaborate here.<br>
+; CHECK: 00000000 <End of list><br>
 <br>
 ; Function Attrs: nounwind uwtable<br>
 define i32 @foo(i32 %a) #0 section "__TEXT,__foo" !dbg !4 {<br>
<br>
Modified: llvm/trunk/test/DebugInfo/Inputs/gmlt.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/gmlt.ll?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/gmlt.ll?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/Inputs/gmlt.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/Inputs/gmlt.ll Wed Sep 12 07:40:04 2018<br>
@@ -83,7 +83,7 @@<br>
 ; written in relocation places (dumper needs to be fixed to read the<br>
 ; relocations rather than interpret that as the end of a range list))<br>
 <br>
-; CHECK: 0x00000030: 0x0000000000000000, 0x0000000000000000<br>
+; CHECK: 00000000 <End of list><br>
 <br>
 <br>
 ; Check that we don't emit any pubnames or pubtypes under -gmlt<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s Wed Sep 12 07:40:04 2018<br>
@@ -1,6 +1,5 @@<br>
 # RUN: llvm-mc -triple x86_64-pc-linux -filetype=obj %s -o %t<br>
 # RUN: llvm-dwarfdump -v %t 2>%t.err | FileCheck %s<br>
-# RUN: llvm-dwarfdump --debug-ranges %t | FileCheck --check-prefix=TERSE %s<br>
 # RUN: FileCheck %s <%t.err -check-prefix=ERR<br>
 <br>
 # CHECK: .debug_info contents:<br>
@@ -11,24 +10,6 @@<br>
 # CHECK-NEXT:    [0x0000000000000003, 0x0000000000000006) ".text"<br>
 # CHECK-NEXT:    [0x0000000000000001, 0x0000000000000002) ".text.foo1")<br>
 <br>
-# CHECK:      .debug_ranges contents:<br>
-# CHECK-NEXT: 0x00000000: 0x0000000000000000, 0x0000000000000001 =><br>
-# CHECK-SAME: [0x0000000000000000, 0x0000000000000001)<br>
-# CHECK-NEXT: 0x00000010: 0x0000000000000003, 0x0000000000000006 =><br>
-# CHECK-SAME: [0x0000000000000003, 0x0000000000000006)<br>
-# CHECK-NEXT: 0x00000020: 0xffffffffffffffff, 0x0000000000000000<br>
-# CHECK-NEXT: 0x00000030: 0x0000000000000001, 0x0000000000000002 =><br>
-# CHECK-SAME: [0x0000000000000001, 0x0000000000000002)<br>
-# CHECK-NEXT: 0x00000040: 0x0000000000000000, 0x0000000000000000<br>
-<br>
-# TERSE:      .debug_ranges contents:<br>
-# TERSE-NEXT: [0x0000000000000000, 0x0000000000000001)<br>
-# TERSE-NEXT: [0x0000000000000003, 0x0000000000000006)<br>
-# TERSE-NEXT: [0x0000000000000001, 0x0000000000000002)<br>
-# TERSE-NEXT: <End of list><br>
-<br>
-<br>
-<br>
 .text<br>
 .globl foo<br>
 .type foo,@function<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/dwarfdump-ranges-unrelocated.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dwarfdump-ranges-unrelocated.s?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dwarfdump-ranges-unrelocated.s?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/dwarfdump-ranges-unrelocated.s (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/dwarfdump-ranges-unrelocated.s Wed Sep 12 07:40:04 2018<br>
@@ -9,13 +9,10 @@<br>
 # CHECK-NEXT:  [0x0000000000000000, 0x0000000000000003) ".text.foo2" [5])<br>
 <br>
 # CHECK: .debug_ranges contents:<br>
-# CHECK-NEXT: 0x00000000: 0x0000000000000000, 0x0000000000000001 =><br>
-# CHECK-SAME: [0x0000000000000000, 0x0000000000000001)<br>
-# CHECK-NEXT: 0x00000010: 0x0000000000000000, 0x0000000000000002 =><br>
-# CHECK-SAME: [0x0000000000000000, 0x0000000000000002)<br>
-# CHECK-NEXT: 0x00000020: 0x0000000000000000, 0x0000000000000003 =><br>
-# CHECK-SAME: [0x0000000000000000, 0x0000000000000003)<br>
-# CHCKK-NEXT: 0x00000030: 0x0000000000000000, 0x0000000000000000<br>
+# CHECK:   00000000 0000000000000000 0000000000000001<br>
+# CHECK:   00000000 0000000000000000 0000000000000002<br>
+# CHECK:   00000000 0000000000000000 0000000000000003<br>
+# CHECK:   00000000 <End of list><br>
 <br>
 # RUN: llvm-dwarfdump %t | FileCheck %s --check-prefix=BRIEF<br>
 # BRIEF: DW_TAG_compile_unit<br>
<br>
Modified: llvm/trunk/test/DebugInfo/dwarfdump-ranges.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-ranges.test?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-ranges.test?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/dwarfdump-ranges.test (original)<br>
+++ llvm/trunk/test/DebugInfo/dwarfdump-ranges.test Wed Sep 12 07:40:04 2018<br>
@@ -1,5 +1,4 @@<br>
 RUN: llvm-dwarfdump -v %p/Inputs/dwarfdump-test4.elf-x86-64 | FileCheck %s<br>
-RUN: llvm-dwarfdump --debug-ranges %p/Inputs/dwarfdump-test4.elf-x86-64 | FileCheck -check-prefix=TERSE %s<br>
 <br>
 CHECK: .debug_info contents:<br>
 CHECK: DW_TAG_compile_unit<br>
@@ -16,21 +15,10 @@ CHECK-NEXT:          [0x0000000000000637<br>
 <br>
 <br>
 CHECK:      .debug_ranges contents:<br>
-CHECK-NEXT: 0x00000000: 0x000000000000062c, 0x0000000000000637 =><br>
-CHECK-SAME: [0x000000000000062c, 0x0000000000000637)<br>
-CHECK-NEXT: 0x00000010: 0x0000000000000637, 0x000000000000063d =><br>
-CHECK-SAME: [0x0000000000000637, 0x000000000000063d)<br>
-CHECK-NEXT: 0x00000020: 0x0000000000000000, 0x0000000000000000<br>
-CHECK-NEXT: 0x00000030: 0x0000000000000640, 0x000000000000064b =><br>
-CHECK-SAME: [0x0000000000000640, 0x000000000000064b)<br>
-CHECK-NEXT: 0x00000040: 0x0000000000000637, 0x000000000000063d =><br>
-CHECK-SAME: [0x0000000000000637, 0x000000000000063d)<br>
-CHECK-NEXT: 0x00000050: 0x0000000000000000, 0x0000000000000000<br>
+CHECK-NEXT: 00000000 000000000000062c 0000000000000637<br>
+CHECK-NEXT: 00000000 0000000000000637 000000000000063d<br>
+CHECK-NEXT: 00000000 <End of list><br>
+CHECK-NEXT: 00000030 0000000000000640 000000000000064b<br>
+CHECK-NEXT: 00000030 0000000000000637 000000000000063d<br>
+CHECK-NEXT: 00000030 <End of list><br>
 <br>
-TERSE:      .debug_ranges contents:<br>
-TERSE-NEXT: [0x000000000000062c, 0x0000000000000637)<br>
-TERSE-NEXT: [0x0000000000000637, 0x000000000000063d)<br>
-TERSE-NEXT: <End of list><br>
-TERSE-NEXT: [0x0000000000000640, 0x000000000000064b)<br>
-TERSE-NEXT: [0x0000000000000637, 0x000000000000063d)<br>
-TERSE-NEXT: <End of list><br>
<br>
Modified: llvm/trunk/test/MC/ARM/dwarf-asm-multiple-sections.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/dwarf-asm-multiple-sections.s?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/dwarf-asm-multiple-sections.s?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/MC/ARM/dwarf-asm-multiple-sections.s (original)<br>
+++ llvm/trunk/test/MC/ARM/dwarf-asm-multiple-sections.s Wed Sep 12 07:40:04 2018<br>
@@ -64,11 +64,12 @@ b:<br>
 <br>
 <br>
 // DWARF: .debug_ranges contents:<br>
-// DWARF-NEXT: 0x00000000: 0xffffffff, 0x00000000<br>
-// DWARF-NEXT: 0x00000008: 0x00000000, 0x00000004 => [0x00000000, 0x00000004)<br>
-// DWARF-NEXT: 0x00000010: 0xffffffff, 0x00000000<br>
-// DWARF-NEXT: 0x00000018: 0x00000000, 0x00000004 => [0x00000000, 0x00000004)<br>
-// DWARF-NEXT: 0x00000020: 0x00000000, 0x00000000<br>
+// DWARF: 00000000 ffffffff 00000000<br>
+// DWARF: 00000000 00000000 00000004<br>
+// DWARF: 00000000 ffffffff 00000000<br>
+// DWARF: 00000000 00000000 00000004<br>
+// DWARF: 00000000 <End of list><br>
+<br>
 <br>
 <br>
 // Offsets are different in DWARF v5 due to different header layout.<br>
<br>
Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)<br>
+++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Wed Sep 12 07:40:04 2018<br>
@@ -43,6 +43,7 @@<br>
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"<br>
+#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFDie.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFSection.h"<br>
@@ -1575,7 +1576,7 @@ DIE *DwarfLinker::DIECloner::cloneDIE(co<br>
 void DwarfLinker::patchRangesForUnit(const CompileUnit &Unit,<br>
                                      DWARFContext &OrigDwarf,<br>
                                      const DebugMapObject &DMO) const {<br>
-  DWARFDebugRnglist RangeList;<br>
+  DWARFDebugRangeList RangeList;<br>
   const auto &FunctionRanges = Unit.getFunctionRanges();<br>
   unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();<br>
   DWARFDataExtractor RangeExtractor(OrigDwarf.getDWARFObj(),<br>
@@ -1595,23 +1596,21 @@ void DwarfLinker::patchRangesForUnit(con<br>
   for (const auto &RangeAttribute : Unit.getRangesAttributes()) {<br>
     uint32_t Offset = RangeAttribute.get();<br>
     RangeAttribute.set(Streamer->getRangesSectionSize());<br>
-    if (Error E = RangeList.extract(RangeExtractor, /* HeaderOffset = */0,<br>
-                                    RangeExtractor.size(),<br>
-                                    Unit.getOrigUnit().getVersion(), &Offset,<br>
-                                    ".debug_ranges", "range")) {<br>
+    if (Error E = RangeList.extract(RangeExtractor, &Offset)) {<br>
       llvm::consumeError(std::move(E));<br>
       reportWarning("invalid range list ignored.", DMO);<br>
       RangeList.clear();<br>
     }<br>
     const auto &Entries = RangeList.getEntries();<br>
-    if (!RangeList.empty()) {<br>
-      const auto &First = Entries.front();<br>
+    if (!Entries.empty()) {<br>
+      const DWARFDebugRangeList::RangeListEntry &First = Entries.front();<br>
+<br>
       if (CurrRange == InvalidRange ||<br>
-          First.getStartAddress() + OrigLowPc < CurrRange.start() ||<br>
-          First.getStartAddress() + OrigLowPc >= CurrRange.stop()) {<br>
-        CurrRange = FunctionRanges.find(First.getStartAddress() + OrigLowPc);<br>
+          First.StartAddress + OrigLowPc < CurrRange.start() ||<br>
+          First.StartAddress + OrigLowPc >= CurrRange.stop()) {<br>
+        CurrRange = FunctionRanges.find(First.StartAddress + OrigLowPc);<br>
         if (CurrRange == InvalidRange ||<br>
-            CurrRange.start() > First.getStartAddress() + OrigLowPc) {<br>
+            CurrRange.start() > First.StartAddress + OrigLowPc) {<br>
           reportWarning("no mapping for range.", DMO);<br>
           continue;<br>
         }<br>
<br>
Modified: llvm/trunk/tools/dsymutil/DwarfStreamer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfStreamer.cpp?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfStreamer.cpp?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/dsymutil/DwarfStreamer.cpp (original)<br>
+++ llvm/trunk/tools/dsymutil/DwarfStreamer.cpp Wed Sep 12 07:40:04 2018<br>
@@ -269,27 +269,28 @@ void DwarfStreamer::emitSwiftAST(StringR<br>
 void DwarfStreamer::emitRangesEntries(<br>
     int64_t UnitPcOffset, uint64_t OrigLowPc,<br>
     const FunctionIntervals::const_iterator &FuncRange,<br>
-    const DWARFDebugRnglist::ListEntries &Entries, unsigned AddressSize) {<br>
+    const std::vector<DWARFDebugRangeList::RangeListEntry> &Entries,<br>
+    unsigned AddressSize) {<br>
   MS->SwitchSection(MC->getObjectFileInfo()->getDwarfRangesSection());<br>
 <br>
   // Offset each range by the right amount.<br>
   int64_t PcOffset = Entries.empty() ? 0 : FuncRange.value() + UnitPcOffset;<br>
   for (const auto &Range : Entries) {<br>
-    if (Range.isBaseAddressSelectionEntry()) {<br>
+    if (Range.isBaseAddressSelectionEntry(AddressSize)) {<br>
       warn("unsupported base address selection operation",<br>
            "emitting debug_ranges");<br>
       break;<br>
     }<br>
     // Do not emit empty ranges.<br>
-    if (Range.isEndOfList() || Range.getStartAddress() == Range.getEndAddress())<br>
+    if (Range.StartAddress == Range.EndAddress)<br>
       continue;<br>
 <br>
     // All range entries should lie in the function range.<br>
-    if (!(Range.getStartAddress() + OrigLowPc >= FuncRange.start() &&<br>
-          Range.getEndAddress() + OrigLowPc <= FuncRange.stop()))<br>
+    if (!(Range.StartAddress + OrigLowPc >= FuncRange.start() &&<br>
+          Range.EndAddress + OrigLowPc <= FuncRange.stop()))<br>
       warn("inconsistent range data.", "emitting debug_ranges");<br>
-    MS->EmitIntValue(Range.getStartAddress() + PcOffset, AddressSize);<br>
-    MS->EmitIntValue(Range.getEndAddress() + PcOffset, AddressSize);<br>
+    MS->EmitIntValue(Range.StartAddress + PcOffset, AddressSize);<br>
+    MS->EmitIntValue(Range.EndAddress + PcOffset, AddressSize);<br>
     RangesSectionSize += 2 * AddressSize;<br>
   }<br>
 <br>
<br>
Modified: llvm/trunk/tools/dsymutil/DwarfStreamer.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfStreamer.h?rev=342056&r1=342055&r2=342056&view=diff">
http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfStreamer.h?rev=342056&r1=342055&r2=342056&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/dsymutil/DwarfStreamer.h (original)<br>
+++ llvm/trunk/tools/dsymutil/DwarfStreamer.h Wed Sep 12 07:40:04 2018<br>
@@ -17,7 +17,7 @@<br>
 #include "llvm/CodeGen/AccelTable.h"<br>
 #include "llvm/CodeGen/AsmPrinter.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"<br>
-#include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"<br>
+#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"<br>
 #include "llvm/MC/MCAsmBackend.h"<br>
 #include "llvm/MC/MCAsmInfo.h"<br>
 #include "llvm/MC/MCCodeEmitter.h"<br>
@@ -83,7 +83,7 @@ public:<br>
   void emitRangesEntries(<br>
       int64_t UnitPcOffset, uint64_t OrigLowPc,<br>
       const FunctionIntervals::const_iterator &FuncRange,<br>
-      const DWARFDebugRnglist::ListEntries &Entries,<br>
+      const std::vector<DWARFDebugRangeList::RangeListEntry> &Entries,<br>
       unsigned AddressSize);<br>
 <br>
   /// Emit debug_aranges entries for \p Unit and if \p DoRangesSection is true,<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
llvm-commits@lists.llvm.org<br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</div>
</span></font></div>
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose,
 or store or copy the information in any medium. Thank you.
</body>
</html>