21void DWARFAbbreviationDeclarationSet::clear() {
30 const uint64_t BeginOffset = *OffsetPtr;
43 if (FirstAbbrCode == 0) {
44 FirstAbbrCode = AbbrDecl.
getCode();
45 }
else if (PrevAbbrCode + 1 != AbbrDecl.
getCode()) {
47 FirstAbbrCode = UINT32_MAX;
49 PrevAbbrCode = AbbrDecl.
getCode();
50 Decls.push_back(std::move(AbbrDecl));
56 for (
const auto &Decl : Decls)
63 if (FirstAbbrCode == UINT32_MAX) {
64 for (
const auto &Decl : Decls) {
65 if (Decl.getCode() == AbbrCode)
70 if (AbbrCode < FirstAbbrCode || AbbrCode >= FirstAbbrCode + Decls.size())
72 return &Decls[AbbrCode - FirstAbbrCode];
77 std::vector<uint32_t> Codes;
78 Codes.reserve(Decls.size());
79 for (
const auto &Decl : Decls)
80 Codes.push_back(Decl.getCode());
86 for (
auto Current = Codes.begin(),
End = Codes.end(); Current !=
End;) {
92 while (++Current !=
End && *Current == RangeEnd + 1)
95 if (RangeStart != RangeEnd)
96 Stream <<
"-" << RangeEnd;
105 : AbbrDeclSets(), PrevAbbrOffsetPos(AbbrDeclSets.end()),
Data(
Data) {}
111 auto I = AbbrDeclSets.begin();
112 while (Data->isValidOffset(
Offset)) {
113 while (
I != AbbrDeclSets.end() &&
I->first <
Offset)
121 AbbrDeclSets.insert(
I, std::make_pair(CUAbbrOffset, std::move(AbbrDecls)));
132 if (AbbrDeclSets.empty()) {
137 for (
const auto &
I : AbbrDeclSets) {
138 OS <<
format(
"Abbrev table for offset: 0x%8.8" PRIx64
"\n",
I.first);
145 const auto End = AbbrDeclSets.end();
146 if (PrevAbbrOffsetPos !=
End && PrevAbbrOffsetPos->first == CUAbbrOffset) {
147 return &PrevAbbrOffsetPos->second;
150 const auto Pos = AbbrDeclSets.find(CUAbbrOffset);
152 PrevAbbrOffsetPos = Pos;
156 if (!Data || CUAbbrOffset >= Data->getData().size())
157 return make_error<llvm::object::GenericBinaryError>(
158 "the abbreviation offset into the .debug_abbrev section is not valid");
163 return std::move(Err);
166 AbbrDeclSets.insert(std::make_pair(CUAbbrOffset, std::move(AbbrDecls)))
168 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.