requires kernel support
Andrew, What is page based watchpoints mainly used for? And how to implement that in the kernel? Go through some check statement at every page access attempts? When the number of this kind of watchpoints goes high, the performance might be impacted. Nevertheless, there won't be too much this kinds of watchpoints I believe.
Whu, The underlying problem is that a CPU's hardware watchpoint mechanism is a very very limited resource. Typically only 1-4 elements can be watched and that limits things to just a few small variables. Page based watchpoints, on the other hand, do not have that limitation - arbitrary memory areas can be monitored for accesses by disabling memory accesses on a page boundary. Against that is the need to juggle things when a page access does occure - the access may not be to the protected variable; and that, as you note, adds additional overhead. However: at least the restriction of only 1-4 watchpoints is removed; and it is more efficient than single-stepping all instructions looking for a faulting access. The kernel requirement would be a mechanism for disabling|enabling access to specific memory pages; possibly on a per thread basis.