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));
65 Decls.shrink_to_fit();
70 for (
const auto &Decl : Decls)
77 if (FirstAbbrCode == UINT32_MAX) {
78 for (
const auto &Decl : Decls) {
79 if (Decl.getCode() == AbbrCode)
84 if (AbbrCode < FirstAbbrCode || AbbrCode >= FirstAbbrCode + Decls.size())
86 return &Decls[AbbrCode - FirstAbbrCode];
91 std::vector<uint32_t> Codes;
92 Codes.reserve(Decls.size());
93 for (
const auto &Decl : Decls)
94 Codes.push_back(Decl.getCode());
100 for (
auto Current = Codes.begin(), End = Codes.end(); Current != End;) {
106 while (++Current != End && *Current == RangeEnd + 1)
109 if (RangeStart != RangeEnd)
110 Stream <<
"-" << RangeEnd;
119 : AbbrDeclSets(), PrevAbbrOffsetPos(AbbrDeclSets.
end()), Data(Data) {}
125 auto I = AbbrDeclSets.begin();
126 while (Data->isValidOffset(
Offset)) {
127 while (
I != AbbrDeclSets.end() &&
I->first <
Offset)
135 AbbrDeclSets.insert(
I, std::make_pair(CUAbbrOffset, std::move(AbbrDecls)));
146 if (AbbrDeclSets.empty()) {
151 for (
const auto &
I : AbbrDeclSets) {
152 OS <<
formatv(
"Abbrev table for offset: {0:x+8}\n",
I.first);
159 const auto End = AbbrDeclSets.end();
160 if (PrevAbbrOffsetPos != End && PrevAbbrOffsetPos->first == CUAbbrOffset) {
161 return &PrevAbbrOffsetPos->second;
164 const auto Pos = AbbrDeclSets.find(CUAbbrOffset);
166 PrevAbbrOffsetPos = Pos;
170 if (!Data || CUAbbrOffset >= Data->getData().size())
172 "the abbreviation offset into the .debug_abbrev section is not valid");
177 return std::move(Err);
180 AbbrDeclSets.insert(std::make_pair(CUAbbrOffset, std::move(AbbrDecls)))
182 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.