summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h2
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp28
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp5
-rw-r--r--llvm/test/CodeGen/X86/debug-loclists.ll2
-rw-r--r--llvm/test/DebugInfo/X86/dwarfdump-debug-loclists.test2
-rw-r--r--llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s44
-rw-r--r--llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s2
7 files changed, 66 insertions, 19 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
index f65a20af0cb..d06818eca9d 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
@@ -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;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 770f129753e..ed6c2b93ce6 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -290,20 +290,24 @@ static void dumpLoclistsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
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;
- }
+ while (Data.isValidOffset(Offset)) {
+ 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());
+ Header.dump(OS, DumpOpts);
+ DataExtractor LocData(Data.getData(),
+ Data.isLittleEndian(), Header.getAddrSize());
- Loclists.parse(LocData, Header.getVersion());
- Loclists.dump(OS, 0, MRI, DumpOffset);
+ 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::getDebugLocDWO() {
// 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();
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
index a243ed3a80b..bdafafc7a37 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
@@ -187,12 +187,11 @@ DWARFDebugLoclists::parseOneLocationList(const DataExtractor &Data,
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 {
diff --git a/llvm/test/CodeGen/X86/debug-loclists.ll b/llvm/test/CodeGen/X86/debug-loclists.ll
index 0c2ab3dfad5..30cab3b01e1 100644
--- a/llvm/test/CodeGen/X86/debug-loclists.ll
+++ b/llvm/test/CodeGen/X86/debug-loclists.ll
@@ -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
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists.test b/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists.test
index 32f2482b511..41893d32690 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists.test
+++ b/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists.test
@@ -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
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s
new file mode 100644
index 00000000000..4e2999dd9c6
--- /dev/null
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s
@@ -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,"",@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:
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s
index 0b2ae5f8e7a..508d9566546 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_startx_length.s
@@ -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,"",@progbits
OpenPOWER on IntegriCloud