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?
When I tried that with gdbserver+gdb on x86-64 linux machine, gdbserver replied with T packet, wherein it stated "watch" as stop reason:
Packet received: T05watch:000000000058c460;06:00deffffff7f0000;07:f0ddffffff7f0000;10:9cd4410000000000;thread:p3425.3425;core:5;