30 for (
const auto &definition : defs) {
34 property.GetValue()->SetParent(shared_from_this());
41 uint32_t property_idx, std::function<
void()> callback) {
44 property->SetValueChangedCallback(std::move(callback));
50 const OptionValueSP &value_sp) {
55 value_sp->SetParent(shared_from_this());
81 bool will_modify)
const {
82 lldb::OptionValueSP value_sp;
91 llvm::StringRef name,
bool will_modify,
93 lldb::OptionValueSP value_sp;
95 return OptionValueSP();
97 llvm::StringRef sub_name;
99 size_t key_len = name.find_first_of(
".[{");
100 if (key_len != llvm::StringRef::npos) {
102 sub_name = name.drop_front(key_len);
107 if (sub_name.empty() || !value_sp)
110 switch (sub_name[0]) {
112 lldb::OptionValueSP return_val_sp;
114 value_sp->GetSubValue(exe_ctx, sub_name.drop_front(), will_modify,
error);
115 if (!return_val_sp) {
117 size_t experimental_len =
119 if (sub_name[experimental_len + 1] ==
'.')
120 return_val_sp = value_sp->GetSubValue(
121 exe_ctx, sub_name.drop_front(experimental_len + 2), will_modify,
error);
127 return return_val_sp;
132 return value_sp->GetSubValue(exe_ctx, sub_name, will_modify,
error);
143 llvm::StringRef name,
144 llvm::StringRef value) {
146 const bool will_modify =
true;
147 llvm::SmallVector<llvm::StringRef, 8> components;
148 name.split(components,
'.');
149 bool name_contains_experimental =
false;
150 for (
const auto &part : components)
152 name_contains_experimental =
true;
154 lldb::OptionValueSP value_sp(
GetSubValue(exe_ctx, name, will_modify,
error));
156 error = value_sp->SetValueFromString(value, op);
160 if (!name_contains_experimental &&
error.AsCString() ==
nullptr) {
161 error.SetErrorStringWithFormat(
"invalid value path '%s'", name.str().c_str());
177 exe_ctx, will_modify,
191 return OptionValueSP();
199 return value_sp->GetAsPathMappings();
208 return value_sp->GetAsFileSpecList();
216 return property->GetValue()->GetAsArch();
225 return property->GetValue()->GetAsLanguage();
325 return property->GetValue()->GetAsDictionary();
456 llvm::StringRef fail_value)
const {
481 return value_sp->GetAsString();
509 for (
size_t i = 0; i < num_properties; ++i)
541 for (
size_t i = 0; i < num_properties; ++i) {
544 OptionValue *option_value =
property->GetValue().get();
545 assert(option_value);
547 property->Dump(exe_ctx, strm, dump_mask);
548 if (!transparent_value)
556 llvm::json::Object json_properties;
558 for (
size_t i = 0; i < num_properties; ++i) {
561 OptionValue *option_value =
property->GetValue().get();
562 assert(option_value);
563 json_properties.try_emplace(property->GetName(),
564 option_value->
ToJSON(exe_ctx));
567 return json_properties;
572 llvm::StringRef property_path,
575 const bool will_modify =
false;
576 lldb::OptionValueSP value_sp(
579 if (!value_sp->ValueIsTransparent()) {
586 strm.
Printf(
"%s", llvm::formatv(
"{0:2}", value_sp->ToJSON(exe_ctx)).str().c_str());
588 value_sp->DumpValue(exe_ctx, strm, dump_mask);
593OptionValuePropertiesSP
598 auto copy_sp = global_props_sp->DeepCopy(global_props_sp->GetParent());
599 return std::static_pointer_cast<OptionValueProperties>(copy_sp);
610 for (
auto &property : props_value_ptr->m_properties) {
613 if (!property.IsGlobal()) {
614 auto value_sp =
property.GetValue()->DeepCopy(copy_sp);
615 property.SetOptionValue(value_sp);
622 const ExecutionContext *exe_ctx,
bool will_modify, llvm::StringRef name)
const {
626 llvm::StringRef sub_name;
628 size_t key_len = name.find_first_of(
".[{");
630 if (key_len != llvm::StringRef::npos) {
632 sub_name = name.drop_front(key_len);
637 if (sub_name.empty() || !property)
640 if (sub_name[0] ==
'.') {
645 sub_name.drop_front());
652 size_t max_name_len = 0;
654 for (
size_t i = 0; i < num_properties; ++i) {
657 max_name_len = std::max<size_t>(property->GetName().size(), max_name_len);
659 for (
size_t i = 0; i < num_properties; ++i) {
662 property->DumpDescription(interpreter, strm, max_name_len,
false);
667 llvm::StringRef keyword,
668 std::vector<const Property *> &matching_properties)
const {
671 for (
size_t i = 0; i < num_properties; ++i) {
677 properties->
Apropos(keyword, matching_properties);
680 llvm::StringRef name =
property->GetName();
681 if (name.contains_insensitive(keyword))
684 llvm::StringRef desc =
property->GetDescription();
685 if (desc.contains_insensitive(keyword))
689 matching_properties.push_back(property);
696lldb::OptionValuePropertiesSP
699 lldb::OptionValueSP option_value_sp(
GetValueForKey(exe_ctx, name,
false));
700 if (option_value_sp) {
703 return ov_properties->shared_from_this();
705 return lldb::OptionValuePropertiesSP();
static llvm::raw_ostream & error(Stream &strm)
A command line argument class.
A uniqued constant string class.
void SetString(const llvm::StringRef &s)
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
"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)
lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx, ConstString name)
virtual lldb::OptionValueSP GetPropertyValueAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef path, llvm::StringRef value) override
bool SetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx, llvm::StringRef new_value)
bool SetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value)
void Initialize(const PropertyDefinitions &setting_definitions)
OptionValueFileSpecList * GetPropertyAtIndexAsOptionValueFileSpecList(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
uint64_t GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx, uint64_t fail_value) const
bool SetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx, uint32_t idx, const FileSpec &file_spec)
OptionValueString * GetPropertyAtIndexAsOptionValueString(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
void Apropos(llvm::StringRef keyword, std::vector< const Property * > &matching_properties) const
NameToIndex m_name_to_index
virtual uint32_t GetPropertyIndex(ConstString name) const
OptionValueDictionary * GetPropertyAtIndexAsOptionValueDictionary(const ExecutionContext *exe_ctx, uint32_t idx) const
FileSpec GetPropertyAtIndexAsFileSpec(const ExecutionContext *exe_ctx, uint32_t idx) const
lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, llvm::StringRef name, bool value_will_be_modified, Status &error) const override
OptionValueSInt64 * GetPropertyAtIndexAsOptionValueSInt64(const ExecutionContext *exe_ctx, uint32_t idx) const
bool SetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value)
lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const override
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
OptionValuePathMappings * GetPropertyAtIndexAsOptionValuePathMappings(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const
virtual const Property * GetPropertyAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
virtual void DumpAllDescriptions(CommandInterpreter &interpreter, Stream &strm) const
void AppendProperty(ConstString name, ConstString desc, bool is_global, const lldb::OptionValueSP &value_sp)
virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx, ConstString key, bool value_will_be_modified) const
virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm, llvm::StringRef property_path, uint32_t dump_mask, bool is_json=false)
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override
bool SetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx, uint32_t idx, bool new_value)
virtual const Property * GetProperty(const ExecutionContext *exe_ctx, bool will_modify, ConstString name) const
OptionValueLanguage * GetPropertyAtIndexAsOptionValueLanguage(const ExecutionContext *exe_ctx, uint32_t idx) const
static lldb::OptionValuePropertiesSP CreateLocalCopy(const Properties &global_properties)
OptionValueFileSpec * GetPropertyAtIndexAsOptionValueFileSpec(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const
bool SetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx, uint64_t new_value)
virtual size_t GetNumProperties() const
virtual const Property * GetPropertyAtPath(const ExecutionContext *exe_ctx, bool will_modify, llvm::StringRef property_path) const
void SetValueChangedCallback(uint32_t property_idx, std::function< void()> callback)
bool GetPropertyAtIndexAsArgs(const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const
OptionValueUInt64 * GetPropertyAtIndexAsOptionValueUInt64(const ExecutionContext *exe_ctx, uint32_t idx) const
llvm::StringRef GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx, llvm::StringRef fail_value) const
bool SetPropertyAtIndexFromArgs(const ExecutionContext *exe_ctx, uint32_t idx, const Args &args)
const FormatEntity::Entry * GetPropertyAtIndexAsFormatEntity(const ExecutionContext *exe_ctx, uint32_t idx)
std::vector< Property > m_properties
Property * ProtectedGetPropertyAtIndex(uint32_t idx)
bool SetPropertyAtIndexAsLanguage(const ExecutionContext *exe_ctx, uint32_t idx, lldb::LanguageType lang)
OptionValueArch * GetPropertyAtIndexAsOptionValueArch(const ExecutionContext *exe_ctx, uint32_t idx) const
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
const RegularExpression * GetPropertyAtIndexAsOptionValueRegex(const ExecutionContext *exe_ctx, uint32_t idx) const
int64_t GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const
OptionValueProperties()=default
bool GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx, uint32_t idx, bool fail_value) const
OptionValueDictionary * GetAsDictionary()
virtual Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign)
OptionValueSInt64 * GetAsSInt64()
virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx)
virtual bool ValueIsTransparent() const
uint64_t GetUInt64Value(uint64_t fail_value, bool *success_ptr)
OptionValueUInt64 * GetAsUInt64()
OptionValueProperties * GetAsProperties()
virtual lldb::OptionValueSP DeepCopy(const lldb::OptionValueSP &new_parent) const
int64_t GetEnumerationValue(int64_t fail_value=-1) const
llvm::StringRef GetStringValue(llvm::StringRef fail_value) const
bool GetBooleanValue(bool fail_value=false) const
OptionValueArgs * GetAsArgs()
OptionValueArray * GetAsArray()
bool SetStringValue(llvm::StringRef new_value)
int64_t GetSInt64Value(int64_t fail_value=0) const
bool SetBooleanValue(bool new_value)
OptionValueFileSpec * GetAsFileSpec()
FileSpec GetFileSpecValue() const
const RegularExpression * GetRegexValue() const
const FormatEntity::Entry * GetFormatEntity() const
bool SetEnumerationValue(int64_t value)
bool SetUInt64Value(uint64_t new_value)
bool SetLanguageValue(lldb::LanguageType new_language)
bool SetSInt64Value(int64_t new_value)
bool SetFileSpecValue(const FileSpec &file_spec)
static bool IsSettingExperimental(llvm::StringRef setting)
virtual lldb::OptionValuePropertiesSP GetValueProperties() const
static const char * GetExperimentalSettingsName()
llvm::StringRef GetName() const
const lldb::OptionValueSP & GetValue() const
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.
T Find(ConstString unique_cstr, T fail_value) const
void Append(ConstString unique_cstr, const T &value)
A class that represents a running process on the host machine.
llvm::ArrayRef< PropertyDefinition > PropertyDefinitions
VarSetOperationType
Settable state variable types.
@ eVarSetOperationReplace
@ eVarSetOperationInvalid
@ eVarSetOperationInsertBefore
@ eVarSetOperationInsertAfter
LanguageType
Programming language type.