diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -269,7 +269,7 @@ const FormatEntity::Entry *GetFrameFormatUnique() const; - uint32_t GetStopDisassemblyMaxSize() const; + uint64_t GetStopDisassemblyMaxSize() const; const FormatEntity::Entry *GetThreadFormat() const; @@ -283,7 +283,7 @@ bool SetREPLLanguage(lldb::LanguageType repl_lang); - uint32_t GetTerminalWidth() const; + uint64_t GetTerminalWidth() const; bool SetTerminalWidth(uint32_t term_width); @@ -329,11 +329,11 @@ llvm::StringRef GetStopShowColumnAnsiSuffix() const; - uint32_t GetStopSourceLineCount(bool before) const; + uint64_t GetStopSourceLineCount(bool before) const; StopDisassemblyType GetStopDisassemblyDisplay() const; - uint32_t GetDisassemblyLineCount() const; + uint64_t GetDisassemblyLineCount() const; llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const; @@ -349,7 +349,7 @@ bool SetPrintDecls(bool b); - uint32_t GetTabSize() const; + uint64_t GetTabSize() const; bool SetTabSize(uint32_t tab_size); diff --git a/lldb/include/lldb/Core/UserSettingsController.h b/lldb/include/lldb/Core/UserSettingsController.h --- a/lldb/include/lldb/Core/UserSettingsController.h +++ b/lldb/include/lldb/Core/UserSettingsController.h @@ -9,6 +9,7 @@ #ifndef LLDB_CORE_USERSETTINGSCONTROLLER_H #define LLDB_CORE_USERSETTINGSCONTROLLER_H +#include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private-enumerations.h" @@ -82,6 +83,27 @@ static bool IsSettingExperimental(llvm::StringRef setting); + template + T GetPropertyAtIndexAs(uint32_t idx, T default_value, + const ExecutionContext *exe_ctx = nullptr) const { + return m_collection_sp->GetPropertyAtIndexAs(idx, exe_ctx) + .value_or(default_value); + } + + template ::type, + std::enable_if_t, bool> = true> + const U * + GetPropertyAtIndexAs(uint32_t idx, + const ExecutionContext *exe_ctx = nullptr) const { + return m_collection_sp->GetPropertyAtIndexAs(idx, exe_ctx); + } + + template + bool SetPropertyAtIndex(uint32_t idx, T t, + const ExecutionContext *exe_ctx = nullptr) const { + return m_collection_sp->SetPropertyAtIndex(idx, t, exe_ctx); + } + protected: lldb::OptionValuePropertiesSP m_collection_sp; }; diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h --- a/lldb/include/lldb/Interpreter/OptionValue.h +++ b/lldb/include/lldb/Interpreter/OptionValue.h @@ -322,6 +322,51 @@ m_callback(); } + template , bool> = true> + std::optional GetValueAs() const { + if constexpr (std::is_same_v) + return GetUInt64Value(); + if constexpr (std::is_same_v) + return GetSInt64Value(); + if constexpr (std::is_same_v) + return GetBooleanValue(); + if constexpr (std::is_same_v) + return GetCharValue(); + if constexpr (std::is_same_v) + return GetFormatValue(); + if constexpr (std::is_same_v) + return GetLanguageValue(); + if constexpr (std::is_same_v) + return GetStringValue(); + if constexpr (std::is_enum_v) + if (std::optional value = GetEnumerationValue()) + return static_cast(*value); + return {}; + } + + template ::type>::type, + std::enable_if_t, bool> = true> + T GetValueAs() const { + if constexpr (std::is_same_v) + return GetFormatEntity(); + if constexpr (std::is_same_v) + return GetRegexValue(); + return {}; + } + + bool SetValueAs(bool v) { return SetBooleanValue(v); } + + bool SetValueAs(llvm::StringRef v) { return SetStringValue(v); } + + bool SetValueAs(lldb::LanguageType v) { return SetLanguageValue(v); } + + template , bool> = true> + bool SetValueAs(T t) { + return SetEnumerationValue(t); + } + protected: using TopmostBase = OptionValue; diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h --- a/lldb/include/lldb/Interpreter/OptionValueProperties.h +++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h @@ -122,57 +122,15 @@ bool SetPropertyAtIndexFromArgs(uint32_t idx, const Args &args, const ExecutionContext *exe_ctx = nullptr); - std::optional - GetPropertyAtIndexAsBoolean(uint32_t idx, - const ExecutionContext *exe_ctx = nullptr) const; - - bool SetPropertyAtIndexAsBoolean(uint32_t idx, bool new_value, - const ExecutionContext *exe_ctx = nullptr); - OptionValueDictionary *GetPropertyAtIndexAsOptionValueDictionary( uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const; - std::optional GetPropertyAtIndexAsEnumeration( - uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const; - - bool - SetPropertyAtIndexAsEnumeration(uint32_t idx, int64_t new_value, - const ExecutionContext *exe_ctx = nullptr); - - const FormatEntity::Entry * - GetPropertyAtIndexAsFormatEntity(uint32_t idx, - const ExecutionContext *exe_ctx = nullptr); - - const RegularExpression *GetPropertyAtIndexAsOptionValueRegex( - uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const; - OptionValueSInt64 *GetPropertyAtIndexAsOptionValueSInt64( uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const; OptionValueUInt64 *GetPropertyAtIndexAsOptionValueUInt64( uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const; - std::optional - GetPropertyAtIndexAsSInt64(uint32_t idx, - const ExecutionContext *exe_ctx = nullptr) const; - - bool SetPropertyAtIndexAsSInt64(uint32_t idx, int64_t new_value, - const ExecutionContext *exe_ctx = nullptr); - - std::optional - GetPropertyAtIndexAsUInt64(uint32_t idx, - const ExecutionContext *exe_ctx = nullptr) const; - - bool SetPropertyAtIndexAsUInt64(uint32_t idx, uint64_t new_value, - const ExecutionContext *exe_ctx = nullptr); - - std::optional - GetPropertyAtIndexAsString(uint32_t idx, - const ExecutionContext *exe_ctx = nullptr) const; - - bool SetPropertyAtIndexAsString(uint32_t idx, llvm::StringRef new_value, - const ExecutionContext *exe_ctx = nullptr); - OptionValueString *GetPropertyAtIndexAsOptionValueString( uint32_t idx, const ExecutionContext *exe_ctx = nullptr) const; @@ -201,6 +159,31 @@ void SetValueChangedCallback(uint32_t property_idx, std::function callback); + template + auto GetPropertyAtIndexAs(uint32_t idx, + const ExecutionContext *exe_ctx = nullptr) const { + if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { + if (OptionValue *value = property->GetValue().get()) + return value->GetValueAs(); + } + if constexpr (std::is_pointer_v) + return T{nullptr}; + else + return std::optional{std::nullopt}; + } + + template + bool SetPropertyAtIndex(uint32_t idx, T t, + const ExecutionContext *exe_ctx = nullptr) const { + if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { + if (OptionValue *value = property->GetValue().get()) { + value->SetValueAs(t); + return true; + } + } + return false; + } + protected: Property *ProtectedGetPropertyAtIndex(uint32_t idx) { assert(idx < m_properties.size() && "invalid property index"); diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -74,7 +74,7 @@ Global, DefaultEnumValue<"eLanguageTypeUnknown">, Desc<"The language to use for the REPL.">; - def StopDisassemblyCount: Property<"stop-disassembly-count", "SInt64">, + def StopDisassemblyCount: Property<"stop-disassembly-count", "UInt64">, Global, DefaultUnsignedValue<4>, Desc<"The number of disassembly lines to show when displaying a stopped context.">; @@ -87,11 +87,11 @@ Global, DefaultUnsignedValue<32000>, Desc<"The size limit to use when disassembling large functions (default: 32KB).">; - def StopLineCountAfter: Property<"stop-line-count-after", "SInt64">, + def StopLineCountAfter: Property<"stop-line-count-after", "UInt64">, Global, DefaultUnsignedValue<3>, Desc<"The number of sources lines to display that come after the current source line when displaying a stopped context.">; - def StopLineCountBefore: Property<"stop-line-count-before", "SInt64">, + def StopLineCountBefore: Property<"stop-line-count-before", "UInt64">, Global, DefaultUnsignedValue<3>, Desc<"The number of sources lines to display that come before the current source line when displaying a stopped context.">; diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -262,47 +262,47 @@ } bool Debugger::GetAutoConfirm() const { - const uint32_t idx = ePropertyAutoConfirm; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_debugger_properties[idx].default_uint_value != 0); + constexpr uint32_t idx = ePropertyAutoConfirm; + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value != 0); } const FormatEntity::Entry *Debugger::GetDisassemblyFormat() const { - const uint32_t idx = ePropertyDisassemblyFormat; - return m_collection_sp->GetPropertyAtIndexAsFormatEntity(idx); + constexpr uint32_t idx = ePropertyDisassemblyFormat; + return GetPropertyAtIndexAs(idx); } const FormatEntity::Entry *Debugger::GetFrameFormat() const { - const uint32_t idx = ePropertyFrameFormat; - return m_collection_sp->GetPropertyAtIndexAsFormatEntity(idx); + constexpr uint32_t idx = ePropertyFrameFormat; + return GetPropertyAtIndexAs(idx); } const FormatEntity::Entry *Debugger::GetFrameFormatUnique() const { - const uint32_t idx = ePropertyFrameFormatUnique; - return m_collection_sp->GetPropertyAtIndexAsFormatEntity(idx); + constexpr uint32_t idx = ePropertyFrameFormatUnique; + return GetPropertyAtIndexAs(idx); } -uint32_t Debugger::GetStopDisassemblyMaxSize() const { - const uint32_t idx = ePropertyStopDisassemblyMaxSize; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_debugger_properties[idx].default_uint_value); +uint64_t Debugger::GetStopDisassemblyMaxSize() const { + constexpr uint32_t idx = ePropertyStopDisassemblyMaxSize; + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value); } bool Debugger::GetNotifyVoid() const { - const uint32_t idx = ePropertyNotiftVoid; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_debugger_properties[idx].default_uint_value != 0); + constexpr uint32_t idx = ePropertyNotiftVoid; + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value != 0); } llvm::StringRef Debugger::GetPrompt() const { - const uint32_t idx = ePropertyPrompt; - return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or( - g_debugger_properties[idx].default_cstr_value); + constexpr uint32_t idx = ePropertyPrompt; + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_cstr_value); } void Debugger::SetPrompt(llvm::StringRef p) { - const uint32_t idx = ePropertyPrompt; - m_collection_sp->SetPropertyAtIndexAsString(idx, p); + constexpr uint32_t idx = ePropertyPrompt; + SetPropertyAtIndex(idx, p); llvm::StringRef new_prompt = GetPrompt(); std::string str = lldb_private::ansi::FormatAnsiTerminalCodes(new_prompt, GetUseColor()); @@ -312,25 +312,25 @@ } const FormatEntity::Entry *Debugger::GetThreadFormat() const { - const uint32_t idx = ePropertyThreadFormat; - return m_collection_sp->GetPropertyAtIndexAsFormatEntity(idx); + constexpr uint32_t idx = ePropertyThreadFormat; + return GetPropertyAtIndexAs(idx); } const FormatEntity::Entry *Debugger::GetThreadStopFormat() const { - const uint32_t idx = ePropertyThreadStopFormat; - return m_collection_sp->GetPropertyAtIndexAsFormatEntity(idx); + constexpr uint32_t idx = ePropertyThreadStopFormat; + return GetPropertyAtIndexAs(idx); } lldb::ScriptLanguage Debugger::GetScriptLanguage() const { const uint32_t idx = ePropertyScriptLanguage; - return (lldb::ScriptLanguage)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_debugger_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_debugger_properties[idx].default_uint_value)); } bool Debugger::SetScriptLanguage(lldb::ScriptLanguage script_lang) { const uint32_t idx = ePropertyScriptLanguage; - return m_collection_sp->SetPropertyAtIndexAsEnumeration(idx, script_lang); + return SetPropertyAtIndex(idx, script_lang); } lldb::LanguageType Debugger::GetREPLLanguage() const { @@ -344,13 +344,13 @@ bool Debugger::SetREPLLanguage(lldb::LanguageType repl_lang) { const uint32_t idx = ePropertyREPLLanguage; - return m_collection_sp->SetPropertyAtIndexAsLanguage(idx, repl_lang); + return SetPropertyAtIndex(idx, repl_lang); } -uint32_t Debugger::GetTerminalWidth() const { +uint64_t Debugger::GetTerminalWidth() const { const uint32_t idx = ePropertyTerminalWidth; - return m_collection_sp->GetPropertyAtIndexAsSInt64(idx).value_or( - g_debugger_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value); } bool Debugger::SetTerminalWidth(uint32_t term_width) { @@ -358,94 +358,94 @@ handler_sp->TerminalSizeChanged(); const uint32_t idx = ePropertyTerminalWidth; - return m_collection_sp->SetPropertyAtIndexAsSInt64(idx, term_width); + return SetPropertyAtIndex(idx, term_width); } bool Debugger::GetUseExternalEditor() const { const uint32_t idx = ePropertyUseExternalEditor; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_debugger_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::SetUseExternalEditor(bool b) { const uint32_t idx = ePropertyUseExternalEditor; - return m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + return SetPropertyAtIndex(idx, b); } llvm::StringRef Debugger::GetExternalEditor() const { const uint32_t idx = ePropertyExternalEditor; - return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or( - g_debugger_properties[idx].default_cstr_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_cstr_value); } bool Debugger::SetExternalEditor(llvm::StringRef editor) { const uint32_t idx = ePropertyExternalEditor; - return m_collection_sp->SetPropertyAtIndexAsString(idx, editor); + return SetPropertyAtIndex(idx, editor); } bool Debugger::GetUseColor() const { const uint32_t idx = ePropertyUseColor; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_debugger_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::SetUseColor(bool b) { const uint32_t idx = ePropertyUseColor; - bool ret = m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + bool ret = SetPropertyAtIndex(idx, b); SetPrompt(GetPrompt()); return ret; } bool Debugger::GetShowProgress() const { const uint32_t idx = ePropertyShowProgress; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_debugger_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::SetShowProgress(bool show_progress) { const uint32_t idx = ePropertyShowProgress; - return m_collection_sp->SetPropertyAtIndexAsBoolean(idx, show_progress); + return SetPropertyAtIndex(idx, show_progress); } llvm::StringRef Debugger::GetShowProgressAnsiPrefix() const { const uint32_t idx = ePropertyShowProgressAnsiPrefix; - return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or( - g_debugger_properties[idx].default_cstr_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_cstr_value); } llvm::StringRef Debugger::GetShowProgressAnsiSuffix() const { const uint32_t idx = ePropertyShowProgressAnsiSuffix; - return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or( - g_debugger_properties[idx].default_cstr_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_cstr_value); } bool Debugger::GetUseAutosuggestion() const { const uint32_t idx = ePropertyShowAutosuggestion; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_debugger_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value != 0); } llvm::StringRef Debugger::GetAutosuggestionAnsiPrefix() const { const uint32_t idx = ePropertyShowAutosuggestionAnsiPrefix; - return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or( - g_debugger_properties[idx].default_cstr_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_cstr_value); } llvm::StringRef Debugger::GetAutosuggestionAnsiSuffix() const { const uint32_t idx = ePropertyShowAutosuggestionAnsiSuffix; - return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or( - g_debugger_properties[idx].default_cstr_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_cstr_value); } bool Debugger::GetUseSourceCache() const { const uint32_t idx = ePropertyUseSourceCache; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_debugger_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::SetUseSourceCache(bool b) { const uint32_t idx = ePropertyUseSourceCache; - bool ret = m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + bool ret = SetPropertyAtIndex(idx, b); if (!ret) { m_source_file_cache.Clear(); } @@ -453,111 +453,111 @@ } bool Debugger::GetHighlightSource() const { const uint32_t idx = ePropertyHighlightSource; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_debugger_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value != 0); } StopShowColumn Debugger::GetStopShowColumn() const { const uint32_t idx = ePropertyStopShowColumn; - return (lldb::StopShowColumn)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_debugger_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_debugger_properties[idx].default_uint_value)); } llvm::StringRef Debugger::GetStopShowColumnAnsiPrefix() const { const uint32_t idx = ePropertyStopShowColumnAnsiPrefix; - return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or( - g_debugger_properties[idx].default_cstr_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_cstr_value); } llvm::StringRef Debugger::GetStopShowColumnAnsiSuffix() const { const uint32_t idx = ePropertyStopShowColumnAnsiSuffix; - return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or( - g_debugger_properties[idx].default_cstr_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_cstr_value); } llvm::StringRef Debugger::GetStopShowLineMarkerAnsiPrefix() const { const uint32_t idx = ePropertyStopShowLineMarkerAnsiPrefix; - return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or( - g_debugger_properties[idx].default_cstr_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_cstr_value); } llvm::StringRef Debugger::GetStopShowLineMarkerAnsiSuffix() const { const uint32_t idx = ePropertyStopShowLineMarkerAnsiSuffix; - return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or( - g_debugger_properties[idx].default_cstr_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_cstr_value); } -uint32_t Debugger::GetStopSourceLineCount(bool before) const { +uint64_t Debugger::GetStopSourceLineCount(bool before) const { const uint32_t idx = before ? ePropertyStopLineCountBefore : ePropertyStopLineCountAfter; - return m_collection_sp->GetPropertyAtIndexAsSInt64(idx).value_or( - g_debugger_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value); } Debugger::StopDisassemblyType Debugger::GetStopDisassemblyDisplay() const { const uint32_t idx = ePropertyStopDisassemblyDisplay; - return (Debugger::StopDisassemblyType)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_debugger_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_debugger_properties[idx].default_uint_value)); } -uint32_t Debugger::GetDisassemblyLineCount() const { +uint64_t Debugger::GetDisassemblyLineCount() const { const uint32_t idx = ePropertyStopDisassemblyCount; - return m_collection_sp->GetPropertyAtIndexAsSInt64(idx).value_or( - g_debugger_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value); } bool Debugger::GetAutoOneLineSummaries() const { const uint32_t idx = ePropertyAutoOneLineSummaries; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_debugger_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::GetEscapeNonPrintables() const { const uint32_t idx = ePropertyEscapeNonPrintables; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_debugger_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::GetAutoIndent() const { const uint32_t idx = ePropertyAutoIndent; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_debugger_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::SetAutoIndent(bool b) { const uint32_t idx = ePropertyAutoIndent; - return m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + return SetPropertyAtIndex(idx, b); } bool Debugger::GetPrintDecls() const { const uint32_t idx = ePropertyPrintDecls; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_debugger_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::SetPrintDecls(bool b) { const uint32_t idx = ePropertyPrintDecls; - return m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + return SetPropertyAtIndex(idx, b); } -uint32_t Debugger::GetTabSize() const { +uint64_t Debugger::GetTabSize() const { const uint32_t idx = ePropertyTabSize; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_debugger_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_debugger_properties[idx].default_uint_value); } bool Debugger::SetTabSize(uint32_t tab_size) { const uint32_t idx = ePropertyTabSize; - return m_collection_sp->SetPropertyAtIndexAsUInt64(idx, tab_size); + return SetPropertyAtIndex(idx, tab_size); } lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() const { const uint32_t idx = ePropertyDWIMPrintVerbosity; - return (lldb::DWIMPrintVerbosity)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_debugger_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_debugger_properties[idx].default_uint_value)); } #pragma mark Debugger @@ -815,6 +815,21 @@ // Initialize the debugger properties as early as possible as other parts of // LLDB will start querying them during construction. m_collection_sp->Initialize(g_debugger_properties); + m_collection_sp->AppendProperty( + ConstString("target"), "Settings specify to debugging targets.", true, + Target::GetGlobalProperties().GetValueProperties()); + m_collection_sp->AppendProperty( + ConstString("platform"), "Platform settings.", true, + Platform::GetGlobalPlatformProperties().GetValueProperties()); + m_collection_sp->AppendProperty( + ConstString("symbols"), "Symbol lookup and cache settings.", true, + ModuleList::GetGlobalModuleListProperties().GetValueProperties()); + if (m_command_interpreter_up) { + m_collection_sp->AppendProperty( + ConstString("interpreter"), + "Settings specify to the debugger's command interpreter.", true, + m_command_interpreter_up->GetValueProperties()); + } if (log_callback) m_callback_handler_sp = std::make_shared(log_callback, baton); @@ -836,21 +851,6 @@ } assert(m_dummy_target_sp.get() && "Couldn't construct dummy target?"); - m_collection_sp->AppendProperty( - ConstString("target"), "Settings specify to debugging targets.", true, - Target::GetGlobalProperties().GetValueProperties()); - m_collection_sp->AppendProperty( - ConstString("platform"), "Platform settings.", true, - Platform::GetGlobalPlatformProperties().GetValueProperties()); - m_collection_sp->AppendProperty( - ConstString("symbols"), "Symbol lookup and cache settings.", true, - ModuleList::GetGlobalModuleListProperties().GetValueProperties()); - if (m_command_interpreter_up) { - m_collection_sp->AppendProperty( - ConstString("interpreter"), - "Settings specify to the debugger's command interpreter.", true, - m_command_interpreter_up->GetValueProperties()); - } OptionValueSInt64 *term_width = m_collection_sp->GetPropertyAtIndexAsOptionValueSInt64( ePropertyTerminalWidth); diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -97,19 +97,18 @@ bool ModuleListProperties::GetEnableExternalLookup() const { const uint32_t idx = ePropertyEnableExternalLookup; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_modulelist_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_modulelist_properties[idx].default_uint_value != 0); } bool ModuleListProperties::SetEnableExternalLookup(bool new_value) { - return m_collection_sp->SetPropertyAtIndexAsBoolean( - ePropertyEnableExternalLookup, new_value); + return SetPropertyAtIndex(ePropertyEnableExternalLookup, new_value); } bool ModuleListProperties::GetEnableBackgroundLookup() const { const uint32_t idx = ePropertyEnableBackgroundLookup; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_modulelist_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_modulelist_properties[idx].default_uint_value != 0); } FileSpec ModuleListProperties::GetClangModulesCachePath() const { @@ -136,31 +135,30 @@ bool ModuleListProperties::GetEnableLLDBIndexCache() const { const uint32_t idx = ePropertyEnableLLDBIndexCache; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_modulelist_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_modulelist_properties[idx].default_uint_value != 0); } bool ModuleListProperties::SetEnableLLDBIndexCache(bool new_value) { - return m_collection_sp->SetPropertyAtIndexAsBoolean( - ePropertyEnableLLDBIndexCache, new_value); + return SetPropertyAtIndex(ePropertyEnableLLDBIndexCache, new_value); } uint64_t ModuleListProperties::GetLLDBIndexCacheMaxByteSize() { const uint32_t idx = ePropertyLLDBIndexCacheMaxByteSize; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_modulelist_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_modulelist_properties[idx].default_uint_value); } uint64_t ModuleListProperties::GetLLDBIndexCacheMaxPercent() { const uint32_t idx = ePropertyLLDBIndexCacheMaxPercent; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_modulelist_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_modulelist_properties[idx].default_uint_value); } uint64_t ModuleListProperties::GetLLDBIndexCacheExpirationDays() { const uint32_t idx = ePropertyLLDBIndexCacheExpirationDays; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_modulelist_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_modulelist_properties[idx].default_uint_value); } void ModuleListProperties::UpdateSymlinkMappings() { @@ -186,8 +184,8 @@ bool ModuleListProperties::GetLoadSymbolOnDemand() { const uint32_t idx = ePropertyLoadSymbolOnDemand; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_modulelist_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_modulelist_properties[idx].default_uint_value != 0); } ModuleList::ModuleList() : m_modules(), m_modules_mutex() {} diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -146,41 +146,41 @@ bool CommandInterpreter::GetExpandRegexAliases() const { const uint32_t idx = ePropertyExpandRegexAliases; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_interpreter_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_interpreter_properties[idx].default_uint_value != 0); } bool CommandInterpreter::GetPromptOnQuit() const { const uint32_t idx = ePropertyPromptOnQuit; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_interpreter_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_interpreter_properties[idx].default_uint_value != 0); } void CommandInterpreter::SetPromptOnQuit(bool enable) { const uint32_t idx = ePropertyPromptOnQuit; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, enable); + SetPropertyAtIndex(idx, enable); } bool CommandInterpreter::GetSaveSessionOnQuit() const { const uint32_t idx = ePropertySaveSessionOnQuit; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_interpreter_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_interpreter_properties[idx].default_uint_value != 0); } void CommandInterpreter::SetSaveSessionOnQuit(bool enable) { const uint32_t idx = ePropertySaveSessionOnQuit; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, enable); + SetPropertyAtIndex(idx, enable); } bool CommandInterpreter::GetOpenTranscriptInEditor() const { const uint32_t idx = ePropertyOpenTranscriptInEditor; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_interpreter_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_interpreter_properties[idx].default_uint_value != 0); } void CommandInterpreter::SetOpenTranscriptInEditor(bool enable) { const uint32_t idx = ePropertyOpenTranscriptInEditor; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, enable); + SetPropertyAtIndex(idx, enable); } FileSpec CommandInterpreter::GetSaveSessionDirectory() const { @@ -190,29 +190,29 @@ void CommandInterpreter::SetSaveSessionDirectory(llvm::StringRef path) { const uint32_t idx = ePropertySaveSessionDirectory; - m_collection_sp->SetPropertyAtIndexAsString(idx, path); + SetPropertyAtIndex(idx, path); } bool CommandInterpreter::GetEchoCommands() const { const uint32_t idx = ePropertyEchoCommands; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_interpreter_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_interpreter_properties[idx].default_uint_value != 0); } void CommandInterpreter::SetEchoCommands(bool enable) { const uint32_t idx = ePropertyEchoCommands; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, enable); + SetPropertyAtIndex(idx, enable); } bool CommandInterpreter::GetEchoCommentCommands() const { const uint32_t idx = ePropertyEchoCommentCommands; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_interpreter_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_interpreter_properties[idx].default_uint_value != 0); } void CommandInterpreter::SetEchoCommentCommands(bool enable) { const uint32_t idx = ePropertyEchoCommentCommands; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, enable); + SetPropertyAtIndex(idx, enable); } void CommandInterpreter::AllowExitCodeOnQuit(bool allow) { @@ -246,26 +246,26 @@ bool CommandInterpreter::GetStopCmdSourceOnError() const { const uint32_t idx = ePropertyStopCmdSourceOnError; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_interpreter_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_interpreter_properties[idx].default_uint_value != 0); } bool CommandInterpreter::GetSpaceReplPrompts() const { const uint32_t idx = ePropertySpaceReplPrompts; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_interpreter_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_interpreter_properties[idx].default_uint_value != 0); } bool CommandInterpreter::GetRepeatPreviousCommand() const { const uint32_t idx = ePropertyRepeatPreviousCommand; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_interpreter_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_interpreter_properties[idx].default_uint_value != 0); } bool CommandInterpreter::GetRequireCommandOverwrite() const { const uint32_t idx = ePropertyRequireCommandOverwrite; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_interpreter_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_interpreter_properties[idx].default_uint_value != 0); } void CommandInterpreter::Initialize() { diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp --- a/lldb/source/Interpreter/OptionValueProperties.cpp +++ b/lldb/source/Interpreter/OptionValueProperties.cpp @@ -277,28 +277,6 @@ return false; } -std::optional OptionValueProperties::GetPropertyAtIndexAsBoolean( - uint32_t idx, const ExecutionContext *exe_ctx) const { - if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { - if (OptionValue *value = property->GetValue().get()) - return value->GetBooleanValue(); - } - return {}; -} - -bool OptionValueProperties::SetPropertyAtIndexAsBoolean( - uint32_t idx, bool new_value, const ExecutionContext *exe_ctx) { - const Property *property = GetPropertyAtIndex(idx, exe_ctx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) { - value->SetBooleanValue(new_value); - return true; - } - } - return false; -} - OptionValueDictionary * OptionValueProperties::GetPropertyAtIndexAsOptionValueDictionary( uint32_t idx, const ExecutionContext *exe_ctx) const { @@ -308,38 +286,6 @@ return nullptr; } -std::optional OptionValueProperties::GetPropertyAtIndexAsEnumeration( - uint32_t idx, const ExecutionContext *exe_ctx) const { - if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { - if (OptionValue *value = property->GetValue().get()) - return value->GetEnumerationValue(); - } - return {}; -} - -bool OptionValueProperties::SetPropertyAtIndexAsEnumeration( - uint32_t idx, int64_t new_value, const ExecutionContext *exe_ctx) { - const Property *property = GetPropertyAtIndex(idx, exe_ctx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->SetEnumerationValue(new_value); - } - return false; -} - -const FormatEntity::Entry * -OptionValueProperties::GetPropertyAtIndexAsFormatEntity( - uint32_t idx, const ExecutionContext *exe_ctx) { - const Property *property = GetPropertyAtIndex(idx, exe_ctx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->GetFormatEntity(); - } - return nullptr; -} - OptionValueFileSpec * OptionValueProperties::GetPropertyAtIndexAsOptionValueFileSpec( uint32_t idx, const ExecutionContext *exe_ctx) const { @@ -375,18 +321,6 @@ return false; } -const RegularExpression * -OptionValueProperties::GetPropertyAtIndexAsOptionValueRegex( - uint32_t idx, const ExecutionContext *exe_ctx) const { - const Property *property = GetPropertyAtIndex(idx, exe_ctx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->GetRegexValue(); - } - return nullptr; -} - OptionValueSInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueSInt64( uint32_t idx, const ExecutionContext *exe_ctx) const { const Property *property = GetPropertyAtIndex(idx, exe_ctx); @@ -409,47 +343,6 @@ return nullptr; } -std::optional OptionValueProperties::GetPropertyAtIndexAsSInt64( - uint32_t idx, const ExecutionContext *exe_ctx) const { - if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { - if (OptionValue *value = property->GetValue().get()) - return value->GetSInt64Value(); - } - return {}; -} - -bool OptionValueProperties::SetPropertyAtIndexAsSInt64( - uint32_t idx, int64_t new_value, const ExecutionContext *exe_ctx) { - const Property *property = GetPropertyAtIndex(idx, exe_ctx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->SetSInt64Value(new_value); - } - return false; -} - -std::optional -OptionValueProperties::GetPropertyAtIndexAsString( - uint32_t idx, const ExecutionContext *exe_ctx) const { - if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { - if (OptionValue *value = property->GetValue().get()) - return value->GetStringValue(); - } - return {}; -} - -bool OptionValueProperties::SetPropertyAtIndexAsString( - uint32_t idx, llvm::StringRef new_value, const ExecutionContext *exe_ctx) { - const Property *property = GetPropertyAtIndex(idx, exe_ctx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->SetStringValue(new_value); - } - return false; -} - OptionValueString *OptionValueProperties::GetPropertyAtIndexAsOptionValueString( uint32_t idx, const ExecutionContext *exe_ctx) const { OptionValueSP value_sp(GetPropertyValueAtIndex(idx, exe_ctx)); @@ -458,26 +351,6 @@ return nullptr; } -std::optional OptionValueProperties::GetPropertyAtIndexAsUInt64( - uint32_t idx, const ExecutionContext *exe_ctx) const { - if (const Property *property = GetPropertyAtIndex(idx, exe_ctx)) { - if (OptionValue *value = property->GetValue().get()) - return value->GetUInt64Value(); - } - return {}; -} - -bool OptionValueProperties::SetPropertyAtIndexAsUInt64( - uint32_t idx, uint64_t new_value, const ExecutionContext *exe_ctx) { - const Property *property = GetPropertyAtIndex(idx, exe_ctx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->SetUInt64Value(new_value); - } - return false; -} - void OptionValueProperties::Clear() { const size_t num_properties = m_properties.size(); for (size_t i = 0; i < num_properties; ++i) diff --git a/lldb/source/Interpreter/Property.cpp b/lldb/source/Interpreter/Property.cpp --- a/lldb/source/Interpreter/Property.cpp +++ b/lldb/source/Interpreter/Property.cpp @@ -226,6 +226,7 @@ } break; } + assert(m_value_sp && "invalid property definition"); } Property::Property(llvm::StringRef name, llvm::StringRef desc, bool is_global, diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -113,15 +113,17 @@ bool GetLoadKexts() const { const uint32_t idx = ePropertyLoadKexts; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( + return GetPropertyAtIndexAs( + idx, g_dynamicloaderdarwinkernel_properties[idx].default_uint_value != 0); } KASLRScanType GetScanType() const { const uint32_t idx = ePropertyScanType; - return (KASLRScanType)m_collection_sp->GetPropertyAtIndexAsEnumeration(idx) - .value_or( - g_dynamicloaderdarwinkernel_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, + static_cast( + g_dynamicloaderdarwinkernel_properties[idx].default_uint_value)); } }; diff --git a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp --- a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp +++ b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp @@ -99,10 +99,10 @@ } EnableJITLoaderGDB GetEnable() const { - return (EnableJITLoaderGDB)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(ePropertyEnable) - .value_or( - g_jitloadergdb_properties[ePropertyEnable].default_uint_value); + return GetPropertyAtIndexAs( + ePropertyEnable, + static_cast( + g_jitloadergdb_properties[ePropertyEnable].default_uint_value)); } }; } // namespace diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -90,9 +90,8 @@ } llvm::Triple::EnvironmentType ABI() const { - return (llvm::Triple::EnvironmentType)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(ePropertyABI) - .value_or(llvm::Triple::UnknownEnvironment); + return GetPropertyAtIndexAs( + ePropertyABI, llvm::Triple::UnknownEnvironment); } OptionValueDictionary *ModuleABIMap() const { diff --git a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp --- a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp +++ b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp @@ -41,8 +41,7 @@ } llvm::StringRef GetArchitecture() { - return m_collection_sp->GetPropertyAtIndexAsString(ePropertyArchitecture) - .value_or(""); + return GetPropertyAtIndexAs(ePropertyArchitecture, ""); } FileSpec GetEmulatorPath() { diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -78,8 +78,8 @@ uint64_t GetPacketTimeout() { const uint32_t idx = ePropertyKDPPacketTimeout; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_processkdp_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_processkdp_properties[idx].default_uint_value); } }; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -142,13 +142,13 @@ uint64_t GetPacketTimeout() { const uint32_t idx = ePropertyPacketTimeout; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_processgdbremote_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_processgdbremote_properties[idx].default_uint_value); } bool SetPacketTimeout(uint64_t timeout) { const uint32_t idx = ePropertyPacketTimeout; - return m_collection_sp->SetPropertyAtIndexAsUInt64(idx, timeout); + return SetPropertyAtIndex(idx, timeout); } FileSpec GetTargetDefinitionFile() const { @@ -158,13 +158,13 @@ bool GetUseSVR4() const { const uint32_t idx = ePropertyUseSVR4; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_processgdbremote_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_processgdbremote_properties[idx].default_uint_value != 0); } bool GetUseGPacketForReading() const { const uint32_t idx = ePropertyUseGPacketForReading; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or(true); + return GetPropertyAtIndexAs(idx, true); } }; diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp --- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -131,14 +131,14 @@ bool GetEnableOnStartup() const { const uint32_t idx = ePropertyEnableOnStartup; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_darwinlog_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_darwinlog_properties[idx].default_uint_value != 0); } llvm::StringRef GetAutoEnableOptions() const { const uint32_t idx = ePropertyAutoEnableOptions; - return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or( - g_darwinlog_properties[idx].default_cstr_value); + return GetPropertyAtIndexAs( + idx, g_darwinlog_properties[idx].default_cstr_value); } const char *GetLoggingModuleName() const { return "libsystem_trace.dylib"; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -125,8 +125,7 @@ } bool IgnoreFileIndexes() const { - return m_collection_sp->GetPropertyAtIndexAsBoolean(ePropertyIgnoreIndexes) - .value_or(false); + return GetPropertyAtIndexAs(ePropertyIgnoreIndexes, false); } }; diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -99,13 +99,12 @@ bool PlatformProperties::GetUseModuleCache() const { const auto idx = ePropertyUseModuleCache; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_platform_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_platform_properties[idx].default_uint_value != 0); } bool PlatformProperties::SetUseModuleCache(bool use_module_cache) { - return m_collection_sp->SetPropertyAtIndexAsBoolean(ePropertyUseModuleCache, - use_module_cache); + return SetPropertyAtIndex(ePropertyUseModuleCache, use_module_cache); } FileSpec PlatformProperties::GetModuleCacheDirectory() const { diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -190,14 +190,14 @@ bool ProcessProperties::GetDisableMemoryCache() const { const uint32_t idx = ePropertyDisableMemCache; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_process_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value != 0); } uint64_t ProcessProperties::GetMemoryCacheLineSize() const { const uint32_t idx = ePropertyMemCacheLineSize; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_process_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value); } Args ProcessProperties::GetExtraStartupCommands() const { @@ -219,13 +219,13 @@ uint32_t ProcessProperties::GetVirtualAddressableBits() const { const uint32_t idx = ePropertyVirtualAddressableBits; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_process_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value); } void ProcessProperties::SetVirtualAddressableBits(uint32_t bits) { const uint32_t idx = ePropertyVirtualAddressableBits; - m_collection_sp->SetPropertyAtIndexAsUInt64(idx, bits); + SetPropertyAtIndex(idx, bits); } void ProcessProperties::SetPythonOSPluginPath(const FileSpec &file) { const uint32_t idx = ePropertyPythonOSPluginPath; @@ -234,96 +234,96 @@ bool ProcessProperties::GetIgnoreBreakpointsInExpressions() const { const uint32_t idx = ePropertyIgnoreBreakpointsInExpressions; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_process_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value != 0); } void ProcessProperties::SetIgnoreBreakpointsInExpressions(bool ignore) { const uint32_t idx = ePropertyIgnoreBreakpointsInExpressions; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, ignore); + SetPropertyAtIndex(idx, ignore); } bool ProcessProperties::GetUnwindOnErrorInExpressions() const { const uint32_t idx = ePropertyUnwindOnErrorInExpressions; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_process_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value != 0); } void ProcessProperties::SetUnwindOnErrorInExpressions(bool ignore) { const uint32_t idx = ePropertyUnwindOnErrorInExpressions; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, ignore); + SetPropertyAtIndex(idx, ignore); } bool ProcessProperties::GetStopOnSharedLibraryEvents() const { const uint32_t idx = ePropertyStopOnSharedLibraryEvents; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_process_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value != 0); } void ProcessProperties::SetStopOnSharedLibraryEvents(bool stop) { const uint32_t idx = ePropertyStopOnSharedLibraryEvents; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, stop); + SetPropertyAtIndex(idx, stop); } bool ProcessProperties::GetDisableLangRuntimeUnwindPlans() const { const uint32_t idx = ePropertyDisableLangRuntimeUnwindPlans; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_process_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value != 0); } void ProcessProperties::SetDisableLangRuntimeUnwindPlans(bool disable) { const uint32_t idx = ePropertyDisableLangRuntimeUnwindPlans; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, disable); + SetPropertyAtIndex(idx, disable); m_process->Flush(); } bool ProcessProperties::GetDetachKeepsStopped() const { const uint32_t idx = ePropertyDetachKeepsStopped; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_process_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value != 0); } void ProcessProperties::SetDetachKeepsStopped(bool stop) { const uint32_t idx = ePropertyDetachKeepsStopped; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, stop); + SetPropertyAtIndex(idx, stop); } bool ProcessProperties::GetWarningsOptimization() const { const uint32_t idx = ePropertyWarningOptimization; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_process_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value != 0); } bool ProcessProperties::GetWarningsUnsupportedLanguage() const { const uint32_t idx = ePropertyWarningUnsupportedLanguage; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_process_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value != 0); } bool ProcessProperties::GetStopOnExec() const { const uint32_t idx = ePropertyStopOnExec; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_process_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value != 0); } std::chrono::seconds ProcessProperties::GetUtilityExpressionTimeout() const { const uint32_t idx = ePropertyUtilityExpressionTimeout; - uint64_t value = m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_process_properties[idx].default_uint_value); + uint64_t value = GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value); return std::chrono::seconds(value); } std::chrono::seconds ProcessProperties::GetInterruptTimeout() const { const uint32_t idx = ePropertyInterruptTimeout; - uint64_t value = m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_process_properties[idx].default_uint_value); + uint64_t value = GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value); return std::chrono::seconds(value); } bool ProcessProperties::GetSteppingRunsAllThreads() const { const uint32_t idx = ePropertySteppingRunsAllThreads; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_process_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_process_properties[idx].default_uint_value != 0); } bool ProcessProperties::GetOSPluginReportsAllThreads() const { @@ -336,7 +336,7 @@ return fail_value; return exp_values - ->GetPropertyAtIndexAsBoolean(ePropertyOSPluginReportsAllThreads) + ->GetPropertyAtIndexAs(ePropertyOSPluginReportsAllThreads) .value_or(fail_value); } @@ -346,14 +346,15 @@ OptionValueProperties *exp_values = exp_property->GetValue()->GetAsProperties(); if (exp_values) - exp_values->SetPropertyAtIndexAsBoolean(ePropertyOSPluginReportsAllThreads, - does_report); + exp_values->SetPropertyAtIndex(ePropertyOSPluginReportsAllThreads, + does_report); } FollowForkMode ProcessProperties::GetFollowForkMode() const { const uint32_t idx = ePropertyFollowForkMode; - return (FollowForkMode)m_collection_sp->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_process_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_process_properties[idx].default_uint_value)); } ProcessSP Process::FindPlugin(lldb::TargetSP target_sp, diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -4136,7 +4136,7 @@ exp_property->GetValue()->GetAsProperties(); if (exp_values) return exp_values - ->GetPropertyAtIndexAsBoolean(ePropertyInjectLocalVars, exe_ctx) + ->GetPropertyAtIndexAs(ePropertyInjectLocalVars, exe_ctx) .value_or(true); else return true; @@ -4149,8 +4149,7 @@ OptionValueProperties *exp_values = exp_property->GetValue()->GetAsProperties(); if (exp_values) - exp_values->SetPropertyAtIndexAsBoolean(ePropertyInjectLocalVars, true, - exe_ctx); + exp_values->SetPropertyAtIndex(ePropertyInjectLocalVars, true, exe_ctx); } ArchSpec TargetProperties::GetDefaultArchitecture() const { @@ -4170,75 +4169,75 @@ bool TargetProperties::GetMoveToNearestCode() const { const uint32_t idx = ePropertyMoveToNearestCode; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } lldb::DynamicValueType TargetProperties::GetPreferDynamicValue() const { const uint32_t idx = ePropertyPreferDynamic; - return (lldb::DynamicValueType)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_target_properties[idx].default_uint_value)); } bool TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) { const uint32_t idx = ePropertyPreferDynamic; - return m_collection_sp->SetPropertyAtIndexAsEnumeration(idx, d); + return SetPropertyAtIndex(idx, d); } bool TargetProperties::GetPreloadSymbols() const { const uint32_t idx = ePropertyPreloadSymbols; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetPreloadSymbols(bool b) { const uint32_t idx = ePropertyPreloadSymbols; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + SetPropertyAtIndex(idx, b); } bool TargetProperties::GetDisableASLR() const { const uint32_t idx = ePropertyDisableASLR; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetDisableASLR(bool b) { const uint32_t idx = ePropertyDisableASLR; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + SetPropertyAtIndex(idx, b); } bool TargetProperties::GetInheritTCC() const { const uint32_t idx = ePropertyInheritTCC; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetInheritTCC(bool b) { const uint32_t idx = ePropertyInheritTCC; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + SetPropertyAtIndex(idx, b); } bool TargetProperties::GetDetachOnError() const { const uint32_t idx = ePropertyDetachOnError; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetDetachOnError(bool b) { const uint32_t idx = ePropertyDetachOnError; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + SetPropertyAtIndex(idx, b); } bool TargetProperties::GetDisableSTDIO() const { const uint32_t idx = ePropertyDisableSTDIO; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetDisableSTDIO(bool b) { const uint32_t idx = ePropertyDisableSTDIO; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + SetPropertyAtIndex(idx, b); } const char *TargetProperties::GetDisassemblyFlavor() const { @@ -4246,28 +4245,30 @@ const char *return_value; x86DisassemblyFlavor flavor_value = - (x86DisassemblyFlavor)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_target_properties[idx].default_uint_value); + GetPropertyAtIndexAs( + idx, static_cast( + g_target_properties[idx].default_uint_value)); + return_value = g_x86_dis_flavor_value_types[flavor_value].string_value; return return_value; } InlineStrategy TargetProperties::GetInlineStrategy() const { const uint32_t idx = ePropertyInlineStrategy; - return (InlineStrategy)m_collection_sp->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, + static_cast(g_target_properties[idx].default_uint_value)); } llvm::StringRef TargetProperties::GetArg0() const { const uint32_t idx = ePropertyArg0; - return m_collection_sp->GetPropertyAtIndexAsString(idx).value_or( - g_target_properties[idx].default_cstr_value); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_cstr_value); } void TargetProperties::SetArg0(llvm::StringRef arg) { const uint32_t idx = ePropertyArg0; - m_collection_sp->SetPropertyAtIndexAsString(idx, arg); + SetPropertyAtIndex(idx, arg); m_launch_info.SetArg0(arg); } @@ -4286,10 +4287,9 @@ Environment env; if (m_target && - m_collection_sp->GetPropertyAtIndexAsBoolean(ePropertyInheritEnv) - .value_or( - g_target_properties[ePropertyInheritEnv].default_uint_value != - 0)) { + GetPropertyAtIndexAs( + ePropertyInheritEnv, + g_target_properties[ePropertyInheritEnv].default_uint_value != 0)) { if (auto platform_sp = m_target->GetPlatform()) { Environment platform_env = platform_sp->GetEnvironment(); for (const auto &KV : platform_env) @@ -4321,10 +4321,9 @@ if (m_target == nullptr) return environment; - if (!m_collection_sp->GetPropertyAtIndexAsBoolean(ePropertyInheritEnv) - .value_or( - g_target_properties[ePropertyInheritEnv].default_uint_value != - 0)) + if (!GetPropertyAtIndexAs( + ePropertyInheritEnv, + g_target_properties[ePropertyInheritEnv].default_uint_value != 0)) return environment; PlatformSP platform_sp = m_target->GetPlatform(); @@ -4363,8 +4362,8 @@ bool TargetProperties::GetSkipPrologue() const { const uint32_t idx = ePropertySkipPrologue; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } PathMappingList &TargetProperties::GetSourcePathMap() const { @@ -4377,8 +4376,8 @@ bool TargetProperties::GetAutoSourceMapRelative() const { const uint32_t idx = ePropertyAutoSourceMapRelative; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } void TargetProperties::AppendExecutableSearchPaths(const FileSpec &dir) { @@ -4415,39 +4414,40 @@ bool TargetProperties::GetEnableAutoImportClangModules() const { const uint32_t idx = ePropertyAutoImportClangModules; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } ImportStdModule TargetProperties::GetImportStdModule() const { const uint32_t idx = ePropertyImportStdModule; - return (ImportStdModule)m_collection_sp->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_target_properties[idx].default_uint_value)); } DynamicClassInfoHelper TargetProperties::GetDynamicClassInfoHelper() const { const uint32_t idx = ePropertyDynamicClassInfoHelper; - return (DynamicClassInfoHelper)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_target_properties[idx].default_uint_value)); } bool TargetProperties::GetEnableAutoApplyFixIts() const { const uint32_t idx = ePropertyAutoApplyFixIts; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } uint64_t TargetProperties::GetNumberOfRetriesWithFixits() const { const uint32_t idx = ePropertyRetriesWithFixIts; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value); } bool TargetProperties::GetEnableNotifyAboutFixIts() const { const uint32_t idx = ePropertyNotifyAboutFixIts; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } FileSpec TargetProperties::GetSaveJITObjectsDir() const { @@ -4490,20 +4490,20 @@ bool TargetProperties::GetEnableSyntheticValue() const { const uint32_t idx = ePropertyEnableSynthetic; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } uint32_t TargetProperties::GetMaxZeroPaddingInFloatFormat() const { const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value); } uint32_t TargetProperties::GetMaximumNumberOfChildrenToDisplay() const { const uint32_t idx = ePropertyMaxChildrenCount; - return m_collection_sp->GetPropertyAtIndexAsSInt64(idx).value_or( - g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value); } std::pair @@ -4517,14 +4517,14 @@ uint32_t TargetProperties::GetMaximumSizeOfStringSummary() const { const uint32_t idx = ePropertyMaxSummaryLength; - return m_collection_sp->GetPropertyAtIndexAsSInt64(idx).value_or( - g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value); } uint32_t TargetProperties::GetMaximumMemReadSize() const { const uint32_t idx = ePropertyMaxMemReadSize; - return m_collection_sp->GetPropertyAtIndexAsSInt64(idx).value_or( - g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value); } FileSpec TargetProperties::GetStandardInputPath() const { @@ -4534,7 +4534,7 @@ void TargetProperties::SetStandardInputPath(llvm::StringRef path) { const uint32_t idx = ePropertyInputPath; - m_collection_sp->SetPropertyAtIndexAsString(idx, path); + SetPropertyAtIndex(idx, path); } FileSpec TargetProperties::GetStandardOutputPath() const { @@ -4544,7 +4544,7 @@ void TargetProperties::SetStandardOutputPath(llvm::StringRef path) { const uint32_t idx = ePropertyOutputPath; - m_collection_sp->SetPropertyAtIndexAsString(idx, path); + SetPropertyAtIndex(idx, path); } FileSpec TargetProperties::GetStandardErrorPath() const { @@ -4554,7 +4554,7 @@ void TargetProperties::SetStandardErrorPath(llvm::StringRef path) { const uint32_t idx = ePropertyErrorPath; - m_collection_sp->SetPropertyAtIndexAsString(idx, path); + SetPropertyAtIndex(idx, path); } LanguageType TargetProperties::GetLanguage() const { @@ -4582,78 +4582,78 @@ uint64_t TargetProperties::GetExprErrorLimit() const { const uint32_t idx = ePropertyExprErrorLimit; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value); } uint64_t TargetProperties::GetExprAllocAddress() const { const uint32_t idx = ePropertyExprAllocAddress; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value); } uint64_t TargetProperties::GetExprAllocSize() const { const uint32_t idx = ePropertyExprAllocSize; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value); } uint64_t TargetProperties::GetExprAllocAlign() const { const uint32_t idx = ePropertyExprAllocAlign; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value); } bool TargetProperties::GetBreakpointsConsultPlatformAvoidList() { const uint32_t idx = ePropertyBreakpointUseAvoidList; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } bool TargetProperties::GetUseHexImmediates() const { const uint32_t idx = ePropertyUseHexImmediates; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } bool TargetProperties::GetUseFastStepping() const { const uint32_t idx = ePropertyUseFastStepping; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } bool TargetProperties::GetDisplayExpressionsInCrashlogs() const { const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } LoadScriptFromSymFile TargetProperties::GetLoadScriptFromSymbolFile() const { const uint32_t idx = ePropertyLoadScriptFromSymbolFile; - return (LoadScriptFromSymFile)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_target_properties[idx].default_uint_value)); } LoadCWDlldbinitFile TargetProperties::GetLoadCWDlldbinitFile() const { const uint32_t idx = ePropertyLoadCWDlldbinitFile; - return (LoadCWDlldbinitFile)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_target_properties[idx].default_uint_value)); } Disassembler::HexImmediateStyle TargetProperties::GetHexImmediateStyle() const { const uint32_t idx = ePropertyHexImmediateStyle; - return (Disassembler::HexImmediateStyle)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_target_properties[idx].default_uint_value)); } MemoryModuleLoadLevel TargetProperties::GetMemoryModuleLoadLevel() const { const uint32_t idx = ePropertyMemoryModuleLoadLevel; - return (MemoryModuleLoadLevel)m_collection_sp - ->GetPropertyAtIndexAsEnumeration(idx) - .value_or(g_target_properties[idx].default_uint_value); + return GetPropertyAtIndexAs( + idx, static_cast( + g_target_properties[idx].default_uint_value)); } bool TargetProperties::GetUserSpecifiedTrapHandlerNames(Args &args) const { @@ -4668,24 +4668,24 @@ bool TargetProperties::GetDisplayRuntimeSupportValues() const { const uint32_t idx = ePropertyDisplayRuntimeSupportValues; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetDisplayRuntimeSupportValues(bool b) { const uint32_t idx = ePropertyDisplayRuntimeSupportValues; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + SetPropertyAtIndex(idx, b); } bool TargetProperties::GetDisplayRecognizedArguments() const { const uint32_t idx = ePropertyDisplayRecognizedArguments; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetDisplayRecognizedArguments(bool b) { const uint32_t idx = ePropertyDisplayRecognizedArguments; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + SetPropertyAtIndex(idx, b); } const ProcessLaunchInfo &TargetProperties::GetProcessLaunchInfo() const { @@ -4722,19 +4722,19 @@ bool TargetProperties::GetRequireHardwareBreakpoints() const { const uint32_t idx = ePropertyRequireHardwareBreakpoints; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetRequireHardwareBreakpoints(bool b) { const uint32_t idx = ePropertyRequireHardwareBreakpoints; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, b); + m_collection_sp->SetPropertyAtIndex(idx, b); } bool TargetProperties::GetAutoInstallMainExecutable() const { const uint32_t idx = ePropertyAutoInstallMainExecutable; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } void TargetProperties::Arg0ValueChangedCallback() { @@ -4796,13 +4796,13 @@ bool TargetProperties::GetDebugUtilityExpression() const { const uint32_t idx = ePropertyDebugUtilityExpression; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_target_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetDebugUtilityExpression(bool debug) { const uint32_t idx = ePropertyDebugUtilityExpression; - m_collection_sp->SetPropertyAtIndexAsBoolean(idx, debug); + SetPropertyAtIndex(idx, debug); } // Target::TargetEventData diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -112,7 +112,7 @@ const RegularExpression *ThreadProperties::GetSymbolsToAvoidRegexp() { const uint32_t idx = ePropertyStepAvoidRegex; - return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(idx); + return GetPropertyAtIndexAs(idx); } FileSpecList ThreadProperties::GetLibrariesToAvoid() const { @@ -125,26 +125,26 @@ bool ThreadProperties::GetTraceEnabledState() const { const uint32_t idx = ePropertyEnableThreadTrace; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value != 0); } bool ThreadProperties::GetStepInAvoidsNoDebug() const { const uint32_t idx = ePropertyStepInAvoidsNoDebug; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value != 0); } bool ThreadProperties::GetStepOutAvoidsNoDebug() const { const uint32_t idx = ePropertyStepOutAvoidsNoDebug; - return m_collection_sp->GetPropertyAtIndexAsBoolean(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value != 0); } uint64_t ThreadProperties::GetMaxBacktraceDepth() const { const uint32_t idx = ePropertyMaxBacktraceDepth; - return m_collection_sp->GetPropertyAtIndexAsUInt64(idx).value_or( - g_thread_properties[idx].default_uint_value != 0); + return GetPropertyAtIndexAs( + idx, g_thread_properties[idx].default_uint_value); } // Thread Event Data