Centralize ptrace helpers in Task.

#590