Skip to content

Commit 3fcc302

Browse files
[lldb] Add a progress event for executing an expression (llvm#119757)
Expressions can take arbitrary amounts of time to run, so IDEs might want to be informed about the fact that an expression is currently being executed. rdar://141253078
1 parent 0d9fc17 commit 3fcc302

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

lldb/source/Expression/FunctionCaller.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "lldb/Expression/FunctionCaller.h"
1010
#include "lldb/Core/Module.h"
11+
#include "lldb/Core/Progress.h"
1112
#include "lldb/Expression/DiagnosticManager.h"
1213
#include "lldb/Expression/IRExecutionUnit.h"
1314
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -338,6 +339,10 @@ lldb::ExpressionResults FunctionCaller::ExecuteFunction(
338339
DiagnosticManager &diagnostic_manager, Value &results) {
339340
lldb::ExpressionResults return_value = lldb::eExpressionSetupError;
340341

342+
Debugger *debugger =
343+
exe_ctx.GetTargetPtr() ? &exe_ctx.GetTargetPtr()->GetDebugger() : nullptr;
344+
Progress progress("Calling function", FunctionName(), {}, debugger);
345+
341346
// FunctionCaller::ExecuteFunction execution is always just to get the
342347
// result. Unless explicitly asked for, ignore breakpoints and unwind on
343348
// error.

lldb/source/Expression/UserExpression.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <string>
1515

1616
#include "lldb/Core/Module.h"
17+
#include "lldb/Core/Progress.h"
1718
#include "lldb/Expression/DiagnosticManager.h"
1819
#include "lldb/Expression/ExpressionVariable.h"
1920
#include "lldb/Expression/IRExecutionUnit.h"
@@ -424,6 +425,18 @@ UserExpression::Execute(DiagnosticManager &diagnostic_manager,
424425
const EvaluateExpressionOptions &options,
425426
lldb::UserExpressionSP &shared_ptr_to_me,
426427
lldb::ExpressionVariableSP &result_var) {
428+
Debugger *debugger =
429+
exe_ctx.GetTargetPtr() ? &exe_ctx.GetTargetPtr()->GetDebugger() : nullptr;
430+
std::string details;
431+
if (m_options.IsForUtilityExpr())
432+
details = "LLDB utility";
433+
else if (m_expr_text.size() > 15)
434+
details = m_expr_text.substr(0, 14) + "";
435+
else
436+
details = m_expr_text;
437+
438+
Progress progress("Running expression", details, {}, debugger);
439+
427440
lldb::ExpressionResults expr_result = DoExecute(
428441
diagnostic_manager, exe_ctx, options, shared_ptr_to_me, result_var);
429442
Target *target = exe_ctx.GetTargetPtr();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# RUN: %lldb -s %s | FileCheck %s
2+
log enable lldb event
3+
expr 1
4+
expr 1 // And a very long comment.
5+
quit
6+
7+
# CHECK: {{title = "Running expression", details = "1"}}
8+
# CHECK: {{title = "Running expression", details = "1 // And a ver…"}}

0 commit comments

Comments
 (0)