22void DWARFAbbreviationDeclarationSet::clear() {
31 const uint64_t BeginOffset = *OffsetPtr;
44 if (FirstAbbrCode == 0) {
45 FirstAbbrCode = AbbrDecl.
getCode();
46 }
else if (PrevAbbrCode + 1 != AbbrDecl.
getCode()) {
48 FirstAbbrCode = UINT32_MAX;
50 PrevAbbrCode = AbbrDecl.
getCode();
51 Decls.push_back(std::move(AbbrDecl));
57 for (
const auto &Decl : Decls)
64 if (FirstAbbrCode == UINT32_MAX) {
65 for (
const auto &Decl : Decls) {
66 if (Decl.getCode() == AbbrCode)
71 if (AbbrCode < FirstAbbrCode || AbbrCode >= FirstAbbrCode + Decls.size())
73 return &Decls[AbbrCode - FirstAbbrCode];
78 std::vector<uint32_t> Codes;
79 Codes.reserve(Decls.size());
80 for (
const auto &Decl : Decls)
81 Codes.push_back(Decl.getCode());
87 for (
auto Current = Codes.begin(),
End = Codes.end(); Current !=
End;) {
93 while (++Current !=
End && *Current == RangeEnd + 1)
96 if (RangeStart != RangeEnd)
97 Stream <<
"-" << RangeEnd;
106 : AbbrDeclSets(), PrevAbbrOffsetPos(AbbrDeclSets.end()),
Data(
Data) {}
112 auto I = AbbrDeclSets.begin();
113 while (Data->isValidOffset(
Offset)) {
114 while (
I != AbbrDeclSets.end() &&
I->first <
Offset)
122 AbbrDeclSets.insert(
I, std::make_pair(CUAbbrOffset, std::move(AbbrDecls)));
133 if (AbbrDeclSets.empty()) {
138 for (
const auto &
I : AbbrDeclSets) {
139 OS <<
format(
"Abbrev table for offset: 0x%8.8" PRIx64
"\n",
I.first);
146 const auto End = AbbrDeclSets.end();
147 if (PrevAbbrOffsetPos !=
End && PrevAbbrOffsetPos->first == CUAbbrOffset) {
148 return &PrevAbbrOffsetPos->second;
151 const auto Pos = AbbrDeclSets.find(CUAbbrOffset);
153 PrevAbbrOffsetPos = Pos;
157 if (!Data || CUAbbrOffset >= Data->getData().size())
158 return make_error<llvm::object::GenericBinaryError>(
159 "the abbreviation offset into the .debug_abbrev section is not valid");
164 return std::move(Err);
167 AbbrDeclSets.insert(std::make_pair(CUAbbrOffset, std::move(AbbrDecls)))
169 return &PrevAbbrOffsetPos->second;
void dump(raw_ostream &OS) const
DWARFAbbreviationDeclarationSet()
const DWARFAbbreviationDeclaration * getAbbreviationDeclaration(uint32_t AbbrCode) const
Error extract(DataExtractor Data, uint64_t *OffsetPtr)
std::string getCodeRange() const
llvm::Expected< ExtractState > extract(DataExtractor Data, uint64_t *OffsetPtr)
Expected< const DWARFAbbreviationDeclarationSet * > getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const
DWARFDebugAbbrev(DataExtractor Data)
void dump(raw_ostream &OS) const
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
This is an optimization pass for GlobalISel generic memory operations.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
void consumeError(Error Err)
Consume a Error without doing anything.