Skip to content
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] Factor out function for experimental properties (NFC) #8298

Open
wants to merge 2 commits into
base: stable/20230725
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lldb/include/lldb/Target/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ class TargetProperties : public Properties {
bool GetEnableTrampolineSupport() const;

private:
std::optional<bool>
GetExperimentalPropertyValue(size_t idx,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this function live upstream?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. (on first glance I thought these were all swift, but one property, inject-local-vars, does exist upstream).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll pick llvm#83504 into this branch.

ExecutionContext *exe_ctx = nullptr) const;

// Callbacks for m_launch_info.
void Arg0ValueChangedCallback();
void RunArgsValueChangedCallback();
Expand Down
102 changes: 25 additions & 77 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4874,18 +4874,22 @@ void TargetProperties::UpdateLaunchInfoFromProperties() {
DisableSTDIOValueChangedCallback();
}

bool TargetProperties::GetInjectLocalVariables(
ExecutionContext *exe_ctx) const {
std::optional<bool> TargetProperties::GetExperimentalPropertyValue(
size_t 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>(idx, exe_ctx);

return std::nullopt;
}

bool TargetProperties::GetInjectLocalVariables(
ExecutionContext *exe_ctx) const {
return GetExperimentalPropertyValue(ePropertyInjectLocalVars, exe_ctx)
.value_or(true);
}

void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx,
Expand All @@ -4899,68 +4903,28 @@ void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx,
}

bool TargetProperties::GetSwiftReadMetadataFromFileCache() const {
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (exp_values)
return exp_values
->GetPropertyAtIndexAs<bool>(ePropertySwiftReadMetadataFromFileCache)
.value_or(true);

return true;
return GetExperimentalPropertyValue(ePropertySwiftReadMetadataFromFileCache)
.value_or(true);
}

bool TargetProperties::GetSwiftUseReflectionSymbols() const {
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (exp_values)
return exp_values
->GetPropertyAtIndexAs<bool>(ePropertySwiftUseReflectionSymbols)
.value_or(true);
else
return true;
return GetExperimentalPropertyValue(ePropertySwiftUseReflectionSymbols)
.value_or(true);
}

bool TargetProperties::GetSwiftReadMetadataFromDSYM() const {
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (exp_values)
return exp_values
->GetPropertyAtIndexAs<bool>(ePropertySwiftReadMetadataFromDSYM)
.value_or(true);

return true;
return GetExperimentalPropertyValue(ePropertySwiftReadMetadataFromDSYM)
.value_or(true);
}

bool TargetProperties::GetSwiftDiscoverImplicitSearchPaths() const {
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (exp_values)
return exp_values
->GetPropertyAtIndexAs<bool>(ePropertySwiftDiscoverImplicitSearchPaths)
.value_or(true);

return true;
return GetExperimentalPropertyValue(ePropertySwiftDiscoverImplicitSearchPaths)
.value_or(true);
}

bool TargetProperties::GetSwiftEnableBareSlashRegex() const {
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (exp_values)
return exp_values
->GetPropertyAtIndexAs<bool>(ePropertySwiftEnableBareSlashRegex)
.value_or(true);

return true;
return GetExperimentalPropertyValue(ePropertySwiftEnableBareSlashRegex)
.value_or(true);
}

EnableSwiftCxxInterop TargetProperties::GetEnableSwiftCxxInterop() const {
Expand All @@ -4975,29 +4939,13 @@ EnableSwiftCxxInterop TargetProperties::GetEnableSwiftCxxInterop() const {
}

bool TargetProperties::GetSwiftEnableFullDwarfDebugging() const {
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (exp_values)
return exp_values
->GetPropertyAtIndexAs<bool>(ePropertySwiftEnableFullDwarfDebugging)
.value_or(false);

return false;
return GetExperimentalPropertyValue(ePropertySwiftEnableFullDwarfDebugging)
.value_or(false);
}

bool TargetProperties::GetSwiftAllowExplicitModules() const {
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (exp_values)
return exp_values
->GetPropertyAtIndexAs<bool>(ePropertySwiftAllowExplicitModules)
.value_or(false);

return false;
return GetExperimentalPropertyValue(ePropertySwiftAllowExplicitModules)
.value_or(false);
}

Args TargetProperties::GetSwiftPluginServerForPath() const {
Expand Down