/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 | | |
19 | | namespace lldb_private { |
20 | | class Properties; |
21 | | |
22 | | class OptionValueProperties |
23 | | : public Cloneable<OptionValueProperties, OptionValue>, |
24 | | public std::enable_shared_from_this<OptionValueProperties> { |
25 | | public: |
26 | 6.09k | OptionValueProperties() = default; |
27 | | |
28 | | OptionValueProperties(llvm::StringRef name); |
29 | | |
30 | 130k | ~OptionValueProperties() override = default; |
31 | | |
32 | 178k | Type GetType() const override { return eTypeProperties; } |
33 | | |
34 | | void Clear() override; |
35 | | |
36 | | static lldb::OptionValuePropertiesSP |
37 | | CreateLocalCopy(const Properties &global_properties); |
38 | | |
39 | | lldb::OptionValueSP |
40 | | DeepCopy(const lldb::OptionValueSP &new_parent) const override; |
41 | | |
42 | | Status |
43 | | SetValueFromString(llvm::StringRef value, |
44 | | VarSetOperationType op = eVarSetOperationAssign) override; |
45 | | |
46 | | void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, |
47 | | uint32_t dump_mask) override; |
48 | | |
49 | | llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override; |
50 | | |
51 | 60.8k | llvm::StringRef GetName() const override { return m_name; } |
52 | | |
53 | | virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx, |
54 | | Stream &strm, llvm::StringRef property_path, |
55 | | uint32_t dump_mask, bool is_json = false); |
56 | | |
57 | | virtual void DumpAllDescriptions(CommandInterpreter &interpreter, |
58 | | Stream &strm) const; |
59 | | |
60 | | void Apropos(llvm::StringRef keyword, |
61 | | std::vector<const Property *> &matching_properties) const; |
62 | | |
63 | | void Initialize(const PropertyDefinitions &setting_definitions); |
64 | | |
65 | | // Subclass specific functions |
66 | | |
67 | | // Get the index of a property given its exact name in this property |
68 | | // collection, "name" can't be a path to a property path that refers to a |
69 | | // property within a property |
70 | | virtual size_t GetPropertyIndex(llvm::StringRef name) const; |
71 | | |
72 | | // Get a property by exact name exists in this property collection, name can |
73 | | // not be a path to a property path that refers to a property within a |
74 | | // property |
75 | | virtual const Property * |
76 | | GetProperty(llvm::StringRef name, |
77 | | const ExecutionContext *exe_ctx = nullptr) const; |
78 | | |
79 | | virtual const Property * |
80 | | GetPropertyAtIndex(size_t idx, |
81 | 5.55M | const ExecutionContext *exe_ctx = nullptr) const { |
82 | 5.55M | return ProtectedGetPropertyAtIndex(idx); |
83 | 5.55M | } |
84 | | |
85 | | // Property can be a property path like |
86 | | // "target.process.extra-startup-command" |
87 | | virtual const Property * |
88 | | GetPropertyAtPath(const ExecutionContext *exe_ctx, |
89 | | llvm::StringRef property_path) const; |
90 | | |
91 | | virtual lldb::OptionValueSP |
92 | | GetPropertyValueAtIndex(size_t idx, const ExecutionContext *exe_ctx) const; |
93 | | |
94 | | virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx, |
95 | | llvm::StringRef key) const; |
96 | | |
97 | | lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, |
98 | | llvm::StringRef name, |
99 | | Status &error) const override; |
100 | | |
101 | | Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op, |
102 | | llvm::StringRef path, llvm::StringRef value) override; |
103 | | |
104 | | bool |
105 | | GetPropertyAtIndexAsArgs(size_t idx, Args &args, |
106 | | const ExecutionContext *exe_ctx = nullptr) const; |
107 | | |
108 | | bool SetPropertyAtIndexFromArgs(size_t idx, const Args &args, |
109 | | const ExecutionContext *exe_ctx = nullptr); |
110 | | |
111 | | OptionValueDictionary *GetPropertyAtIndexAsOptionValueDictionary( |
112 | | size_t idx, const ExecutionContext *exe_ctx = nullptr) const; |
113 | | |
114 | | OptionValueSInt64 *GetPropertyAtIndexAsOptionValueSInt64( |
115 | | size_t idx, const ExecutionContext *exe_ctx = nullptr) const; |
116 | | |
117 | | OptionValueUInt64 *GetPropertyAtIndexAsOptionValueUInt64( |
118 | | size_t idx, const ExecutionContext *exe_ctx = nullptr) const; |
119 | | |
120 | | OptionValueString *GetPropertyAtIndexAsOptionValueString( |
121 | | size_t idx, const ExecutionContext *exe_ctx = nullptr) const; |
122 | | |
123 | | OptionValueFileSpec *GetPropertyAtIndexAsOptionValueFileSpec( |
124 | | size_t idx, const ExecutionContext *exe_ctx = nullptr) const; |
125 | | |
126 | | OptionValuePathMappings *GetPropertyAtIndexAsOptionValuePathMappings( |
127 | | size_t idx, const ExecutionContext *exe_ctx = nullptr) const; |
128 | | |
129 | | OptionValueFileSpecList *GetPropertyAtIndexAsOptionValueFileSpecList( |
130 | | size_t idx, const ExecutionContext *exe_ctx = nullptr) const; |
131 | | |
132 | | void AppendProperty(llvm::StringRef name, llvm::StringRef desc, |
133 | | bool is_global, const lldb::OptionValueSP &value_sp); |
134 | | |
135 | | lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx, |
136 | | llvm::StringRef name); |
137 | | |
138 | | void SetValueChangedCallback(size_t property_idx, |
139 | | std::function<void()> callback); |
140 | | |
141 | | template <typename T> |
142 | | auto GetPropertyAtIndexAs(size_t idx, |
143 | 11.3M | const ExecutionContext *exe_ctx = nullptr) const { |
144 | 11.3M | if (const Property *property11.3M = GetPropertyAtIndex(idx, exe_ctx)) { |
145 | 11.3M | if (OptionValue *value = property->GetValue().get()) |
146 | 11.3M | return value->GetValueAs<T>(); |
147 | 11.3M | } |
148 | 18.4E | if constexpr (std::is_pointer_v<T>) |
149 | 0 | return T{nullptr}; |
150 | 18.4E | else |
151 | 18.4E | return std::optional<T>{std::nullopt}; |
152 | 18.4E | } auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::FormatEntity::Entry const*>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 1.00M | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 1.00M | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 1.00M | if (OptionValue *value = property->GetValue().get()) | 146 | 1.00M | return value->GetValueAs<T>(); | 147 | 1.00M | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb::ScriptLanguage>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 509k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 509k | if (const Property *property509k = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 509k | if (OptionValue *value = property->GetValue().get()) | 146 | 509k | return value->GetValueAs<T>(); | 147 | 509k | } | 148 | 18.4E | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 18.4E | else | 151 | 18.4E | return std::optional<T>{std::nullopt}; | 152 | 18.4E | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb::StopShowColumn>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 1.49k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 1.49k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 1.49k | if (OptionValue *value = property->GetValue().get()) | 146 | 1.49k | return value->GetValueAs<T>(); | 147 | 1.49k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::Debugger::StopDisassemblyType>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 1.58k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 1.58k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 1.58k | if (OptionValue *value = property->GetValue().get()) | 146 | 1.58k | return value->GetValueAs<T>(); | 147 | 1.58k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb::DWIMPrintVerbosity>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 74 | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 74 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 74 | if (OptionValue *value = property->GetValue().get()) | 146 | 74 | return value->GetValueAs<T>(); | 147 | 74 | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<bool>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 7.32M | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 7.32M | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 7.32M | if (OptionValue *value = property->GetValue().get()) | 146 | 7.32M | return value->GetValueAs<T>(); | 147 | 7.32M | } | 148 | 4 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 4 | else | 151 | 4 | return std::optional<T>{std::nullopt}; | 152 | 4 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::FileSpec>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 58.5k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 58.5k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 58.5k | if (OptionValue *value = property->GetValue().get()) | 146 | 58.5k | return value->GetValueAs<T>(); | 147 | 58.5k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<unsigned long long>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 744k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 744k | if (const Property *property744k = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 744k | if (OptionValue *value = property->GetValue().get()) | 146 | 744k | return value->GetValueAs<T>(); | 147 | 744k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::FileSpecList>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 346k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 346k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 346k | if (OptionValue *value = property->GetValue().get()) | 146 | 346k | return value->GetValueAs<T>(); | 147 | 346k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::FollowForkMode>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 13 | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 13 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 13 | if (OptionValue *value = property->GetValue().get()) | 146 | 13 | return value->GetValueAs<T>(); | 147 | 13 | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::ArchSpec>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 6.29k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 6.29k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 6.29k | if (OptionValue *value = property->GetValue().get()) | 146 | 6.29k | return value->GetValueAs<T>(); | 147 | 6.29k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb::DynamicValueType>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 51.6k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 51.6k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 51.6k | if (OptionValue *value = property->GetValue().get()) | 146 | 51.6k | return value->GetValueAs<T>(); | 147 | 51.6k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<x86DisassemblyFlavor>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 46.4k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 46.4k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 46.4k | if (OptionValue *value = property->GetValue().get()) | 146 | 46.4k | return value->GetValueAs<T>(); | 147 | 46.4k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::InlineStrategy>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 1.15k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 1.15k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 1.15k | if (OptionValue *value = property->GetValue().get()) | 146 | 1.15k | return value->GetValueAs<T>(); | 147 | 1.15k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<llvm::StringRef>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 32.1k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 32.1k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 32.1k | if (OptionValue *value = property->GetValue().get()) | 146 | 32.1k | return value->GetValueAs<T>(); | 147 | 32.1k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::ImportStdModule>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 7.55k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 7.55k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 7.55k | if (OptionValue *value = property->GetValue().get()) | 146 | 7.55k | return value->GetValueAs<T>(); | 147 | 7.55k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::DynamicClassInfoHelper>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 985 | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 985 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 985 | if (OptionValue *value = property->GetValue().get()) | 146 | 985 | return value->GetValueAs<T>(); | 147 | 985 | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<long long>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 9.73k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 9.73k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 9.73k | if (OptionValue *value = property->GetValue().get()) | 146 | 9.73k | return value->GetValueAs<T>(); | 147 | 9.73k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb::LanguageType>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 11.4k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 11.4k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 11.4k | if (OptionValue *value = property->GetValue().get()) | 146 | 11.4k | return value->GetValueAs<T>(); | 147 | 11.4k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::LoadScriptFromSymFile>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 233k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 233k | if (const Property *property233k = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 233k | if (OptionValue *value = property->GetValue().get()) | 146 | 233k | return value->GetValueAs<T>(); | 147 | 233k | } | 148 | 18.4E | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 18.4E | else | 151 | 18.4E | return std::optional<T>{std::nullopt}; | 152 | 18.4E | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::LoadCWDlldbinitFile>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 2 | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 2 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 2 | if (OptionValue *value = property->GetValue().get()) | 146 | 2 | return value->GetValueAs<T>(); | 147 | 2 | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::Disassembler::HexImmediateStyle>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 975k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 975k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 975k | if (OptionValue *value = property->GetValue().get()) | 146 | 975k | return value->GetValueAs<T>(); | 147 | 975k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::MemoryModuleLoadLevel>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 6 | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 6 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 6 | if (OptionValue *value = property->GetValue().get()) | 146 | 6 | return value->GetValueAs<T>(); | 147 | 6 | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<lldb_private::RegularExpression const*>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 227 | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 227 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 227 | if (OptionValue *value = property->GetValue().get()) | 146 | 227 | return value->GetValueAs<T>(); | 147 | 227 | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<KASLRScanType>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 284 | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 284 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 284 | if (OptionValue *value = property->GetValue().get()) | 146 | 284 | return value->GetValueAs<T>(); | 147 | 284 | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
JITLoaderGDB.cpp:auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<(anonymous namespace)::EnableJITLoaderGDB>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 2.32k | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 2.32k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 2.32k | if (OptionValue *value = property->GetValue().get()) | 146 | 2.32k | return value->GetValueAs<T>(); | 147 | 2.32k | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
auto lldb_private::OptionValueProperties::GetPropertyAtIndexAs<llvm::Triple::EnvironmentType>(unsigned long, lldb_private::ExecutionContext const*) const Line | Count | Source | 143 | 45 | const ExecutionContext *exe_ctx = nullptr) const { | 144 | 45 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 145 | 45 | if (OptionValue *value = property->GetValue().get()) | 146 | 45 | return value->GetValueAs<T>(); | 147 | 45 | } | 148 | 0 | if constexpr (std::is_pointer_v<T>) | 149 | 0 | return T{nullptr}; | 150 | 0 | else | 151 | 0 | return std::optional<T>{std::nullopt}; | 152 | 0 | } |
|
153 | | |
154 | | template <typename T> |
155 | | bool SetPropertyAtIndex(size_t idx, T t, |
156 | 30.3k | const ExecutionContext *exe_ctx = nullptr) const { |
157 | 30.3k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { |
158 | 30.3k | if (OptionValue *value = property->GetValue().get()) { |
159 | 30.3k | value->SetValueAs(t); |
160 | 30.3k | return true; |
161 | 30.3k | } |
162 | 30.3k | } |
163 | 0 | return false; |
164 | 30.3k | } bool lldb_private::OptionValueProperties::SetPropertyAtIndex<lldb::ScriptLanguage>(unsigned long, lldb::ScriptLanguage, lldb_private::ExecutionContext const*) const Line | Count | Source | 156 | 18 | const ExecutionContext *exe_ctx = nullptr) const { | 157 | 18 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 158 | 18 | if (OptionValue *value = property->GetValue().get()) { | 159 | 18 | value->SetValueAs(t); | 160 | 18 | return true; | 161 | 18 | } | 162 | 18 | } | 163 | 0 | return false; | 164 | 18 | } |
bool lldb_private::OptionValueProperties::SetPropertyAtIndex<lldb::LanguageType>(unsigned long, lldb::LanguageType, lldb_private::ExecutionContext const*) const Line | Count | Source | 156 | 2 | const ExecutionContext *exe_ctx = nullptr) const { | 157 | 2 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 158 | 2 | if (OptionValue *value = property->GetValue().get()) { | 159 | 2 | value->SetValueAs(t); | 160 | 2 | return true; | 161 | 2 | } | 162 | 2 | } | 163 | 0 | return false; | 164 | 2 | } |
bool lldb_private::OptionValueProperties::SetPropertyAtIndex<bool>(unsigned long, bool, lldb_private::ExecutionContext const*) const Line | Count | Source | 156 | 6.61k | const ExecutionContext *exe_ctx = nullptr) const { | 157 | 6.61k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 158 | 6.61k | if (OptionValue *value = property->GetValue().get()) { | 159 | 6.61k | value->SetValueAs(t); | 160 | 6.61k | return true; | 161 | 6.61k | } | 162 | 6.61k | } | 163 | 0 | return false; | 164 | 6.61k | } |
bool lldb_private::OptionValueProperties::SetPropertyAtIndex<lldb_private::FileSpec>(unsigned long, lldb_private::FileSpec, lldb_private::ExecutionContext const*) const Line | Count | Source | 156 | 11.8k | const ExecutionContext *exe_ctx = nullptr) const { | 157 | 11.8k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 158 | 11.8k | if (OptionValue *value = property->GetValue().get()) { | 159 | 11.8k | value->SetValueAs(t); | 160 | 11.8k | return true; | 161 | 11.8k | } | 162 | 11.8k | } | 163 | 0 | return false; | 164 | 11.8k | } |
bool lldb_private::OptionValueProperties::SetPropertyAtIndex<unsigned long long>(unsigned long, unsigned long long, lldb_private::ExecutionContext const*) const Line | Count | Source | 156 | 15 | const ExecutionContext *exe_ctx = nullptr) const { | 157 | 15 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 158 | 15 | if (OptionValue *value = property->GetValue().get()) { | 159 | 15 | value->SetValueAs(t); | 160 | 15 | return true; | 161 | 15 | } | 162 | 15 | } | 163 | 0 | return false; | 164 | 15 | } |
bool lldb_private::OptionValueProperties::SetPropertyAtIndex<lldb_private::ArchSpec>(unsigned long, lldb_private::ArchSpec, lldb_private::ExecutionContext const*) const Line | Count | Source | 156 | 4 | const ExecutionContext *exe_ctx = nullptr) const { | 157 | 4 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 158 | 4 | if (OptionValue *value = property->GetValue().get()) { | 159 | 4 | value->SetValueAs(t); | 160 | 4 | return true; | 161 | 4 | } | 162 | 4 | } | 163 | 0 | return false; | 164 | 4 | } |
bool lldb_private::OptionValueProperties::SetPropertyAtIndex<lldb::DynamicValueType>(unsigned long, lldb::DynamicValueType, lldb_private::ExecutionContext const*) const Line | Count | Source | 156 | 32 | const ExecutionContext *exe_ctx = nullptr) const { | 157 | 32 | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 158 | 32 | if (OptionValue *value = property->GetValue().get()) { | 159 | 32 | value->SetValueAs(t); | 160 | 32 | return true; | 161 | 32 | } | 162 | 32 | } | 163 | 0 | return false; | 164 | 32 | } |
bool lldb_private::OptionValueProperties::SetPropertyAtIndex<llvm::StringRef>(unsigned long, llvm::StringRef, lldb_private::ExecutionContext const*) const Line | Count | Source | 156 | 11.7k | const ExecutionContext *exe_ctx = nullptr) const { | 157 | 11.7k | if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { | 158 | 11.7k | if (OptionValue *value = property->GetValue().get()) { | 159 | 11.7k | value->SetValueAs(t); | 160 | 11.7k | return true; | 161 | 11.7k | } | 162 | 11.7k | } | 163 | 0 | return false; | 164 | 11.7k | } |
|
165 | | |
166 | | protected: |
167 | 127k | Property *ProtectedGetPropertyAtIndex(size_t idx) { |
168 | 127k | assert(idx < m_properties.size() && "invalid property index"); |
169 | 127k | return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr0 ); |
170 | 127k | } |
171 | | |
172 | 11.7M | const Property *ProtectedGetPropertyAtIndex(size_t idx) const { |
173 | 11.7M | assert(idx < m_properties.size() && "invalid property index"); |
174 | 18.4E | return (11.7M (idx < m_properties.size())11.7M ? &m_properties[idx]11.7M : nullptr); |
175 | 11.7M | } |
176 | | |
177 | | std::string m_name; |
178 | | std::vector<Property> m_properties; |
179 | | llvm::StringMap<size_t> m_name_to_index; |
180 | | }; |
181 | | |
182 | | } // namespace lldb_private |
183 | | |
184 | | #endif // LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H |