GDB, strace, and rr are all built on the exact PTRACE_PEEKDATA/PTRACE_POKEDATA/PTRACE_SINGLESTEP primitives you implement here; the INT3 (0xCC) breakpoint-insertion trick is the same technique every native debugger on Linux uses under the hood. Sandboxing tools and malware analysis harnesses also use ptrace to intercept syscalls made by an untrusted process.