Coverage Report

Created: 2022-01-15 10:30

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
Line
Count
Source
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
19
class DWARFAttribute {
20
public:
21
  DWARFAttribute(dw_attr_t attr, dw_form_t form,
22
                 DWARFFormValue::ValueType value)
23
3.05M
      : m_attr(attr), m_form(form), m_value(value) {}
24
25
12.0M
  dw_attr_t get_attr() const { return m_attr; }
26
21.1M
  dw_form_t get_form() const { return m_form; }
27
1
  DWARFFormValue::ValueType get_value() const { return m_value; }
28
  void get(dw_attr_t &attr, dw_form_t &form,
29
2.13M
           DWARFFormValue::ValueType &val) const {
30
2.13M
    attr = m_attr;
31
2.13M
    form = m_form;
32
2.13M
    val = m_value;
33
2.13M
  }
34
  typedef std::vector<DWARFAttribute> collection;
35
  typedef collection::iterator iterator;
36
  typedef collection::const_iterator const_iterator;
37
38
protected:
39
  dw_attr_t m_attr;
40
  dw_form_t m_form;
41
  DWARFFormValue::ValueType m_value;
42
};
43
44
class DWARFAttributes {
45
public:
46
  DWARFAttributes();
47
  ~DWARFAttributes();
48
49
  void Append(const DWARFFormValue &form_value, dw_offset_t attr_die_offset,
50
              dw_attr_t attr);
51
1.49M
  DWARFUnit *CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; }
52
1.37M
  dw_offset_t DIEOffsetAtIndex(uint32_t i) const {
53
1.37M
    return m_infos[i].die_offset;
54
1.37M
  }
55
1.97M
  dw_attr_t AttributeAtIndex(uint32_t i) const {
56
1.97M
    return m_infos[i].attr.get_attr();
57
1.97M
  }
58
1.37M
  dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); }
59
1
  DWARFFormValue::ValueType ValueAtIndex(uint32_t i) const {
60
1
    return m_infos[i].attr.get_value();
61
1
  }
62
  bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const;
63
  DWARFDIE FormValueAsReferenceAtIndex(uint32_t i) const;
64
  DWARFDIE FormValueAsReference(dw_attr_t attr) const;
65
  uint32_t FindAttributeIndex(dw_attr_t attr) const;
66
1
  void Clear() { m_infos.clear(); }
67
518k
  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
73
    dw_offset_t die_offset;
74
    DWARFAttribute attr;
75
  };
76
  typedef llvm::SmallVector<AttributeValue, 8> collection;
77
  collection m_infos;
78
};
79
80
#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H