From 9c48aa68f455a63fc5e20e196d3c3e8822bfa6af Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 1 May 2023 21:04:24 -0700 Subject: [PATCH] [lldb] Refactor OptionValueProperties to return a std::optional (NFC) Similar to fdbe7c7faa54, refactor OptionValueProperties to return a std::optional instead of taking a fail value. This allows the caller to handle situations where there's no value, instead of being unable to distinguish between the absence of a value and the value happening the match the fail value. When a fail value is required, std::optional::value_or() provides the same functionality. --- .../lldb/Interpreter/OptionValueProperties.h | 27 +-- lldb/source/Core/Debugger.cpp | 117 +++++++----- lldb/source/Core/ModuleList.cpp | 28 +-- .../source/Interpreter/CommandInterpreter.cpp | 40 ++-- .../Interpreter/OptionValueProperties.cpp | 72 +++---- .../DynamicLoaderDarwinKernel.cpp | 14 +- .../Plugins/JITLoader/GDB/JITLoaderGDB.cpp | 7 +- .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 6 +- .../Platform/QemuUser/PlatformQemuUser.cpp | 5 +- .../Process/MacOSX-Kernel/ProcessKDP.cpp | 4 +- .../Process/gdb-remote/ProcessGDBRemote.cpp | 12 +- .../DarwinLog/StructuredDataDarwinLog.cpp | 8 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 5 +- lldb/source/Target/Platform.cpp | 4 +- lldb/source/Target/Process.cpp | 66 +++---- lldb/source/Target/Target.cpp | 180 +++++++++--------- lldb/source/Target/Thread.cpp | 16 +- 17 files changed, 318 insertions(+), 293 deletions(-) diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h index 814e0a895cc6..691a42a7aeec 100644 --- a/lldb/include/lldb/Interpreter/OptionValueProperties.h +++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h @@ -125,8 +125,9 @@ public: bool SetPropertyAtIndexFromArgs(const ExecutionContext *exe_ctx, uint32_t idx, const Args &args); - bool GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx, - uint32_t idx, bool fail_value) const; + std::optional + GetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx, + uint32_t idx) const; bool SetPropertyAtIndexAsBoolean(const ExecutionContext *exe_ctx, uint32_t idx, bool new_value); @@ -135,9 +136,9 @@ public: GetPropertyAtIndexAsOptionValueDictionary(const ExecutionContext *exe_ctx, uint32_t idx) const; - int64_t GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx, - uint32_t idx, - int64_t fail_value) const; + std::optional + GetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx, + uint32_t idx) const; bool SetPropertyAtIndexAsEnumeration(const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value); @@ -158,21 +159,23 @@ public: GetPropertyAtIndexAsOptionValueUInt64(const ExecutionContext *exe_ctx, uint32_t idx) const; - int64_t GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, - uint32_t idx, int64_t fail_value) const; + std::optional + GetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, + uint32_t idx) const; bool SetPropertyAtIndexAsSInt64(const ExecutionContext *exe_ctx, uint32_t idx, int64_t new_value); - uint64_t GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, - uint32_t idx, uint64_t fail_value) const; + std::optional + GetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, + uint32_t idx) const; bool SetPropertyAtIndexAsUInt64(const ExecutionContext *exe_ctx, uint32_t idx, uint64_t new_value); - llvm::StringRef GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, - uint32_t idx, - llvm::StringRef fail_value) const; + std::optional + GetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, + uint32_t idx) const; bool SetPropertyAtIndexAsString(const ExecutionContext *exe_ctx, uint32_t idx, llvm::StringRef new_value); diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index ee51dd75a9ff..2e0bbba81536 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -263,8 +263,8 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx, bool Debugger::GetAutoConfirm() const { const uint32_t idx = ePropertyAutoConfirm; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_debugger_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value != 0); } const FormatEntity::Entry *Debugger::GetDisassemblyFormat() const { @@ -284,20 +284,20 @@ const FormatEntity::Entry *Debugger::GetFrameFormatUnique() const { uint32_t Debugger::GetStopDisassemblyMaxSize() const { const uint32_t idx = ePropertyStopDisassemblyMaxSize; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - nullptr, idx, g_debugger_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value); } bool Debugger::GetNotifyVoid() const { const uint32_t idx = ePropertyNotiftVoid; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_debugger_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value != 0); } llvm::StringRef Debugger::GetPrompt() const { const uint32_t idx = ePropertyPrompt; - return m_collection_sp->GetPropertyAtIndexAsString( - nullptr, idx, g_debugger_properties[idx].default_cstr_value); + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx) + .value_or(g_debugger_properties[idx].default_cstr_value); } void Debugger::SetPrompt(llvm::StringRef p) { @@ -323,8 +323,9 @@ const FormatEntity::Entry *Debugger::GetThreadStopFormat() const { lldb::ScriptLanguage Debugger::GetScriptLanguage() const { const uint32_t idx = ePropertyScriptLanguage; - return (lldb::ScriptLanguage)m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, g_debugger_properties[idx].default_uint_value); + return (lldb::ScriptLanguage)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value); } bool Debugger::SetScriptLanguage(lldb::ScriptLanguage script_lang) { @@ -349,8 +350,8 @@ bool Debugger::SetREPLLanguage(lldb::LanguageType repl_lang) { uint32_t Debugger::GetTerminalWidth() const { const uint32_t idx = ePropertyTerminalWidth; - return m_collection_sp->GetPropertyAtIndexAsSInt64( - nullptr, idx, g_debugger_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsSInt64(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value); } bool Debugger::SetTerminalWidth(uint32_t term_width) { @@ -363,8 +364,8 @@ bool Debugger::SetTerminalWidth(uint32_t term_width) { bool Debugger::GetUseExternalEditor() const { const uint32_t idx = ePropertyUseExternalEditor; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_debugger_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::SetUseExternalEditor(bool b) { @@ -374,7 +375,8 @@ bool Debugger::SetUseExternalEditor(bool b) { llvm::StringRef Debugger::GetExternalEditor() const { const uint32_t idx = ePropertyExternalEditor; - return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, ""); + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx) + .value_or(g_debugger_properties[idx].default_cstr_value); } bool Debugger::SetExternalEditor(llvm::StringRef editor) { @@ -384,8 +386,8 @@ bool Debugger::SetExternalEditor(llvm::StringRef editor) { bool Debugger::GetUseColor() const { const uint32_t idx = ePropertyUseColor; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_debugger_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::SetUseColor(bool b) { @@ -397,8 +399,8 @@ bool Debugger::SetUseColor(bool b) { bool Debugger::GetShowProgress() const { const uint32_t idx = ePropertyShowProgress; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_debugger_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::SetShowProgress(bool show_progress) { @@ -409,34 +411,38 @@ bool Debugger::SetShowProgress(bool show_progress) { llvm::StringRef Debugger::GetShowProgressAnsiPrefix() const { const uint32_t idx = ePropertyShowProgressAnsiPrefix; - return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, ""); + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx) + .value_or(g_debugger_properties[idx].default_cstr_value); } llvm::StringRef Debugger::GetShowProgressAnsiSuffix() const { const uint32_t idx = ePropertyShowProgressAnsiSuffix; - return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, ""); + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx) + .value_or(g_debugger_properties[idx].default_cstr_value); } bool Debugger::GetUseAutosuggestion() const { const uint32_t idx = ePropertyShowAutosuggestion; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_debugger_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value != 0); } llvm::StringRef Debugger::GetAutosuggestionAnsiPrefix() const { const uint32_t idx = ePropertyShowAutosuggestionAnsiPrefix; - return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, ""); + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx) + .value_or(g_debugger_properties[idx].default_cstr_value); } llvm::StringRef Debugger::GetAutosuggestionAnsiSuffix() const { const uint32_t idx = ePropertyShowAutosuggestionAnsiSuffix; - return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, ""); + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx) + .value_or(g_debugger_properties[idx].default_cstr_value); } bool Debugger::GetUseSourceCache() const { const uint32_t idx = ePropertyUseSourceCache; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_debugger_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::SetUseSourceCache(bool b) { @@ -449,69 +455,77 @@ bool Debugger::SetUseSourceCache(bool b) { } bool Debugger::GetHighlightSource() const { const uint32_t idx = ePropertyHighlightSource; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_debugger_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value); } StopShowColumn Debugger::GetStopShowColumn() const { const uint32_t idx = ePropertyStopShowColumn; - return (lldb::StopShowColumn)m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, g_debugger_properties[idx].default_uint_value); + return (lldb::StopShowColumn)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value); } llvm::StringRef Debugger::GetStopShowColumnAnsiPrefix() const { const uint32_t idx = ePropertyStopShowColumnAnsiPrefix; - return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, ""); + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx) + .value_or(g_debugger_properties[idx].default_cstr_value); } llvm::StringRef Debugger::GetStopShowColumnAnsiSuffix() const { const uint32_t idx = ePropertyStopShowColumnAnsiSuffix; - return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, ""); + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx) + .value_or(g_debugger_properties[idx].default_cstr_value); } llvm::StringRef Debugger::GetStopShowLineMarkerAnsiPrefix() const { const uint32_t idx = ePropertyStopShowLineMarkerAnsiPrefix; - return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, ""); + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx) + .value_or(g_debugger_properties[idx].default_cstr_value); } llvm::StringRef Debugger::GetStopShowLineMarkerAnsiSuffix() const { const uint32_t idx = ePropertyStopShowLineMarkerAnsiSuffix; - return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, ""); + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx) + .value_or(g_debugger_properties[idx].default_cstr_value); } uint32_t Debugger::GetStopSourceLineCount(bool before) const { const uint32_t idx = before ? ePropertyStopLineCountBefore : ePropertyStopLineCountAfter; - return m_collection_sp->GetPropertyAtIndexAsSInt64( - nullptr, idx, g_debugger_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsSInt64(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value); } Debugger::StopDisassemblyType Debugger::GetStopDisassemblyDisplay() const { const uint32_t idx = ePropertyStopDisassemblyDisplay; - return (Debugger::StopDisassemblyType) - m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, g_debugger_properties[idx].default_uint_value); + return (Debugger::StopDisassemblyType)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value); } uint32_t Debugger::GetDisassemblyLineCount() const { const uint32_t idx = ePropertyStopDisassemblyCount; - return m_collection_sp->GetPropertyAtIndexAsSInt64( - nullptr, idx, g_debugger_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsSInt64(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value); } bool Debugger::GetAutoOneLineSummaries() const { const uint32_t idx = ePropertyAutoOneLineSummaries; - return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, true); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::GetEscapeNonPrintables() const { const uint32_t idx = ePropertyEscapeNonPrintables; - return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, true); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::GetAutoIndent() const { const uint32_t idx = ePropertyAutoIndent; - return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, true); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::SetAutoIndent(bool b) { @@ -521,7 +535,8 @@ bool Debugger::SetAutoIndent(bool b) { bool Debugger::GetPrintDecls() const { const uint32_t idx = ePropertyPrintDecls; - return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, true); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value != 0); } bool Debugger::SetPrintDecls(bool b) { @@ -531,8 +546,8 @@ bool Debugger::SetPrintDecls(bool b) { uint32_t Debugger::GetTabSize() const { const uint32_t idx = ePropertyTabSize; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - nullptr, idx, g_debugger_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value); } bool Debugger::SetTabSize(uint32_t tab_size) { @@ -542,9 +557,9 @@ bool Debugger::SetTabSize(uint32_t tab_size) { lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() const { const uint32_t idx = ePropertyDWIMPrintVerbosity; - return (lldb::DWIMPrintVerbosity) - m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, g_debugger_properties[idx].default_uint_value); + return (lldb::DWIMPrintVerbosity)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(g_debugger_properties[idx].default_uint_value); } #pragma mark Debugger diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 5aa58d9bba6b..db592b0d941c 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -97,8 +97,8 @@ ModuleListProperties::ModuleListProperties() { bool ModuleListProperties::GetEnableExternalLookup() const { const uint32_t idx = ePropertyEnableExternalLookup; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_modulelist_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_modulelist_properties[idx].default_uint_value != 0); } bool ModuleListProperties::SetEnableExternalLookup(bool new_value) { @@ -108,8 +108,8 @@ bool ModuleListProperties::SetEnableExternalLookup(bool new_value) { bool ModuleListProperties::GetEnableBackgroundLookup() const { const uint32_t idx = ePropertyEnableBackgroundLookup; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_modulelist_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_modulelist_properties[idx].default_uint_value != 0); } FileSpec ModuleListProperties::GetClangModulesCachePath() const { @@ -138,8 +138,8 @@ bool ModuleListProperties::SetLLDBIndexCachePath(const FileSpec &path) { bool ModuleListProperties::GetEnableLLDBIndexCache() const { const uint32_t idx = ePropertyEnableLLDBIndexCache; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_modulelist_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_modulelist_properties[idx].default_uint_value != 0); } bool ModuleListProperties::SetEnableLLDBIndexCache(bool new_value) { @@ -149,20 +149,20 @@ bool ModuleListProperties::SetEnableLLDBIndexCache(bool new_value) { uint64_t ModuleListProperties::GetLLDBIndexCacheMaxByteSize() { const uint32_t idx = ePropertyLLDBIndexCacheMaxByteSize; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - nullptr, idx, g_modulelist_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(g_modulelist_properties[idx].default_uint_value); } uint64_t ModuleListProperties::GetLLDBIndexCacheMaxPercent() { const uint32_t idx = ePropertyLLDBIndexCacheMaxPercent; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - nullptr, idx, g_modulelist_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(g_modulelist_properties[idx].default_uint_value); } uint64_t ModuleListProperties::GetLLDBIndexCacheExpirationDays() { const uint32_t idx = ePropertyLLDBIndexCacheExpirationDays; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - nullptr, idx, g_modulelist_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(g_modulelist_properties[idx].default_uint_value); } void ModuleListProperties::UpdateSymlinkMappings() { @@ -188,8 +188,8 @@ PathMappingList ModuleListProperties::GetSymlinkMappings() const { bool ModuleListProperties::GetLoadSymbolOnDemand() { const uint32_t idx = ePropertyLoadSymbolOnDemand; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_modulelist_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(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 index ba6188430344..7e08653ad141 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -146,14 +146,14 @@ CommandInterpreter::CommandInterpreter(Debugger &debugger, bool CommandInterpreter::GetExpandRegexAliases() const { const uint32_t idx = ePropertyExpandRegexAliases; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_interpreter_properties[idx].default_uint_value != 0); } bool CommandInterpreter::GetPromptOnQuit() const { const uint32_t idx = ePropertyPromptOnQuit; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_interpreter_properties[idx].default_uint_value != 0); } void CommandInterpreter::SetPromptOnQuit(bool enable) { @@ -163,8 +163,8 @@ void CommandInterpreter::SetPromptOnQuit(bool enable) { bool CommandInterpreter::GetSaveSessionOnQuit() const { const uint32_t idx = ePropertySaveSessionOnQuit; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_interpreter_properties[idx].default_uint_value != 0); } void CommandInterpreter::SetSaveSessionOnQuit(bool enable) { @@ -174,8 +174,8 @@ void CommandInterpreter::SetSaveSessionOnQuit(bool enable) { bool CommandInterpreter::GetOpenTranscriptInEditor() const { const uint32_t idx = ePropertyOpenTranscriptInEditor; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_interpreter_properties[idx].default_uint_value != 0); } void CommandInterpreter::SetOpenTranscriptInEditor(bool enable) { @@ -195,8 +195,8 @@ void CommandInterpreter::SetSaveSessionDirectory(llvm::StringRef path) { bool CommandInterpreter::GetEchoCommands() const { const uint32_t idx = ePropertyEchoCommands; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_interpreter_properties[idx].default_uint_value != 0); } void CommandInterpreter::SetEchoCommands(bool enable) { @@ -206,8 +206,8 @@ void CommandInterpreter::SetEchoCommands(bool enable) { bool CommandInterpreter::GetEchoCommentCommands() const { const uint32_t idx = ePropertyEchoCommentCommands; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_interpreter_properties[idx].default_uint_value != 0); } void CommandInterpreter::SetEchoCommentCommands(bool enable) { @@ -246,26 +246,26 @@ void CommandInterpreter::ResolveCommand(const char *command_line, bool CommandInterpreter::GetStopCmdSourceOnError() const { const uint32_t idx = ePropertyStopCmdSourceOnError; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_interpreter_properties[idx].default_uint_value != 0); } bool CommandInterpreter::GetSpaceReplPrompts() const { const uint32_t idx = ePropertySpaceReplPrompts; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_interpreter_properties[idx].default_uint_value != 0); } bool CommandInterpreter::GetRepeatPreviousCommand() const { const uint32_t idx = ePropertyRepeatPreviousCommand; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_interpreter_properties[idx].default_uint_value != 0); } bool CommandInterpreter::GetRequireCommandOverwrite() const { const uint32_t idx = ePropertyRequireCommandOverwrite; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(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 index 4cd5e5984763..e3a175c9aa20 100644 --- a/lldb/source/Interpreter/OptionValueProperties.cpp +++ b/lldb/source/Interpreter/OptionValueProperties.cpp @@ -291,15 +291,13 @@ bool OptionValueProperties::SetPropertyAtIndexFromArgs( return false; } -bool OptionValueProperties::GetPropertyAtIndexAsBoolean( - const ExecutionContext *exe_ctx, uint32_t idx, bool fail_value) const { - const Property *property = GetPropertyAtIndex(exe_ctx, false, idx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->GetBooleanValue().value_or(fail_value); +std::optional OptionValueProperties::GetPropertyAtIndexAsBoolean( + const ExecutionContext *exe_ctx, uint32_t idx) const { + if (const Property *property = GetPropertyAtIndex(exe_ctx, false, idx)) { + if (OptionValue *value = property->GetValue().get()) + return value->GetBooleanValue(); } - return fail_value; + return {}; } bool OptionValueProperties::SetPropertyAtIndexAsBoolean( @@ -324,15 +322,13 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueDictionary( return nullptr; } -int64_t OptionValueProperties::GetPropertyAtIndexAsEnumeration( - const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const { - const Property *property = GetPropertyAtIndex(exe_ctx, false, idx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->GetEnumerationValue().value_or(fail_value); +std::optional OptionValueProperties::GetPropertyAtIndexAsEnumeration( + const ExecutionContext *exe_ctx, uint32_t idx) const { + if (const Property *property = GetPropertyAtIndex(exe_ctx, false, idx)) { + if (OptionValue *value = property->GetValue().get()) + return value->GetEnumerationValue(); } - return fail_value; + return {}; } bool OptionValueProperties::SetPropertyAtIndexAsEnumeration( @@ -427,15 +423,13 @@ OptionValueUInt64 *OptionValueProperties::GetPropertyAtIndexAsOptionValueUInt64( return nullptr; } -int64_t OptionValueProperties::GetPropertyAtIndexAsSInt64( - const ExecutionContext *exe_ctx, uint32_t idx, int64_t fail_value) const { - const Property *property = GetPropertyAtIndex(exe_ctx, false, idx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->GetSInt64Value().value_or(fail_value); +std::optional OptionValueProperties::GetPropertyAtIndexAsSInt64( + const ExecutionContext *exe_ctx, uint32_t idx) const { + if (const Property *property = GetPropertyAtIndex(exe_ctx, false, idx)) { + if (OptionValue *value = property->GetValue().get()) + return value->GetSInt64Value(); } - return fail_value; + return {}; } bool OptionValueProperties::SetPropertyAtIndexAsSInt64( @@ -449,16 +443,14 @@ bool OptionValueProperties::SetPropertyAtIndexAsSInt64( return false; } -llvm::StringRef OptionValueProperties::GetPropertyAtIndexAsString( - const ExecutionContext *exe_ctx, uint32_t idx, - llvm::StringRef fail_value) const { - const Property *property = GetPropertyAtIndex(exe_ctx, false, idx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->GetStringValue().value_or(fail_value); +std::optional +OptionValueProperties::GetPropertyAtIndexAsString( + const ExecutionContext *exe_ctx, uint32_t idx) const { + if (const Property *property = GetPropertyAtIndex(exe_ctx, false, idx)) { + if (OptionValue *value = property->GetValue().get()) + return value->GetStringValue(); } - return fail_value; + return {}; } bool OptionValueProperties::SetPropertyAtIndexAsString( @@ -480,15 +472,13 @@ OptionValueString *OptionValueProperties::GetPropertyAtIndexAsOptionValueString( return nullptr; } -uint64_t OptionValueProperties::GetPropertyAtIndexAsUInt64( - const ExecutionContext *exe_ctx, uint32_t idx, uint64_t fail_value) const { - const Property *property = GetPropertyAtIndex(exe_ctx, false, idx); - if (property) { - OptionValue *value = property->GetValue().get(); - if (value) - return value->GetUInt64Value().value_or(fail_value); +std::optional OptionValueProperties::GetPropertyAtIndexAsUInt64( + const ExecutionContext *exe_ctx, uint32_t idx) const { + if (const Property *property = GetPropertyAtIndex(exe_ctx, false, idx)) { + if (OptionValue *value = property->GetValue().get()) + return value->GetUInt64Value(); } - return fail_value; + return {}; } bool OptionValueProperties::SetPropertyAtIndexAsUInt64( diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index e84a7d6a047e..9ab8bf3fc4d4 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -113,16 +113,18 @@ public: bool GetLoadKexts() const { const uint32_t idx = ePropertyLoadKexts; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, - g_dynamicloaderdarwinkernel_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or( + g_dynamicloaderdarwinkernel_properties[idx].default_uint_value != + 0); } KASLRScanType GetScanType() const { const uint32_t idx = ePropertyScanType; - return (KASLRScanType)m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, - g_dynamicloaderdarwinkernel_properties[idx].default_uint_value); + return (KASLRScanType)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or( + 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 index a9868336f02e..e62ac79d798d 100644 --- a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp +++ b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp @@ -99,9 +99,10 @@ public: } EnableJITLoaderGDB GetEnable() const { - return (EnableJITLoaderGDB)m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, ePropertyEnable, - g_jitloadergdb_properties[ePropertyEnable].default_uint_value); + return (EnableJITLoaderGDB)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, ePropertyEnable) + .value_or( + 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 index bfea299646e7..8ae1186da3bd 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -90,9 +90,9 @@ public: } llvm::Triple::EnvironmentType ABI() const { - return (llvm::Triple::EnvironmentType) - m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, ePropertyABI, llvm::Triple::UnknownEnvironment); + return (llvm::Triple::EnvironmentType)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, ePropertyABI) + .value_or(llvm::Triple::UnknownEnvironment); } OptionValueDictionary *ModuleABIMap() const { diff --git a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp index e0bc8bf97dcf..9c099508e6e1 100644 --- a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp +++ b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp @@ -41,8 +41,9 @@ public: } llvm::StringRef GetArchitecture() { - return m_collection_sp->GetPropertyAtIndexAsString( - nullptr, ePropertyArchitecture, ""); + return m_collection_sp + ->GetPropertyAtIndexAsString(nullptr, ePropertyArchitecture) + .value_or(""); } FileSpec GetEmulatorPath() { diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index faebe5dd34f8..668b7b0ebf9f 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -78,8 +78,8 @@ public: uint64_t GetPacketTimeout() { const uint32_t idx = ePropertyKDPPacketTimeout; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - NULL, idx, g_processkdp_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsUInt64(NULL, idx).value_or( + 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 index 087344198e22..a50327fdf201 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -142,8 +142,8 @@ public: uint64_t GetPacketTimeout() { const uint32_t idx = ePropertyPacketTimeout; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - nullptr, idx, g_processgdbremote_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(g_processgdbremote_properties[idx].default_uint_value); } bool SetPacketTimeout(uint64_t timeout) { @@ -158,14 +158,14 @@ public: bool GetUseSVR4() const { const uint32_t idx = ePropertyUseSVR4; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, - g_processgdbremote_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_processgdbremote_properties[idx].default_uint_value != 0); } bool GetUseGPacketForReading() const { const uint32_t idx = ePropertyUseGPacketForReading; - return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, true); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(true); } }; diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp index fadf0cc41299..5d70fd2d6b30 100644 --- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -131,14 +131,14 @@ public: bool GetEnableOnStartup() const { const uint32_t idx = ePropertyEnableOnStartup; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_darwinlog_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_darwinlog_properties[idx].default_uint_value != 0); } llvm::StringRef GetAutoEnableOptions() const { const uint32_t idx = ePropertyAutoEnableOptions; - return m_collection_sp->GetPropertyAtIndexAsString( - nullptr, idx, g_darwinlog_properties[idx].default_cstr_value); + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx) + .value_or(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 index 879949b9e7dc..999acab9ea5b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -125,8 +125,9 @@ public: } bool IgnoreFileIndexes() const { - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, ePropertyIgnoreIndexes, false); + return m_collection_sp + ->GetPropertyAtIndexAsBoolean(nullptr, ePropertyIgnoreIndexes) + .value_or(false); } }; diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index a132e0ce202f..167fa94ddf49 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -99,8 +99,8 @@ PlatformProperties::PlatformProperties() { bool PlatformProperties::GetUseModuleCache() const { const auto idx = ePropertyUseModuleCache; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_platform_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_platform_properties[idx].default_uint_value != 0); } bool PlatformProperties::SetUseModuleCache(bool use_module_cache) { diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 3f2e3b839480..a61a607c6105 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -190,14 +190,14 @@ ProcessProperties::~ProcessProperties() = default; bool ProcessProperties::GetDisableMemoryCache() const { const uint32_t idx = ePropertyDisableMemCache; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_process_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_process_properties[idx].default_uint_value != 0); } uint64_t ProcessProperties::GetMemoryCacheLineSize() const { const uint32_t idx = ePropertyMemCacheLineSize; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - nullptr, idx, g_process_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(g_process_properties[idx].default_uint_value); } Args ProcessProperties::GetExtraStartupCommands() const { @@ -219,8 +219,8 @@ FileSpec ProcessProperties::GetPythonOSPluginPath() const { uint32_t ProcessProperties::GetVirtualAddressableBits() const { const uint32_t idx = ePropertyVirtualAddressableBits; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - nullptr, idx, g_process_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(g_process_properties[idx].default_uint_value); } void ProcessProperties::SetVirtualAddressableBits(uint32_t bits) { @@ -234,8 +234,8 @@ void ProcessProperties::SetPythonOSPluginPath(const FileSpec &file) { bool ProcessProperties::GetIgnoreBreakpointsInExpressions() const { const uint32_t idx = ePropertyIgnoreBreakpointsInExpressions; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_process_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_process_properties[idx].default_uint_value != 0); } void ProcessProperties::SetIgnoreBreakpointsInExpressions(bool ignore) { @@ -245,8 +245,8 @@ void ProcessProperties::SetIgnoreBreakpointsInExpressions(bool ignore) { bool ProcessProperties::GetUnwindOnErrorInExpressions() const { const uint32_t idx = ePropertyUnwindOnErrorInExpressions; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_process_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_process_properties[idx].default_uint_value != 0); } void ProcessProperties::SetUnwindOnErrorInExpressions(bool ignore) { @@ -256,8 +256,8 @@ void ProcessProperties::SetUnwindOnErrorInExpressions(bool ignore) { bool ProcessProperties::GetStopOnSharedLibraryEvents() const { const uint32_t idx = ePropertyStopOnSharedLibraryEvents; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_process_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_process_properties[idx].default_uint_value != 0); } void ProcessProperties::SetStopOnSharedLibraryEvents(bool stop) { @@ -267,8 +267,8 @@ void ProcessProperties::SetStopOnSharedLibraryEvents(bool stop) { bool ProcessProperties::GetDisableLangRuntimeUnwindPlans() const { const uint32_t idx = ePropertyDisableLangRuntimeUnwindPlans; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_process_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_process_properties[idx].default_uint_value != 0); } void ProcessProperties::SetDisableLangRuntimeUnwindPlans(bool disable) { @@ -279,8 +279,8 @@ void ProcessProperties::SetDisableLangRuntimeUnwindPlans(bool disable) { bool ProcessProperties::GetDetachKeepsStopped() const { const uint32_t idx = ePropertyDetachKeepsStopped; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_process_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_process_properties[idx].default_uint_value != 0); } void ProcessProperties::SetDetachKeepsStopped(bool stop) { @@ -290,40 +290,40 @@ void ProcessProperties::SetDetachKeepsStopped(bool stop) { bool ProcessProperties::GetWarningsOptimization() const { const uint32_t idx = ePropertyWarningOptimization; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_process_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_process_properties[idx].default_uint_value != 0); } bool ProcessProperties::GetWarningsUnsupportedLanguage() const { const uint32_t idx = ePropertyWarningUnsupportedLanguage; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_process_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_process_properties[idx].default_uint_value != 0); } bool ProcessProperties::GetStopOnExec() const { const uint32_t idx = ePropertyStopOnExec; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_process_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(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( - nullptr, idx, g_process_properties[idx].default_uint_value); + uint64_t value = m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(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( - nullptr, idx, g_process_properties[idx].default_uint_value); + uint64_t value = m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(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( - nullptr, idx, g_process_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_process_properties[idx].default_uint_value != 0); } bool ProcessProperties::GetOSPluginReportsAllThreads() const { @@ -335,8 +335,9 @@ bool ProcessProperties::GetOSPluginReportsAllThreads() const { if (!exp_values) return fail_value; - return exp_values->GetPropertyAtIndexAsBoolean( - nullptr, ePropertyOSPluginReportsAllThreads, fail_value); + return exp_values + ->GetPropertyAtIndexAsBoolean(nullptr, ePropertyOSPluginReportsAllThreads) + .value_or(fail_value); } void ProcessProperties::SetOSPluginReportsAllThreads(bool does_report) { @@ -351,8 +352,9 @@ void ProcessProperties::SetOSPluginReportsAllThreads(bool does_report) { FollowForkMode ProcessProperties::GetFollowForkMode() const { const uint32_t idx = ePropertyFollowForkMode; - return (FollowForkMode)m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, g_process_properties[idx].default_uint_value); + return (FollowForkMode)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(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 index 84e399fc52d2..388512716214 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -4135,8 +4135,9 @@ bool TargetProperties::GetInjectLocalVariables( OptionValueProperties *exp_values = exp_property->GetValue()->GetAsProperties(); if (exp_values) - return exp_values->GetPropertyAtIndexAsBoolean( - exe_ctx, ePropertyInjectLocalVars, true); + return exp_values + ->GetPropertyAtIndexAsBoolean(exe_ctx, ePropertyInjectLocalVars) + .value_or(true); else return true; } @@ -4169,15 +4170,15 @@ void TargetProperties::SetDefaultArchitecture(const ArchSpec &arch) { bool TargetProperties::GetMoveToNearestCode() const { const uint32_t idx = ePropertyMoveToNearestCode; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(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( - nullptr, idx, g_target_properties[idx].default_uint_value); + return (lldb::DynamicValueType)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } bool TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) { @@ -4187,8 +4188,8 @@ bool TargetProperties::SetPreferDynamicValue(lldb::DynamicValueType d) { bool TargetProperties::GetPreloadSymbols() const { const uint32_t idx = ePropertyPreloadSymbols; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetPreloadSymbols(bool b) { @@ -4198,8 +4199,8 @@ void TargetProperties::SetPreloadSymbols(bool b) { bool TargetProperties::GetDisableASLR() const { const uint32_t idx = ePropertyDisableASLR; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetDisableASLR(bool b) { @@ -4209,8 +4210,8 @@ void TargetProperties::SetDisableASLR(bool b) { bool TargetProperties::GetInheritTCC() const { const uint32_t idx = ePropertyInheritTCC; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetInheritTCC(bool b) { @@ -4220,8 +4221,8 @@ void TargetProperties::SetInheritTCC(bool b) { bool TargetProperties::GetDetachOnError() const { const uint32_t idx = ePropertyDetachOnError; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetDetachOnError(bool b) { @@ -4231,8 +4232,8 @@ void TargetProperties::SetDetachOnError(bool b) { bool TargetProperties::GetDisableSTDIO() const { const uint32_t idx = ePropertyDisableSTDIO; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetDisableSTDIO(bool b) { @@ -4245,22 +4246,24 @@ const char *TargetProperties::GetDisassemblyFlavor() const { const char *return_value; x86DisassemblyFlavor flavor_value = - (x86DisassemblyFlavor)m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, g_target_properties[idx].default_uint_value); + (x86DisassemblyFlavor)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(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( - nullptr, idx, g_target_properties[idx].default_uint_value); + return (InlineStrategy)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } llvm::StringRef TargetProperties::GetArg0() const { const uint32_t idx = ePropertyArg0; - return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, - llvm::StringRef()); + return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx) + .value_or(g_target_properties[idx].default_cstr_value); } void TargetProperties::SetArg0(llvm::StringRef arg) { @@ -4284,9 +4287,10 @@ Environment TargetProperties::ComputeEnvironment() const { Environment env; if (m_target && - m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, ePropertyInheritEnv, - g_target_properties[ePropertyInheritEnv].default_uint_value != 0)) { + m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, ePropertyInheritEnv) + .value_or( + 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) @@ -4319,9 +4323,11 @@ Environment TargetProperties::GetInheritedEnvironment() const { if (m_target == nullptr) return environment; - if (!m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, ePropertyInheritEnv, - g_target_properties[ePropertyInheritEnv].default_uint_value != 0)) + if (!m_collection_sp + ->GetPropertyAtIndexAsBoolean(nullptr, ePropertyInheritEnv) + .value_or( + g_target_properties[ePropertyInheritEnv].default_uint_value != + 0)) return environment; PlatformSP platform_sp = m_target->GetPlatform(); @@ -4360,8 +4366,8 @@ void TargetProperties::SetEnvironment(Environment env) { bool TargetProperties::GetSkipPrologue() const { const uint32_t idx = ePropertySkipPrologue; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } PathMappingList &TargetProperties::GetSourcePathMap() const { @@ -4375,8 +4381,8 @@ PathMappingList &TargetProperties::GetSourcePathMap() const { bool TargetProperties::GetAutoSourceMapRelative() const { const uint32_t idx = ePropertyAutoSourceMapRelative; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } void TargetProperties::AppendExecutableSearchPaths(const FileSpec &dir) { @@ -4417,39 +4423,40 @@ FileSpecList TargetProperties::GetClangModuleSearchPaths() { bool TargetProperties::GetEnableAutoImportClangModules() const { const uint32_t idx = ePropertyAutoImportClangModules; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } ImportStdModule TargetProperties::GetImportStdModule() const { const uint32_t idx = ePropertyImportStdModule; - return (ImportStdModule)m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, g_target_properties[idx].default_uint_value); + return (ImportStdModule)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } DynamicClassInfoHelper TargetProperties::GetDynamicClassInfoHelper() const { const uint32_t idx = ePropertyDynamicClassInfoHelper; - return (DynamicClassInfoHelper) - m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, g_target_properties[idx].default_uint_value); + return (DynamicClassInfoHelper)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } bool TargetProperties::GetEnableAutoApplyFixIts() const { const uint32_t idx = ePropertyAutoApplyFixIts; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } uint64_t TargetProperties::GetNumberOfRetriesWithFixits() const { const uint32_t idx = ePropertyRetriesWithFixIts; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - nullptr, idx, g_target_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } bool TargetProperties::GetEnableNotifyAboutFixIts() const { const uint32_t idx = ePropertyNotifyAboutFixIts; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } FileSpec TargetProperties::GetSaveJITObjectsDir() const { @@ -4492,20 +4499,20 @@ void TargetProperties::CheckJITObjectsDir() { bool TargetProperties::GetEnableSyntheticValue() const { const uint32_t idx = ePropertyEnableSynthetic; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } uint32_t TargetProperties::GetMaxZeroPaddingInFloatFormat() const { const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - nullptr, idx, g_target_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } uint32_t TargetProperties::GetMaximumNumberOfChildrenToDisplay() const { const uint32_t idx = ePropertyMaxChildrenCount; - return m_collection_sp->GetPropertyAtIndexAsSInt64( - nullptr, idx, g_target_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsSInt64(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } std::pair @@ -4519,14 +4526,14 @@ TargetProperties::GetMaximumDepthOfChildrenToDisplay() const { uint32_t TargetProperties::GetMaximumSizeOfStringSummary() const { const uint32_t idx = ePropertyMaxSummaryLength; - return m_collection_sp->GetPropertyAtIndexAsSInt64( - nullptr, idx, g_target_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsSInt64(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } uint32_t TargetProperties::GetMaximumMemReadSize() const { const uint32_t idx = ePropertyMaxMemReadSize; - return m_collection_sp->GetPropertyAtIndexAsSInt64( - nullptr, idx, g_target_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsSInt64(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } FileSpec TargetProperties::GetStandardInputPath() const { @@ -4585,59 +4592,60 @@ llvm::StringRef TargetProperties::GetExpressionPrefixContents() { uint64_t TargetProperties::GetExprErrorLimit() const { const uint32_t idx = ePropertyExprErrorLimit; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - nullptr, idx, g_target_properties[idx].default_uint_value); + return m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } bool TargetProperties::GetBreakpointsConsultPlatformAvoidList() { const uint32_t idx = ePropertyBreakpointUseAvoidList; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } bool TargetProperties::GetUseHexImmediates() const { const uint32_t idx = ePropertyUseHexImmediates; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } bool TargetProperties::GetUseFastStepping() const { const uint32_t idx = ePropertyUseFastStepping; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } bool TargetProperties::GetDisplayExpressionsInCrashlogs() const { const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } LoadScriptFromSymFile TargetProperties::GetLoadScriptFromSymbolFile() const { const uint32_t idx = ePropertyLoadScriptFromSymbolFile; - return (LoadScriptFromSymFile) - m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, g_target_properties[idx].default_uint_value); + return (LoadScriptFromSymFile)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } LoadCWDlldbinitFile TargetProperties::GetLoadCWDlldbinitFile() const { const uint32_t idx = ePropertyLoadCWDlldbinitFile; - return (LoadCWDlldbinitFile)m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, g_target_properties[idx].default_uint_value); + return (LoadCWDlldbinitFile)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } Disassembler::HexImmediateStyle TargetProperties::GetHexImmediateStyle() const { const uint32_t idx = ePropertyHexImmediateStyle; - return (Disassembler::HexImmediateStyle) - m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, g_target_properties[idx].default_uint_value); + return (Disassembler::HexImmediateStyle)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } MemoryModuleLoadLevel TargetProperties::GetMemoryModuleLoadLevel() const { const uint32_t idx = ePropertyMemoryModuleLoadLevel; - return (MemoryModuleLoadLevel) - m_collection_sp->GetPropertyAtIndexAsEnumeration( - nullptr, idx, g_target_properties[idx].default_uint_value); + return (MemoryModuleLoadLevel)m_collection_sp + ->GetPropertyAtIndexAsEnumeration(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value); } bool TargetProperties::GetUserSpecifiedTrapHandlerNames(Args &args) const { @@ -4652,7 +4660,8 @@ void TargetProperties::SetUserSpecifiedTrapHandlerNames(const Args &args) { bool TargetProperties::GetDisplayRuntimeSupportValues() const { const uint32_t idx = ePropertyDisplayRuntimeSupportValues; - return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetDisplayRuntimeSupportValues(bool b) { @@ -4662,7 +4671,8 @@ void TargetProperties::SetDisplayRuntimeSupportValues(bool b) { bool TargetProperties::GetDisplayRecognizedArguments() const { const uint32_t idx = ePropertyDisplayRecognizedArguments; - return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetDisplayRecognizedArguments(bool b) { @@ -4704,8 +4714,8 @@ void TargetProperties::SetProcessLaunchInfo( bool TargetProperties::GetRequireHardwareBreakpoints() const { const uint32_t idx = ePropertyRequireHardwareBreakpoints; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetRequireHardwareBreakpoints(bool b) { @@ -4715,8 +4725,8 @@ void TargetProperties::SetRequireHardwareBreakpoints(bool b) { bool TargetProperties::GetAutoInstallMainExecutable() const { const uint32_t idx = ePropertyAutoInstallMainExecutable; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } void TargetProperties::Arg0ValueChangedCallback() { @@ -4778,8 +4788,8 @@ void TargetProperties::DisableSTDIOValueChangedCallback() { bool TargetProperties::GetDebugUtilityExpression() const { const uint32_t idx = ePropertyDebugUtilityExpression; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_target_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_target_properties[idx].default_uint_value != 0); } void TargetProperties::SetDebugUtilityExpression(bool debug) { diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index c71e65398f10..4fa86bc14954 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -126,26 +126,26 @@ FileSpecList ThreadProperties::GetLibrariesToAvoid() const { bool ThreadProperties::GetTraceEnabledState() const { const uint32_t idx = ePropertyEnableThreadTrace; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_thread_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_thread_properties[idx].default_uint_value != 0); } bool ThreadProperties::GetStepInAvoidsNoDebug() const { const uint32_t idx = ePropertyStepInAvoidsNoDebug; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_thread_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_thread_properties[idx].default_uint_value != 0); } bool ThreadProperties::GetStepOutAvoidsNoDebug() const { const uint32_t idx = ePropertyStepOutAvoidsNoDebug; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - nullptr, idx, g_thread_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx) + .value_or(g_thread_properties[idx].default_uint_value != 0); } uint64_t ThreadProperties::GetMaxBacktraceDepth() const { const uint32_t idx = ePropertyMaxBacktraceDepth; - return m_collection_sp->GetPropertyAtIndexAsUInt64( - nullptr, idx, g_thread_properties[idx].default_uint_value != 0); + return m_collection_sp->GetPropertyAtIndexAsUInt64(nullptr, idx) + .value_or(g_thread_properties[idx].default_uint_value != 0); } // Thread Event Data -- GitLab