dlav-sc wrote:

**II ==== Watchpoint.cpp ================================================**

I conducted significant refactoring of the internal logic of the `Watchpoint` 
class. Initially, I created two separate classes, `SoftwareWatchpoint` and 
`HardwareWatchpoint`, which inherited from the `Watchpoint` class, because the 
logic of many methods in the `Watchpoint` class differed significantly.

However, I later noticed that the main differences were due to how the 
watchpoints calculated their watched value. How a watchpoint calculates the 
value depends on what we are trying to track. If we are tracking a value 
located in memory (e.g., a local variable), then the watchpoint simply needs to 
read the memory contents at the address of the tracked value. If we are 
tracking a register value or a complex expression like `foo() + boo() + d` 
which does not reside in memory, then the watchpoint must use the expression 
evaluation mechanism (`(lldb) $expr --`) to obtain the value of the expression.

Therefore, I decided to extract the logic for calculating the watched value 
into separate entities: `AddressWatchpointCalculateStrategy` and 
`ExpressionWatchpointCalculateStrategy` (the latter is not in this patch) for 
calculating the watched value when the expression resides in memory and when it 
does not, respectively.

Please note that this is generally unrelated to whether the watchpoint is 
software or hardware. For tracking a value in memory, we can use either a 
software watchpoint (which must read the memory value after each step) or a 
hardware watchpoint (which can simply set a trigger on that memory region). 
However, a watchpoint on an expression not residing in memory can only be 
software, as there is nowhere for hardware to set a trigger in this case.

Additionally, I extracted some logic into separate functions to improve code 
readability (e.g., `IsValueObjectsEqual`) and improved error handling in some 
places.


https://github.com/llvm/llvm-project/pull/159807
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to