Coverage Report

Created: 2022-01-15 10:30

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Core/LoadedModuleInfoList.h
Line
Count
Source (jump to first uncovered line)
1
//===-- LoadedModuleInfoList.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_CORE_LOADEDMODULEINFOLIST_H
10
#define LLDB_CORE_LOADEDMODULEINFOLIST_H
11
12
#include <cassert>
13
#include <string>
14
#include <vector>
15
16
#include "lldb/lldb-defines.h"
17
#include "lldb/lldb-private-forward.h"
18
#include "lldb/lldb-types.h"
19
20
namespace lldb_private {
21
class LoadedModuleInfoList {
22
public:
23
  class LoadedModuleInfo {
24
  public:
25
    enum e_data_point {
26
      e_has_name = 0,
27
      e_has_base,
28
      e_has_dynamic,
29
      e_has_link_map,
30
      e_num
31
    };
32
33
6
    LoadedModuleInfo() {
34
30
      for (uint32_t i = 0; i < e_num; 
++i24
)
35
24
        m_has[i] = false;
36
6
    };
37
38
6
    void set_name(const std::string &name) {
39
6
      m_name = name;
40
6
      m_has[e_has_name] = true;
41
6
    }
42
3
    bool get_name(std::string &out) const {
43
3
      out = m_name;
44
3
      return m_has[e_has_name];
45
3
    }
46
47
6
    void set_base(const lldb::addr_t base) {
48
6
      m_base = base;
49
6
      m_has[e_has_base] = true;
50
6
    }
51
3
    bool get_base(lldb::addr_t &out) const {
52
3
      out = m_base;
53
3
      return m_has[e_has_base];
54
3
    }
55
56
6
    void set_base_is_offset(bool is_offset) { m_base_is_offset = is_offset; }
57
3
    bool get_base_is_offset(bool &out) const {
58
3
      out = m_base_is_offset;
59
3
      return m_has[e_has_base];
60
3
    }
61
62
0
    void set_link_map(const lldb::addr_t addr) {
63
0
      m_link_map = addr;
64
0
      m_has[e_has_link_map] = true;
65
0
    }
66
3
    bool get_link_map(lldb::addr_t &out) const {
67
3
      out = m_link_map;
68
3
      return m_has[e_has_link_map];
69
3
    }
70
71
0
    void set_dynamic(const lldb::addr_t addr) {
72
0
      m_dynamic = addr;
73
0
      m_has[e_has_dynamic] = true;
74
0
    }
75
0
    bool get_dynamic(lldb::addr_t &out) const {
76
0
      out = m_dynamic;
77
0
      return m_has[e_has_dynamic];
78
0
    }
79
80
0
    bool has_info(e_data_point datum) const {
81
0
      assert(datum < e_num);
82
0
      return m_has[datum];
83
0
    }
84
85
0
    bool operator==(LoadedModuleInfo const &rhs) const {
86
0
      for (size_t i = 0; i < e_num; ++i) {
87
0
        if (m_has[i] != rhs.m_has[i])
88
0
          return false;
89
0
      }
90
0
91
0
      return (m_base == rhs.m_base) && (m_link_map == rhs.m_link_map) &&
92
0
             (m_dynamic == rhs.m_dynamic) && (m_name == rhs.m_name);
93
0
    }
94
95
  protected:
96
    bool m_has[e_num];
97
    std::string m_name;
98
    lldb::addr_t m_link_map;
99
    lldb::addr_t m_base;
100
    bool m_base_is_offset;
101
    lldb::addr_t m_dynamic;
102
  };
103
104
113
  LoadedModuleInfoList() {}
105
106
6
  void add(const LoadedModuleInfo &mod) { m_list.push_back(mod); }
107
108
0
  void clear() { m_list.clear(); }
109
110
  std::vector<LoadedModuleInfo> m_list;
111
  lldb::addr_t m_link_map = LLDB_INVALID_ADDRESS;
112
};
113
} // namespace lldb_private
114
115
#endif // LLDB_CORE_LOADEDMODULEINFOLIST_H