[llvm] r374232 - llvm-dwarfdump: Support multiple debug_loclists contributions

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 9 14:25:28 PDT 2019


Author: dblaikie
Date: Wed Oct  9 14:25:28 2019
New Revision: 374232

URL: http://llvm.org/viewvc/llvm-project?rev=374232&view=rev
Log:
llvm-dwarfdump: Support multiple debug_loclists contributions

Also fixing the incorrect "offset" field being computed/printed for each
location list.

Added:
    llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s
Modified:
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
    llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
    llvm/trunk/test/CodeGen/X86/debug-loclists.ll
    llvm/trunk/test/DebugInfo/X86/dwarfdump-debug-loclists.test
    llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h?rev=374232&r1=374231&r2=374232&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h Wed Oct  9 14:25:28 2019
@@ -99,7 +99,7 @@ private:
   bool IsLittleEndian;
 
 public:
-  void parse(DataExtractor data, unsigned Version);
+  void parse(DataExtractor data, uint64_t Offset, uint64_t EndOffset, uint16_t Version);
   void dump(raw_ostream &OS, uint64_t BaseAddr, const MCRegisterInfo *RegInfo,
             Optional<uint64_t> Offset) const;
 

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=374232&r1=374231&r2=374232&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Wed Oct  9 14:25:28 2019
@@ -290,20 +290,24 @@ static void dumpLoclistsSection(raw_ostr
                                 const MCRegisterInfo *MRI,
                                 Optional<uint64_t> DumpOffset) {
   uint64_t Offset = 0;
-  DWARFDebugLoclists Loclists;
 
-  DWARFListTableHeader Header(".debug_loclists", "locations");
-  if (Error E = Header.extract(Data, &Offset)) {
-    WithColor::error() << toString(std::move(E)) << '\n';
-    return;
-  }
-
-  Header.dump(OS, DumpOpts);
-  DataExtractor LocData(Data.getData().drop_front(Offset),
-                        Data.isLittleEndian(), Header.getAddrSize());
+  while (Data.isValidOffset(Offset)) {
+    DWARFListTableHeader Header(".debug_loclists", "locations");
+    if (Error E = Header.extract(Data, &Offset)) {
+      WithColor::error() << toString(std::move(E)) << '\n';
+      return;
+    }
 
-  Loclists.parse(LocData, Header.getVersion());
-  Loclists.dump(OS, 0, MRI, DumpOffset);
+    Header.dump(OS, DumpOpts);
+    DataExtractor LocData(Data.getData(),
+                          Data.isLittleEndian(), Header.getAddrSize());
+
+    DWARFDebugLoclists Loclists;
+    uint64_t EndOffset = Header.length() + Header.getHeaderOffset();
+    Loclists.parse(LocData, Offset, EndOffset, Header.getVersion());
+    Loclists.dump(OS, 0, MRI, DumpOffset);
+    Offset = EndOffset;
+  }
 }
 
 void DWARFContext::dump(
@@ -733,7 +737,7 @@ const DWARFDebugLoclists *DWARFContext::
   // Use version 4. DWO does not support the DWARF v5 .debug_loclists yet and
   // that means we are parsing the new style .debug_loc (pre-standatized version
   // of the .debug_loclists).
-  LocDWO->parse(LocData, 4 /* Version */);
+  LocDWO->parse(LocData, 0, LocData.getData().size(), 4 /* Version */);
   return LocDWO.get();
 }
 

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp?rev=374232&r1=374231&r2=374232&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp Wed Oct  9 14:25:28 2019
@@ -187,12 +187,11 @@ DWARFDebugLoclists::parseOneLocationList
   return LL;
 }
 
