bool DWARFAbbreviationDeclaration::operator == (const DWARFAbbreviationDeclaration& rhs) const { return Tag() == rhs.Tag() && HasChildren() == rhs.HasChildren() && Attributes() == rhs.Attributes(); }
void DWARFDie::attribute_iterator::updateForIndex( const DWARFAbbreviationDeclaration &AbbrDecl, uint32_t I) { Index = I; // AbbrDecl must be valid before calling this function. auto NumAttrs = AbbrDecl.getNumAttributes(); if (Index < NumAttrs) { AttrValue.Attr = AbbrDecl.getAttrByIndex(Index); // Add the previous byte size of any previous attribute value. AttrValue.Offset += AttrValue.ByteSize; uint32_t ParseOffset = AttrValue.Offset; auto U = Die.getDwarfUnit(); assert(U && "Die must have valid DWARF unit"); AttrValue.Value = DWARFFormValue::createFromUnit( AbbrDecl.getFormByIndex(Index), U, &ParseOffset); AttrValue.ByteSize = ParseOffset - AttrValue.Offset; } else { assert(Index == NumAttrs && "Indexes should be [0, NumAttrs) only"); AttrValue.clear(); } }
//---------------------------------------------------------------------- // DWARFAbbreviationDeclarationSet::Extract() //---------------------------------------------------------------------- bool DWARFAbbreviationDeclarationSet::Extract(const DWARFDataExtractor &data, lldb::offset_t *offset_ptr) { const lldb::offset_t begin_offset = *offset_ptr; m_offset = begin_offset; Clear(); DWARFAbbreviationDeclaration abbrevDeclaration; dw_uleb128_t prev_abbr_code = 0; while (abbrevDeclaration.Extract(data, offset_ptr)) { m_decls.push_back(abbrevDeclaration); if (m_idx_offset == 0) m_idx_offset = abbrevDeclaration.Code(); else { if (prev_abbr_code + 1 != abbrevDeclaration.Code()) m_idx_offset = UINT32_MAX; // Out of order indexes, we can't do O(1) lookups... } prev_abbr_code = abbrevDeclaration.Code(); } return begin_offset != *offset_ptr; }
bool DWARFAbbreviationDeclarationSet::extract(DataExtractor Data, uint32_t *OffsetPtr) { clear(); const uint32_t BeginOffset = *OffsetPtr; Offset = BeginOffset; DWARFAbbreviationDeclaration AbbrDecl; uint32_t PrevAbbrCode = 0; while (AbbrDecl.extract(Data, OffsetPtr)) { if (FirstAbbrCode == 0) { FirstAbbrCode = AbbrDecl.getCode(); } else { if (PrevAbbrCode + 1 != AbbrDecl.getCode()) { // Codes are not consecutive, can't do O(1) lookups. FirstAbbrCode = UINT32_MAX; } } PrevAbbrCode = AbbrDecl.getCode(); Decls.push_back(std::move(AbbrDecl)); } return BeginOffset != *OffsetPtr; }
void DWARFDie::attribute_iterator::updateForIndex( const DWARFAbbreviationDeclaration &AbbrDecl, uint32_t I) { Index = I; // AbbrDecl must be valid befor calling this function. auto NumAttrs = AbbrDecl.getNumAttributes(); if (Index < NumAttrs) { AttrValue.Attr = AbbrDecl.getAttrByIndex(Index); // Add the previous byte size of any previous attribute value. AttrValue.Offset += AttrValue.ByteSize; AttrValue.Value.setForm(AbbrDecl.getFormByIndex(Index)); uint32_t ParseOffset = AttrValue.Offset; auto U = Die.getDwarfUnit(); assert(U && "Die must have valid DWARF unit"); bool b = AttrValue.Value.extractValue(U->getDebugInfoExtractor(), &ParseOffset, U); (void)b; assert(b && "extractValue cannot fail on fully parsed DWARF"); AttrValue.ByteSize = ParseOffset - AttrValue.Offset; } else { assert(Index == NumAttrs && "Indexes should be [0, NumAttrs) only"); AttrValue.clear(); } }