[Lldb-commits] [lldb] 4639610 - [lldb] Add interface to check if UserExpression::Parse() is cacheable (#66826)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 16 14:20:19 PST 2023
Author: Augusto Noronha
Date: 2023-11-16T14:20:14-08:00
New Revision: 46396108deb24564159c441c6e6ebfac26714d7b
URL: https://github.com/llvm/llvm-project/commit/46396108deb24564159c441c6e6ebfac26714d7b
DIFF: https://github.com/llvm/llvm-project/commit/46396108deb24564159c441c6e6ebfac26714d7b.diff
LOG: [lldb] Add interface to check if UserExpression::Parse() is cacheable (#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.
Added:
Modified:
lldb/include/lldb/Expression/UserExpression.h
lldb/source/Breakpoint/BreakpointLocation.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Expression/UserExpression.h b/lldb/include/lldb/Expression/UserExpression.h
index df7a76664f6d5b6..b6cfeec7e899330 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -192,6 +192,14 @@ 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.
+ /// This function exists to provide an escape hatch for supporting languages
+ /// where parsing an expression in the exact same context is unsafe. For
+ /// example, languages where generic functions aren't monomorphized, but
+ /// implement some other mechanism to represent generic values, may be unsafe
+ /// to cache, as the concrete type substitution may be
diff erent in every
+ /// expression evaluation.
+ 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 27dc7458dc26f70..931e1ad4b2d9339 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