]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/OptionValueProperties.h
Import DTS files from Linux 4.18
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Interpreter / OptionValueProperties.h
1 //===-- OptionValueProperties.h ---------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_OptionValueProperties_h_
11 #define liblldb_OptionValueProperties_h_
12
13 // C Includes
14 // C++ Includes
15 #include <vector>
16
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/Core/FormatEntity.h"
20 #include "lldb/Core/UniqueCStringMap.h"
21 #include "lldb/Interpreter/OptionValue.h"
22 #include "lldb/Interpreter/Property.h"
23 #include "lldb/Utility/ConstString.h"
24
25 namespace lldb_private {
26
27 class OptionValueProperties
28     : public OptionValue,
29       public std::enable_shared_from_this<OptionValueProperties> {
30 public:
31   OptionValueProperties()
32       : OptionValue(), m_name(), m_properties(), m_name_to_index() {}
33
34   OptionValueProperties(const ConstString &name);
35
36   OptionValueProperties(const OptionValueProperties &global_properties);
37
38   ~OptionValueProperties() override = default;
39
40   Type GetType() const override { return eTypeProperties; }
41
42   bool Clear() override;
43
44   lldb::OptionValueSP DeepCopy() const override;
45
46   Status
47   SetValueFromString(llvm::StringRef value,
48                      VarSetOperationType op = eVarSetOperationAssign) override;
49
50   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
51                  uint32_t dump_mask) override;
52
53   ConstString GetName() const override { return m_name; }
54
55   virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx,
56                                    Stream &strm, llvm::StringRef property_path,
57                                    uint32_t dump_mask);
58
59   virtual void DumpAllDescriptions(CommandInterpreter &interpreter,
60                                    Stream &strm) const;
61
62   void Apropos(llvm::StringRef keyword,
63                std::vector<const Property *> &matching_properties) const;
64
65   void Initialize(const PropertyDefinition *setting_definitions);
66
67   //    bool
68   //    GetQualifiedName (Stream &strm);
69
70   //---------------------------------------------------------------------
71   // Subclass specific functions
72   //---------------------------------------------------------------------
73
74   virtual size_t GetNumProperties() const;
75
76   //---------------------------------------------------------------------
77   // Get the index of a property given its exact name in this property
78   // collection, "name" can't be a path to a property path that refers
79   // to a property within a property
80   //---------------------------------------------------------------------
81   virtual uint32_t GetPropertyIndex(const ConstString &name) const;
82
83   //---------------------------------------------------------------------
84   // Get a property by exact name exists in this property collection, name
85   // can not be a path to a property path that refers to a property within
86   // a property
87   //---------------------------------------------------------------------
88   virtual const Property *GetProperty(const ExecutionContext *exe_ctx,
89                                       bool will_modify,
90                                       const ConstString &name) const;
91
92   virtual const Property *GetPropertyAtIndex(const ExecutionContext *exe_ctx,
93                                              bool will_modify,
94                                              uint32_t idx) const;
95
96   //---------------------------------------------------------------------
97   // Property can be be a property path like
98   // "target.process.extra-startup-command"
99   //---------------------------------------------------------------------
100   virtual const Property *GetPropertyAtPath(const ExecutionContext *exe_ctx,
101                                             bool will_modify,
102     llvm::StringRef property_path) const;
103
104   virtual lldb::OptionValueSP
105   GetPropertyValueAtIndex(const ExecutionContext *exe_ctx, bool will_modify,
106                           uint32_t idx) const;
107
108   virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx,
109                                              const ConstString &key,
110                                              bool value_will_be_modified) const;
111
112   lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
113                                   llvm::StringRef name,
114                                   bool value_will_be_modified,
115                                   Status &error) const override;
116
117   Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op,
118                      llvm::StringRef path, llvm::StringRef value) override;
119
120   virtual bool PredicateMatches(const ExecutionContext *exe_ctx,
121     llvm::StringRef predicate) const {
122     return false;
123   }
124
125   OptionValueArch *
126   GetPropertyAtIndexAsOptionValueArch(const ExecutionContext *exe_ctx,
127                                       uint32_t idx) const;
128
129   OptionValueLanguage *
130   GetPropertyAtIndexAsOptionValueLanguage(const ExecutionContext *exe_ctx,
131                                           uint32_t idx) const;
132
133   bool GetPropertyAtIndexAsArgs(const ExecutionContext *exe_ctx, uint32_t idx,
134                                 Args &args) const;
135
136   bool SetPropertyAtIndexFromArgs(const ExecutionContext *exe_ctx, uint32_t idx,
137                                   const Args &args);
138
139   bool GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
140                                    uint32_t idx, bool fail_value) const;
141
142   bool SetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx,
143                                    uint32_t idx, bool new_value);
144
145   OptionValueDictionary *
146   GetPropertyAtIndexAsOptionValueDictionary(const ExecutionContext *exe_ctx,
147                                             uint32_t idx) const;
148
149   int64_t GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
150                                           uint32_t idx,
151                                           int64_t fail_value) const;
152
153   bool SetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx,
154                                        uint32_t idx, int64_t new_value);
155
156   const FormatEntity::Entry *
157   GetPropertyAtIndexAsFormatEntity(const ExecutionContext *exe_ctx,
158                                    uint32_t idx);
159
160   const RegularExpression *
161   GetPropertyAtIndexAsOptionValueRegex(const ExecutionContext *exe_ctx,
162                                        uint32_t idx) const;
163
164   OptionValueSInt64 *
165   GetPropertyAtIndexAsOptionValueSInt64(const ExecutionContext *exe_ctx,
166                                         uint32_t idx) const;
167
168   int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx,
169                                      uint32_t idx, int64_t fail_value) const;
170
171   bool SetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx,
172                                   int64_t new_value);
173
174   uint64_t GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx,
175                                       uint32_t idx, uint64_t fail_value) const;
176
177   bool SetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx,
178                                   uint64_t new_value);
179
180   llvm::StringRef GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx,
181                                          uint32_t idx,
182                                          llvm::StringRef fail_value) const;
183
184   bool SetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx,
185                                   llvm::StringRef new_value);
186
187   OptionValueString *
188   GetPropertyAtIndexAsOptionValueString(const ExecutionContext *exe_ctx,
189                                         bool will_modify, uint32_t idx) const;
190
191   OptionValueFileSpec *
192   GetPropertyAtIndexAsOptionValueFileSpec(const ExecutionContext *exe_ctx,
193                                           bool will_modify, uint32_t idx) const;
194
195   FileSpec GetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx,
196                                         uint32_t idx) const;
197
198   bool SetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx,
199                                     uint32_t idx, const FileSpec &file_spec);
200
201   OptionValuePathMappings *GetPropertyAtIndexAsOptionValuePathMappings(
202       const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
203
204   OptionValueFileSpecList *GetPropertyAtIndexAsOptionValueFileSpecList(
205       const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
206
207   void AppendProperty(const ConstString &name, const ConstString &desc,
208                       bool is_global, const lldb::OptionValueSP &value_sp);
209
210   lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
211                                                const ConstString &name);
212
213   void SetValueChangedCallback(uint32_t property_idx,
214                                OptionValueChangedCallback callback,
215                                void *baton);
216
217 protected:
218   Property *ProtectedGetPropertyAtIndex(uint32_t idx) {
219     return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
220   }
221
222   const Property *ProtectedGetPropertyAtIndex(uint32_t idx) const {
223     return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
224   }
225
226   typedef UniqueCStringMap<size_t> NameToIndex;
227
228   ConstString m_name;
229   std::vector<Property> m_properties;
230   NameToIndex m_name_to_index;
231 };
232
233 } // namespace lldb_private
234
235 #endif // liblldb_OptionValueProperties_h_