-
Notifications
You must be signed in to change notification settings - Fork 11.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb] Extract getter function for experimental target properties (NFC) #83504
[lldb] Extract getter function for experimental target properties (NFC) #83504
Conversation
@llvm/pr-subscribers-lldb Author: Dave Lee (kastiglione) ChangesFull diff: https://github.com/llvm/llvm-project/pull/83504.diff 2 Files Affected:
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 {
|
} | ||
|
||
void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx, | ||
bool b) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, b
wasn't even being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT, thanks for improving this!
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.