[Lldb-commits] [lldb] [lldb] add software watchpoints support (PR #151195)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 25 06:33:09 PDT 2025
dlav-sc wrote:
@jimingham,
> I found this a bit confusing when reading this patch. There are really two "conditions" being talked about here. There's the primary "hidden" condition that tests "did the region we are watching change value" and then there's the watchpoint condition set with watch modify -c. Sometimes the patch wasn't clear about this.
The first condition you mentioned is generally speaking only necessary for modify-type watchpoints.
With hardware watchpoints, lldb-server can only detect read/write access to the watched region but cannot determine the actual value. Therefore, to implement modify-type watchpoint logic, lldb-client needs to perform additional checks to verify that the watched value has actually changed (ensuring we're not writing the same value) after lldb-server reports write access to the watched region.
For software watchpoints, the entire logic is implemented on the lldb-client side. Since we cannot trigger on memory access (read or write), software watchpoints can only be of the modify type (gdb also only supports modify-type for software watchpoints). lldb-client checks whether the watched value has changed, similar to hardware modify-type watchpoints, but after each step in this case.
The second condition is the one I referenced in my previous comment. It is checked by lldb-client using the standard expression mechanism (similar to when you type expr -- <expression>).
Please take a look at `Watchpoint::WatchedValueReportable`. In this function, I check both conditions: first, I check the watch condition (the second one) using `CheckWatchpointCondition()` then I calculate the current watched value (`CalculateWatchedValue()`) and compare it with the old value for software watchpoints and hardware modify-type watchpoints using `IsValueObjectsEqual()` (the first condition).
https://github.com/llvm/llvm-project/pull/151195
More information about the lldb-commits
mailing list