180814287SRaphael Isemann //===-- OptionValueProperties.cpp -----------------------------------------===//
267cc0636SGreg Clayton //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
667cc0636SGreg Clayton //
767cc0636SGreg Clayton //===----------------------------------------------------------------------===//
867cc0636SGreg Clayton
967cc0636SGreg Clayton #include "lldb/Interpreter/OptionValueProperties.h"
1067cc0636SGreg Clayton
1101c3243fSZachary Turner #include "lldb/Utility/Flags.h"
1201c3243fSZachary Turner
1367cc0636SGreg Clayton #include "lldb/Core/UserSettingsController.h"
1467cc0636SGreg Clayton #include "lldb/Interpreter/OptionValues.h"
1567cc0636SGreg Clayton #include "lldb/Interpreter/Property.h"
16145d95c9SPavel Labath #include "lldb/Utility/Args.h"
17bf9a7730SZachary Turner #include "lldb/Utility/Stream.h"
18573ab909SZachary Turner #include "lldb/Utility/StringList.h"
1967cc0636SGreg Clayton
2067cc0636SGreg Clayton using namespace lldb;
2167cc0636SGreg Clayton using namespace lldb_private;
2267cc0636SGreg Clayton
OptionValueProperties(ConstString name)238cdcd41eSTatyana Krasnukha OptionValueProperties::OptionValueProperties(ConstString name) : m_name(name) {}
2467cc0636SGreg Clayton
GetNumProperties() const25b9c1b51eSKate Stone size_t OptionValueProperties::GetNumProperties() const {
2667cc0636SGreg Clayton return m_properties.size();
2767cc0636SGreg Clayton }
2867cc0636SGreg Clayton
Initialize(const PropertyDefinitions & defs)29e40db05bSTatyana Krasnukha void OptionValueProperties::Initialize(const PropertyDefinitions &defs) {
30e40db05bSTatyana Krasnukha for (const auto &definition : defs) {
31e40db05bSTatyana Krasnukha Property property(definition);
3267cc0636SGreg Clayton assert(property.IsValid());
334d35d6b3SPavel Labath m_name_to_index.Append(ConstString(property.GetName()), m_properties.size());
3467cc0636SGreg Clayton property.GetValue()->SetParent(shared_from_this());
3567cc0636SGreg Clayton m_properties.push_back(property);
3667cc0636SGreg Clayton }
3767cc0636SGreg Clayton m_name_to_index.Sort();
3867cc0636SGreg Clayton }
3967cc0636SGreg Clayton
SetValueChangedCallback(uint32_t property_idx,std::function<void ()> callback)40b9c1b51eSKate Stone void OptionValueProperties::SetValueChangedCallback(
415c4661b7SPavel Labath uint32_t property_idx, std::function<void()> callback) {
42332e8b1cSGreg Clayton Property *property = ProtectedGetPropertyAtIndex(property_idx);
43332e8b1cSGreg Clayton if (property)
445c4661b7SPavel Labath property->SetValueChangedCallback(std::move(callback));
45332e8b1cSGreg Clayton }
46332e8b1cSGreg Clayton
AppendProperty(ConstString name,ConstString desc,bool is_global,const OptionValueSP & value_sp)470e4c4821SAdrian Prantl void OptionValueProperties::AppendProperty(ConstString name,
480e4c4821SAdrian Prantl ConstString desc,
4967cc0636SGreg Clayton bool is_global,
50b9c1b51eSKate Stone const OptionValueSP &value_sp) {
51ff7ce0afSPavel Labath Property property(name.GetStringRef(), desc.GetStringRef(), is_global,
52ff7ce0afSPavel Labath value_sp);
534d35d6b3SPavel Labath m_name_to_index.Append(name, m_properties.size());
5467cc0636SGreg Clayton m_properties.push_back(property);
5567cc0636SGreg Clayton value_sp->SetParent(shared_from_this());
5667cc0636SGreg Clayton m_name_to_index.Sort();
5767cc0636SGreg Clayton }
5867cc0636SGreg Clayton
5967cc0636SGreg Clayton // bool
6067cc0636SGreg Clayton // OptionValueProperties::GetQualifiedName (Stream &strm)
6167cc0636SGreg Clayton //{
6267cc0636SGreg Clayton // bool dumped_something = false;
6367cc0636SGreg Clayton //// lldb::OptionValuePropertiesSP parent_sp(GetParent ());
6467cc0636SGreg Clayton //// if (parent_sp)
6567cc0636SGreg Clayton //// {
6667cc0636SGreg Clayton //// parent_sp->GetQualifiedName (strm);
6767cc0636SGreg Clayton //// strm.PutChar('.');
6867cc0636SGreg Clayton //// dumped_something = true;
6967cc0636SGreg Clayton //// }
7067cc0636SGreg Clayton // if (m_name)
7167cc0636SGreg Clayton // {
7267cc0636SGreg Clayton // strm << m_name;
7367cc0636SGreg Clayton // dumped_something = true;
7467cc0636SGreg Clayton // }
7567cc0636SGreg Clayton // return dumped_something;
7667cc0636SGreg Clayton //}
7767cc0636SGreg Clayton //
7867cc0636SGreg Clayton lldb::OptionValueSP
GetValueForKey(const ExecutionContext * exe_ctx,ConstString key,bool will_modify) const7967cc0636SGreg Clayton OptionValueProperties::GetValueForKey(const ExecutionContext *exe_ctx,
800e4c4821SAdrian Prantl ConstString key,
81b9c1b51eSKate Stone bool will_modify) const {
8267cc0636SGreg Clayton lldb::OptionValueSP value_sp;
834d35d6b3SPavel Labath size_t idx = m_name_to_index.Find(key, SIZE_MAX);
8467cc0636SGreg Clayton if (idx < m_properties.size())
8567cc0636SGreg Clayton value_sp = GetPropertyAtIndex(exe_ctx, will_modify, idx)->GetValue();
8667cc0636SGreg Clayton return value_sp;
8767cc0636SGreg Clayton }
8867cc0636SGreg Clayton
8967cc0636SGreg Clayton lldb::OptionValueSP
GetSubValue(const ExecutionContext * exe_ctx,llvm::StringRef name,bool will_modify,Status & error) const9067cc0636SGreg Clayton OptionValueProperties::GetSubValue(const ExecutionContext *exe_ctx,
9131d97a5cSZachary Turner llvm::StringRef name, bool will_modify,
9297206d57SZachary Turner Status &error) const {
9367cc0636SGreg Clayton lldb::OptionValueSP value_sp;
9431d97a5cSZachary Turner if (name.empty())
9531d97a5cSZachary Turner return OptionValueSP();
9667cc0636SGreg Clayton
9731d97a5cSZachary Turner llvm::StringRef sub_name;
9867cc0636SGreg Clayton ConstString key;
9931d97a5cSZachary Turner size_t key_len = name.find_first_of(".[{");
10031d97a5cSZachary Turner if (key_len != llvm::StringRef::npos) {
10131d97a5cSZachary Turner key.SetString(name.take_front(key_len));
10231d97a5cSZachary Turner sub_name = name.drop_front(key_len);
103b9c1b51eSKate Stone } else
10431d97a5cSZachary Turner key.SetString(name);
10567cc0636SGreg Clayton
10667cc0636SGreg Clayton value_sp = GetValueForKey(exe_ctx, key, will_modify);
10731d97a5cSZachary Turner if (sub_name.empty() || !value_sp)
10831d97a5cSZachary Turner return value_sp;
10931d97a5cSZachary Turner
110b9c1b51eSKate Stone switch (sub_name[0]) {
111b9c1b51eSKate Stone case '.': {
1128b57dcf8SJim Ingham lldb::OptionValueSP return_val_sp;
113b9c1b51eSKate Stone return_val_sp =
11431d97a5cSZachary Turner value_sp->GetSubValue(exe_ctx, sub_name.drop_front(), will_modify, error);
115b9c1b51eSKate Stone if (!return_val_sp) {
11631d97a5cSZachary Turner if (Properties::IsSettingExperimental(sub_name.drop_front())) {
117b9c1b51eSKate Stone size_t experimental_len =
118b9c1b51eSKate Stone strlen(Properties::GetExperimentalSettingsName());
11931d97a5cSZachary Turner if (sub_name[experimental_len + 1] == '.')
120b9c1b51eSKate Stone return_val_sp = value_sp->GetSubValue(
12131d97a5cSZachary Turner exe_ctx, sub_name.drop_front(experimental_len + 2), will_modify, error);
1228b57dcf8SJim Ingham // It isn't an error if an experimental setting is not present.
1238b57dcf8SJim Ingham if (!return_val_sp)
1248b57dcf8SJim Ingham error.Clear();
1258b57dcf8SJim Ingham }
1268b57dcf8SJim Ingham }
1278b57dcf8SJim Ingham return return_val_sp;
1288b57dcf8SJim Ingham }
12967cc0636SGreg Clayton case '[':
13005097246SAdrian Prantl // Array or dictionary access for subvalues like: "[12]" -- access
13105097246SAdrian Prantl // 12th array element "['hello']" -- dictionary access of key named hello
13267cc0636SGreg Clayton return value_sp->GetSubValue(exe_ctx, sub_name, will_modify, error);
13367cc0636SGreg Clayton
13467cc0636SGreg Clayton default:
13567cc0636SGreg Clayton value_sp.reset();
13667cc0636SGreg Clayton break;
13767cc0636SGreg Clayton }
13867cc0636SGreg Clayton return value_sp;
13967cc0636SGreg Clayton }
14067cc0636SGreg Clayton
SetSubValue(const ExecutionContext * exe_ctx,VarSetOperationType op,llvm::StringRef name,llvm::StringRef value)14197206d57SZachary Turner Status OptionValueProperties::SetSubValue(const ExecutionContext *exe_ctx,
14267cc0636SGreg Clayton VarSetOperationType op,
14397206d57SZachary Turner llvm::StringRef name,
14497206d57SZachary Turner llvm::StringRef value) {
14597206d57SZachary Turner Status error;
14667cc0636SGreg Clayton const bool will_modify = true;
147b81afd65SJason Molenda llvm::SmallVector<llvm::StringRef, 8> components;
148b81afd65SJason Molenda name.split(components, '.');
149b81afd65SJason Molenda bool name_contains_experimental = false;
150b81afd65SJason Molenda for (const auto &part : components)
151b81afd65SJason Molenda if (Properties::IsSettingExperimental(part))
152b81afd65SJason Molenda name_contains_experimental = true;
153b81afd65SJason Molenda
15467cc0636SGreg Clayton lldb::OptionValueSP value_sp(GetSubValue(exe_ctx, name, will_modify, error));
15567cc0636SGreg Clayton if (value_sp)
15631d97a5cSZachary Turner error = value_sp->SetValueFromString(value, op);
157b9c1b51eSKate Stone else {
158b81afd65SJason Molenda // Don't set an error if the path contained .experimental. - those are
159b81afd65SJason Molenda // allowed to be missing and should silently fail.
160a6682a41SJonas Devlieghere if (!name_contains_experimental && error.AsCString() == nullptr) {
16131d97a5cSZachary Turner error.SetErrorStringWithFormat("invalid value path '%s'", name.str().c_str());
16267cc0636SGreg Clayton }
163b81afd65SJason Molenda }
16467cc0636SGreg Clayton return error;
16567cc0636SGreg Clayton }
16667cc0636SGreg Clayton
16767cc0636SGreg Clayton uint32_t
GetPropertyIndex(ConstString name) const1680e4c4821SAdrian Prantl OptionValueProperties::GetPropertyIndex(ConstString name) const {
1694d35d6b3SPavel Labath return m_name_to_index.Find(name, SIZE_MAX);
17067cc0636SGreg Clayton }
17167cc0636SGreg Clayton
17267cc0636SGreg Clayton const Property *
GetProperty(const ExecutionContext * exe_ctx,bool will_modify,ConstString name) const173b9c1b51eSKate Stone OptionValueProperties::GetProperty(const ExecutionContext *exe_ctx,
174b9c1b51eSKate Stone bool will_modify,
1750e4c4821SAdrian Prantl ConstString name) const {
1764fa098a5SZachary Turner return GetPropertyAtIndex(
1774fa098a5SZachary Turner exe_ctx, will_modify,
1784d35d6b3SPavel Labath m_name_to_index.Find(name, SIZE_MAX));
17967cc0636SGreg Clayton }
18067cc0636SGreg Clayton
GetPropertyAtIndex(const ExecutionContext * exe_ctx,bool will_modify,uint32_t idx) const181b9c1b51eSKate Stone const Property *OptionValueProperties::GetPropertyAtIndex(
182b9c1b51eSKate Stone const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const {
18367cc0636SGreg Clayton return ProtectedGetPropertyAtIndex(idx);
18467cc0636SGreg Clayton }
18567cc0636SGreg Clayton
GetPropertyValueAtIndex(const ExecutionContext * exe_ctx,bool will_modify,uint32_t idx) const186b9c1b51eSKate Stone lldb::OptionValueSP OptionValueProperties::GetPropertyValueAtIndex(
187b9c1b51eSKate Stone const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const {
18867cc0636SGreg Clayton const Property *setting = GetPropertyAtIndex(exe_ctx, will_modify, idx);
18967cc0636SGreg Clayton if (setting)
19067cc0636SGreg Clayton return setting->GetValue();
19167cc0636SGreg Clayton return OptionValueSP();
19267cc0636SGreg Clayton }
19367cc0636SGreg Clayton
19467cc0636SGreg Clayton OptionValuePathMappings *
GetPropertyAtIndexAsOptionValuePathMappings(const ExecutionContext * exe_ctx,bool will_modify,uint32_t idx) const195b9c1b51eSKate Stone OptionValueProperties::GetPropertyAtIndexAsOptionValuePathMappings(
196b9c1b51eSKate Stone const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const {
19767cc0636SGreg Clayton OptionValueSP value_sp(GetPropertyValueAtIndex(exe_ctx, will_modify, idx));
19867cc0636SGreg Clayton if (value_sp)
19967cc0636SGreg Clayton return value_sp->GetAsPathMappings();
200d78c9576SEd Maste return nullptr;
20167cc0636SGreg Clayton }
20267cc0636SGreg Clayton
20367cc0636SGreg Clayton OptionValueFileSpecList *
GetPropertyAtIndexAsOptionValueFileSpecList(const ExecutionContext * exe_ctx,bool will_modify,uint32_t idx) const204b9c1b51eSKate Stone OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpecList(
205b9c1b51eSKate Stone const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const {
20667cc0636SGreg Clayton OptionValueSP value_sp(GetPropertyValueAtIndex(exe_ctx, will_modify, idx));
20767cc0636SGreg Clayton if (value_sp)
20867cc0636SGreg Clayton return value_sp->GetAsFileSpecList();
209d78c9576SEd Maste return nullptr;
21067cc0636SGreg Clayton }
21167cc0636SGreg Clayton
GetPropertyAtIndexAsOptionValueArch(const ExecutionContext * exe_ctx,uint32_t idx) const212b9c1b51eSKate Stone OptionValueArch *OptionValueProperties::GetPropertyAtIndexAsOptionValueArch(
213b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx) const {
21467cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
21567cc0636SGreg Clayton if (property)
21667cc0636SGreg Clayton return property->GetValue()->GetAsArch();
217d78c9576SEd Maste return nullptr;
21867cc0636SGreg Clayton }
21967cc0636SGreg Clayton
22023b1decbSDawn Perchik OptionValueLanguage *
GetPropertyAtIndexAsOptionValueLanguage(const ExecutionContext * exe_ctx,uint32_t idx) const221b9c1b51eSKate Stone OptionValueProperties::GetPropertyAtIndexAsOptionValueLanguage(
222b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx) const {
22323b1decbSDawn Perchik const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
22423b1decbSDawn Perchik if (property)
22523b1decbSDawn Perchik return property->GetValue()->GetAsLanguage();
22623b1decbSDawn Perchik return nullptr;
22723b1decbSDawn Perchik }
22823b1decbSDawn Perchik
SetPropertyAtIndexAsLanguage(const ExecutionContext * exe_ctx,uint32_t idx,const LanguageType lang)22946a28a95SJonas Devlieghere bool OptionValueProperties::SetPropertyAtIndexAsLanguage(
23046a28a95SJonas Devlieghere const ExecutionContext *exe_ctx, uint32_t idx, const LanguageType lang) {
23146a28a95SJonas Devlieghere const Property *property = GetPropertyAtIndex(exe_ctx, true, idx);
23246a28a95SJonas Devlieghere if (property) {
23346a28a95SJonas Devlieghere OptionValue *value = property->GetValue().get();
23446a28a95SJonas Devlieghere if (value)
23546a28a95SJonas Devlieghere return value->SetLanguageValue(lang);
23646a28a95SJonas Devlieghere }
23746a28a95SJonas Devlieghere return false;
23846a28a95SJonas Devlieghere }
23946a28a95SJonas Devlieghere
GetPropertyAtIndexAsArgs(const ExecutionContext * exe_ctx,uint32_t idx,Args & args) const240b9c1b51eSKate Stone bool OptionValueProperties::GetPropertyAtIndexAsArgs(
241b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const {
24267cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
243ef447fe0STatyana Krasnukha if (!property)
244ef447fe0STatyana Krasnukha return false;
245ef447fe0STatyana Krasnukha
24667cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
247ef447fe0STatyana Krasnukha if (!value)
248ef447fe0STatyana Krasnukha return false;
249ef447fe0STatyana Krasnukha
250ef447fe0STatyana Krasnukha const OptionValueArgs *arguments = value->GetAsArgs();
251ef447fe0STatyana Krasnukha if (arguments)
252ef447fe0STatyana Krasnukha return arguments->GetArgs(args);
253ef447fe0STatyana Krasnukha
25467cc0636SGreg Clayton const OptionValueArray *array = value->GetAsArray();
25567cc0636SGreg Clayton if (array)
25667cc0636SGreg Clayton return array->GetArgs(args);
257ef447fe0STatyana Krasnukha
25867cc0636SGreg Clayton const OptionValueDictionary *dict = value->GetAsDictionary();
25967cc0636SGreg Clayton if (dict)
26067cc0636SGreg Clayton return dict->GetArgs(args);
261ef447fe0STatyana Krasnukha
26267cc0636SGreg Clayton return false;
26367cc0636SGreg Clayton }
26467cc0636SGreg Clayton
SetPropertyAtIndexFromArgs(const ExecutionContext * exe_ctx,uint32_t idx,const Args & args)265b9c1b51eSKate Stone bool OptionValueProperties::SetPropertyAtIndexFromArgs(
266b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx, const Args &args) {
26767cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, true, idx);
268ef447fe0STatyana Krasnukha if (!property)
269ef447fe0STatyana Krasnukha return false;
270ef447fe0STatyana Krasnukha
27167cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
272ef447fe0STatyana Krasnukha if (!value)
273ef447fe0STatyana Krasnukha return false;
274ef447fe0STatyana Krasnukha
275ef447fe0STatyana Krasnukha OptionValueArgs *arguments = value->GetAsArgs();
276ef447fe0STatyana Krasnukha if (arguments)
277ef447fe0STatyana Krasnukha return arguments->SetArgs(args, eVarSetOperationAssign).Success();
278ef447fe0STatyana Krasnukha
27967cc0636SGreg Clayton OptionValueArray *array = value->GetAsArray();
28067cc0636SGreg Clayton if (array)
28167cc0636SGreg Clayton return array->SetArgs(args, eVarSetOperationAssign).Success();
282ef447fe0STatyana Krasnukha
28367cc0636SGreg Clayton OptionValueDictionary *dict = value->GetAsDictionary();
28467cc0636SGreg Clayton if (dict)
28567cc0636SGreg Clayton return dict->SetArgs(args, eVarSetOperationAssign).Success();
286ef447fe0STatyana Krasnukha
28767cc0636SGreg Clayton return false;
28867cc0636SGreg Clayton }
28967cc0636SGreg Clayton
GetPropertyAtIndexAsBoolean(const ExecutionContext * exe_ctx,uint32_t idx,bool fail_value) const290b9c1b51eSKate Stone bool OptionValueProperties::GetPropertyAtIndexAsBoolean(
291b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx, bool fail_value) const {
29267cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
293b9c1b51eSKate Stone if (property) {
29467cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
29567cc0636SGreg Clayton if (value)
29667cc0636SGreg Clayton return value->GetBooleanValue(fail_value);
29767cc0636SGreg Clayton }
29867cc0636SGreg Clayton return fail_value;
29967cc0636SGreg Clayton }
30067cc0636SGreg Clayton
SetPropertyAtIndexAsBoolean(const ExecutionContext * exe_ctx,uint32_t idx,bool new_value)301b9c1b51eSKate Stone bool OptionValueProperties::SetPropertyAtIndexAsBoolean(
302b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx, bool new_value) {
30367cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, true, idx);
304b9c1b51eSKate Stone if (property) {
30567cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
306b9c1b51eSKate Stone if (value) {
30767cc0636SGreg Clayton value->SetBooleanValue(new_value);
30867cc0636SGreg Clayton return true;
30967cc0636SGreg Clayton }
31067cc0636SGreg Clayton }
31167cc0636SGreg Clayton return false;
31267cc0636SGreg Clayton }
31367cc0636SGreg Clayton
31467cc0636SGreg Clayton OptionValueDictionary *
GetPropertyAtIndexAsOptionValueDictionary(const ExecutionContext * exe_ctx,uint32_t idx) const315b9c1b51eSKate Stone OptionValueProperties::GetPropertyAtIndexAsOptionValueDictionary(
316b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx) const {
31767cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
31867cc0636SGreg Clayton if (property)
31967cc0636SGreg Clayton return property->GetValue()->GetAsDictionary();
320d78c9576SEd Maste return nullptr;
32167cc0636SGreg Clayton }
32267cc0636SGreg Clayton
GetPropertyAtIndexAsEnumeration(const ExecutionContext * exe_ctx,uint32_t idx,int64_t fail_value) const323b9c1b51eSKate Stone int64_t OptionValueProperties::GetPropertyAtIndexAsEnumeration(
324b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const {
32567cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
326b9c1b51eSKate Stone if (property) {
32767cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
32867cc0636SGreg Clayton if (value)
32967cc0636SGreg Clayton return value->GetEnumerationValue(fail_value);
33067cc0636SGreg Clayton }
33167cc0636SGreg Clayton return fail_value;
33267cc0636SGreg Clayton }
33367cc0636SGreg Clayton
SetPropertyAtIndexAsEnumeration(const ExecutionContext * exe_ctx,uint32_t idx,int64_t new_value)334b9c1b51eSKate Stone bool OptionValueProperties::SetPropertyAtIndexAsEnumeration(
335b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value) {
33667cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, true, idx);
337b9c1b51eSKate Stone if (property) {
33867cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
33967cc0636SGreg Clayton if (value)
34067cc0636SGreg Clayton return value->SetEnumerationValue(new_value);
34167cc0636SGreg Clayton }
34267cc0636SGreg Clayton return false;
34367cc0636SGreg Clayton }
34467cc0636SGreg Clayton
345554f68d3SGreg Clayton const FormatEntity::Entry *
GetPropertyAtIndexAsFormatEntity(const ExecutionContext * exe_ctx,uint32_t idx)346b9c1b51eSKate Stone OptionValueProperties::GetPropertyAtIndexAsFormatEntity(
347b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx) {
348554f68d3SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, true, idx);
349b9c1b51eSKate Stone if (property) {
350554f68d3SGreg Clayton OptionValue *value = property->GetValue().get();
351554f68d3SGreg Clayton if (value)
352554f68d3SGreg Clayton return value->GetFormatEntity();
353554f68d3SGreg Clayton }
354554f68d3SGreg Clayton return nullptr;
355554f68d3SGreg Clayton }
35667cc0636SGreg Clayton
3576920b52bSGreg Clayton OptionValueFileSpec *
GetPropertyAtIndexAsOptionValueFileSpec(const ExecutionContext * exe_ctx,bool will_modify,uint32_t idx) const358b9c1b51eSKate Stone OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpec(
359b9c1b51eSKate Stone const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const {
3606920b52bSGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
361b9c1b51eSKate Stone if (property) {
3626920b52bSGreg Clayton OptionValue *value = property->GetValue().get();
3636920b52bSGreg Clayton if (value)
3646920b52bSGreg Clayton return value->GetAsFileSpec();
3656920b52bSGreg Clayton }
366d78c9576SEd Maste return nullptr;
3676920b52bSGreg Clayton }
3686920b52bSGreg Clayton
GetPropertyAtIndexAsFileSpec(const ExecutionContext * exe_ctx,uint32_t idx) const369b9c1b51eSKate Stone FileSpec OptionValueProperties::GetPropertyAtIndexAsFileSpec(
370b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx) const {
37167cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
372b9c1b51eSKate Stone if (property) {
37367cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
37467cc0636SGreg Clayton if (value)
37567cc0636SGreg Clayton return value->GetFileSpecValue();
37667cc0636SGreg Clayton }
37767cc0636SGreg Clayton return FileSpec();
37867cc0636SGreg Clayton }
37967cc0636SGreg Clayton
SetPropertyAtIndexAsFileSpec(const ExecutionContext * exe_ctx,uint32_t idx,const FileSpec & new_file_spec)380b9c1b51eSKate Stone bool OptionValueProperties::SetPropertyAtIndexAsFileSpec(
381b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx,
382b9c1b51eSKate Stone const FileSpec &new_file_spec) {
38367cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, true, idx);
384b9c1b51eSKate Stone if (property) {
38567cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
38667cc0636SGreg Clayton if (value)
38767cc0636SGreg Clayton return value->SetFileSpecValue(new_file_spec);
38867cc0636SGreg Clayton }
38967cc0636SGreg Clayton return false;
39067cc0636SGreg Clayton }
39167cc0636SGreg Clayton
39267cc0636SGreg Clayton const RegularExpression *
GetPropertyAtIndexAsOptionValueRegex(const ExecutionContext * exe_ctx,uint32_t idx) const393b9c1b51eSKate Stone OptionValueProperties::GetPropertyAtIndexAsOptionValueRegex(
394b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx) const {
39567cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
396b9c1b51eSKate Stone if (property) {
39767cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
39867cc0636SGreg Clayton if (value)
39967cc0636SGreg Clayton return value->GetRegexValue();
40067cc0636SGreg Clayton }
401d78c9576SEd Maste return nullptr;
40267cc0636SGreg Clayton }
40367cc0636SGreg Clayton
GetPropertyAtIndexAsOptionValueSInt64(const ExecutionContext * exe_ctx,uint32_t idx) const404b9c1b51eSKate Stone OptionValueSInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueSInt64(
405b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx) const {
40667cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
407b9c1b51eSKate Stone if (property) {
40867cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
40967cc0636SGreg Clayton if (value)
41067cc0636SGreg Clayton return value->GetAsSInt64();
41167cc0636SGreg Clayton }
412d78c9576SEd Maste return nullptr;
41367cc0636SGreg Clayton }
41467cc0636SGreg Clayton
GetPropertyAtIndexAsOptionValueUInt64(const ExecutionContext * exe_ctx,uint32_t idx) const415*2f9fc576SDave Lee OptionValueUInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueUInt64(
416*2f9fc576SDave Lee const ExecutionContext *exe_ctx, uint32_t idx) const {
417*2f9fc576SDave Lee const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
418*2f9fc576SDave Lee if (property) {
419*2f9fc576SDave Lee OptionValue *value = property->GetValue().get();
420*2f9fc576SDave Lee if (value)
421*2f9fc576SDave Lee return value->GetAsUInt64();
422*2f9fc576SDave Lee }
423*2f9fc576SDave Lee return nullptr;
424*2f9fc576SDave Lee }
425*2f9fc576SDave Lee
GetPropertyAtIndexAsSInt64(const ExecutionContext * exe_ctx,uint32_t idx,int64_t fail_value) const426b9c1b51eSKate Stone int64_t OptionValueProperties::GetPropertyAtIndexAsSInt64(
427b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const {
42867cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
429b9c1b51eSKate Stone if (property) {
43067cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
43167cc0636SGreg Clayton if (value)
43267cc0636SGreg Clayton return value->GetSInt64Value(fail_value);
43367cc0636SGreg Clayton }
43467cc0636SGreg Clayton return fail_value;
43567cc0636SGreg Clayton }
43667cc0636SGreg Clayton
SetPropertyAtIndexAsSInt64(const ExecutionContext * exe_ctx,uint32_t idx,int64_t new_value)437b9c1b51eSKate Stone bool OptionValueProperties::SetPropertyAtIndexAsSInt64(
438b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value) {
43967cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, true, idx);
440b9c1b51eSKate Stone if (property) {
44167cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
44267cc0636SGreg Clayton if (value)
44367cc0636SGreg Clayton return value->SetSInt64Value(new_value);
44467cc0636SGreg Clayton }
44567cc0636SGreg Clayton return false;
44667cc0636SGreg Clayton }
44767cc0636SGreg Clayton
GetPropertyAtIndexAsString(const ExecutionContext * exe_ctx,uint32_t idx,llvm::StringRef fail_value) const44831d97a5cSZachary Turner llvm::StringRef OptionValueProperties::GetPropertyAtIndexAsString(
449b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx,
45031d97a5cSZachary Turner llvm::StringRef fail_value) const {
45167cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
452b9c1b51eSKate Stone if (property) {
45367cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
45467cc0636SGreg Clayton if (value)
45567cc0636SGreg Clayton return value->GetStringValue(fail_value);
45667cc0636SGreg Clayton }
45767cc0636SGreg Clayton return fail_value;
45867cc0636SGreg Clayton }
45967cc0636SGreg Clayton
SetPropertyAtIndexAsString(const ExecutionContext * exe_ctx,uint32_t idx,llvm::StringRef new_value)460b9c1b51eSKate Stone bool OptionValueProperties::SetPropertyAtIndexAsString(
461514d8cd8SZachary Turner const ExecutionContext *exe_ctx, uint32_t idx, llvm::StringRef new_value) {
46267cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, true, idx);
463b9c1b51eSKate Stone if (property) {
46467cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
46567cc0636SGreg Clayton if (value)
46667cc0636SGreg Clayton return value->SetStringValue(new_value);
46767cc0636SGreg Clayton }
46867cc0636SGreg Clayton return false;
46967cc0636SGreg Clayton }
47067cc0636SGreg Clayton
GetPropertyAtIndexAsOptionValueString(const ExecutionContext * exe_ctx,bool will_modify,uint32_t idx) const471b9c1b51eSKate Stone OptionValueString *OptionValueProperties::GetPropertyAtIndexAsOptionValueString(
472b9c1b51eSKate Stone const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const {
4734c05410fSGreg Clayton OptionValueSP value_sp(GetPropertyValueAtIndex(exe_ctx, will_modify, idx));
4744c05410fSGreg Clayton if (value_sp)
4754c05410fSGreg Clayton return value_sp->GetAsString();
476d78c9576SEd Maste return nullptr;
4774c05410fSGreg Clayton }
4784c05410fSGreg Clayton
GetPropertyAtIndexAsUInt64(const ExecutionContext * exe_ctx,uint32_t idx,uint64_t fail_value) const479b9c1b51eSKate Stone uint64_t OptionValueProperties::GetPropertyAtIndexAsUInt64(
480b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx, uint64_t fail_value) const {
48167cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
482b9c1b51eSKate Stone if (property) {
48367cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
48467cc0636SGreg Clayton if (value)
48567cc0636SGreg Clayton return value->GetUInt64Value(fail_value);
48667cc0636SGreg Clayton }
48767cc0636SGreg Clayton return fail_value;
48867cc0636SGreg Clayton }
48967cc0636SGreg Clayton
SetPropertyAtIndexAsUInt64(const ExecutionContext * exe_ctx,uint32_t idx,uint64_t new_value)490b9c1b51eSKate Stone bool OptionValueProperties::SetPropertyAtIndexAsUInt64(
491b9c1b51eSKate Stone const ExecutionContext *exe_ctx, uint32_t idx, uint64_t new_value) {
49267cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, true, idx);
493b9c1b51eSKate Stone if (property) {
49467cc0636SGreg Clayton OptionValue *value = property->GetValue().get();
49567cc0636SGreg Clayton if (value)
49667cc0636SGreg Clayton return value->SetUInt64Value(new_value);
49767cc0636SGreg Clayton }
49867cc0636SGreg Clayton return false;
49967cc0636SGreg Clayton }
50067cc0636SGreg Clayton
Clear()5018d6aa688SJim Ingham void OptionValueProperties::Clear() {
50267cc0636SGreg Clayton const size_t num_properties = m_properties.size();
50367cc0636SGreg Clayton for (size_t i = 0; i < num_properties; ++i)
50467cc0636SGreg Clayton m_properties[i].GetValue()->Clear();
50567cc0636SGreg Clayton }
50667cc0636SGreg Clayton
SetValueFromString(llvm::StringRef value,VarSetOperationType op)50797206d57SZachary Turner Status OptionValueProperties::SetValueFromString(llvm::StringRef value,
508b9c1b51eSKate Stone VarSetOperationType op) {
50997206d57SZachary Turner Status error;
51067cc0636SGreg Clayton
51167cc0636SGreg Clayton // Args args(value_cstr);
51267cc0636SGreg Clayton // const size_t argc = args.GetArgumentCount();
513b9c1b51eSKate Stone switch (op) {
51467cc0636SGreg Clayton case eVarSetOperationClear:
51567cc0636SGreg Clayton Clear();
51667cc0636SGreg Clayton break;
51767cc0636SGreg Clayton
51867cc0636SGreg Clayton case eVarSetOperationReplace:
51967cc0636SGreg Clayton case eVarSetOperationAssign:
52067cc0636SGreg Clayton case eVarSetOperationRemove:
52167cc0636SGreg Clayton case eVarSetOperationInsertBefore:
52267cc0636SGreg Clayton case eVarSetOperationInsertAfter:
52367cc0636SGreg Clayton case eVarSetOperationAppend:
52467cc0636SGreg Clayton case eVarSetOperationInvalid:
525c95f7e2aSPavel Labath error = OptionValue::SetValueFromString(value, op);
52667cc0636SGreg Clayton break;
52767cc0636SGreg Clayton }
52867cc0636SGreg Clayton
52967cc0636SGreg Clayton return error;
53067cc0636SGreg Clayton }
53167cc0636SGreg Clayton
DumpValue(const ExecutionContext * exe_ctx,Stream & strm,uint32_t dump_mask)532b9c1b51eSKate Stone void OptionValueProperties::DumpValue(const ExecutionContext *exe_ctx,
533b9c1b51eSKate Stone Stream &strm, uint32_t dump_mask) {
53467cc0636SGreg Clayton const size_t num_properties = m_properties.size();
535b9c1b51eSKate Stone for (size_t i = 0; i < num_properties; ++i) {
53667cc0636SGreg Clayton const Property *property = GetPropertyAtIndex(exe_ctx, false, i);
537b9c1b51eSKate Stone if (property) {
53867cc0636SGreg Clayton OptionValue *option_value = property->GetValue().get();
53967cc0636SGreg Clayton assert(option_value);
54067cc0636SGreg Clayton const bool transparent_value = option_value->ValueIsTransparent();
541b9c1b51eSKate Stone property->Dump(exe_ctx, strm, dump_mask);
54267cc0636SGreg Clayton if (!transparent_value)
54367cc0636SGreg Clayton strm.EOL();
54467cc0636SGreg Clayton }
54567cc0636SGreg Clayton }
54667cc0636SGreg Clayton }
54767cc0636SGreg Clayton
DumpPropertyValue(const ExecutionContext * exe_ctx,Stream & strm,llvm::StringRef property_path,uint32_t dump_mask)54897206d57SZachary Turner Status OptionValueProperties::DumpPropertyValue(const ExecutionContext *exe_ctx,
54967cc0636SGreg Clayton Stream &strm,
55031d97a5cSZachary Turner llvm::StringRef property_path,
551b9c1b51eSKate Stone uint32_t dump_mask) {
55297206d57SZachary Turner Status error;
55367cc0636SGreg Clayton const bool will_modify = false;
554b9c1b51eSKate Stone lldb::OptionValueSP value_sp(
555b9c1b51eSKate Stone GetSubValue(exe_ctx, property_path, will_modify, error));
556b9c1b51eSKate Stone if (value_sp) {
557b9c1b51eSKate Stone if (!value_sp->ValueIsTransparent()) {
55867cc0636SGreg Clayton if (dump_mask & eDumpOptionName)
55967cc0636SGreg Clayton strm.PutCString(property_path);
56067cc0636SGreg Clayton if (dump_mask & ~eDumpOptionName)
56167cc0636SGreg Clayton strm.PutChar(' ');
56267cc0636SGreg Clayton }
56367cc0636SGreg Clayton value_sp->DumpValue(exe_ctx, strm, dump_mask);
56467cc0636SGreg Clayton }
56567cc0636SGreg Clayton return error;
56667cc0636SGreg Clayton }
56767cc0636SGreg Clayton
568f0f183eeSTatyana Krasnukha OptionValuePropertiesSP
CreateLocalCopy(const Properties & global_properties)569f0f183eeSTatyana Krasnukha OptionValueProperties::CreateLocalCopy(const Properties &global_properties) {
570f0f183eeSTatyana Krasnukha auto global_props_sp = global_properties.GetValueProperties();
571f0f183eeSTatyana Krasnukha lldbassert(global_props_sp);
572f0f183eeSTatyana Krasnukha
573f0f183eeSTatyana Krasnukha auto copy_sp = global_props_sp->DeepCopy(global_props_sp->GetParent());
574f0f183eeSTatyana Krasnukha return std::static_pointer_cast<OptionValueProperties>(copy_sp);
575f0f183eeSTatyana Krasnukha }
576f0f183eeSTatyana Krasnukha
577f0f183eeSTatyana Krasnukha OptionValueSP
DeepCopy(const OptionValueSP & new_parent) const578f0f183eeSTatyana Krasnukha OptionValueProperties::DeepCopy(const OptionValueSP &new_parent) const {
579f0f183eeSTatyana Krasnukha auto copy_sp = OptionValue::DeepCopy(new_parent);
580f0f183eeSTatyana Krasnukha // copy_sp->GetAsProperties cannot be used here as it doesn't work for derived
581f0f183eeSTatyana Krasnukha // types that override GetType returning a different value.
582f0f183eeSTatyana Krasnukha auto *props_value_ptr = static_cast<OptionValueProperties *>(copy_sp.get());
583f0f183eeSTatyana Krasnukha lldbassert(props_value_ptr);
584f0f183eeSTatyana Krasnukha
585f0f183eeSTatyana Krasnukha for (auto &property : props_value_ptr->m_properties) {
586f0f183eeSTatyana Krasnukha // Duplicate any values that are not global when constructing properties
587f0f183eeSTatyana Krasnukha // from a global copy.
588f0f183eeSTatyana Krasnukha if (!property.IsGlobal()) {
589f0f183eeSTatyana Krasnukha auto value_sp = property.GetValue()->DeepCopy(copy_sp);
590f0f183eeSTatyana Krasnukha property.SetOptionValue(value_sp);
591f0f183eeSTatyana Krasnukha }
592f0f183eeSTatyana Krasnukha }
593f0f183eeSTatyana Krasnukha return copy_sp;
59467cc0636SGreg Clayton }
59567cc0636SGreg Clayton
GetPropertyAtPath(const ExecutionContext * exe_ctx,bool will_modify,llvm::StringRef name) const596b9c1b51eSKate Stone const Property *OptionValueProperties::GetPropertyAtPath(
59731d97a5cSZachary Turner const ExecutionContext *exe_ctx, bool will_modify, llvm::StringRef name) const {
598d78c9576SEd Maste const Property *property = nullptr;
59931d97a5cSZachary Turner if (name.empty())
60031d97a5cSZachary Turner return nullptr;
60131d97a5cSZachary Turner llvm::StringRef sub_name;
60267cc0636SGreg Clayton ConstString key;
60331d97a5cSZachary Turner size_t key_len = name.find_first_of(".[{");
60467cc0636SGreg Clayton
60531d97a5cSZachary Turner if (key_len != llvm::StringRef::npos) {
60631d97a5cSZachary Turner key.SetString(name.take_front(key_len));
60731d97a5cSZachary Turner sub_name = name.drop_front(key_len);
608b9c1b51eSKate Stone } else
60931d97a5cSZachary Turner key.SetString(name);
61067cc0636SGreg Clayton
61167cc0636SGreg Clayton property = GetProperty(exe_ctx, will_modify, key);
61231d97a5cSZachary Turner if (sub_name.empty() || !property)
61331d97a5cSZachary Turner return property;
61431d97a5cSZachary Turner
615b9c1b51eSKate Stone if (sub_name[0] == '.') {
616b9c1b51eSKate Stone OptionValueProperties *sub_properties =
617b9c1b51eSKate Stone property->GetValue()->GetAsProperties();
61867cc0636SGreg Clayton if (sub_properties)
619b9c1b51eSKate Stone return sub_properties->GetPropertyAtPath(exe_ctx, will_modify,
62031d97a5cSZachary Turner sub_name.drop_front());
62167cc0636SGreg Clayton }
62231d97a5cSZachary Turner return nullptr;
62367cc0636SGreg Clayton }
62467cc0636SGreg Clayton
DumpAllDescriptions(CommandInterpreter & interpreter,Stream & strm) const625b9c1b51eSKate Stone void OptionValueProperties::DumpAllDescriptions(CommandInterpreter &interpreter,
626b9c1b51eSKate Stone Stream &strm) const {
62767cc0636SGreg Clayton size_t max_name_len = 0;
62867cc0636SGreg Clayton const size_t num_properties = m_properties.size();
629b9c1b51eSKate Stone for (size_t i = 0; i < num_properties; ++i) {
63067cc0636SGreg Clayton const Property *property = ProtectedGetPropertyAtIndex(i);
63167cc0636SGreg Clayton if (property)
632e6f6d4c2SZachary Turner max_name_len = std::max<size_t>(property->GetName().size(), max_name_len);
63367cc0636SGreg Clayton }
634b9c1b51eSKate Stone for (size_t i = 0; i < num_properties; ++i) {
63567cc0636SGreg Clayton const Property *property = ProtectedGetPropertyAtIndex(i);
63667cc0636SGreg Clayton if (property)
63767cc0636SGreg Clayton property->DumpDescription(interpreter, strm, max_name_len, false);
63867cc0636SGreg Clayton }
63967cc0636SGreg Clayton }
64067cc0636SGreg Clayton
Apropos(llvm::StringRef keyword,std::vector<const Property * > & matching_properties) const641b9c1b51eSKate Stone void OptionValueProperties::Apropos(
642067d1db1SZachary Turner llvm::StringRef keyword,
643b9c1b51eSKate Stone std::vector<const Property *> &matching_properties) const {
64467cc0636SGreg Clayton const size_t num_properties = m_properties.size();
64567cc0636SGreg Clayton StreamString strm;
646b9c1b51eSKate Stone for (size_t i = 0; i < num_properties; ++i) {
64767cc0636SGreg Clayton const Property *property = ProtectedGetPropertyAtIndex(i);
648b9c1b51eSKate Stone if (property) {
649b9c1b51eSKate Stone const OptionValueProperties *properties =
650b9c1b51eSKate Stone property->GetValue()->GetAsProperties();
651b9c1b51eSKate Stone if (properties) {
65267cc0636SGreg Clayton properties->Apropos(keyword, matching_properties);
653b9c1b51eSKate Stone } else {
65467cc0636SGreg Clayton bool match = false;
655e6f6d4c2SZachary Turner llvm::StringRef name = property->GetName();
656e50f9c41SMartin Storsjö if (name.contains_insensitive(keyword))
65767cc0636SGreg Clayton match = true;
658b9c1b51eSKate Stone else {
659e6f6d4c2SZachary Turner llvm::StringRef desc = property->GetDescription();
660e50f9c41SMartin Storsjö if (desc.contains_insensitive(keyword))
66167cc0636SGreg Clayton match = true;
66267cc0636SGreg Clayton }
663b9c1b51eSKate Stone if (match) {
66467cc0636SGreg Clayton matching_properties.push_back(property);
66567cc0636SGreg Clayton }
66667cc0636SGreg Clayton }
66767cc0636SGreg Clayton }
66867cc0636SGreg Clayton }
66967cc0636SGreg Clayton }
67067cc0636SGreg Clayton
671e8cd0c98SGreg Clayton lldb::OptionValuePropertiesSP
GetSubProperty(const ExecutionContext * exe_ctx,ConstString name)672e8cd0c98SGreg Clayton OptionValueProperties::GetSubProperty(const ExecutionContext *exe_ctx,
6730e4c4821SAdrian Prantl ConstString name) {
674e8cd0c98SGreg Clayton lldb::OptionValueSP option_value_sp(GetValueForKey(exe_ctx, name, false));
675b9c1b51eSKate Stone if (option_value_sp) {
676e8cd0c98SGreg Clayton OptionValueProperties *ov_properties = option_value_sp->GetAsProperties();
677e8cd0c98SGreg Clayton if (ov_properties)
678e8cd0c98SGreg Clayton return ov_properties->shared_from_this();
679e8cd0c98SGreg Clayton }
680e8cd0c98SGreg Clayton return lldb::OptionValuePropertiesSP();
681e8cd0c98SGreg Clayton }
682