Coverage Report

Created: 2023-11-11 10:31

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
Line
Count
Source (jump to first uncovered line)
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
namespace lldb_private::plugin {
18
namespace dwarf {
19
class DWARFUnit;
20
21
class DWARFAttribute {
22
public:
23
  DWARFAttribute(dw_attr_t attr, dw_form_t form,
24
                 DWARFFormValue::ValueType value)
25
1.63M
      : m_attr(attr), m_form(form), m_value(value) {}
26
27
1.78M
  dw_attr_t get_attr() const { return m_attr; }
28
1.07M
  dw_form_t get_form() const { return m_form; }
29
1
  DWARFFormValue::ValueType get_value() const { return m_value; }
30
  void get(dw_attr_t &attr, dw_form_t &form,
31
0
           DWARFFormValue::ValueType &val) const {
32
0
    attr = m_attr;
33
0
    form = m_form;
34
0
    val = m_value;
35
0
  }
36
37
protected:
38
  dw_attr_t m_attr;
39
  dw_form_t m_form;
40
  DWARFFormValue::ValueType m_value;
41
};
42
43
class DWARFAttributes {
44
public:
45
  DWARFAttributes();
46
  ~DWARFAttributes();
47
48
  void Append(const DWARFFormValue &form_value, dw_offset_t attr_die_offset,
49
              dw_attr_t attr);
50
1.15M
  DWARFUnit *CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; }
51
1.07M
  dw_offset_t DIEOffsetAtIndex(uint32_t i) const {
52
1.07M
    return m_infos[i].die_offset;
53
1.07M
  }
54
1.62M
  dw_attr_t AttributeAtIndex(uint32_t i) const {
55
1.62M
    return m_infos[i].attr.get_attr();
56
1.62M
  }
57
1.07M
  dw_form_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); }
58
1
  DWARFFormValue::ValueType ValueAtIndex(uint32_t i) const {
59
1
    return m_infos[i].attr.get_value();
60
1
  }
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
1
  void Clear() { m_infos.clear(); }
66
2.31M
  size_t Size() const { return m_infos.size(); }
67
68
protected:
69
  struct AttributeValue {
70
    DWARFUnit *cu; // Keep the compile unit with each attribute in
71
                   // case we have DW_FORM_ref_addr values
72
    dw_offset_t die_offset;
73
    DWARFAttribute attr;
74
  };
75
  typedef llvm::SmallVector<AttributeValue, 8> collection;
76
  collection m_infos;
77
};
78
} // namespace dwarf
79
} // namespace lldb_private::plugin
80
81
#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H