]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / source / Plugins / SymbolFile / DWARF / DWARFAbbreviationDeclaration.h
1 //===-- DWARFAbbreviationDeclaration.h --------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_DWARFAbbreviationDeclaration_h_
11 #define liblldb_DWARFAbbreviationDeclaration_h_
12
13 #include "SymbolFileDWARF.h"
14 #include "DWARFAttribute.h"
15
16 class DWARFCompileUnit;
17
18 class DWARFAbbreviationDeclaration
19 {
20 public:
21     enum { InvalidCode = 0 };
22                     DWARFAbbreviationDeclaration();
23
24                     // For hand crafting an abbreviation declaration
25                     DWARFAbbreviationDeclaration(dw_tag_t tag, uint8_t has_children);
26     void            AddAttribute(const DWARFAttribute& attr)
27                     {
28                         m_attributes.push_back(attr);
29                     }
30
31     dw_uleb128_t    Code() const { return m_code; }
32     void            SetCode(dw_uleb128_t code) { m_code = code; }
33     dw_tag_t        Tag() const { return m_tag; }
34     bool            HasChildren() const { return m_has_children; }
35     size_t          NumAttributes() const { return m_attributes.size(); }
36     dw_attr_t       GetAttrByIndex(uint32_t idx) const { return m_attributes.size() > idx ? m_attributes[idx].get_attr() : 0; }
37     dw_form_t       GetFormByIndex(uint32_t idx) const { return m_attributes.size() > idx ? m_attributes[idx].get_form() : 0; }
38     bool            GetAttrAndFormByIndex(uint32_t idx, dw_attr_t& attr, dw_form_t& form) const
39                     {
40                         if (m_attributes.size() > idx)
41                         {
42                             m_attributes[idx].get(attr, form);
43                             return true;
44                         }
45                         attr = form = 0;
46                         return false;
47                     }
48
49                     // idx is assumed to be valid when calling GetAttrAndFormByIndexUnchecked()
50     void            GetAttrAndFormByIndexUnchecked(uint32_t idx, dw_attr_t& attr, dw_form_t& form) const
51                     {
52                         m_attributes[idx].get(attr, form);
53                     }
54     dw_form_t       GetFormByIndexUnchecked (uint32_t idx) const
55                     {
56                         return m_attributes[idx].get_form();
57                     }
58     uint32_t        FindAttributeIndex(dw_attr_t attr) const;
59     bool            Extract(const lldb_private::DWARFDataExtractor& data, lldb::offset_t *offset_ptr);
60     bool            Extract(const lldb_private::DWARFDataExtractor& data, lldb::offset_t *offset_ptr, dw_uleb128_t code);
61     bool            IsValid();
62     void            Dump(lldb_private::Stream *s) const;
63     bool            operator == (const DWARFAbbreviationDeclaration& rhs) const;
64     const DWARFAttribute::collection& Attributes() const { return m_attributes; }
65 protected:
66     dw_uleb128_t        m_code;
67     dw_tag_t            m_tag;
68     uint8_t             m_has_children;
69     DWARFAttribute::collection m_attributes;
70 };
71
72 #endif  // liblldb_DWARFAbbreviationDeclaration_h_