Skip to content

Commit

Permalink
[lldb] Extract getter function for experimental target properties (NF…
Browse files Browse the repository at this point in the history
…C) (#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.
  • Loading branch information
kastiglione committed Mar 7, 2024
1 parent c7fbbec commit ca7492f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
6 changes: 4 additions & 2 deletions lldb/include/lldb/Target/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
24 changes: 9 additions & 15 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ca7492f

Please sign in to comment.