1 //===-- DWARFAbbreviationDeclaration.h --------------------------*- 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 #ifndef liblldb_DWARFAbbreviationDeclaration_h_
11 #define liblldb_DWARFAbbreviationDeclaration_h_
13 #include "DWARFAttribute.h"
14 #include "SymbolFileDWARF.h"
16 class DWARFCompileUnit;
18 class DWARFAbbreviationDeclaration {
20 enum { InvalidCode = 0 };
21 DWARFAbbreviationDeclaration();
23 // For hand crafting an abbreviation declaration
24 DWARFAbbreviationDeclaration(dw_tag_t tag, uint8_t has_children);
25 void AddAttribute(const DWARFAttribute &attr) {
26 m_attributes.push_back(attr);
29 dw_uleb128_t Code() const { return m_code; }
30 void SetCode(dw_uleb128_t code) { m_code = code; }
31 dw_tag_t Tag() const { return m_tag; }
32 bool HasChildren() const { return m_has_children; }
33 size_t NumAttributes() const { return m_attributes.size(); }
34 dw_attr_t GetAttrByIndex(uint32_t idx) const {
35 return m_attributes.size() > idx ? m_attributes[idx].get_attr() : 0;
37 dw_form_t GetFormByIndex(uint32_t idx) const {
38 return m_attributes.size() > idx ? m_attributes[idx].get_form() : 0;
40 bool GetAttrAndFormByIndex(uint32_t idx, dw_attr_t &attr,
41 dw_form_t &form) const {
42 if (m_attributes.size() > idx) {
43 m_attributes[idx].get(attr, form);
50 // idx is assumed to be valid when calling GetAttrAndFormByIndexUnchecked()
51 void GetAttrAndFormByIndexUnchecked(uint32_t idx, dw_attr_t &attr,
52 dw_form_t &form) const {
53 m_attributes[idx].get(attr, form);
55 dw_form_t GetFormByIndexUnchecked(uint32_t idx) const {
56 return m_attributes[idx].get_form();
58 uint32_t FindAttributeIndex(dw_attr_t attr) const;
59 bool Extract(const lldb_private::DWARFDataExtractor &data,
60 lldb::offset_t *offset_ptr);
61 bool Extract(const lldb_private::DWARFDataExtractor &data,
62 lldb::offset_t *offset_ptr, dw_uleb128_t code);
64 void Dump(lldb_private::Stream *s) const;
65 bool operator==(const DWARFAbbreviationDeclaration &rhs) const;
66 const DWARFAttribute::collection &Attributes() const { return m_attributes; }
71 uint8_t m_has_children;
72 DWARFAttribute::collection m_attributes;
75 #endif // liblldb_DWARFAbbreviationDeclaration_h_