Path: blob/main/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
39645 views
//===-- DWARFAttribute.h ----------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H9#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H1011#include "DWARFDefines.h"12#include "DWARFFormValue.h"13#include "llvm/ADT/SmallVector.h"14#include <vector>1516namespace lldb_private::plugin {17namespace dwarf {18class DWARFUnit;1920class DWARFAttribute {21public:22DWARFAttribute(dw_attr_t attr, dw_form_t form,23DWARFFormValue::ValueType value)24: m_attr(attr), m_form(form), m_value(value) {}2526dw_attr_t get_attr() const { return m_attr; }27dw_form_t get_form() const { return m_form; }28DWARFFormValue::ValueType get_value() const { return m_value; }29void get(dw_attr_t &attr, dw_form_t &form,30DWARFFormValue::ValueType &val) const {31attr = m_attr;32form = m_form;33val = m_value;34}3536protected:37dw_attr_t m_attr;38dw_form_t m_form;39DWARFFormValue::ValueType m_value;40};4142class DWARFAttributes {43public:44DWARFAttributes();45~DWARFAttributes();4647void Append(const DWARFFormValue &form_value, dw_offset_t attr_die_offset,48dw_attr_t attr);49DWARFUnit *CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; }50dw_offset_t DIEOffsetAtIndex(uint32_t i) const {51return m_infos[i].die_offset;52}53dw_attr_t AttributeAtIndex(uint32_t i) const {54return m_infos[i].attr.get_attr();55}56dw_form_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); }57DWARFFormValue::ValueType ValueAtIndex(uint32_t i) const {58return m_infos[i].attr.get_value();59}60bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const;61DWARFDIE FormValueAsReferenceAtIndex(uint32_t i) const;62DWARFDIE FormValueAsReference(dw_attr_t attr) const;63uint32_t FindAttributeIndex(dw_attr_t attr) const;64void Clear() { m_infos.clear(); }65size_t Size() const { return m_infos.size(); }6667protected:68struct AttributeValue {69DWARFUnit *cu; // Keep the compile unit with each attribute in70// case we have DW_FORM_ref_addr values71dw_offset_t die_offset;72DWARFAttribute attr;73};74typedef llvm::SmallVector<AttributeValue, 8> collection;75collection m_infos;76};77} // namespace dwarf78} // namespace lldb_private::plugin7980#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H818283