Skip to content

Commit ca7492f

Browse files
authored
[lldb] Extract getter function for experimental target properties (NFC) (llvm#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.
1 parent c7fbbec commit ca7492f

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

lldb/include/lldb/Target/Target.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ class TargetProperties : public Properties {
244244

245245
bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const;
246246

247-
void SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b);
248-
249247
void SetRequireHardwareBreakpoints(bool b);
250248

251249
bool GetRequireHardwareBreakpoints() const;
@@ -259,6 +257,10 @@ class TargetProperties : public Properties {
259257
bool GetDebugUtilityExpression() const;
260258

261259
private:
260+
std::optional<bool>
261+
GetExperimentalPropertyValue(size_t prop_idx,
262+
ExecutionContext *exe_ctx = nullptr) const;
263+
262264
// Callbacks for m_launch_info.
263265
void Arg0ValueChangedCallback();
264266
void RunArgsValueChangedCallback();

lldb/source/Target/Target.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "lldb/Symbol/ObjectFile.h"
4444
#include "lldb/Symbol/Symbol.h"
4545
#include "lldb/Target/ABI.h"
46+
#include "lldb/Target/ExecutionContext.h"
4647
#include "lldb/Target/Language.h"
4748
#include "lldb/Target/LanguageRuntime.h"
4849
#include "lldb/Target/Process.h"
@@ -4227,28 +4228,21 @@ void TargetProperties::UpdateLaunchInfoFromProperties() {
42274228
DisableSTDIOValueChangedCallback();
42284229
}
42294230

4230-
bool TargetProperties::GetInjectLocalVariables(
4231-
ExecutionContext *exe_ctx) const {
4231+
std::optional<bool> TargetProperties::GetExperimentalPropertyValue(
4232+
size_t prop_idx, ExecutionContext *exe_ctx) const {
42324233
const Property *exp_property =
42334234
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx);
42344235
OptionValueProperties *exp_values =
42354236
exp_property->GetValue()->GetAsProperties();
42364237
if (exp_values)
4237-
return exp_values
4238-
->GetPropertyAtIndexAs<bool>(ePropertyInjectLocalVars, exe_ctx)
4239-
.value_or(true);
4240-
else
4241-
return true;
4238+
return exp_values->GetPropertyAtIndexAs<bool>(prop_idx, exe_ctx);
4239+
return std::nullopt;
42424240
}
42434241

4244-
void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx,
4245-
bool b) {
4246-
const Property *exp_property =
4247-
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx);
4248-
OptionValueProperties *exp_values =
4249-
exp_property->GetValue()->GetAsProperties();
4250-
if (exp_values)
4251-
exp_values->SetPropertyAtIndex(ePropertyInjectLocalVars, true, exe_ctx);
4242+
bool TargetProperties::GetInjectLocalVariables(
4243+
ExecutionContext *exe_ctx) const {
4244+
return GetExperimentalPropertyValue(ePropertyInjectLocalVars, exe_ctx)
4245+
.value_or(true);
42524246
}
42534247

42544248
ArchSpec TargetProperties::GetDefaultArchitecture() const {

0 commit comments

Comments
 (0)