summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-11-12 11:36:19 +0100
committerPavel Labath <pavel@labath.sk>2019-11-14 10:01:48 +0100
commiteafe0cf5fa8255257bac3923237e62382610e6d6 (patch)
treef200e3e8a0c4ffe854f4e89f2d2f7845454f0ab6 /llvm
parentea2ba51b0b2f5bc0bea650bf64e5cbd63476563f (diff)
downloadbcm5719-llvm-eafe0cf5fa8255257bac3923237e62382610e6d6.tar.gz
bcm5719-llvm-eafe0cf5fa8255257bac3923237e62382610e6d6.zip
DWARFDebugLoclists: stricter base address handling
Summary: This removes the use of zero as a base address in section-based dumping. Although this will often be true for (unlinked) object files with a single compile unit, it is not true in general. This means that section-based dumping will not be able to resolve entries referencing the base address (DW_LLE_offset_pair) -- it wasn't able to do that correctly before either, but now it will be more explicit about it. One exception to that is if the location list contains an explicit DW_LLE_base_address entry -- in this case the dumper will pick it up, and resolve subsequent entries normally. The patch also removes the fallback to zero in the "inline" dumping in case the compile unit does not contain a base address. Reviewers: dblaikie, probinson, JDevlieghere, aprantl, SouraVX Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70115
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h6
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp12
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp10
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDie.cpp9
-rw-r--r--llvm/test/DebugInfo/X86/dwarfdump-debug-loclists.test3
-rw-r--r--llvm/test/tools/llvm-dwarfdump/X86/debug_loclists.s6
-rw-r--r--llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s4
7 files changed, 26 insertions, 24 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
index 356757b5724..7391061d3d0 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
@@ -58,7 +58,8 @@ public:
/// iff it has successfully reched the end of the list. This means that one
/// can attempt to parse another list after the current one (\p Offset will be
/// updated to point past the end of the current list).
- bool dumpLocationList(uint64_t *Offset, raw_ostream &OS, uint64_t BaseAddr,
+ bool dumpLocationList(uint64_t *Offset, raw_ostream &OS,
+ Optional<object::SectionedAddress> BaseAddr,
const MCRegisterInfo *MRI, DWARFUnit *U,
DIDumpOptions DumpOpts, unsigned Indent) const;
@@ -133,8 +134,7 @@ public:
/// Dump all location lists within the given range.
void dumpRange(uint64_t StartOffset, uint64_t Size, raw_ostream &OS,
- uint64_t BaseAddr, const MCRegisterInfo *MRI,
- DIDumpOptions DumpOpts);
+ const MCRegisterInfo *MRI, DIDumpOptions DumpOpts);
protected:
void dumpRawEntry(const DWARFLocationEntry &Entry, raw_ostream &OS,
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 7ca319baa8e..5a1668442fc 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -306,14 +306,13 @@ static void dumpLoclistsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
if (DumpOffset) {
if (DumpOffset >= Offset && DumpOffset < EndOffset) {
Offset = *DumpOffset;
- Loc.dumpLocationList(&Offset, OS, /*BaseAddr=*/0, MRI, nullptr,
+ Loc.dumpLocationList(&Offset, OS, /*BaseAddr=*/None, MRI, nullptr,
DumpOpts, /*Indent=*/0);
OS << "\n";
return;
}
} else {
- Loc.dumpRange(Offset, EndOffset - Offset, OS, /*BaseAddr=*/0, MRI,
- DumpOpts);
+ Loc.dumpRange(Offset, EndOffset - Offset, OS, MRI, DumpOpts);
}
Offset = EndOffset;
}
@@ -409,12 +408,11 @@ void DWARFContext::dump(
if (*Off) {
uint64_t Offset = **Off;
Loc.dumpLocationList(&Offset, OS,
- /*BaseAddr=*/0, getRegisterInfo(), nullptr, DumpOpts,
- /*Indent=*/0);
+ /*BaseAddr=*/None, getRegisterInfo(), nullptr,
+ DumpOpts, /*Indent=*/0);
OS << "\n";
} else {
- Loc.dumpRange(0, Data.getData().size(), OS, /*BaseAddr=*/0,
- getRegisterInfo(), DumpOpts);
+ Loc.dumpRange(0, Data.getData().size(), OS, getRegisterInfo(), DumpOpts);
}
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
index 8bb9fc5837d..f84de263a78 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
@@ -102,13 +102,12 @@ static void dumpExpression(raw_ostream &OS, ArrayRef<uint8_t> Data,
}
bool DWARFLocationTable::dumpLocationList(uint64_t *Offset, raw_ostream &OS,
- uint64_t BaseAddr,
+ Optional<SectionedAddress> BaseAddr,
const MCRegisterInfo *MRI,
DWARFUnit *U, DIDumpOptions DumpOpts,
unsigned Indent) const {
DWARFLocationInterpreter Interp(
- SectionedAddress{BaseAddr, SectionedAddress::UndefSection},
- [U](uint32_t Index) -> Optional<SectionedAddress> {
+ BaseAddr, [U](uint32_t Index) -> Optional<SectionedAddress> {
if (U)
return U->getAddrOffsetSectionItem(Index);
return None;
@@ -342,8 +341,7 @@ void DWARFDebugLoclists::dumpRawEntry(const DWARFLocationEntry &Entry,
}
void DWARFDebugLoclists::dumpRange(uint64_t StartOffset, uint64_t Size,
- raw_ostream &OS, uint64_t BaseAddr,
- const MCRegisterInfo *MRI,
+ raw_ostream &OS, const MCRegisterInfo *MRI,
DIDumpOptions DumpOpts) {
if (!Data.isValidOffsetForDataOfSize(StartOffset, Size)) {
OS << "Invalid dump range\n";
@@ -356,7 +354,7 @@ void DWARFDebugLoclists::dumpRange(uint64_t StartOffset, uint64_t Size,
OS << Separator;
Separator = "\n";
- CanContinue = dumpLocationList(&Offset, OS, BaseAddr, MRI, nullptr,
+ CanContinue = dumpLocationList(&Offset, OS, /*BaseAddr=*/None, MRI, nullptr,
DumpOpts, /*Indent=*/12);
OS << '\n';
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index 308f731570c..abe63f2716a 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -96,12 +96,10 @@ static void dumpLocation(raw_ostream &OS, DWARFFormValue &FormValue,
LLDumpOpts.Verbose = false;
uint64_t Offset = *FormValue.getAsSectionOffset();
- uint64_t BaseAddr = 0;
- if (Optional<object::SectionedAddress> BA = U->getBaseAddress())
- BaseAddr = BA->Address;
if (const DWARFLocationTable *LT = U->getLocationTable()) {
- LT->dumpLocationList(&Offset, OS, BaseAddr, MRI, U, LLDumpOpts, Indent);
+ LT->dumpLocationList(&Offset, OS, U->getBaseAddress(), MRI, U, LLDumpOpts,
+ Indent);
return;
}
@@ -114,6 +112,9 @@ static void dumpLocation(raw_ostream &OS, DWARFFormValue &FormValue,
if (Expected<DWARFDebugLoc::LocationList> LL =
DebugLoc.parseOneLocationList(Data, &Offset)) {
+ uint64_t BaseAddr = 0;
+ if (Optional<object::SectionedAddress> BA = U->getBaseAddress())
+ BaseAddr = BA->Address;
LL->dump(OS, BaseAddr, Ctx.isLittleEndian(), Obj.getAddressSize(), MRI, U,
LLDumpOpts, Indent);
} else {
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists.test b/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists.test
index a427e03c231..5b6b6b8d5cc 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists.test
+++ b/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists.test
@@ -11,8 +11,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: 0x0000000c:
-# CHECK-NEXT: DW_LLE_offset_pair (0x0000000000000000, 0x0000000000000010)
-# CHECK-NEXT: => [0x0000000000000000, 0x0000000000000010): DW_OP_breg5 RDI+0
+# CHECK-NEXT: DW_LLE_offset_pair (0x0000000000000000, 0x0000000000000010): DW_OP_breg5 RDI+0
# CHECK-NEXT: DW_LLE_base_address (0x0000000000000500)
# CHECK-NEXT: DW_LLE_offset_pair (0x0000000000000030, 0x0000000000000040)
# CHECK-NEXT: => [0x0000000000000530, 0x0000000000000540): DW_OP_breg6 RBP-8, DW_OP_deref
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists.s
index 59c0a967013..7e97fe90237 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists.s
@@ -70,6 +70,10 @@ f: # @f
.byte 23 # DW_FORM_sec_offset
.ascii "\214\001" # DW_AT_loclists_base
.byte 23 # DW_FORM_sec_offset
+ .byte 17 # DW_AT_low_pc
+ .byte 27 # DW_FORM_addrx
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 2 # Abbreviation Code
@@ -100,6 +104,8 @@ f: # @f
.byte 1 # Abbrev [1] 0xc:0x3c DW_TAG_compile_unit
.long .Laddr_table_base0 # DW_AT_addr_base
.long .Lloclists_table_base0 # DW_AT_loclists_base
+ .byte 0 # DW_AT_low_pc
+ .long .Lfend-.Lf0 # DW_AT_high_pc
.byte 2 # Abbrev [2] 0x27:0x1c DW_TAG_subprogram
.byte 0 # DW_AT_low_pc
.long .Lfend-.Lf0 # DW_AT_high_pc
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s
index 4e2999dd9c6..a0188a6a981 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_loclists_multiple.s
@@ -5,9 +5,9 @@
# CHECK: .debug_loclists contents:
# CHECK: 0x00000000: locations list header:
# CHECK: 0x0000000c:
-# CHECK: [0x0000000000000001, 0x0000000000000002): DW_OP_consts +7, DW_OP_stack_value
+# CHECK: DW_LLE_offset_pair (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
+# CHECK: DW_LLE_offset_pair (0x0000000000000005, 0x0000000000000007): DW_OP_consts +12, DW_OP_stack_value
.section .debug_loclists,"",@progbits
.long .Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0 # Length
OpenPOWER on IntegriCloud