diff options
author | Dave Lee <davelee.com@gmail.com> | 2023-02-15 08:23:57 -0800 |
---|---|---|
committer | Dave Lee <davelee.com@gmail.com> | 2023-02-17 17:50:08 -0800 |
commit | 920b46e108b23454e6827ed0fa5e0a69fcb4a6e6 (patch) | |
tree | 99adc2826326883ec2b78c9e6fffe38537ffae9b /lldb/source/Commands/CommandObjectExpression.cpp | |
parent | e49b93ef29a6559b5c2c9d51b5bcd299ca7cb91e (diff) | |
download | llvm-920b46e108b23454e6827ed0fa5e0a69fcb4a6e6.zip llvm-920b46e108b23454e6827ed0fa5e0a69fcb4a6e6.tar.gz llvm-920b46e108b23454e6827ed0fa5e0a69fcb4a6e6.tar.bz2 |
[lldb] Add expression command options in dwim-print
Adopt `expression`'s options in `dwim-print`.
This is primarily added to support the `--language`/`-l` flag.
Differential Revision: https://reviews.llvm.org/D144114
Diffstat (limited to 'lldb/source/Commands/CommandObjectExpression.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 89 |
1 files changed, 44 insertions, 45 deletions
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 9402000..f576729 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -181,6 +181,48 @@ CommandObjectExpression::CommandOptions::GetDefinitions() { return llvm::ArrayRef(g_expression_options); } +EvaluateExpressionOptions +CommandObjectExpression::CommandOptions::GetEvaluateExpressionOptions( + const Target &target, const OptionGroupValueObjectDisplay &display_opts) { + EvaluateExpressionOptions options; + options.SetCoerceToId(display_opts.use_objc); + if (m_verbosity == eLanguageRuntimeDescriptionDisplayVerbosityCompact) + options.SetSuppressPersistentResult(display_opts.use_objc); + options.SetUnwindOnError(unwind_on_error); + options.SetIgnoreBreakpoints(ignore_breakpoints); + options.SetKeepInMemory(true); + options.SetUseDynamic(display_opts.use_dynamic); + options.SetTryAllThreads(try_all_threads); + options.SetDebug(debug); + options.SetLanguage(language); + options.SetExecutionPolicy( + allow_jit ? EvaluateExpressionOptions::default_execution_policy + : lldb_private::eExecutionPolicyNever); + + bool auto_apply_fixits; + if (this->auto_apply_fixits == eLazyBoolCalculate) + auto_apply_fixits = target.GetEnableAutoApplyFixIts(); + else + auto_apply_fixits = this->auto_apply_fixits == eLazyBoolYes; + + options.SetAutoApplyFixIts(auto_apply_fixits); + options.SetRetriesWithFixIts(target.GetNumberOfRetriesWithFixits()); + + if (top_level) + options.SetExecutionPolicy(eExecutionPolicyTopLevel); + + // If there is any chance we are going to stop and want to see what went + // wrong with our expression, we should generate debug info + if (!ignore_breakpoints || !unwind_on_error) + options.SetGenerateDebugInfo(true); + + if (timeout > 0) + options.SetTimeout(std::chrono::microseconds(timeout)); + else + options.SetTimeout(std::nullopt); + return options; +} + CommandObjectExpression::CommandObjectExpression( CommandInterpreter &interpreter) : CommandObjectRaw(interpreter, "expression", @@ -343,50 +385,6 @@ CanBeUsedForElementCountPrinting(ValueObject &valobj) { return Status(); } -EvaluateExpressionOptions -CommandObjectExpression::GetEvalOptions(const Target &target) { - EvaluateExpressionOptions options; - options.SetCoerceToId(m_varobj_options.use_objc); - if (m_command_options.m_verbosity == - eLanguageRuntimeDescriptionDisplayVerbosityCompact) - options.SetSuppressPersistentResult(m_varobj_options.use_objc); - options.SetUnwindOnError(m_command_options.unwind_on_error); - options.SetIgnoreBreakpoints(m_command_options.ignore_breakpoints); - options.SetKeepInMemory(true); - options.SetUseDynamic(m_varobj_options.use_dynamic); - options.SetTryAllThreads(m_command_options.try_all_threads); - options.SetDebug(m_command_options.debug); - options.SetLanguage(m_command_options.language); - options.SetExecutionPolicy( - m_command_options.allow_jit - ? EvaluateExpressionOptions::default_execution_policy - : lldb_private::eExecutionPolicyNever); - - bool auto_apply_fixits; - if (m_command_options.auto_apply_fixits == eLazyBoolCalculate) - auto_apply_fixits = target.GetEnableAutoApplyFixIts(); - else - auto_apply_fixits = m_command_options.auto_apply_fixits == eLazyBoolYes; - - options.SetAutoApplyFixIts(auto_apply_fixits); - options.SetRetriesWithFixIts(target.GetNumberOfRetriesWithFixits()); - - if (m_command_options.top_level) - options.SetExecutionPolicy(eExecutionPolicyTopLevel); - - // If there is any chance we are going to stop and want to see what went - // wrong with our expression, we should generate debug info - if (!m_command_options.ignore_breakpoints || - !m_command_options.unwind_on_error) - options.SetGenerateDebugInfo(true); - - if (m_command_options.timeout > 0) - options.SetTimeout(std::chrono::microseconds(m_command_options.timeout)); - else - options.SetTimeout(std::nullopt); - return options; -} - bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr, Stream &output_stream, Stream &error_stream, @@ -407,7 +405,8 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr, return false; } - const EvaluateExpressionOptions options = GetEvalOptions(target); + const EvaluateExpressionOptions options = + m_command_options.GetEvaluateExpressionOptions(target, m_varobj_options); ExpressionResults success = target.EvaluateExpression( expr, frame, result_valobj_sp, options, &m_fixed_expression); |