https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/83504
None >From 969f441344e179c9167fe707cf8f01edae6dbfc5 Mon Sep 17 00:00:00 2001 From: Dave Lee <davelee....@gmail.com> Date: Thu, 29 Feb 2024 15:38:22 -0800 Subject: [PATCH] [lldb] Extract getter function for experimental target properties (NFC) --- lldb/include/lldb/Target/Target.h | 6 ++++-- lldb/source/Target/Target.cpp | 24 +++++++++--------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 8f57358981d4d2..2c2e6b2831ccee 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -244,8 +244,6 @@ class TargetProperties : public Properties { bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const; - void SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b); - void SetRequireHardwareBreakpoints(bool b); bool GetRequireHardwareBreakpoints() const; @@ -259,6 +257,10 @@ class TargetProperties : public Properties { bool GetDebugUtilityExpression() const; private: + std::optional<bool> + GetExperimentalPropertyValue(size_t prop_idx, + ExecutionContext *exe_ctx = nullptr) const; + // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); void RunArgsValueChangedCallback(); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index e982a30a3ae4ff..09b0ac42631d1a 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -43,6 +43,7 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Target/ABI.h" +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Language.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/Process.h" @@ -4227,28 +4228,21 @@ void TargetProperties::UpdateLaunchInfoFromProperties() { DisableSTDIOValueChangedCallback(); } -bool TargetProperties::GetInjectLocalVariables( - ExecutionContext *exe_ctx) const { +std::optional<bool> TargetProperties::GetExperimentalPropertyValue( + size_t prop_idx, ExecutionContext *exe_ctx) const { const Property *exp_property = m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx); OptionValueProperties *exp_values = exp_property->GetValue()->GetAsProperties(); if (exp_values) - return exp_values - ->GetPropertyAtIndexAs<bool>(ePropertyInjectLocalVars, exe_ctx) - .value_or(true); - else - return true; + return exp_values->GetPropertyAtIndexAs<bool>(prop_idx, exe_ctx); + return std::nullopt; } -void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx, - bool b) { - const Property *exp_property = - m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx); - OptionValueProperties *exp_values = - exp_property->GetValue()->GetAsProperties(); - if (exp_values) - exp_values->SetPropertyAtIndex(ePropertyInjectLocalVars, true, exe_ctx); +bool TargetProperties::GetInjectLocalVariables( + ExecutionContext *exe_ctx) const { + return GetExperimentalPropertyValue(ePropertyInjectLocalVars, exe_ctx) + .value_or(true); } ArchSpec TargetProperties::GetDefaultArchitecture() const { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits