Coverage Report

Created: 2022-01-15 10:30

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Interpreter/OptionValueProperties.h
Line
Count
Source (jump to first uncovered line)
1
//===-- OptionValueProperties.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_INTERPRETER_OPTIONVALUEPROPERTIES_H
10
#define LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H
11
12
#include <vector>
13
14
#include "lldb/Core/FormatEntity.h"
15
#include "lldb/Core/UniqueCStringMap.h"
16
#include "lldb/Interpreter/OptionValue.h"
17
#include "lldb/Interpreter/Property.h"
18
#include "lldb/Utility/ConstString.h"
19
20
namespace lldb_private {
21
class Properties;
22
23
class OptionValueProperties
24
    : public Cloneable<OptionValueProperties, OptionValue>,
25
      public std::enable_shared_from_this<OptionValueProperties> {
26
public:
27
5.94k
  OptionValueProperties() = default;
28
29
  OptionValueProperties(ConstString name);
30
31
108k
  ~OptionValueProperties() override = default;
32
33
122k
  Type GetType() const override { return eTypeProperties; }
34
35
  void Clear() override;
36
37
  static lldb::OptionValuePropertiesSP
38
  CreateLocalCopy(const Properties &global_properties);
39
40
  lldb::OptionValueSP
41
  DeepCopy(const lldb::OptionValueSP &new_parent) const override;
42
43
  Status
44
  SetValueFromString(llvm::StringRef value,
45
                     VarSetOperationType op = eVarSetOperationAssign) override;
46
47
  void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
48
                 uint32_t dump_mask) override;
49
50
45.0k
  ConstString GetName() const override { return m_name; }
51
52
  virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx,
53
                                   Stream &strm, llvm::StringRef property_path,
54
                                   uint32_t dump_mask);
55
56
  virtual void DumpAllDescriptions(CommandInterpreter &interpreter,
57
                                   Stream &strm) const;
58
59
  void Apropos(llvm::StringRef keyword,
60
               std::vector<const Property *> &matching_properties) const;
61
62
  void Initialize(const PropertyDefinitions &setting_definitions);
63
64
  //    bool
65
  //    GetQualifiedName (Stream &strm);
66
67
  // Subclass specific functions
68
69
  virtual size_t GetNumProperties() const;
70
71
  // Get the index of a property given its exact name in this property
72
  // collection, "name" can't be a path to a property path that refers to a
73
  // property within a property
74
  virtual uint32_t GetPropertyIndex(ConstString name) const;
75
76
  // Get a property by exact name exists in this property collection, name can
77
  // not be a path to a property path that refers to a property within a
78
  // property
79
  virtual const Property *GetProperty(const ExecutionContext *exe_ctx,
80
                                      bool will_modify,
81
                                      ConstString name) const;
82
83
  virtual const Property *GetPropertyAtIndex(const ExecutionContext *exe_ctx,
84
                                             bool will_modify,
85
                                             uint32_t idx) const;
86
87
  // Property can be be a property path like
88
  // "target.process.extra-startup-command"
89
  virtual const Property *GetPropertyAtPath(const ExecutionContext *exe_ctx,
90
                                            bool will_modify,
91
    llvm::StringRef property_path) const;
92
93
  virtual lldb::OptionValueSP
94
  GetPropertyValueAtIndex(const ExecutionContext *exe_ctx, bool will_modify,
95
                          uint32_t idx) const;
96
97
  virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx,
98
                                             ConstString key,
99
                                             bool value_will_be_modified) const;
100
101
  lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
102
                                  llvm::StringRef name,
103
                                  bool value_will_be_modified,
104
                                  Status &error) const override;
105
106
  Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op,
107
                     llvm::StringRef path, llvm::StringRef value) override;
108
109
  OptionValueArch *
110
  GetPropertyAtIndexAsOptionValueArch(const ExecutionContext *exe_ctx,
111
                                      uint32_t idx) const;
112
113
  OptionValueLanguage *
114
  GetPropertyAtIndexAsOptionValueLanguage(const ExecutionContext *exe_ctx,
115
                                          uint32_t idx) const;
116
117
  bool SetPropertyAtIndexAsLanguage(const ExecutionContext *exe_ctx,
118
                                    uint32_t idx, lldb::LanguageType lang);
119
120
  bool GetPropertyAtIndexAsArgs(const ExecutionContext *exe_ctx, uint32_t idx,
121
                                Args &args) const;
122
123
  bool SetPropertyAtIndexFromArgs(const ExecutionContext *exe_ctx, uint32_t idx,
124
                                  const Args &args);
125
126
  bool GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
127
                                   uint32_t idx, bool fail_value) const;
128
129
  bool SetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
130
                                   uint32_t idx, bool new_value);
131
132
  OptionValueDictionary *
133
  GetPropertyAtIndexAsOptionValueDictionary(const ExecutionContext *exe_ctx,
134
                                            uint32_t idx) const;
135
136
  int64_t GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
137
                                          uint32_t idx,
138
                                          int64_t fail_value) const;
139
140
  bool SetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
141
                                       uint32_t idx, int64_t new_value);
142
143
  const FormatEntity::Entry *
144
  GetPropertyAtIndexAsFormatEntity(const ExecutionContext *exe_ctx,
145
                                   uint32_t idx);
146
147
  const RegularExpression *
148
  GetPropertyAtIndexAsOptionValueRegex(const ExecutionContext *exe_ctx,
149
                                       uint32_t idx) const;
150
151
  OptionValueSInt64 *
152
  GetPropertyAtIndexAsOptionValueSInt64(const ExecutionContext *exe_ctx,
153
                                        uint32_t idx) const;
154
155
  int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx,
156
                                     uint32_t idx, int64_t fail_value) const;
157
158
  bool SetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx,
159
                                  int64_t new_value);
160
161
  uint64_t GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx,
162
                                      uint32_t idx, uint64_t fail_value) const;
163
164
  bool SetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx,
165
                                  uint64_t new_value);
166
167
  llvm::StringRef GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx,
168
                                         uint32_t idx,
169
                                         llvm::StringRef fail_value) const;
170
171
  bool SetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx,
172
                                  llvm::StringRef new_value);
173
174
  OptionValueString *
175
  GetPropertyAtIndexAsOptionValueString(const ExecutionContext *exe_ctx,
176
                                        bool will_modify, uint32_t idx) const;
177
178
  OptionValueFileSpec *
179
  GetPropertyAtIndexAsOptionValueFileSpec(const ExecutionContext *exe_ctx,
180
                                          bool will_modify, uint32_t idx) const;
181
182
  FileSpec GetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx,
183
                                        uint32_t idx) const;
184
185
  bool SetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx,
186
                                    uint32_t idx, const FileSpec &file_spec);
187
188
  OptionValuePathMappings *GetPropertyAtIndexAsOptionValuePathMappings(
189
      const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
190
191
  OptionValueFileSpecList *GetPropertyAtIndexAsOptionValueFileSpecList(
192
      const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
193
194
  void AppendProperty(ConstString name, ConstString desc,
195
                      bool is_global, const lldb::OptionValueSP &value_sp);
196
197
  lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
198
                                               ConstString name);
199
200
  void SetValueChangedCallback(uint32_t property_idx,
201
                               std::function<void()> callback);
202
203
protected:
204
115k
  Property *ProtectedGetPropertyAtIndex(uint32_t idx) {
205
115k
    return ((idx < m_properties.size()) ? &m_properties[idx] : 
nullptr0
);
206
115k
  }
207
208
9.81M
  const Property *ProtectedGetPropertyAtIndex(uint32_t idx) const {
209
9.81M
    return ((idx < m_properties.size()) ? 
&m_properties[idx]9.80M
:
nullptr5.90k
);
210
9.81M
  }
211
212
  typedef UniqueCStringMap<size_t> NameToIndex;
213
214
  ConstString m_name;
215
  std::vector<Property> m_properties;
216
  NameToIndex m_name_to_index;
217
};
218
219
} // namespace lldb_private
220
221
#endif // LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H