diff options
author | Adrian Prantl <aprantl@apple.com> | 2017-09-21 18:52:03 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2017-09-21 18:52:03 +0000 |
commit | 67be5f5362cc42db87a5a6059b7d439cac6bf825 (patch) | |
tree | cd0bf4c260139a4ee07cdd1fd702758619f3cb01 /lib/DebugInfo | |
parent | c02a4f5a57b8786e77949bba6c6383cd068d2105 (diff) |
llvm-dwarfdump support --debug-frame=<offset> and --eh-frame=<offset>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313900 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/DebugInfo')
-rw-r--r-- | lib/DebugInfo/DWARF/DWARFContext.cpp | 10 | ||||
-rw-r--r-- | lib/DebugInfo/DWARF/DWARFDebugFrame.cpp | 39 |
2 files changed, 33 insertions, 16 deletions
diff --git a/lib/DebugInfo/DWARF/DWARFContext.cpp b/lib/DebugInfo/DWARF/DWARFContext.cpp index f20a7ca024b..69a4fe64b75 100644 --- a/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -299,14 +299,12 @@ void DWARFContext::dump( } if (shouldDump(Explicit, ".debug_frame", DIDT_ID_DebugFrame, - DObj->getDebugFrameSection())) { - getDebugFrame()->dump(OS); - } + DObj->getDebugFrameSection())) + getDebugFrame()->dump(OS, DumpOffset); if (shouldDump(Explicit, ".eh_frame", DIDT_ID_DebugFrame, - DObj->getEHFrameSection())) { - getEHFrame()->dump(OS); - } + DObj->getEHFrameSection())) + getEHFrame()->dump(OS, DumpOffset); if (DumpType & DIDT_DebugMacro) { if (Explicit || !getDebugMacro()->empty()) { diff --git a/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp index 6e8b5f4f471..bceb0162b35 100644 --- a/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp +++ b/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp @@ -11,7 +11,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" @@ -46,19 +45,26 @@ public: FrameKind getKind() const { return Kind; } virtual uint64_t getOffset() const { return Offset; } - /// \brief Parse and store a sequence of CFI instructions from Data, + /// Parse and store a sequence of CFI instructions from Data, /// starting at *Offset and ending at EndOffset. If everything /// goes well, *Offset should be equal to EndOffset when this method /// returns. Otherwise, an error occurred. virtual void parseInstructions(DataExtractor Data, uint32_t *Offset, uint32_t EndOffset); - /// \brief Dump the entry header to the given output stream. + /// Dump the entry header to the given output stream. virtual void dumpHeader(raw_ostream &OS) const = 0; - /// \brief Dump the entry's instructions to the given output stream. + /// Dump the entry's instructions to the given output stream. virtual void dumpInstructions(raw_ostream &OS) const; + /// Dump the entire entry to the given output stream. + void dump(raw_ostream &OS) const { + dumpHeader(OS); + dumpInstructions(OS); + OS << "\n"; + } + protected: const FrameKind Kind; @@ -692,11 +698,24 @@ void DWARFDebugFrame::parse(DataExtractor Data) { } } -void DWARFDebugFrame::dump(raw_ostream &OS) const { - OS << "\n"; - for (const auto &Entry : Entries) { - Entry->dumpHeader(OS); - Entry->dumpInstructions(OS); - OS << "\n"; +FrameEntry *DWARFDebugFrame::getEntryAtOffset(uint64_t Offset) const { + auto It = + std::lower_bound(Entries.begin(), Entries.end(), Offset, + [](const std::unique_ptr<FrameEntry> &E, + uint64_t Offset) { return E->getOffset() < Offset; }); + if (It != Entries.end() && (*It)->getOffset() == Offset) + return It->get(); + return nullptr; +} + +void DWARFDebugFrame::dump(raw_ostream &OS, Optional<uint64_t> Offset) const { + if (Offset) { + if (auto *Entry = getEntryAtOffset(*Offset)) + Entry->dump(OS); + return; } + + OS << "\n"; + for (const auto &Entry : Entries) + Entry->dump(OS); } |