Skip to content

Commit 2568b78

Browse files
committed
[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 (cherry picked from commit 3fcc302)
1 parent 6110cb1 commit 2568b78

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"
@@ -431,6 +432,18 @@ UserExpression::Execute(DiagnosticManager &diagnostic_manager,
431432
const EvaluateExpressionOptions &options,
432433
lldb::UserExpressionSP &shared_ptr_to_me,
433434
lldb::ExpressionVariableSP &result_var) {
435+
Debugger *debugger =
436+
exe_ctx.GetTargetPtr() ? &exe_ctx.GetTargetPtr()->GetDebugger() : nullptr;
437+
std::string details;
438+
if (m_options.IsForUtilityExpr())
439+
details = "LLDB utility";
440+
else if (m_expr_text.size() > 15)
441+
details = m_expr_text.substr(0, 14) + "";
442+
else
443+
details = m_expr_text;
444+
445+
Progress progress("Running expression", details, {}, debugger);
446+
434447
lldb::ExpressionResults expr_result = DoExecute(
435448
diagnostic_manager, exe_ctx, options, shared_ptr_to_me, result_var);
436449
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)