[Lldb-commits] [lldb] [lldb] Add interface to check if UserExpression::Parse() is cacheable (PR #66826)
Augusto Noronha via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 19 14:37:48 PDT 2023
https://github.com/augusto2112 created https://github.com/llvm/llvm-project/pull/66826
When setting conditional breakpoints, we currently assume that a call to UserExpression::Parse() can be cached and resued multiple times. This may not be true for every user expression. Add a new method so subclasses of UserExpression can customize if they are parseable or not.
>From 5593f33bea5ebf0362b69d4b4a70a65edd77ca9d Mon Sep 17 00:00:00 2001
From: Augusto Noronha <augusto2112 at me.com>
Date: Tue, 19 Sep 2023 13:27:41 -0700
Subject: [PATCH] [lldb] Add interface to check if UserExpression::Parse() is
cacheable
When setting conditional breakpoints, we currently assume that a call to
UserExpression::Parse() can be cached and resued multiple times. This
may not be true for every user expression. Add a new method so
subclasses of UserExpression can customize if they are parseable or not.
---
lldb/include/lldb/Expression/UserExpression.h | 2 ++
lldb/source/Breakpoint/BreakpointLocation.cpp | 1 +
2 files changed, 3 insertions(+)
diff --git a/lldb/include/lldb/Expression/UserExpression.h b/lldb/include/lldb/Expression/UserExpression.h
index 2d62fa37a24c2c4..03aa5e87c4cd579 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -192,6 +192,8 @@ class UserExpression : public Expression {
/// expression. Text() should contain the definition of this function.
const char *FunctionName() override { return "$__lldb_expr"; }
+ /// Returns whether the call to Parse on this user expression is cacheable.
+ virtual bool IsParseCacheable() { return true; }
/// Return the language that should be used when parsing. To use the
/// default, return eLanguageTypeUnknown.
lldb::LanguageType Language() const override { return m_language; }
diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp
index 0fcefe5c63be749..2d2e00883f32ef7 100644
--- a/lldb/source/Breakpoint/BreakpointLocation.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -250,6 +250,7 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
DiagnosticManager diagnostics;
if (condition_hash != m_condition_hash || !m_user_expression_sp ||
+ !m_user_expression_sp->IsParseCacheable() ||
!m_user_expression_sp->MatchesContext(exe_ctx)) {
LanguageType language = eLanguageTypeUnknown;
// See if we can figure out the language from the frame, otherwise use the
More information about the lldb-commits
mailing list