From: Chris Emerson <cemerson@ch...> - 2001-09-11 07:39:53
I've hacked up a way of setting a "breakpoint" which triggers when
writing to a particular memory location. I write-protect the page,
and emulate the faulting instructions, but calling a function which
gdb can breakpoint if the one address of interest is written to. I've
used this to catch writes to init's task->blocked, filtering out all
the noise from the rest of the task structure.
This works ok on ppc, where only a few instructions write to memory
(ie store instructions), which are easy to decode emulate. It
would be neater and more portable if there's an obvious way of
returning from the signal handler and trapping again after one
instruction, so that we can protect the page again. This can be in
kernel code. Any ideas?
 The exception is "stfd" (store float double), since it's not
obvious how I'd get at the faulting code's floating point registers.
They're not in the sigcontext structure. I got around this by
compiling UML with -msoft-float, so gcc didn't generate stfd for
copying small structures.
Chris Emerson, obsessed Cambridge juggler
Web page: http://www.chiark.greenend.org.uk/~cemerson/