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
17namespace lldb_private::plugin {
18namespace dwarf {
19class DWARFUnit;
20
22public:
25 : m_attr(attr), m_form(form), m_value(value) {}
26
27 dw_attr_t get_attr() const { return m_attr; }
28 dw_form_t get_form() const { return m_form; }
30 void get(dw_attr_t &attr, dw_form_t &form,
31 DWARFFormValue::ValueType &val) const {
32 attr = m_attr;
33 form = m_form;
34 val = m_value;
35 }
36
37protected:
41};
42
44public:
47
48 void Append(const DWARFFormValue &form_value, dw_offset_t attr_die_offset,
49 dw_attr_t attr);
50 DWARFUnit *CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; }
51 dw_offset_t DIEOffsetAtIndex(uint32_t i) const {
52 return m_infos[i].die_offset;
53 }
54 dw_attr_t AttributeAtIndex(uint32_t i) const {
55 return m_infos[i].attr.get_attr();
56 }
57 dw_form_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); }
59 return m_infos[i].attr.get_value();
60 }
61 bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const;
62 DWARFDIE FormValueAsReferenceAtIndex(uint32_t i) const;
64 uint32_t FindAttributeIndex(dw_attr_t attr) const;
65 void Clear() { m_infos.clear(); }
66 size_t Size() const { return m_infos.size(); }
67
68protected:
70 DWARFUnit *cu; // Keep the compile unit with each attribute in
71 // case we have DW_FORM_ref_addr values
74 };
75 typedef llvm::SmallVector<AttributeValue, 8> collection;
77};
78} // namespace dwarf
79} // namespace lldb_private::plugin
80
81#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H
DWARFFormValue::ValueType get_value() const
void get(dw_attr_t &attr, dw_form_t &form, DWARFFormValue::ValueType &val) const
DWARFAttribute(dw_attr_t attr, dw_form_t form, DWARFFormValue::ValueType value)
DWARFUnit * CompileUnitAtIndex(uint32_t i) const
dw_attr_t AttributeAtIndex(uint32_t i) const
DWARFDIE FormValueAsReferenceAtIndex(uint32_t i) const
llvm::SmallVector< AttributeValue, 8 > collection
dw_offset_t DIEOffsetAtIndex(uint32_t i) const
dw_form_t FormAtIndex(uint32_t i) const
DWARFDIE FormValueAsReference(dw_attr_t attr) const
bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const
uint32_t FindAttributeIndex(dw_attr_t attr) const
DWARFFormValue::ValueType ValueAtIndex(uint32_t i) const
void Append(const DWARFFormValue &form_value, dw_offset_t attr_die_offset, dw_attr_t attr)
uint64_t dw_offset_t
Definition: dwarf.h:31
llvm::dwarf::Attribute dw_attr_t
Definition: dwarf.h:24
llvm::dwarf::Form dw_form_t
Definition: dwarf.h:25