I'm writing gdbstub for ARM and I have a question. I'm trying to implement watchpoints for my stub. GDB has special packets for different types of watchpoins (read, write, access), but every time I set a watchpoint at some values I got GDB implementation - single-stepping through the code and comparing values on each step. It's specified in GDB documentation, but then why do you need a special packet to write watchpoints?
Obviously, GDB native implementation is slow. This packet might be needed to re-define the implementation. For example, when I set wp at addr, not value, Z2 packet is really sent. But I don't understand how GDB should understand that the "S05"(stop packet) was sent because of a watchpoint.
In breakpoints the decision is made on comparison between the current bp_address
and the program counter value.
How does it work with watchpoints?