• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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);
AddAttribute(const DWARFAttribute & attr)26     void            AddAttribute(const DWARFAttribute& attr)
27                     {
28                         m_attributes.push_back(attr);
29                     }
30 
Code()31     dw_uleb128_t    Code() const { return m_code; }
SetCode(dw_uleb128_t code)32     void            SetCode(dw_uleb128_t code) { m_code = code; }
Tag()33     dw_tag_t        Tag() const { return m_tag; }
HasChildren()34     bool            HasChildren() const { return m_has_children; }
NumAttributes()35     size_t          NumAttributes() const { return m_attributes.size(); }
GetAttrByIndex(uint32_t idx)36     dw_attr_t       GetAttrByIndex(uint32_t idx) const { return m_attributes.size() > idx ? m_attributes[idx].get_attr() : 0; }
GetFormByIndex(uint32_t idx)37     dw_form_t       GetFormByIndex(uint32_t idx) const { return m_attributes.size() > idx ? m_attributes[idx].get_form() : 0; }
GetAttrAndFormByIndex(uint32_t idx,dw_attr_t & attr,dw_form_t & form)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()
GetAttrAndFormByIndexUnchecked(uint32_t idx,dw_attr_t & attr,dw_form_t & form)50     void            GetAttrAndFormByIndexUnchecked(uint32_t idx, dw_attr_t& attr, dw_form_t& form) const
51                     {
52                         m_attributes[idx].get(attr, form);
53                     }
GetFormByIndexUnchecked(uint32_t idx)54     dw_form_t       GetFormByIndexUnchecked (uint32_t idx) const
55                     {
56                         return m_attributes[idx].get_form();
57                     }
58     void            CopyExcludingAddressAttributes(const DWARFAbbreviationDeclaration& abbr_decl, const uint32_t idx);
59     void            CopyChangingStringToStrp(
60                         const DWARFAbbreviationDeclaration& abbr_decl,
61                         const lldb_private::DataExtractor& debug_info_data,
62                         dw_offset_t debug_info_offset,
63                         const DWARFCompileUnit* cu,
64                         const uint32_t strp_min_len);
65     uint32_t        FindAttributeIndex(dw_attr_t attr) const;
66     bool            Extract(const lldb_private::DataExtractor& data, lldb::offset_t *offset_ptr);
67     bool            Extract(const lldb_private::DataExtractor& data, lldb::offset_t *offset_ptr, dw_uleb128_t code);
68 //  void            Append(BinaryStreamBuf& out_buff) const;
69     bool            IsValid();
70     void            Dump(lldb_private::Stream *s) const;
71     bool            operator == (const DWARFAbbreviationDeclaration& rhs) const;
72 //  DWARFAttribute::collection& Attributes() { return m_attributes; }
Attributes()73     const DWARFAttribute::collection& Attributes() const { return m_attributes; }
74 protected:
75     dw_uleb128_t        m_code;
76     dw_tag_t            m_tag;
77     uint8_t             m_has_children;
78     DWARFAttribute::collection m_attributes;
79 };
80 
81 #endif  // liblldb_DWARFAbbreviationDeclaration_h_
82