diff --git a/lldb/include/lldb/Target/StackFrame.h b/lldb/include/lldb/Target/StackFrame.h index 3881137583b94..fce3a943413ca 100644 --- a/lldb/include/lldb/Target/StackFrame.h +++ b/lldb/include/lldb/Target/StackFrame.h @@ -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; diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index cab21c29a7486..b5becfb0e4fe1 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -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; diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 3761b867452c9..25b50a070f0e2 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -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()) diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 242d2eaec2a15..57ecbbc29bce6 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -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(ePropertyUseDIL, exe_ctx) + .value_or(false); + else + return true; +} + +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(idx, {}); diff --git a/lldb/source/Target/TargetProperties.td b/lldb/source/Target/TargetProperties.td index 00ad8dd2a9f7f..8978a4a143b6f 100644 --- a/lldb/source/Target/TargetProperties.td +++ b/lldb/source/Target/TargetProperties.td @@ -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 {