aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectExpression.cpp
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2021-04-22 18:44:58 +0200
committerRaphael Isemann <teemperor@gmail.com>2021-04-22 18:51:03 +0200
commitd616a6bd107fcc0dc74f79e174e0b4fe27b26fe6 (patch)
treedc288f8e5ce24a204315d6217c075b3f19543134 /lldb/source/Commands/CommandObjectExpression.cpp
parent77f14c96e53a4b4bbef9f5b4c925f24eab1b5835 (diff)
downloadllvm-d616a6bd107fcc0dc74f79e174e0b4fe27b26fe6.zip
llvm-d616a6bd107fcc0dc74f79e174e0b4fe27b26fe6.tar.gz
llvm-d616a6bd107fcc0dc74f79e174e0b4fe27b26fe6.tar.bz2
[lldb] Fix that the expression commands --top-level flag overwrites --allow-jit false
The `--allow-jit` flag allows the user to force the IR interpreter to run the provided expression. The `--top-level` flag parses and injects the code as if its in the top level scope of a source file. Both flags just change the ExecutionPolicy of the expression: * `--allow-jit true` -> doesn't change anything (its the default) * `--allow-jit false` -> ExecutionPolicyNever * `--top-level` -> ExecutionPolicyTopLevel Passing `--allow-jit false` and `--top-level` currently causes the `--top-level` to silently overwrite the ExecutionPolicy value that was set by `--allow-jit false`. There isn't any ExecutionPolicy value that says "top-level but only interpret", so I would say we reject this combination of flags until someone finds time to refactor top-level feature out of the ExecutionPolicy enum. The SBExpressionOptions suffer from a similar symptom as `SetTopLevel` and `SetAllowJIT` just silently disable each other. But those functions don't have any error handling, so not a lot we can do about this in the meantime. Reviewed By: labath, kastiglione Differential Revision: https://reviews.llvm.org/D91780
Diffstat (limited to 'lldb/source/Commands/CommandObjectExpression.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectExpression.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp
index c7866f9..4f4318e 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -408,6 +408,13 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
lldb::ValueObjectSP result_valobj_sp;
StackFrame *frame = exe_ctx.GetFramePtr();
+ if (m_command_options.top_level && !m_command_options.allow_jit) {
+ result.AppendErrorWithFormat(
+ "Can't disable JIT compilation for top-level expressions.\n");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
const EvaluateExpressionOptions options = GetEvalOptions(target);
ExpressionResults success = target.EvaluateExpression(
expr, frame, result_valobj_sp, options, &m_fixed_expression);