Skip to content

Commit 8ac0aaa

Browse files
authored
[lldb] Improve user expression diagnostics (#123242)
This patch rewords some of the user expression diagnostics. - Differentiate between being interrupted and hitting a breakpoint. - Use "expression execution" to make it more obvious that the diagnostic is associated with the user expression. - Consistently use a colon instead of semicolons and commas. rdar://143059974
1 parent 13c7617 commit 8ac0aaa

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

Diff for: lldb/source/Expression/LLVMUserExpression.cpp

+28-20
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,22 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager,
187187
if (execution_result == lldb::eExpressionInterrupted ||
188188
execution_result == lldb::eExpressionHitBreakpoint) {
189189
const char *error_desc = nullptr;
190+
const char *explanation = execution_result == lldb::eExpressionInterrupted
191+
? "was interrupted"
192+
: "hit a breakpoint";
190193

191194
if (user_expression_plan) {
192195
if (auto real_stop_info_sp = user_expression_plan->GetRealStopInfo())
193196
error_desc = real_stop_info_sp->GetDescription();
194197
}
198+
195199
if (error_desc)
196200
diagnostic_manager.Printf(lldb::eSeverityError,
197-
"Execution was interrupted, reason: %s.",
201+
"Expression execution %s: %s.", explanation,
198202
error_desc);
199203
else
200-
diagnostic_manager.PutString(lldb::eSeverityError,
201-
"Execution was interrupted.");
204+
diagnostic_manager.Printf(lldb::eSeverityError,
205+
"Expression execution %s.", explanation);
202206

203207
if ((execution_result == lldb::eExpressionInterrupted &&
204208
options.DoesUnwindOnError()) ||
@@ -212,31 +216,35 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager,
212216
user_expression_plan->TransferExpressionOwnership();
213217
diagnostic_manager.AppendMessageToDiagnostic(
214218
"The process has been left at the point where it was "
215-
"interrupted, "
216-
"use \"thread return -x\" to return to the state before "
217-
"expression evaluation.");
219+
"interrupted, use \"thread return -x\" to return to the state "
220+
"before expression evaluation.");
218221
}
219222

220223
return execution_result;
221-
} else if (execution_result == lldb::eExpressionStoppedForDebug) {
224+
}
225+
226+
if (execution_result == lldb::eExpressionStoppedForDebug) {
222227
diagnostic_manager.PutString(
223228
lldb::eSeverityInfo,
224-
"Execution was halted at the first instruction of the expression "
225-
"function because \"debug\" was requested.\n"
229+
"Expression execution was halted at the first instruction of the "
230+
"expression function because \"debug\" was requested.\n"
226231
"Use \"thread return -x\" to return to the state before expression "
227232
"evaluation.");
228233
return execution_result;
229-
} else if (execution_result == lldb::eExpressionThreadVanished) {
230-
diagnostic_manager.Printf(
231-
lldb::eSeverityError,
232-
"Couldn't complete execution; the thread "
233-
"on which the expression was being run: 0x%" PRIx64
234-
" exited during its execution.",
235-
expr_thread_id);
234+
}
235+
236+
if (execution_result == lldb::eExpressionThreadVanished) {
237+
diagnostic_manager.Printf(lldb::eSeverityError,
238+
"Couldn't execute expression: the thread on "
239+
"which the expression was being run (0x%" PRIx64
240+
") exited during its execution.",
241+
expr_thread_id);
236242
return execution_result;
237-
} else if (execution_result != lldb::eExpressionCompleted) {
243+
}
244+
245+
if (execution_result != lldb::eExpressionCompleted) {
238246
diagnostic_manager.Printf(lldb::eSeverityError,
239-
"Couldn't execute function; result was %s",
247+
"Couldn't execute expression: result was %s",
240248
toString(execution_result).c_str());
241249
return execution_result;
242250
}
@@ -245,9 +253,9 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager,
245253
if (FinalizeJITExecution(diagnostic_manager, exe_ctx, result,
246254
function_stack_bottom, function_stack_top)) {
247255
return lldb::eExpressionCompleted;
248-
} else {
249-
return lldb::eExpressionResultUnavailable;
250256
}
257+
258+
return lldb::eExpressionResultUnavailable;
251259
}
252260

253261
bool LLVMUserExpression::FinalizeJITExecution(

Diff for: lldb/test/API/commands/expression/call-function/TestCallStopAndContinue.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test(self):
3131
self.expect(
3232
"expr -i false -- returnsFive()",
3333
error=True,
34-
substrs=["Execution was interrupted, reason: breakpoint"],
34+
substrs=["Expression execution hit a breakpoint: breakpoint"],
3535
)
3636

3737
self.runCmd("continue", "Continue completed")

Diff for: lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Test stopping at a breakpoint in an expression, and unwinding from there.
33
"""
44

5-
65
import lldb
76
from lldbsuite.test.decorators import *
87
from lldbsuite.test.lldbtest import *
@@ -71,7 +70,7 @@ def do_unwind_test(self, thread, bkpt, timeout):
7170
self.assertTrue(val.GetError().Fail(), "We did not complete the execution.")
7271
error_str = val.GetError().GetCString()
7372
self.assertIn(
74-
"Execution was interrupted, reason: breakpoint",
73+
"Expression execution hit a breakpoint: breakpoint",
7574
error_str,
7675
"And the reason was right.",
7776
)

0 commit comments

Comments
 (0)