Skip to content

[lldb] Add interface to check if UserExpression::Parse() is cacheable #66826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lldb/include/lldb/Expression/UserExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 different 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; }
Expand Down
1 change: 1 addition & 0 deletions lldb/source/Breakpoint/BreakpointLocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down