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);
self.assertSuccess(result.GetError())
self.assertEqual(result.GetValueAsSigned(), 18, "got the right value.")
+ def test_allow_jit_with_top_level(self):
+ """Test combined --allow-jit and --top-level flags"""
+ # Can't force interpreting for top-level expressions which are always
+ # injected.
+ self.expect("expr --allow-jit false --top-level -- int i;", error=True,
+ substrs=["Can't disable JIT compilation for top-level expressions."])
+
+ self.build()
+ lldbutil.run_to_source_breakpoint(self, "Set a breakpoint here", lldb.SBFileSpec("main.c"))
+ # Allowing JITing for top-level expressions is redundant but should work.
+ self.expect("expr --allow-jit true --top-level -- int top_level_f() { return 2; }")
+ # Make sure we actually declared a working top-level function.
+ self.expect_expr("top_level_f()", result_value="2")