mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-02 18:31:54 +00:00
llvm-dwarfdump: Support multiple debug_loclists contributions
Also fixing the incorrect "offset" field being computed/printed for each location list. llvm-svn: 374232
This commit is contained in:
parent
0bfa80a30c
commit
ab16c40b7b
@ -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;
|
||||
|
||||
|
@ -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(),
|
||||
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;
|
||||
}
|
||||
|
||||
Header.dump(OS, DumpOpts);
|
||||
DataExtractor LocData(Data.getData().drop_front(Offset),
|
||||
Data.isLittleEndian(), Header.getAddrSize());
|
||||
|
||||
Loclists.parse(LocData, Header.getVersion());
|
||||
Loclists.dump(OS, 0, MRI, DumpOffset);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
44
test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s
Normal file
44
test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s
Normal file
@ -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:
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user