24void DWARFAbbreviationDeclaration::clear() {
29 AttributeSpecs.
clear();
30 FixedAttributeSize.reset();
42 Code =
Data.getULEB128(OffsetPtr, &Err);
44 return std::move(Err);
49 CodeByteSize = *OffsetPtr -
Offset;
52 return std::move(Err);
54 if (
Tag == DW_TAG_null) {
56 return make_error<llvm::object::GenericBinaryError>(
57 "abbreviation declaration requires a non-null tag");
61 return std::move(Err);
67 FixedAttributeSize = FixedSizeInfo();
70 while (
Data.isValidOffset(*OffsetPtr)) {
73 return std::move(Err);
75 auto F =
static_cast<Form>(
Data.getULEB128(OffsetPtr, &Err));
77 return std::move(Err);
91 return make_error<llvm::object::GenericBinaryError>(
92 "malformed abbreviation declaration attribute. Either the attribute "
93 "or the form is zero while the other is not");
96 bool IsImplicitConst = (
F == DW_FORM_implicit_const);
97 if (IsImplicitConst) {
98 int64_t V =
Data.getSLEB128(OffsetPtr);
102 std::optional<uint8_t> ByteSize;
107 if (FixedAttributeSize)
108 ++FixedAttributeSize->NumAddrs;
111 case DW_FORM_ref_addr:
112 if (FixedAttributeSize)
113 ++FixedAttributeSize->NumRefAddrs;
117 case DW_FORM_GNU_ref_alt:
118 case DW_FORM_GNU_strp_alt:
119 case DW_FORM_line_strp:
120 case DW_FORM_sec_offset:
121 case DW_FORM_strp_sup:
122 if (FixedAttributeSize)
123 ++FixedAttributeSize->NumDwarfOffsets;
130 if (FixedAttributeSize)
131 FixedAttributeSize->NumBytes += *ByteSize;
137 FixedAttributeSize.reset();
143 return make_error<llvm::object::GenericBinaryError>(
144 "abbreviation declaration attribute list was not terminated with a null "
151 OS <<
"\tDW_CHILDREN_" << (
hasChildren() ?
"yes" :
"no") <<
'\n';
154 if (
Spec.isImplicitConst())
155 OS <<
'\t' <<
Spec.getImplicitConstValue();
161std::optional<uint32_t>
163 for (
uint32_t i = 0, e = AttributeSpecs.
size(); i != e; ++i) {
164 if (AttributeSpecs[i].Attr == Attr)
177 for (
uint32_t CurAttrIdx = 0; CurAttrIdx != AttrIndex; ++CurAttrIdx)
179 if (
auto FixedSize = AttributeSpecs[CurAttrIdx].getByteSize(U))
183 &
Offset, U.getFormParams());
187std::optional<DWARFFormValue>
191 "Attribute Index is out of bounds.");
195 if (
Spec.isImplicitConst())
197 Spec.getImplicitConstValue());
206std::optional<DWARFFormValue>
221size_t DWARFAbbreviationDeclaration::FixedSizeInfo::getByteSize(
223 size_t ByteSize = NumBytes;
225 ByteSize += NumAddrs * U.getAddressByteSize();
227 ByteSize += NumRefAddrs * U.getRefAddrByteSize();
229 ByteSize += NumDwarfOffsets * U.getDwarfOffsetByteSize();
239 std::optional<int64_t> S;
248 if (FixedAttributeSize)
249 return FixedAttributeSize->getByteSize(U);
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file contains constants used for implementing Dwarf debug support.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::Expected< ExtractState > extract(DataExtractor Data, uint64_t *OffsetPtr)
uint64_t getAttributeOffsetFromIndex(uint32_t AttrIndex, uint64_t DIEOffset, const DWARFUnit &U) const
Compute an offset from a DIE specified by DIE offset and attribute index.
dwarf::Tag getTag() const
std::optional< uint32_t > findAttributeIndex(dwarf::Attribute attr) const
Get the index of the specified attribute.
std::optional< DWARFFormValue > getAttributeValue(const uint64_t DIEOffset, const dwarf::Attribute Attr, const DWARFUnit &U) const
Extract a DWARF form value from a DIE specified by DIE offset.
std::optional< size_t > getFixedAttributesByteSize(const DWARFUnit &U) const
void dump(raw_ostream &OS) const
std::optional< DWARFFormValue > getAttributeValueFromOffset(uint32_t AttrIndex, uint64_t Offset, const DWARFUnit &U) const
Extract a DWARF form value from a DIE speccified by attribute index and its offset.
DWARFAbbreviationDeclaration()
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.
void push_back(const T &Elt)
This class implements an extremely fast bulk output stream that can only output to a stream.
std::optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)
Get the fixed byte size for a given form.
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
std::optional< int64_t > getByteSize(const DWARFUnit &U) const
Get the fixed byte size of this Form if possible.
bool isImplicitConst() const