Coverage Report

Created: 2022-01-22 13:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
Line
Count
Source (jump to first uncovered line)
1
//===-- DWARFBaseDIE.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_DWARFBASEDIE_H
10
#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFBASEDIE_H
11
12
#include "lldb/Core/dwarf.h"
13
#include "lldb/lldb-types.h"
14
15
#include "llvm/Support/Error.h"
16
17
class DIERef;
18
class DWARFASTParser;
19
class DWARFAttributes;
20
class DWARFUnit;
21
class DWARFDebugInfoEntry;
22
class DWARFDeclContext;
23
class SymbolFileDWARF;
24
25
class DWARFBaseDIE {
26
public:
27
1.90M
  DWARFBaseDIE() = default;
28
29
  DWARFBaseDIE(DWARFUnit *cu, DWARFDebugInfoEntry *die)
30
3.06M
      : m_cu(cu), m_die(die) {}
31
32
  DWARFBaseDIE(const DWARFUnit *cu, DWARFDebugInfoEntry *die)
33
0
      : m_cu(const_cast<DWARFUnit *>(cu)), m_die(die) {}
34
35
  DWARFBaseDIE(DWARFUnit *cu, const DWARFDebugInfoEntry *die)
36
1.39M
      : m_cu(cu), m_die(const_cast<DWARFDebugInfoEntry *>(die)) {}
37
38
  DWARFBaseDIE(const DWARFUnit *cu, const DWARFDebugInfoEntry *die)
39
      : m_cu(const_cast<DWARFUnit *>(cu)),
40
0
        m_die(const_cast<DWARFDebugInfoEntry *>(die)) {}
41
42
  // Tests
43
7.29M
  explicit operator bool() const { return IsValid(); }
44
45
17.9M
  bool IsValid() const { return m_cu && 
m_die16.4M
; }
46
47
  bool HasChildren() const;
48
49
  bool Supports_DW_AT_APPLE_objc_complete_type() const;
50
51
  // Accessors
52
  SymbolFileDWARF *GetDWARF() const;
53
54
2.91M
  DWARFUnit *GetCU() const { return m_cu; }
55
56
5.70M
  DWARFDebugInfoEntry *GetDIE() const { return m_die; }
57
58
  llvm::Optional<DIERef> GetDIERef() const;
59
60
0
  void Set(DWARFUnit *cu, DWARFDebugInfoEntry *die) {
61
0
    if (cu && die) {
62
0
      m_cu = cu;
63
0
      m_die = die;
64
0
    } else {
65
0
      Clear();
66
0
    }
67
0
  }
68
69
16.0k
  void Clear() {
70
16.0k
    m_cu = nullptr;
71
16.0k
    m_die = nullptr;
72
16.0k
  }
73
74
  // Get the data that contains the attribute values for this DIE. Support
75
  // for .debug_types means that any DIE can have its data either in the
76
  // .debug_info or the .debug_types section; this method will return the
77
  // correct section data.
78
  //
79
  // Clients must validate that this object is valid before calling this.
80
  const lldb_private::DWARFDataExtractor &GetData() const;
81
82
  // Accessing information about a DIE
83
  dw_tag_t Tag() const;
84
85
  const char *GetTagAsCString() const;
86
87
  dw_offset_t GetOffset() const;
88
89
  // Get the LLDB user ID for this DIE. This is often just the DIE offset,
90
  // but it might have a SymbolFileDWARF::GetID() in the high 32 bits if
91
  // we are doing Darwin DWARF in .o file, or DWARF stand alone debug
92
  // info.
93
  lldb::user_id_t GetID() const;
94
95
  const char *GetName() const;
96
97
  lldb::ModuleSP GetModule() const;
98
99
  // Getting attribute values from the DIE.
100
  //
101
  // GetAttributeValueAsXXX() functions should only be used if you are
102
  // looking for one or two attributes on a DIE. If you are trying to
103
  // parse all attributes, use GetAttributes (...) instead
104
  const char *GetAttributeValueAsString(const dw_attr_t attr,
105
                                        const char *fail_value) const;
106
107
  uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr,
108
                                       uint64_t fail_value) const;
109
110
  uint64_t GetAttributeValueAsAddress(const dw_attr_t attr,
111
                                      uint64_t fail_value) const;
112
113
  enum class Recurse : bool { no, yes };
114
  size_t GetAttributes(DWARFAttributes &attributes,
115
                       Recurse recurse = Recurse::yes) const;
116
117
protected:
118
  DWARFUnit *m_cu = nullptr;
119
  DWARFDebugInfoEntry *m_die = nullptr;
120
};
121
122
bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs);
123
bool operator!=(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs);
124
125
#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFBASEDIE_H