1254721Semaste//===-- DWARFAbbreviationDeclaration.h --------------------------*- C++ -*-===//
2254721Semaste//
3254721Semaste//                     The LLVM Compiler Infrastructure
4254721Semaste//
5254721Semaste// This file is distributed under the University of Illinois Open Source
6254721Semaste// License. See LICENSE.TXT for details.
7254721Semaste//
8254721Semaste//===----------------------------------------------------------------------===//
9254721Semaste
10254721Semaste#ifndef liblldb_DWARFAbbreviationDeclaration_h_
11254721Semaste#define liblldb_DWARFAbbreviationDeclaration_h_
12254721Semaste
13254721Semaste#include "SymbolFileDWARF.h"
14254721Semaste#include "DWARFAttribute.h"
15254721Semaste
16254721Semasteclass DWARFCompileUnit;
17254721Semaste
18254721Semasteclass DWARFAbbreviationDeclaration
19254721Semaste{
20254721Semastepublic:
21254721Semaste    enum { InvalidCode = 0 };
22254721Semaste                    DWARFAbbreviationDeclaration();
23254721Semaste
24254721Semaste                    // For hand crafting an abbreviation declaration
25254721Semaste                    DWARFAbbreviationDeclaration(dw_tag_t tag, uint8_t has_children);
26254721Semaste    void            AddAttribute(const DWARFAttribute& attr)
27254721Semaste                    {
28254721Semaste                        m_attributes.push_back(attr);
29254721Semaste                    }
30254721Semaste
31254721Semaste    dw_uleb128_t    Code() const { return m_code; }
32254721Semaste    void            SetCode(dw_uleb128_t code) { m_code = code; }
33254721Semaste    dw_tag_t        Tag() const { return m_tag; }
34254721Semaste    bool            HasChildren() const { return m_has_children; }
35254721Semaste    size_t          NumAttributes() const { return m_attributes.size(); }
36254721Semaste    dw_attr_t       GetAttrByIndex(uint32_t idx) const { return m_attributes.size() > idx ? m_attributes[idx].get_attr() : 0; }
37254721Semaste    dw_form_t       GetFormByIndex(uint32_t idx) const { return m_attributes.size() > idx ? m_attributes[idx].get_form() : 0; }
38254721Semaste    bool            GetAttrAndFormByIndex(uint32_t idx, dw_attr_t& attr, dw_form_t& form) const
39254721Semaste                    {
40254721Semaste                        if (m_attributes.size() > idx)
41254721Semaste                        {
42254721Semaste                            m_attributes[idx].get(attr, form);
43254721Semaste                            return true;
44254721Semaste                        }
45254721Semaste                        attr = form = 0;
46254721Semaste                        return false;
47254721Semaste                    }
48254721Semaste
49254721Semaste                    // idx is assumed to be valid when calling GetAttrAndFormByIndexUnchecked()
50254721Semaste    void            GetAttrAndFormByIndexUnchecked(uint32_t idx, dw_attr_t& attr, dw_form_t& form) const
51254721Semaste                    {
52254721Semaste                        m_attributes[idx].get(attr, form);
53254721Semaste                    }
54254721Semaste    dw_form_t       GetFormByIndexUnchecked (uint32_t idx) const
55254721Semaste                    {
56254721Semaste                        return m_attributes[idx].get_form();
57254721Semaste                    }
58254721Semaste    void            CopyExcludingAddressAttributes(const DWARFAbbreviationDeclaration& abbr_decl, const uint32_t idx);
59254721Semaste    void            CopyChangingStringToStrp(
60254721Semaste                        const DWARFAbbreviationDeclaration& abbr_decl,
61263363Semaste                        const lldb_private::DWARFDataExtractor& debug_info_data,
62254721Semaste                        dw_offset_t debug_info_offset,
63254721Semaste                        const DWARFCompileUnit* cu,
64254721Semaste                        const uint32_t strp_min_len);
65254721Semaste    uint32_t        FindAttributeIndex(dw_attr_t attr) const;
66263363Semaste    bool            Extract(const lldb_private::DWARFDataExtractor& data, lldb::offset_t *offset_ptr);
67263363Semaste    bool            Extract(const lldb_private::DWARFDataExtractor& data, lldb::offset_t *offset_ptr, dw_uleb128_t code);
68254721Semaste//  void            Append(BinaryStreamBuf& out_buff) const;
69254721Semaste    bool            IsValid();
70254721Semaste    void            Dump(lldb_private::Stream *s) const;
71254721Semaste    bool            operator == (const DWARFAbbreviationDeclaration& rhs) const;
72254721Semaste//  DWARFAttribute::collection& Attributes() { return m_attributes; }
73254721Semaste    const DWARFAttribute::collection& Attributes() const { return m_attributes; }
74254721Semasteprotected:
75254721Semaste    dw_uleb128_t        m_code;
76254721Semaste    dw_tag_t            m_tag;
77254721Semaste    uint8_t             m_has_children;
78254721Semaste    DWARFAttribute::collection m_attributes;
79254721Semaste};
80254721Semaste
81254721Semaste#endif  // liblldb_DWARFAbbreviationDeclaration_h_
82