LLDB  mainline
DWARFAttribute.h
Go to the documentation of this file.
1 //===-- DWARFAttribute.h ----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef SymbolFileDWARF_DWARFAttribute_h_
10 #define SymbolFileDWARF_DWARFAttribute_h_
11 
12 #include "DWARFDefines.h"
13 #include "DWARFFormValue.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include <vector>
16 
17 class DWARFUnit;
18 
20 public:
23  : m_attr(attr), m_form(form), m_value(value) {}
24 
25  void set(dw_attr_t attr, dw_form_t form) {
26  m_attr = attr;
27  m_form = form;
28  }
29  dw_attr_t get_attr() const { return m_attr; }
30  dw_form_t get_form() const { return m_form; }
31  void get(dw_attr_t &attr, dw_form_t &form,
32  DWARFFormValue::ValueType &val) const {
33  attr = m_attr;
34  form = m_form;
35  val = m_value;
36  }
37  bool operator==(const DWARFAttribute &rhs) const {
38  return m_attr == rhs.m_attr && m_form == rhs.m_form;
39  }
40  typedef std::vector<DWARFAttribute> collection;
41  typedef collection::iterator iterator;
42  typedef collection::const_iterator const_iterator;
43 
44 protected:
48 };
49 
51 public:
53  ~DWARFAttributes();
54 
55  void Append(const DWARFUnit *cu, dw_offset_t attr_die_offset,
56  dw_attr_t attr, dw_form_t form);
58  return m_infos[i].cu;
59  }
61  return m_infos[i].die_offset;
62  }
64  return m_infos[i].attr.get_attr();
65  }
66  dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); }
67  bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const;
68  uint64_t FormValueAsUnsignedAtIndex(uint32_t i, uint64_t fail_value) const;
69  uint64_t FormValueAsUnsigned(dw_attr_t attr, uint64_t fail_value) const;
70  uint32_t FindAttributeIndex(dw_attr_t attr) const;
71  void Clear() { m_infos.clear(); }
72  size_t Size() const { return m_infos.size(); }
73 
74 protected:
75  struct AttributeValue {
76  const DWARFUnit *cu; // Keep the compile unit with each attribute in
77  // case we have DW_FORM_ref_addr values
80  };
81  typedef llvm::SmallVector<AttributeValue, 8> collection;
82  collection m_infos;
83 };
84 
85 #endif // SymbolFileDWARF_DWARFAttribute_h_
dw_attr_t m_attr
bool operator==(const DWARFAttribute &rhs) const
size_t Size() const
DWARFFormValue::ValueType m_value
DWARFAttribute(dw_attr_t attr, dw_form_t form, DWARFFormValue::ValueType value)
collection m_infos
dw_form_t get_form() const
collection::const_iterator const_iterator
collection::iterator iterator
dw_attr_t AttributeAtIndex(uint32_t i) const
dw_offset_t DIEOffsetAtIndex(uint32_t i) const
std::vector< DWARFAttribute > collection
dw_attr_t get_attr() const
llvm::SmallVector< AttributeValue, 8 > collection
const DWARFUnit * CompileUnitAtIndex(uint32_t i) const
dw_attr_t FormAtIndex(uint32_t i) const
dw_form_t m_form