[Lldb-commits] [PATCH] D149719: [LLDB] Add a hook to notify REPLs that an expression was evaluated
walter erquinigo via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue May 2 19:44:05 PDT 2023
wallace created this revision.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
REPL implementations don't have an easy way to know that an expression has been evaluated, so I'm adding a simple function for that. In the future we can add another hook for meta commands.
Repository:
rG LLVM Github Monorepo
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,7 +342,8 @@
expr_prefix, result_valobj_sp, error,
nullptr); // fixed expression
- // CommandInterpreter &ci = debugger.GetCommandInterpreter();
+ OnExpressionEvaluated(exe_ctx, code, expr_options, execution_results,
+ result_valobj_sp, error);
if (process_sp && process_sp->IsAlive()) {
bool add_to_code = true;
Index: lldb/include/lldb/Expression/REPL.h
===================================================================
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -107,6 +107,18 @@
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 included by this method.
+ virtual void
+ 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) {}
+
static int CalculateActualIndentation(const StringList &lines);
// Subclasses should override these functions to implement a functional REPL.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149719.518950.patch
Type: text/x-patch
Size: 1731 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230503/e6835e6b/attachment-0001.bin>
More information about the lldb-commits
mailing list