This revision was automatically updated to reflect the committed changes.
Closed by commit rGbfb7c99f3aea: [LLDB] Add a hook to notify REPLs that an 
expression was evaluated (authored by wallace).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149719/new/

https://reviews.llvm.org/D149719

Files:
  lldb/include/lldb/Expression/REPL.h
  lldb/source/Expression/REPL.cpp


Index: lldb/source/Expression/REPL.cpp
===================================================================
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -342,9 +342,11 @@
                                    expr_prefix, result_valobj_sp, error,
                                    nullptr); // fixed expression
 
-      // CommandInterpreter &ci = debugger.GetCommandInterpreter();
-
-      if (process_sp && process_sp->IsAlive()) {
+      if (llvm::Error err = OnExpressionEvaluated(exe_ctx, code, expr_options,
+                                                  execution_results,
+                                                  result_valobj_sp, error)) {
+        *error_sp << llvm::toString(std::move(err)) << "\n";
+      } else if (process_sp && process_sp->IsAlive()) {
         bool add_to_code = true;
         bool handled = false;
         if (result_valobj_sp) {
Index: lldb/include/lldb/Expression/REPL.h
===================================================================
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -107,6 +107,24 @@
                          CompletionRequest &request) override;
 
 protected:
+  /// Method that can be optionally overriden by subclasses to get notified
+  /// whenever an expression has been evaluated. The params of this method
+  /// include the inputs and outputs of the expression evaluation.
+  ///
+  /// Note: meta commands that start with : are not covered by this method.
+  ///
+  /// \return
+  ///   An \a Error object that, if it is a failure, aborts the regular
+  ///   REPL expression result handling.
+  virtual llvm::Error
+  OnExpressionEvaluated(const ExecutionContext &exe_ctx, llvm::StringRef code,
+                        const EvaluateExpressionOptions &expr_options,
+                        lldb::ExpressionResults execution_results,
+                        const lldb::ValueObjectSP &result_valobj_sp,
+                        const Status &error) {
+    return llvm::Error::success();
+  }
+
   static int CalculateActualIndentation(const StringList &lines);
 
   // Subclasses should override these functions to implement a functional REPL.


Index: lldb/source/Expression/REPL.cpp
===================================================================
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -342,9 +342,11 @@
                                    expr_prefix, result_valobj_sp, error,
                                    nullptr); // fixed expression
 
-      // CommandInterpreter &ci = debugger.GetCommandInterpreter();
-
-      if (process_sp && process_sp->IsAlive()) {
+      if (llvm::Error err = OnExpressionEvaluated(exe_ctx, code, expr_options,
+                                                  execution_results,
+                                                  result_valobj_sp, error)) {
+        *error_sp << llvm::toString(std::move(err)) << "\n";
+      } else if (process_sp && process_sp->IsAlive()) {
         bool add_to_code = true;
         bool handled = false;
         if (result_valobj_sp) {
Index: lldb/include/lldb/Expression/REPL.h
===================================================================
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -107,6 +107,24 @@
                          CompletionRequest &request) override;
 
 protected:
+  /// Method that can be optionally overriden by subclasses to get notified
+  /// whenever an expression has been evaluated. The params of this method
+  /// include the inputs and outputs of the expression evaluation.
+  ///
+  /// Note: meta commands that start with : are not covered by this method.
+  ///
+  /// \return
+  ///   An \a Error object that, if it is a failure, aborts the regular
+  ///   REPL expression result handling.
+  virtual llvm::Error
+  OnExpressionEvaluated(const ExecutionContext &exe_ctx, llvm::StringRef code,
+                        const EvaluateExpressionOptions &expr_options,
+                        lldb::ExpressionResults execution_results,
+                        const lldb::ValueObjectSP &result_valobj_sp,
+                        const Status &error) {
+    return llvm::Error::success();
+  }
+
   static int CalculateActualIndentation(const StringList &lines);
 
   // Subclasses should override these functions to implement a functional REPL.
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to