21 std::optional<int64_t> &ImplicitConst) {
24 ImplicitConst = std::nullopt;
25 if (Form == dwarf::DW_FORM_implicit_const)
27 return Name != 0 || Form != 0;
34void DWARFAbbreviationDeclarationSet::clear() {
43 const uint64_t BeginOffset = *OffsetPtr;
56 if (FirstAbbrCode == 0) {
57 FirstAbbrCode = AbbrDecl.
getCode();
58 }
else if (PrevAbbrCode + 1 != AbbrDecl.
getCode()) {
60 FirstAbbrCode = UINT32_MAX;
62 PrevAbbrCode = AbbrDecl.
getCode();
63 Decls.push_back(std::move(AbbrDecl));
69 for (
const auto &Decl : Decls)
76 if (FirstAbbrCode == UINT32_MAX) {
77 for (
const auto &Decl : Decls) {
78 if (Decl.getCode() == AbbrCode)
83 if (AbbrCode < FirstAbbrCode || AbbrCode >= FirstAbbrCode + Decls.size())
85 return &Decls[AbbrCode - FirstAbbrCode];
90 std::vector<uint32_t> Codes;
91 Codes.reserve(Decls.size());
92 for (
const auto &Decl : Decls)
93 Codes.push_back(Decl.getCode());
99 for (
auto Current = Codes.begin(), End = Codes.end(); Current != End;) {
105 while (++Current != End && *Current == RangeEnd + 1)
108 if (RangeStart != RangeEnd)
109 Stream <<
"-" << RangeEnd;
118 : AbbrDeclSets(), PrevAbbrOffsetPos(AbbrDeclSets.
end()), Data(Data) {}
124 auto I = AbbrDeclSets.begin();
125 while (Data->isValidOffset(
Offset)) {
126 while (
I != AbbrDeclSets.end() &&
I->first <
Offset)
134 AbbrDeclSets.insert(
I, std::make_pair(CUAbbrOffset, std::move(AbbrDecls)));
145 if (AbbrDeclSets.empty()) {
150 for (
const auto &
I : AbbrDeclSets) {
151 OS <<
formatv(
"Abbrev table for offset: {0:x+8}\n",
I.first);
158 const auto End = AbbrDeclSets.end();
159 if (PrevAbbrOffsetPos != End && PrevAbbrOffsetPos->first == CUAbbrOffset) {
160 return &PrevAbbrOffsetPos->second;
163 const auto Pos = AbbrDeclSets.find(CUAbbrOffset);
165 PrevAbbrOffsetPos = Pos;
169 if (!Data || CUAbbrOffset >= Data->getData().size())
171 "the abbreviation offset into the .debug_abbrev section is not valid");
176 return std::move(Err);
179 AbbrDeclSets.insert(std::make_pair(CUAbbrOffset, std::move(AbbrDecls)))
181 return &PrevAbbrOffsetPos->second;
LLVM_ABI void dump(raw_ostream &OS) const
LLVM_ABI DWARFAbbreviationDeclarationSet()
LLVM_ABI const DWARFAbbreviationDeclaration * getAbbreviationDeclaration(uint32_t AbbrCode) const
LLVM_ABI Error extract(DataExtractor Data, uint64_t *OffsetPtr)
LLVM_ABI std::string getCodeRange() const
LLVM_ABI llvm::Expected< ExtractState > extract(DataExtractor Data, uint64_t *OffsetPtr)
LLVM_ABI Expected< const DWARFAbbreviationDeclarationSet * > getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const
LLVM_ABI Error parse() const
DWARFAbbreviationDeclarationSetMap::const_iterator end() const
LLVM_ABI DWARFDebugAbbrev(DataExtractor Data)
LLVM_ABI 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.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
LLVM_ABI bool readAbbrevAttribute(const DataExtractor &AbbrevData, uint64_t *Offset, dwarf::Attribute &Name, dwarf::Form &Form, std::optional< int64_t > &ImplicitConst)
Read the next (attribute, form) specification from an abbreviation declaration at Offset,...
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
void consumeError(Error Err)
Consume a Error without doing anything.