[Lldb-commits] [PATCH] D91780: [lldb] Fix that the expression commands --top-level flag overwrites --allow-jit false

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 22 09:51:32 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd616a6bd107f: [lldb] Fix that the expression commands --top-level flag overwrites --allow-jit… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91780/new/

https://reviews.llvm.org/D91780

Files:
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/test/API/commands/expression/dont_allow_jit/TestAllowJIT.py


Index: lldb/test/API/commands/expression/dont_allow_jit/TestAllowJIT.py
===================================================================
--- lldb/test/API/commands/expression/dont_allow_jit/TestAllowJIT.py
+++ lldb/test/API/commands/expression/dont_allow_jit/TestAllowJIT.py
@@ -80,3 +80,16 @@
         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")
Index: lldb/source/Commands/CommandObjectExpression.cpp
===================================================================
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -408,6 +408,13 @@
   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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91780.339693.patch
Type: text/x-patch
Size: 2025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210422/77b7fec0/attachment.bin>


More information about the lldb-commits mailing list