diff options
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF')
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 24 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | 5 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp | 1 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 10 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp | 1 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp | 9 |
6 files changed, 33 insertions, 17 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp index ea33637..cf5b7fb 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp @@ -321,17 +321,29 @@ void AppleAcceleratorTable::Iterator::prepareNextEntryOrEnd() { } void AppleAcceleratorTable::Iterator::prepareNextStringOrEnd() { - std::optional<uint32_t> StrOffset = getTable().readStringOffsetAt(Offset); + const AppleAcceleratorTable &Table = getTable(); + if (Offset == 0) { + // Always start looking for strings using a valid offset from the Offsets + // table. Entries are not always consecutive. + std::optional<uint64_t> OptOffset = Table.readIthOffset(OffsetIdx++); + if (!OptOffset) + return setToEnd(); + Offset = *OptOffset; + } + std::optional<uint32_t> StrOffset = Table.readStringOffsetAt(Offset); if (!StrOffset) return setToEnd(); - // A zero denotes the end of the collision list. Read the next string - // again. - if (*StrOffset == 0) + // A zero denotes the end of the collision list. Skip to the next offset + // in the offsets table by setting the Offset to zero so we will grab the + // next offset from the offsets table. + if (*StrOffset == 0) { + Offset = 0; return prepareNextStringOrEnd(); + } Current.StrOffset = *StrOffset; - std::optional<uint32_t> MaybeNumEntries = getTable().readU32FromAccel(Offset); + std::optional<uint32_t> MaybeNumEntries = Table.readU32FromAccel(Offset); if (!MaybeNumEntries || *MaybeNumEntries == 0) return setToEnd(); NumEntriesToCome = *MaybeNumEntries; @@ -339,7 +351,7 @@ void AppleAcceleratorTable::Iterator::prepareNextStringOrEnd() { AppleAcceleratorTable::Iterator::Iterator(const AppleAcceleratorTable &Table, bool SetEnd) - : Current(Table), Offset(Table.getEntriesBase()), NumEntriesToCome(0) { + : Current(Table), Offset(0), NumEntriesToCome(0) { if (SetEnd) setToEnd(); else diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp index 6c78ef0..deafee8 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -31,7 +31,6 @@ #include <cinttypes> #include <cstdint> #include <string> -#include <utility> using namespace llvm; using namespace dwarf; @@ -704,7 +703,9 @@ void DWARFDie::dump(raw_ostream &OS, unsigned Indent, DIDumpOptions ChildDumpOpts = DumpOpts; ChildDumpOpts.ShowParents = false; while (Child) { - Child.dump(OS, Indent + 2, ChildDumpOpts); + if (DumpOpts.FilterChildTag.empty() || + llvm::is_contained(DumpOpts.FilterChildTag, Child.getTag())) + Child.dump(OS, Indent + 2, ChildDumpOpts); Child = Child.getSibling(); } } diff --git a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp index a201fae..db6170c 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp @@ -17,7 +17,6 @@ #include <cinttypes> #include <cstdint> #include <set> -#include <utility> using namespace llvm; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index da0bf03..b8fbdfc 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -1187,9 +1187,15 @@ DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA) { if (getVersion() >= 5) { if (DA.getData().data() == nullptr) return std::nullopt; - Offset += Header.getFormat() == dwarf::DwarfFormat::DWARF32 ? 8 : 16; + // FYI: The .debug_str_offsets.dwo section may use DWARF64 even when the + // rest of the file uses DWARF32, so respect whichever encoding the + // header/length uses. + uint64_t Length = 0; + DwarfFormat Format = dwarf::DwarfFormat::DWARF32; + std::tie(Length, Format) = DA.getInitialLength(&Offset); + Offset += 4; // Skip the DWARF version uint16_t and the uint16_t padding. // Look for a valid contribution at the given offset. - auto DescOrError = parseDWARFStringOffsetsTableHeader(DA, Header.getFormat(), Offset); + auto DescOrError = parseDWARFStringOffsetsTableHeader(DA, Format, Offset); if (!DescOrError) return DescOrError.takeError(); return *DescOrError; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp index a88f4a5..a4bdd1f 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnwindTablePrinter.cpp @@ -15,7 +15,6 @@ #include <cassert> #include <cinttypes> #include <cstdint> -#include <optional> using namespace llvm; using namespace dwarf; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp index 5ab80e33..693454e 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -917,11 +917,10 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die, } // Check if the offset matches any of the sequence offset. - auto It = - std::find_if(LineTable->Sequences.begin(), LineTable->Sequences.end(), - [SectionOffset](const auto &Sequence) { - return Sequence.StmtSeqOffset == *SectionOffset; - }); + auto It = llvm::find_if(LineTable->Sequences, + [SectionOffset](const auto &Sequence) { + return Sequence.StmtSeqOffset == *SectionOffset; + }); if (It == LineTable->Sequences.end()) ReportError( |
