[Lldb-commits] [lldb] ca7492f - [lldb] Extract getter function for experimental target properties (NFC) (#83504)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 6 20:41:51 PST 2024
Author: Dave Lee
Date: 2024-03-06T20:41:46-08:00
New Revision: ca7492fae42c5a21db96eccaca7a5e827ab1bf65
URL: https://github.com/llvm/llvm-project/commit/ca7492fae42c5a21db96eccaca7a5e827ab1bf65
DIFF: https://github.com/llvm/llvm-project/commit/ca7492fae42c5a21db96eccaca7a5e827ab1bf65.diff
LOG: [lldb] Extract getter function for experimental target properties (NFC) (#83504)
In Swift's downstream lldb, there are a number of experimental properties. This change
extracts a getter function containing the common logic for getting a boolean valued
experimental property.
This also deletes `SetInjectLocalVariables` which isn't used anywhere.
Added:
Modified:
lldb/include/lldb/Target/Target.h
lldb/source/Target/Target.cpp
Removed:
################################################################################
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 {
More information about the lldb-commits
mailing list