diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2017-09-27 09:33:36 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2017-09-27 09:33:36 +0000 |
commit | 622c563b5a828764a99eac8d950b833ae1b2c68a (patch) | |
tree | fdf2b5bd2f915eb29f346187d263c6399166c93c /llvm/lib/DebugInfo | |
parent | 6992817a0e2d3413eeb29ac5f4de1148625681c1 (diff) | |
download | bcm5719-llvm-622c563b5a828764a99eac8d950b833ae1b2c68a.tar.gz bcm5719-llvm-622c563b5a828764a99eac8d950b833ae1b2c68a.zip |
[dwarfdump] Add support for -debug-loc=OFFSET
This patch adds support for passing an offset to -debug-loc.
Differential revision: https://reviews.llvm.org/D38237
llvm-svn: 314286
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp | 50 |
2 files changed, 48 insertions, 6 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 156c65ad92a..8bb47c94d54 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -291,11 +291,11 @@ void DWARFContext::dump( if (shouldDump(Explicit, ".debug_loc", DIDT_ID_DebugLoc, DObj->getLocSection().Data)) { - getDebugLoc()->dump(OS, getRegisterInfo()); + getDebugLoc()->dump(OS, getRegisterInfo(), DumpOffset); } if (shouldDump(ExplicitDWO, ".debug_loc.dwo", DIDT_ID_DebugLoc, DObj->getLocDWOSection().Data)) { - getDebugLocDWO()->dump(OS, getRegisterInfo()); + getDebugLocDWO()->dump(OS, getRegisterInfo(), DumpOffset); } if (shouldDump(Explicit, ".debug_frame", DIDT_ID_DebugFrame, diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp index 68bc0e51306..58f88536f31 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp @@ -50,11 +50,32 @@ void DWARFDebugLoc::LocationList::dump(raw_ostream &OS, bool IsLittleEndian, } } -void DWARFDebugLoc::dump(raw_ostream &OS, const MCRegisterInfo *MRI) const { - for (const LocationList &L : Locations) { +DWARFDebugLoc::LocationList const * +DWARFDebugLoc::getLocationListAtOffset(uint64_t Offset) const { + auto It = std::lower_bound( + Locations.begin(), Locations.end(), Offset, + [](const LocationList &L, uint64_t Offset) { return L.Offset < Offset; }); + if (It != Locations.end() && It->Offset == Offset) + return &(*It); + return nullptr; +} + +void DWARFDebugLoc::dump(raw_ostream &OS, const MCRegisterInfo *MRI, + Optional<uint64_t> Offset) const { + auto DumpLocationList = [&](const LocationList &L) { OS << format("0x%8.8x: ", L.Offset); L.dump(OS, IsLittleEndian, AddressSize, MRI, 12); OS << "\n\n"; + }; + + if (Offset) { + if (auto *L = getLocationListAtOffset(*Offset)) + DumpLocationList(*L); + return; + } + + for (const LocationList &L : Locations) { + DumpLocationList(L); } } @@ -161,6 +182,16 @@ void DWARFDebugLocDWO::parse(DataExtractor data) { } } +DWARFDebugLocDWO::LocationList const * +DWARFDebugLocDWO::getLocationListAtOffset(uint64_t Offset) const { + auto It = std::lower_bound( + Locations.begin(), Locations.end(), Offset, + [](const LocationList &L, uint64_t Offset) { return L.Offset < Offset; }); + if (It != Locations.end() && It->Offset == Offset) + return &(*It); + return nullptr; +} + void DWARFDebugLocDWO::LocationList::dump(raw_ostream &OS, bool IsLittleEndian, unsigned AddressSize, const MCRegisterInfo *MRI, @@ -173,10 +204,21 @@ void DWARFDebugLocDWO::LocationList::dump(raw_ostream &OS, bool IsLittleEndian, } } -void DWARFDebugLocDWO::dump(raw_ostream &OS, const MCRegisterInfo *MRI) const { - for (const LocationList &L : Locations) { +void DWARFDebugLocDWO::dump(raw_ostream &OS, const MCRegisterInfo *MRI, + Optional<uint64_t> Offset) const { + auto DumpLocationList = [&](const LocationList &L) { OS << format("0x%8.8x: ", L.Offset); L.dump(OS, IsLittleEndian, AddressSize, MRI, /*Indent=*/12); OS << "\n\n"; + }; + + if (Offset) { + if (auto *L = getLocationListAtOffset(*Offset)) + DumpLocationList(*L); + return; + } + + for (const LocationList &L : Locations) { + DumpLocationList(L); } } |