Skip to content

[LLDB] Add framework for Data Inspection Language (DIL) work. #115666

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

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lldb/include/lldb/Target/StackFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,16 @@ class StackFrame : public ExecutionContextScope,
bool HasCachedData() const;

private:
/// Private methods, called from GetValueForVariableExpressionPath.
/// See that method for documentation of parameters and return value.
lldb::ValueObjectSP LegacyGetValueForVariableExpressionPath(
llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic,
uint32_t options, lldb::VariableSP &var_sp, Status &error);

lldb::ValueObjectSP DILGetValueForVariableExpressionPath(
llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic,
uint32_t options, lldb::VariableSP &var_sp, Status &error);

/// For StackFrame only.
/// \{
lldb::ThreadWP m_thread_wp;
Expand Down
4 changes: 4 additions & 0 deletions lldb/include/lldb/Target/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ class TargetProperties : public Properties {

bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const;

bool GetUseDIL(ExecutionContext *exe_ctx) const;

void SetUseDIL(ExecutionContext *exe_ctx, bool b);

void SetRequireHardwareBreakpoints(bool b);

bool GetRequireHardwareBreakpoints() const;
Expand Down
23 changes: 23 additions & 0 deletions lldb/source/Target/StackFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,29 @@ StackFrame::GetInScopeVariableList(bool get_file_globals,
ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
llvm::StringRef var_expr, DynamicValueType use_dynamic, uint32_t options,
VariableSP &var_sp, Status &error) {
ExecutionContext exe_ctx;
CalculateExecutionContext(exe_ctx);
bool use_DIL = exe_ctx.GetTargetRef().GetUseDIL(&exe_ctx);
if (use_DIL)
return DILGetValueForVariableExpressionPath(var_expr, use_dynamic, options,
var_sp, error);

return LegacyGetValueForVariableExpressionPath(var_expr, use_dynamic, options,
var_sp, error);
}

ValueObjectSP StackFrame::DILGetValueForVariableExpressionPath(
llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic,
uint32_t options, lldb::VariableSP &var_sp, Status &error) {
// This is a place-holder for the calls into the DIL parser and
// evaluator. For now, just call the "real" frame variable implementation.
return LegacyGetValueForVariableExpressionPath(var_expr, use_dynamic, options,
var_sp, error);
}

ValueObjectSP StackFrame::LegacyGetValueForVariableExpressionPath(
llvm::StringRef var_expr, DynamicValueType use_dynamic, uint32_t options,
VariableSP &var_sp, Status &error) {
llvm::StringRef original_var_expr = var_expr;
// We can't fetch variable information for a history stack frame.
if (IsHistorical())
Expand Down
21 changes: 21 additions & 0 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4385,6 +4385,27 @@ bool TargetProperties::GetInjectLocalVariables(
.value_or(true);
}

bool TargetProperties::GetUseDIL(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>(ePropertyUseDIL, exe_ctx)
.value_or(false);
else
return true;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be false as well? Otherwise DIL will be enabled if exp_values is not available (not sure when this happens though).

}

void TargetProperties::SetUseDIL(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(ePropertyUseDIL, true, exe_ctx);
}

ArchSpec TargetProperties::GetDefaultArchitecture() const {
const uint32_t idx = ePropertyDefaultArch;
return GetPropertyAtIndexAs<ArchSpec>(idx, {});
Expand Down
3 changes: 3 additions & 0 deletions lldb/source/Target/TargetProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ let Definition = "target_experimental" in {
def InjectLocalVars : Property<"inject-local-vars", "Boolean">,
Global, DefaultTrue,
Desc<"If true, inject local variables explicitly into the expression text. This will fix symbol resolution when there are name collisions between ivars and local variables. But it can make expressions run much more slowly.">;
def UseDIL : Property<"use-DIL", "Boolean">,
Global, DefaultFalse,
Desc<"If true, use the alternative DIL implementation for frame variable evaluation.">;
}

let Definition = "target" in {
Expand Down
Loading