Skip to content

Commit 4c356df

Browse files
committed
[lldb/Expression] Improve interpreter error message with a non-running target
When trying to interpret an expression with a function call, if the process hasn't been launched, the expression fails to be interpreted and the user gets the following error message: ```error: Can't run the expression locally``` This message doesn't explain why the expression failed to be interpreted, that's why this patch improves the error message that is displayed when trying to run an expression while no process is running. rdar://11991708 Differential Revision: https://reviews.llvm.org/D72510 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent a44ccf3 commit 4c356df

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lldb/packages/Python/lldbsuite/test/commands/expression/dont_allow_jit/TestAllowJIT.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ def expr_cmd_test(self):
4040
"Set a breakpoint here", self.main_source_file)
4141

4242
frame = thread.GetFrameAtIndex(0)
43-
43+
4444
# First make sure we can call the function with
4545
interp = self.dbg.GetCommandInterpreter()
4646
self.expect("expr --allow-jit 1 -- call_me(10)",
4747
substrs = ["(int) $", "= 18"])
4848
# Now make sure it fails with the "can't IR interpret message" if allow-jit is false:
4949
self.expect("expr --allow-jit 0 -- call_me(10)",
5050
error=True,
51-
substrs = ["Can't run the expression locally"])
52-
51+
substrs = ["Can't evaluate the expression without a running target"])
52+
5353
def expr_options_test(self):
5454
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
5555
"Set a breakpoint here", self.main_source_file)
@@ -74,7 +74,7 @@ def expr_options_test(self):
7474
# Again use it and ensure we fail:
7575
result = frame.EvaluateExpression("call_me(10)", options)
7676
self.assertTrue(result.GetError().Fail(), "expression failed with no JIT")
77-
self.assertTrue("Can't run the expression locally" in result.GetError().GetCString(), "Got right error")
77+
self.assertTrue("Can't evaluate the expression without a running target" in result.GetError().GetCString(), "Got right error")
7878

7979
# Finally set the allow JIT value back to true and make sure that works:
8080
options.SetAllowJIT(True)

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,8 +1253,9 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution(
12531253
interpret_error, interpret_function_calls);
12541254

12551255
if (!can_interpret && execution_policy == eExecutionPolicyNever) {
1256-
err.SetErrorStringWithFormat("Can't run the expression locally: %s",
1257-
interpret_error.AsCString());
1256+
err.SetErrorStringWithFormat(
1257+
"Can't evaluate the expression without a running target due to: %s",
1258+
interpret_error.AsCString());
12581259
return err;
12591260
}
12601261
}

0 commit comments

Comments
 (0)