This patch makes sure that we are setting the correct number of hardware breakpoint or watchpoint registers while setting/clearing hardware watchpoints/breakpoints.
In current implementation of AArch64 Watchpoints we try to set all debug registers present in user_hwdebug_state structure.
There are more debug registers declared by user_hwdebug_state than the one exported to ptrace for hardware watchpoints and hardware breakpoints.
We only should be setting the N number of registers supported by the target in response to read debug registers calls.
Failure to do so results in unexpected watchpoint behavior.
You are using offsetof with a value determined in runtime (m_max_hwp_supported) what won't be work in all case (it isn't standard compliance AFAIK). I suggest to sue the following version instead: