Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
Line
Count
Source (jump to first uncovered line)
1
//===-- ValueObjectSyntheticFilter.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_VALUEOBJECTSYNTHETICFILTER_H
10
#define LLDB_CORE_VALUEOBJECTSYNTHETICFILTER_H
11
12
#include "lldb/Core/ValueObject.h"
13
#include "lldb/Symbol/CompilerType.h"
14
#include "lldb/Utility/ConstString.h"
15
#include "lldb/lldb-defines.h"
16
#include "lldb/lldb-enumerations.h"
17
#include "lldb/lldb-forward.h"
18
#include "lldb/lldb-private-enumerations.h"
19
20
#include <cstdint>
21
#include <memory>
22
23
#include <cstddef>
24
25
namespace lldb_private {
26
class Declaration;
27
class Status;
28
class SyntheticChildrenFrontEnd;
29
30
/// A ValueObject that obtains its children from some source other than
31
/// real information.
32
/// This is currently used to implement Python-based children and filters but
33
/// you can bind it to any source of synthetic information and have it behave
34
/// accordingly.
35
class ValueObjectSynthetic : public ValueObject {
36
public:
37
  ~ValueObjectSynthetic() override;
38
39
  llvm::Optional<uint64_t> GetByteSize() override;
40
41
  ConstString GetTypeName() override;
42
43
  ConstString GetQualifiedTypeName() override;
44
45
  ConstString GetDisplayTypeName() override;
46
47
  bool MightHaveChildren() override;
48
49
  size_t CalculateNumChildren(uint32_t max) override;
50
51
  lldb::ValueType GetValueType() const override;
52
53
  lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override;
54
55
  lldb::ValueObjectSP GetChildMemberWithName(ConstString name,
56
                                             bool can_create) override;
57
58
  size_t GetIndexOfChildWithName(ConstString name) override;
59
60
  lldb::ValueObjectSP
61
  GetDynamicValue(lldb::DynamicValueType valueType) override;
62
63
  bool IsInScope() override;
64
65
2.34k
  bool HasSyntheticValue() override { return false; }
66
67
16.9k
  bool IsSynthetic() override { return true; }
68
69
0
  void CalculateSyntheticValue() override {}
70
71
8.35k
  bool IsDynamic() override {
72
8.35k
    return ((m_parent != nullptr) ? m_parent->IsDynamic() : 
false0
);
73
8.35k
  }
74
75
504
  lldb::ValueObjectSP GetStaticValue() override {
76
504
    return ((m_parent != nullptr) ? m_parent->GetStaticValue() : 
GetSP()0
);
77
504
  }
78
79
0
  virtual lldb::DynamicValueType GetDynamicValueType() {
80
0
    return ((m_parent != nullptr) ? m_parent->GetDynamicValueType()
81
0
                                  : lldb::eNoDynamicValues);
82
0
  }
83
84
0
  ValueObject *GetParent() override {
85
0
    return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
86
0
  }
87
88
0
  const ValueObject *GetParent() const override {
89
0
    return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
90
0
  }
91
92
  lldb::ValueObjectSP GetNonSyntheticValue() override;
93
94
  bool CanProvideValue() override;
95
96
362
  bool DoesProvideSyntheticValue() override {
97
362
    return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
98
362
  }
99
100
63.0k
  bool GetIsConstant() const override { return false; }
101
102
  bool SetValueFromCString(const char *value_str, Status &error) override;
103
104
  void SetFormat(lldb::Format format) override;
105
106
  lldb::LanguageType GetPreferredDisplayLanguage() override;
107
108
  void SetPreferredDisplayLanguage(lldb::LanguageType);
109
110
  bool IsSyntheticChildrenGenerated() override;
111
112
  void SetSyntheticChildrenGenerated(bool b) override;
113
114
  bool GetDeclaration(Declaration &decl) override;
115
116
  uint64_t GetLanguageFlags() override;
117
118
  void SetLanguageFlags(uint64_t flags) override;
119
120
protected:
121
  bool UpdateValue() override;
122
123
63.3k
  LazyBool CanUpdateWithInvalidExecutionContext() override {
124
63.3k
    return eLazyBoolYes;
125
63.3k
  }
126
127
  CompilerType GetCompilerTypeImpl() override;
128
129
  virtual void CreateSynthFilter();
130
131
  // we need to hold on to the SyntheticChildren because someone might delete
132
  // the type binding while we are alive
133
  lldb::SyntheticChildrenSP m_synth_sp;
134
  std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_up;
135
136
  typedef std::map<uint32_t, ValueObject *> ByIndexMap;
137
  typedef std::map<const char *, uint32_t> NameToIndexMap;
138
  typedef std::vector<lldb::ValueObjectSP> SyntheticChildrenCache;
139
140
  typedef ByIndexMap::iterator ByIndexIterator;
141
  typedef NameToIndexMap::iterator NameToIndexIterator;
142
143
  std::mutex m_child_mutex;
144
  /// Guarded by m_child_mutex;
145
  ByIndexMap m_children_byindex;
146
  /// Guarded by m_child_mutex;
147
  NameToIndexMap m_name_toindex;
148
  /// Guarded by m_child_mutex;
149
  SyntheticChildrenCache m_synthetic_children_cache;
150
151
  // FIXME: use the ValueObject's  ChildrenManager instead of a special purpose
152
  // solution.
153
  uint32_t m_synthetic_children_count;
154
155
  ConstString m_parent_type_name;
156
157
  LazyBool m_might_have_children;
158
159
  LazyBool m_provides_value;
160
161
private:
162
  friend class ValueObject;
163
  ValueObjectSynthetic(ValueObject &parent, lldb::SyntheticChildrenSP filter);
164
165
  void CopyValueData(ValueObject *source);
166
167
  ValueObjectSynthetic(const ValueObjectSynthetic &) = delete;
168
  const ValueObjectSynthetic &operator=(const ValueObjectSynthetic &) = delete;
169
};
170
171
} // namespace lldb_private
172
173
#endif // LLDB_CORE_VALUEOBJECTSYNTHETICFILTER_H