brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · e05ccc9 Raw
82 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H10#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H11 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 21class DWARFAttribute {22public:23  DWARFAttribute(dw_attr_t attr, dw_form_t form,24                 DWARFFormValue::ValueType value)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; }29  DWARFFormValue::ValueType get_value() const { return m_value; }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:38  dw_attr_t m_attr;39  dw_form_t m_form;40  DWARFFormValue::ValueType m_value;41};42 43class DWARFAttributes {44public:45  DWARFAttributes();46  ~DWARFAttributes();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(); }58  DWARFFormValue::ValueType ValueAtIndex(uint32_t i) const {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;63  DWARFDIE FormValueAsReference(dw_attr_t attr) 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:69  struct AttributeValue {70    DWARFUnit *cu; // Keep the compile unit with each attribute in71                   // case we have DW_FORM_ref_addr values72    dw_offset_t die_offset;73    DWARFAttribute attr;74  };75  typedef llvm::SmallVector<AttributeValue, 8> collection;76  collection m_infos;77};78} // namespace dwarf79} // namespace lldb_private::plugin80 81#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H82