================
@@ -546,3 +595,154 @@ WatchpointSP
Watchpoint::WatchpointEventData::GetWatchpointFromEvent(
return wp_sp;
}
+
+bool Watchpoint::CheckWatchpointCondition(
+ const ExecutionContext &exe_ctx) const {
+ if (GetConditionText() == nullptr)
+ return true;
+
+ Log *log = GetLog(LLDBLog::Watchpoints);
+
+ // We need to make sure the user sees any parse errors in their
+ // condition, so we'll hook the constructor errors up to the
+ // debugger's Async I/O.
+ EvaluateExpressionOptions expr_options;
+ expr_options.SetUnwindOnError(true);
+ expr_options.SetIgnoreBreakpoints(true);
+ ValueObjectSP result_value_sp;
+ ExpressionResults result_code = m_target.EvaluateExpression(
+ GetConditionText(), exe_ctx.GetBestExecutionContextScope(),
+ result_value_sp, expr_options);
+
+ if (!result_value_sp || result_code != eExpressionCompleted) {
+ LLDB_LOGF(log, "Error evaluating condition:\n");
+
+ StreamString strm;
+ strm << "stopped due to an error evaluating condition of "
+ "watchpoint ";
+ GetDescription(&strm, eDescriptionLevelBrief);
+ strm << ": \"" << GetConditionText() << "\"\n";
+
+ Debugger::ReportError(strm.GetString().str(),
+ exe_ctx.GetTargetRef().GetDebugger().GetID());
+ return true;
+ }
+
+ Scalar scalar_value;
+ if (!result_value_sp->ResolveValue(scalar_value)) {
+ LLDB_LOGF(log, "Failed to get an integer result from the expression.");
+ return true;
+ }
+
+ bool should_stop = scalar_value.ULongLong(1) != 0;
+
+ LLDB_LOGF(log, "Condition successfully evaluated, result is %s.\n",
+ should_stop ? "true" : "false");
+
+ return should_stop;
+}
+
+// The HasTargetRunSinceMe class remembers the process resume_id before a
+// watchpoint callback execution. After the execution, HasTargetRunSinceMe uses
+// this stored value to determine whether callback itself caused the target to
+// resume.
+class HasTargetRunSinceMe {
----------------
DavidSpickett wrote:
I get the idea of this, it's a checkpoint you make then can ask if a resume has
happened since that point.
I'm not sure what the "Me" suffix means. It sounds like the "Me" is another
target or process but it feels like the "Me" is the code that constructs this
object.
HasTargetRunSince is probably a fine name.
https://github.com/llvm/llvm-project/pull/163695
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits