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 LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_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  dw_attr_t get_attr() const { return m_attr; }
26  dw_form_t get_form() const { return m_form; }
28  void get(dw_attr_t &attr, dw_form_t &form,
29  DWARFFormValue::ValueType &val) const {
30  attr = m_attr;
31  form = m_form;
32  val = m_value;
33  }
34  typedef std::vector<DWARFAttribute> collection;
35  typedef collection::iterator iterator;
36  typedef collection::const_iterator const_iterator;
37 
38 protected:
42 };
43 
45 public:
48 
49  void Append(const DWARFFormValue &form_value, dw_offset_t attr_die_offset,
50  dw_attr_t attr);
51  DWARFUnit *CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; }
53  return m_infos[i].die_offset;
54  }
56  return m_infos[i].attr.get_attr();
57  }
58  dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); }
60  return m_infos[i].attr.get_value();
61  }
62  bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const;
66  void Clear() { m_infos.clear(); }
67  size_t Size() const { return m_infos.size(); }
68 
69 protected:
70  struct AttributeValue {
71  DWARFUnit *cu; // Keep the compile unit with each attribute in
72  // case we have DW_FORM_ref_addr values
75  };
76  typedef llvm::SmallVector<AttributeValue, 8> collection;
78 };
79 
80 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H
DWARFFormValue.h
DWARFAttributes::AttributeValue
Definition: DWARFAttribute.h:70
DWARFAttribute::get
void get(dw_attr_t &attr, dw_form_t &form, DWARFFormValue::ValueType &val) const
Definition: DWARFAttribute.h:28
DWARFAttribute::collection
std::vector< DWARFAttribute > collection
Definition: DWARFAttribute.h:34
DWARFAttributes::FormValueAsReference
DWARFDIE FormValueAsReference(dw_attr_t attr) const
Definition: DWARFAttribute.cpp:50
DWARFAttributes::AttributeValue::attr
DWARFAttribute attr
Definition: DWARFAttribute.h:74
DWARFAttributes::AttributeValue::die_offset
dw_offset_t die_offset
Definition: DWARFAttribute.h:73
DWARFAttributes::Clear
void Clear()
Definition: DWARFAttribute.h:66
DWARFDefines.h
DWARFAttributes
Definition: DWARFAttribute.h:44
DWARFDIE
Definition: DWARFDIE.h:16
DWARFAttributes::collection
llvm::SmallVector< AttributeValue, 8 > collection
Definition: DWARFAttribute.h:76
DWARFAttributes::~DWARFAttributes
~DWARFAttributes()
DWARFUnit
Definition: DWARFUnit.h:80
DWARFAttributes::m_infos
collection m_infos
Definition: DWARFAttribute.h:77
DWARFAttribute::get_value
DWARFFormValue::ValueType get_value() const
Definition: DWARFAttribute.h:27
DWARFAttribute::m_value
DWARFFormValue::ValueType m_value
Definition: DWARFAttribute.h:41
DWARFAttribute::const_iterator
collection::const_iterator const_iterator
Definition: DWARFAttribute.h:36
DWARFFormValue
Definition: DWARFFormValue.h:20
DWARFAttributes::ExtractFormValueAtIndex
bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const
Definition: DWARFAttribute.cpp:36
DWARFAttribute::get_form
dw_form_t get_form() const
Definition: DWARFAttribute.h:26
DWARFAttributes::FormAtIndex
dw_attr_t FormAtIndex(uint32_t i) const
Definition: DWARFAttribute.h:58
DWARFAttribute::m_attr
dw_attr_t m_attr
Definition: DWARFAttribute.h:39
DWARFAttributes::ValueAtIndex
DWARFFormValue::ValueType ValueAtIndex(uint32_t i) const
Definition: DWARFAttribute.h:59
DWARFAttributes::FormValueAsReferenceAtIndex
DWARFDIE FormValueAsReferenceAtIndex(uint32_t i) const
Definition: DWARFAttribute.cpp:58
DWARFAttribute::DWARFAttribute
DWARFAttribute(dw_attr_t attr, dw_form_t form, DWARFFormValue::ValueType value)
Definition: DWARFAttribute.h:21
DWARFAttributes::FindAttributeIndex
uint32_t FindAttributeIndex(dw_attr_t attr) const
Definition: DWARFAttribute.cpp:17
DWARFAttribute::iterator
collection::iterator iterator
Definition: DWARFAttribute.h:35
uint32_t
DWARFFormValue::ValueTypeTag
Definition: DWARFFormValue.h:22
uint16_t
DWARFAttributes::AttributeAtIndex
dw_attr_t AttributeAtIndex(uint32_t i) const
Definition: DWARFAttribute.h:55
DWARFAttribute
Definition: DWARFAttribute.h:19
DWARFAttributes::Size
size_t Size() const
Definition: DWARFAttribute.h:67
DWARFAttributes::DWARFAttributes
DWARFAttributes()
Definition: DWARFAttribute.cpp:13
DWARFAttributes::DIEOffsetAtIndex
dw_offset_t DIEOffsetAtIndex(uint32_t i) const
Definition: DWARFAttribute.h:52
DWARFAttribute::get_attr
dw_attr_t get_attr() const
Definition: DWARFAttribute.h:25
DWARFAttributes::CompileUnitAtIndex
DWARFUnit * CompileUnitAtIndex(uint32_t i) const
Definition: DWARFAttribute.h:51
DWARFAttributes::Append
void Append(const DWARFFormValue &form_value, dw_offset_t attr_die_offset, dw_attr_t attr)
Definition: DWARFAttribute.cpp:28
DWARFAttributes::AttributeValue::cu
DWARFUnit * cu
Definition: DWARFAttribute.h:71
DWARFAttribute::m_form
dw_form_t m_form
Definition: DWARFAttribute.h:40