32 property.GetValue()->SetParent(shared_from_this());
44 size_t property_idx, std::function<
void()> callback) {
47 property->SetValueChangedCallback(std::move(callback));
51 llvm::StringRef desc,
bool is_global,
53 Property property(name, desc, is_global, value_sp);
56 value_sp->SetParent(shared_from_this());
61 assert(value_sp->GetName() == name);
63 "Mismatch between parents from TableGen and actual parents");
70 llvm::StringRef key)
const {
74 const size_t idx = iter->second;
87 llvm::StringRef sub_name;
89 size_t key_len = name.find_first_of(
".[{");
90 if (key_len != llvm::StringRef::npos) {
91 key = name.take_front(key_len);
92 sub_name = name.drop_front(key_len);
97 if (sub_name.empty() || !value_sp)
100 switch (sub_name[0]) {
104 value_sp->GetSubValue(exe_ctx, sub_name.drop_front(),
error);
105 if (!return_val_sp) {
107 const size_t experimental_len =
109 if (sub_name[experimental_len + 1] ==
'.')
110 return_val_sp = value_sp->GetSubValue(
111 exe_ctx, sub_name.drop_front(experimental_len + 2),
error);
117 return return_val_sp;
122 return value_sp->GetSubValue(exe_ctx, sub_name,
error);
133 llvm::StringRef name,
134 llvm::StringRef value) {
136 llvm::SmallVector<llvm::StringRef, 8> components;
137 name.split(components,
'.');
138 bool name_contains_experimental =
false;
139 for (
const auto &part : components)
141 name_contains_experimental =
true;
145 error = value_sp->SetValueFromString(value, op);
149 if (!name_contains_experimental &&
error.AsCString() ==
nullptr) {
186 return value_sp->GetAsPathMappings();
195 return value_sp->GetAsFileSpecList();
260 return property->GetValue()->GetAsDictionary();
302 return value_sp->GetAsString();
308 for (
size_t i = 0; i < num_properties; ++i)
338 Stream &strm, uint32_t dump_mask) {
340 for (
size_t i = 0; i < num_properties; ++i) {
343 OptionValue *option_value =
property->GetValue().get();
344 assert(option_value);
346 property->Dump(exe_ctx, strm, dump_mask);
347 if (!transparent_value)
355 llvm::json::Object json_properties;
357 for (
size_t i = 0; i < num_properties; ++i) {
360 OptionValue *option_value =
property->GetValue().get();
361 assert(option_value);
362 json_properties.try_emplace(property->GetName(),
363 option_value->
ToJSON(exe_ctx));
366 return json_properties;
371 llvm::StringRef property_path,
377 if (!value_sp->ValueIsTransparent()) {
386 llvm::formatv(
"{0:2}", value_sp->ToJSON(exe_ctx)).str().c_str());
388 value_sp->DumpValue(exe_ctx, strm, dump_mask);
398 auto copy_sp = global_props_sp->DeepCopy(global_props_sp->GetParent());
399 return std::static_pointer_cast<OptionValueProperties>(copy_sp);
410 for (
auto &property : props_value_ptr->m_properties) {
413 if (!property.IsGlobal()) {
414 auto value_sp =
property.GetValue()->DeepCopy(copy_sp);
415 property.SetOptionValue(value_sp);
423 llvm::StringRef name)
const {
428 llvm::StringRef sub_name;
430 size_t key_len = name.find_first_of(
".[{");
432 if (key_len != llvm::StringRef::npos) {
433 key = name.take_front(key_len);
434 sub_name = name.drop_front(key_len);
439 if (sub_name.empty() || !property)
442 if (sub_name[0] ==
'.') {
444 property->GetValue()->GetAsProperties();
453 size_t max_name_len = 0;
455 for (
size_t i = 0; i < num_properties; ++i) {
458 max_name_len = std::max<size_t>(property->GetName().size(), max_name_len);
460 for (
size_t i = 0; i < num_properties; ++i) {
463 property->DumpDescription(interpreter, strm, max_name_len,
false);
468 llvm::StringRef keyword,
469 std::vector<const Property *> &matching_properties)
const {
472 for (
size_t i = 0; i < num_properties; ++i) {
476 property->GetValue()->GetAsProperties();
478 properties->
Apropos(keyword, matching_properties);
481 llvm::StringRef name =
property->GetName();
482 if (name.contains_insensitive(keyword))
485 llvm::StringRef desc =
property->GetDescription();
486 if (desc.contains_insensitive(keyword))
490 matching_properties.push_back(property);
499 llvm::StringRef name) {
501 if (option_value_sp) {
504 return ov_properties->shared_from_this();
516 if (!parent_properties)
519 auto [prefix, expected_name] = llvm::StringRef(
m_expected_path).rsplit(
'.');
521 if (expected_name.empty()) {
static llvm::raw_ostream & error(Stream &strm)
A command line argument class.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
size_t GetArgs(Args &args) const
Status SetArgs(const Args &args, VarSetOperationType op)
size_t GetArgs(Args &args) const
size_t GetArgs(Args &args) const
Status SetArgs(const Args &args, VarSetOperationType op)
void AppendProperty(llvm::StringRef name, llvm::StringRef desc, bool is_global, const lldb::OptionValueSP &value_sp)
llvm::StringMap< size_t > m_name_to_index
Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef path, llvm::StringRef value) override
OptionValueFileSpec * GetPropertyAtIndexAsOptionValueFileSpec(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
std::string m_expected_path
void Apropos(llvm::StringRef keyword, std::vector< const Property * > &matching_properties) const
void Initialize(const PropertyCollectionDefinition &setting_definitions)
lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const override
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
virtual void DumpAllDescriptions(CommandInterpreter &interpreter, Stream &strm) const
OptionValueFileSpecList * GetPropertyAtIndexAsOptionValueFileSpecList(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
Property * ProtectedGetPropertyAtIndex(size_t idx)
OptionValueString * GetPropertyAtIndexAsOptionValueString(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm, llvm::StringRef property_path, uint32_t dump_mask, bool is_json=false)
OptionValueDictionary * GetPropertyAtIndexAsOptionValueDictionary(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
llvm::StringRef GetName() const override
void SetExpectedPath(std::string path)
static lldb::OptionValuePropertiesSP CreateLocalCopy(const Properties &global_properties)
lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, llvm::StringRef name, Status &error) const override
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override
std::vector< Property > m_properties
void SetValueChangedCallback(size_t property_idx, std::function< void()> callback)
bool SetPropertyAtIndexFromArgs(size_t idx, const Args &args, const ExecutionContext *exe_ctx=nullptr)
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
virtual const Property * GetPropertyAtPath(const ExecutionContext *exe_ctx, llvm::StringRef property_path) const
virtual const Property * GetPropertyAtIndex(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx, llvm::StringRef key) const
lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx, llvm::StringRef name)
virtual lldb::OptionValueSP GetPropertyValueAtIndex(size_t idx, const ExecutionContext *exe_ctx) const
OptionValueUInt64 * GetPropertyAtIndexAsOptionValueUInt64(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
OptionValuePathMappings * GetPropertyAtIndexAsOptionValuePathMappings(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
OptionValueSInt64 * GetPropertyAtIndexAsOptionValueSInt64(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
virtual const Property * GetProperty(llvm::StringRef name, const ExecutionContext *exe_ctx=nullptr) const
bool GetPropertyAtIndexAsArgs(size_t idx, Args &args, const ExecutionContext *exe_ctx=nullptr) const
virtual size_t GetPropertyIndex(llvm::StringRef name) const
OptionValueProperties()=default
OptionValueDictionary * GetAsDictionary()
virtual Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign)
OptionValueSInt64 * GetAsSInt64()
virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const =0
virtual bool ValueIsTransparent() const
OptionValueUInt64 * GetAsUInt64()
virtual lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const
lldb::OptionValueSP GetParent() const
OptionValueArgs * GetAsArgs()
OptionValueArray * GetAsArray()
OptionValueFileSpec * GetAsFileSpec()
static bool IsSettingExperimental(llvm::StringRef setting)
static llvm::StringRef GetExperimentalSettingsName()
lldb::OptionValuePropertiesSP GetValueProperties() const
const lldb::OptionValueSP & GetValue() const
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
bool Success() const
Test for success condition.
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t EOL()
Output and End of Line character to the stream.
A class that represents a running process on the host machine.
VarSetOperationType
Settable state variable types.
@ eVarSetOperationReplace
@ eVarSetOperationInvalid
@ eVarSetOperationInsertBefore
@ eVarSetOperationInsertAfter
std::shared_ptr< lldb_private::OptionValueProperties > OptionValuePropertiesSP
std::shared_ptr< lldb_private::OptionValue > OptionValueSP
llvm::StringRef expected_path
llvm::ArrayRef< PropertyDefinition > definitions