diff options
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp')
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp index 76dd2e4c21b..4830c36a8ee 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp @@ -68,9 +68,7 @@ DWARFAbbreviationDeclarationSet::getAbbreviationDeclaration( return &Decls[AbbrCode - FirstAbbrCode]; } -DWARFDebugAbbrev::DWARFDebugAbbrev() { - clear(); -} +DWARFDebugAbbrev::DWARFDebugAbbrev() { clear(); } void DWARFDebugAbbrev::clear() { AbbrDeclSets.clear(); @@ -79,18 +77,29 @@ void DWARFDebugAbbrev::clear() { void DWARFDebugAbbrev::extract(DataExtractor Data) { clear(); + this->Data = Data; +} +void DWARFDebugAbbrev::parse() const { + if (!Data) + return; uint32_t Offset = 0; DWARFAbbreviationDeclarationSet AbbrDecls; - while (Data.isValidOffset(Offset)) { + auto I = AbbrDeclSets.begin(); + while (Data->isValidOffset(Offset)) { + while (I != AbbrDeclSets.end() && I->first < Offset) + ++I; uint32_t CUAbbrOffset = Offset; - if (!AbbrDecls.extract(Data, &Offset)) + if (!AbbrDecls.extract(*Data, &Offset)) break; - AbbrDeclSets[CUAbbrOffset] = std::move(AbbrDecls); + AbbrDeclSets.insert(I, std::make_pair(CUAbbrOffset, std::move(AbbrDecls))); } + Data = None; } void DWARFDebugAbbrev::dump(raw_ostream &OS) const { + parse(); + if (AbbrDeclSets.empty()) { OS << "< EMPTY >\n"; return; @@ -115,5 +124,16 @@ DWARFDebugAbbrev::getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const { return &(Pos->second); } + if (Data && CUAbbrOffset < Data->getData().size()) { + uint32_t Offset = CUAbbrOffset; + DWARFAbbreviationDeclarationSet AbbrDecls; + if (!AbbrDecls.extract(*Data, &Offset)) + return nullptr; + PrevAbbrOffsetPos = + AbbrDeclSets.insert(std::make_pair(CUAbbrOffset, std::move(AbbrDecls))) + .first; + return &PrevAbbrOffsetPos->second; + } + return nullptr; } |

