Re: x86 watchpoints bug (Re: ping: Re: PATCH : allow to set length of hw watchpoints (e.g. for Valgrind gdbserver))

Philippe Waroquiers
2011-05-31T20:25:49Z

> Not sure I understand what is different between GDB and GDBserver
> here. A watchpoint, from breakpoint.c's perpective can be composed
> of several low-level watchpoints. E.g., if the expression the user
> wants to watch requires trapping accesses to two disjoint memory
> regions for changes, each of those memory regions will correspond
> to one low-level hardware watchpoint. In GDBserver's or i386-nat.c's
> perpective, there will be two watchpoints. If the second fails to
> insert, then breakpoint.c in GDB rolls back the first. This applies
> to GDBserver as well.

> ../../../src/gdb/gdbserver/linux-x86-low.c:511: A problem internal to GDBserver has been detected.
> Assertion `DR_FIRSTADDR <= regnum && regnum < DR_LASTADDR' failed.

Sorry for the somewhat wrong analysis of the bug.

I have applied your patch in the assert, and tested again.
The GDBserver does not crash anymore (but it still keeps a DR register
busy for no reason).

So, there is for sure still a difference of behaviour (probably in breakpoint.c
placing a "local" watch and a "remote" watch).

Note that there is another similar (but I believe correct) assert in the code, but
slightly different. I am not sure to understand why regnum validity is tested
differently in the below:
if (! (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR))
fatal ("Invalid debug register %d", regnum);

Thanks for looking at all this
Philippe