-void DWARFDebugLoclists::parse(DataExtractor data, unsigned Version) {
+void DWARFDebugLoclists::parse(DataExtractor data, uint64_t Offset, uint64_t EndOffset, uint16_t Version) {
   IsLittleEndian = data.isLittleEndian();
   AddressSize = data.getAddressSize();
 
-  uint64_t Offset = 0;
-  while (Offset < data.getData().size()) {
+  while (Offset < EndOffset) {
     if (auto LL = parseOneLocationList(data, &Offset, Version))
       Locations.push_back(std::move(*LL));
     else {

Modified: llvm/trunk/test/CodeGen/X86/debug-loclists.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/debug-loclists.ll?rev=374232&r1=374231&r2=374232&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/debug-loclists.ll (original)
+++ llvm/trunk/test/CodeGen/X86/debug-loclists.ll Wed Oct  9 14:25:28 2019
@@ -12,7 +12,7 @@
 
 ; CHECK:      .debug_loclists contents:
 ; CHECK-NEXT: 0x00000000: locations list header: length = 0x00000015, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
-; CHECK-NEXT: 0x00000000:
+; CHECK-NEXT: 0x0000000c:
 ; CHECK-NEXT:  [0x0000000000000000, 0x0000000000000004): DW_OP_breg5 RDI+0
 ; CHECK-NEXT:  [0x0000000000000004, 0x0000000000000012): DW_OP_breg3 RBX+0
 

Modified: llvm/trunk/test/DebugInfo/X86/dwarfdump-debug-loclists.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dwarfdump-debug-loclists.test?rev=374232&r1=374231&r2=374232&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/dwarfdump-debug-loclists.test (original)
+++ llvm/trunk/test/DebugInfo/X86/dwarfdump-debug-loclists.test Wed Oct  9 14:25:28 2019
@@ -10,7 +10,7 @@
 
 # CHECK:      .debug_loclists contents:
 # CHECK-NEXT: 0x00000000: locations list header: length = 0x0000002c, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
-# CHECK-NEXT: 0x00000000:
+# CHECK-NEXT: 0x0000000c:
 # CHECK-NEXT:   [0x0000000000000000, 0x0000000000000010): DW_OP_breg5 RDI+0
 # CHECK-NEXT:   [0x0000000000000530, 0x0000000000000540): DW_OP_breg6 RBP-8, DW_OP_deref
 # CHECK-NEXT:   [0x0000000000000700, 0x0000000000000710): DW_OP_breg5 RDI+0

Added: llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s?rev=374232&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s (added)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s Wed Oct  9 14:25:28 2019
@@ -0,0 +1,44 @@
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o %t.o
+# RUN: llvm-dwarfdump -v %t.o | FileCheck %s
+
+# Test dumping of multiple separate debug_loclist contributions
+# CHECK: .debug_loclists contents:
+# CHECK: 0x00000000: locations list header:
+# CHECK: 0x0000000c:
+# CHECK:             [0x0000000000000001, 0x0000000000000002): DW_OP_consts +7, DW_OP_stack_value
+# CHECK: 0x00000014: locations list header:
+# CHECK:             [0x0000000000000005, 0x0000000000000007): DW_OP_consts +12, DW_OP_stack_value
+
+	.section	.debug_loclists,"", at progbits
+	.long	.Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0 # Length
+.Ldebug_loclist_table_start0:
+	.short	5                       # Version
+	.byte	8                       # Address size
+	.byte	0                       # Segment selector size
+	.long	0                       # Offset entry count
+
+	.byte	4                       # DW_LLE_offset_pair
+	.uleb128	1               #   starting offset
+	.uleb128	2               #   ending offset
+	.byte	3                       # Loc expr size
+	.byte	17                      # DW_OP_consts
+	.byte	7                       # 7
+	.byte	159                     # DW_OP_stack_value
+	.byte	0                       # DW_LLE_end_of_list
+.Ldebug_loclist_table_end0:
+	.long	.Ldebug_loclist_table_end1-.Ldebug_loclist_table_start1 # Length
+.Ldebug_loclist_table_start1:
+	.short	5                       # Version
+	.byte	8                       # Address size
+	.byte	0                       # Segment selector size
+	.long	0                       # Offset entry count
+
+	.byte	4                       # DW_LLE_offset_pair
+	.uleb128	5               #   starting offset
+	.uleb128	7               #   ending offset
+	.byte	3                       # Loc expr size
+	.byte	17                      # DW_OP_consts
+	.byte	12                      # 12
+	.byte	159                     # DW_OP_stack_value
+	.byte	0                       # DW_LLE_end_of_list
+.Ldebug_loclist_table_end1:

Modified: llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s?rev=374232&r1=374231&r2=374232&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s Wed Oct  9 14:25:28 2019
@@ -7,7 +7,7 @@
 
 # CHECK:         .debug_loclists contents:
 # CHECK-NEXT:    0x00000000: locations list header: length = 0x0000000e, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
-# CHECK-NEXT:    0x00000000:
+# CHECK-NEXT:    0x0000000c:
 # CHECK-NEXT:    Addr idx 1 (w/ length 16): DW_OP_reg5 RDI
 
 .section .debug_loclists,"", at progbits




More information about the llvm-commits mailing list