diff options
author | Pavel Labath <pavel@labath.sk> | 2019-11-12 11:36:19 +0100 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2019-11-14 10:01:48 +0100 |
commit | eafe0cf5fa8255257bac3923237e62382610e6d6 (patch) | |
tree | f200e3e8a0c4ffe854f4e89f2d2f7845454f0ab6 /llvm/lib/DebugInfo/DWARF | |
parent | ea2ba51b0b2f5bc0bea650bf64e5cbd63476563f (diff) | |
download | bcm5719-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/lib/DebugInfo/DWARF')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | 9 |
3 files changed, 14 insertions, 17 deletions
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 { |