]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
MFV r336960: 9256 zfs send space estimation off by > 10% on some datasets
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / 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 "DWARFAttribute.h"
14 #include "SymbolFileDWARF.h"
15
16 class DWARFCompileUnit;
17
18 class DWARFAbbreviationDeclaration {
19 public:
20   enum { InvalidCode = 0 };
21   DWARFAbbreviationDeclaration();
22
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);
27   }
28
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;
36   }
37   dw_form_t GetFormByIndex(uint32_t idx) const {
38     return m_attributes.size() > idx ? m_attributes[idx].get_form() : 0;
39   }
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);
44       return true;
45     }
46     attr = form = 0;
47     return false;
48   }
49
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);
54   }
55   dw_form_t GetFormByIndexUnchecked(uint32_t idx) const {
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,
60                lldb::offset_t *offset_ptr);
61   bool Extract(const lldb_private::DWARFDataExtractor &data,
62                lldb::offset_t *offset_ptr, dw_uleb128_t code);
63   bool IsValid();
64   void Dump(lldb_private::Stream *s) const;
65   bool operator==(const DWARFAbbreviationDeclaration &rhs) const;
66   const DWARFAttribute::collection &Attributes() const { return m_attributes; }
67
68 protected:
69   dw_uleb128_t m_code;
70   dw_tag_t m_tag;
71   uint8_t m_has_children;
72   DWARFAttribute::collection m_attributes;
73 };
74
75 #endif // liblldb_DWARFAbbreviationDeclaration_h_