Incomplete and untested. And: even if this is right "in general", this code will be re-factored later anyway. Just some draft and very dirty code for early review.
I came to conclusion it doesn't make sense to move ptrace_set_action() and friends into ptrace_context first, it is better to introduce the new code and then kill the old one. Oleg.