kcov icon indicating copy to clipboard operation
kcov copied to clipboard

ptrace: Setup breakpoints via /proc/$pid/mem

Open SimonKagstrom opened this issue 9 years ago • 7 comments

Assuming it works this should provide much better performance when ptracing.

SimonKagstrom avatar Jan 22 '15 13:01 SimonKagstrom

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.

SimonKagstrom avatar Apr 14 '15 12:04 SimonKagstrom

On Linux you might get an even bigger speedup by using process_vm_writev.

rocallahan avatar Jan 14 '17 20:01 rocallahan

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!

SimonKagstrom avatar Jan 15 '17 15:01 SimonKagstrom

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).

rocallahan avatar Jan 15 '17 22:01 rocallahan

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.

SimonKagstrom avatar Jan 16 '17 06:01 SimonKagstrom

Actually process_vm_writev can't write to read-only mappings, so that's not an option here.

rocallahan avatar May 30 '17 00:05 rocallahan

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).

SimonKagstrom avatar Jun 01 '17 13:06 SimonKagstrom