[Lldb-commits] [lldb] [lldb] Speed up evaluating breakpoint conditions by using DIL (PR #224740)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 18 15:56:11 PDT 2026
================
@@ -226,10 +229,71 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
StopCondition condition = GetCondition();
if (!condition) {
+ m_dil_expr_tree.reset();
m_user_expression_sp.reset();
return false;
}
+ // Attempt to parse the condition using Data Inspection Language (DIL).
+ if (condition.GetHash() != m_condition_hash && exe_ctx.HasFrameScope() &&
+ exe_ctx.GetTargetSP()->GetUseDILForBreakpointConditions()) {
+ // Lex the expression.
+ auto lex_or_err = dil::DILLexer::Create(condition.GetText(), eDILModeFull);
+ if (lex_or_err) {
+ // Parse the expression.
+ auto tree_or_error = dil::DILParser::Parse(
+ condition.GetText(), std::move(*lex_or_err), exe_ctx.GetFrameRef(),
+ lldb::eNoDynamicValues, eDILModeFull);
+ if (tree_or_error) {
+ m_dil_expr_tree = std::move(*tree_or_error);
+ m_condition_hash = condition.GetHash();
+ LLDB_LOGF(log, "DIL successfully parsed the condition: %s.",
+ condition.GetText().str().c_str());
+ } else {
+ m_dil_expr_tree.reset();
+ error = Status::FromError(tree_or_error.takeError());
+ LLDB_LOGF(log, "Parsing condition with DIL failed:\n%s.",
+ error.AsCString());
+ }
+ } else {
+ m_dil_expr_tree.reset();
+ error = Status::FromError(lex_or_err.takeError());
+ LLDB_LOGF(log, "Lexing condition with DIL failed:\n%s.",
+ error.AsCString());
+ }
+ }
+ // If the expression was parsed successfully, it can be evaluated separately
+ // at every breakpoint without having to parse it again.
+ if (m_dil_expr_tree) {
+ dil::Interpreter interpreter(exe_ctx.GetTargetSP(), condition.GetText(),
+ exe_ctx.GetFrameRef(), lldb::eNoDynamicValues,
+ 0);
+ // Evaluate the expression by DIL.
+ auto valobj_or_error = interpreter.Evaluate(*m_dil_expr_tree);
+ if (valobj_or_error) {
+ ValueObjectSP value_sp = *valobj_or_error;
+ if (value_sp && value_sp->GetError().Success()) {
+ llvm::Expected<bool> bool_result = value_sp->GetValueAsBool();
+ if (bool_result) {
+ LLDB_LOGF(log,
----------------
jimingham wrote:
I'd argue both should be verbose, but it's not all that important.
https://github.com/llvm/llvm-project/pull/224740
More information about the lldb-commits
mailing list