Skip to content

Conversation

@adrian-prantl
Copy link
Collaborator

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

@llvmbot
Copy link
Member

llvmbot commented Dec 12, 2024

@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/119757.diff

2 Files Affected:

  • (modified) lldb/source/Expression/UserExpression.cpp (+9)
  • (added) lldb/test/Shell/Expr/TestExecProgress.test (+6)
diff --git a/lldb/source/Expression/UserExpression.cpp b/lldb/source/Expression/UserExpression.cpp
index f1f69ae1c89b85..aa0516c43d139b 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -14,6 +14,7 @@
 #include <string>
 
 #include "lldb/Core/Module.h"
+#include "lldb/Core/Progress.h"
 #include "lldb/Expression/DiagnosticManager.h"
 #include "lldb/Expression/ExpressionVariable.h"
 #include "lldb/Expression/IRExecutionUnit.h"
@@ -424,6 +425,14 @@ UserExpression::Execute(DiagnosticManager &diagnostic_manager,
                         const EvaluateExpressionOptions &options,
                         lldb::UserExpressionSP &shared_ptr_to_me,
                         lldb::ExpressionVariableSP &result_var) {
+  Debugger *debugger =
+      exe_ctx.GetTargetPtr() ? &exe_ctx.GetTargetPtr()->GetDebugger() : nullptr;
+  Progress progress("Running expression",
+                    m_options.IsForUtilityExpr()
+                        ? "(LLDB utility)"
+                        : m_expr_text.substr(0, 12) + "...",
+                    {}, debugger);
+
   lldb::ExpressionResults expr_result = DoExecute(
       diagnostic_manager, exe_ctx, options, shared_ptr_to_me, result_var);
   Target *target = exe_ctx.GetTargetPtr();
diff --git a/lldb/test/Shell/Expr/TestExecProgress.test b/lldb/test/Shell/Expr/TestExecProgress.test
new file mode 100644
index 00000000000000..93a8469f18ce06
--- /dev/null
+++ b/lldb/test/Shell/Expr/TestExecProgress.test
@@ -0,0 +1,6 @@
+# RUN: %lldb -s %s  | FileCheck %s
+log enable lldb event
+expr 1
+quit
+
+# CHECK: {{title = "Running expression", details = "1}}

@adrian-prantl adrian-prantl force-pushed the 141253078 branch 2 times, most recently from c014afa to 9a4f8c4 Compare December 12, 2024 23:35
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
@adrian-prantl adrian-prantl merged commit 3fcc302 into llvm:main Dec 13, 2024
7 checks passed
adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Dec 13, 2024
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)
adrian-prantl added a commit to swiftlang/llvm-project that referenced this pull request Dec 13, 2024
…23-lldb-Add-a-progress-event-for-executing-an-expression-119757

[Cherry-pick into stable/20240723] [lldb] Add a progress event for executing an expression (llvm#119757)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants