1 //===-- DWARFAbbreviationDeclaration.cpp ------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "DWARFAbbreviationDeclaration.h"
12 #include "lldb/Core/dwarf.h"
14 #include "DWARFFormValue.h"
16 using namespace lldb_private;
18 DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration() :
26 DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration(dw_tag_t tag, uint8_t has_children) :
29 m_has_children (has_children),
35 DWARFAbbreviationDeclaration::Extract(const DWARFDataExtractor& data, lldb::offset_t* offset_ptr)
37 return Extract(data, offset_ptr, data.GetULEB128(offset_ptr));
41 DWARFAbbreviationDeclaration::Extract(const DWARFDataExtractor& data, lldb::offset_t *offset_ptr, dw_uleb128_t code)
47 m_tag = data.GetULEB128(offset_ptr);
48 m_has_children = data.GetU8(offset_ptr);
50 while (data.ValidOffset(*offset_ptr))
52 dw_attr_t attr = data.GetULEB128(offset_ptr);
53 dw_form_t form = data.GetULEB128(offset_ptr);
56 m_attributes.push_back(DWARFAttribute(attr, form));
74 DWARFAbbreviationDeclaration::Dump(Stream *s) const
76 s->Printf("Debug Abbreviation Declaration: code = 0x%4.4x, tag = %s, has_children = %s\n", m_code, DW_TAG_value_to_name(m_tag), DW_CHILDREN_value_to_name(m_has_children));
78 DWARFAttribute::const_iterator pos;
80 for (pos = m_attributes.begin(); pos != m_attributes.end(); ++pos)
81 s->Printf(" attr = %s, form = %s\n", DW_AT_value_to_name(pos->get_attr()), DW_FORM_value_to_name(pos->get_form()));
89 DWARFAbbreviationDeclaration::IsValid()
91 return m_code != 0 && m_tag != 0;
97 DWARFAbbreviationDeclaration::FindAttributeIndex(dw_attr_t attr) const
100 const uint32_t kNumAttributes = m_attributes.size();
101 for (i = 0; i < kNumAttributes; ++i)
103 if (m_attributes[i].get_attr() == attr)
106 return DW_INVALID_INDEX;
111 DWARFAbbreviationDeclaration::operator == (const DWARFAbbreviationDeclaration& rhs) const
113 return Tag() == rhs.Tag()
114 && HasChildren() == rhs.HasChildren()
115 && Attributes() == rhs.Attributes();