kcov
kcov copied to clipboard
ptrace: Setup breakpoints via /proc/$pid/mem
Assuming it works this should provide much better performance when ptracing.
Mostly implemented, but needs some thinking for how to handle the multi-process case: There will be one /proc/$pid/mem for each process when forking is involved.
On Linux you might get an even bigger speedup by using process_vm_writev
.
OK, thanks for the hint. I didn't know about it. It appears to be kernel >= 3.2, but I suppose it would be worthwhile exploring.
I guess it's time to revisit this issue again!
The main features that make process_vm_writev
attractive here are that you don't need a file descriptor and that you can write a large number of discontiguous ranges with a single system call (up to IOV_MAX
in fact, which is 1024 on Linux).
OK, thanks for the explanation. It should be said that kcov has other performance issues as well, mainly that collection runs lock-step with reporting. Better would be to thread collection and just queue up hit breakpoints.
Actually process_vm_writev
can't write to read-only mappings, so that's not an option here.
OK, then I guess I should get back to my /proc/$pid/mem
implementation someday. I still believe the main slowness culprit is the process being blocked by kcov reporting (as opposed to only collection).