tracexec
tracexec copied to clipboard
[Feature] allow external debugger to attach
Use case:
I have an app my-app and another app B. There's a bug that occurs only when B executes my-app. I want to directly debug my-app when executing B.
And BTW it's very painful to debug multi-process applications in gdb.
How:
- Add breakpoints on exec(e.g. break when exec my-app)
- Ask if launching external debugger on breakpoint hit
- Detach from the tracee to be debugged and launch external debugger(e.g. gdb in a new window) and let it attach to tracee.
Unresolved questions:
- Is this compatible with seccomp-bpf optimization?
- How could we transfer ptrace from tracexec to external debugger?
- Should the breakpoint be triggered on syscall enter stop or syscall exit stop?
Caveats:
- Further exec events will not be available for the detached tracee.
Alternative
Maybe I could implement gdb server protocol in tracexec and let gdb as a client connect to it. This way further exec events can also be traced.
- https://github.com/luser/rust-gdb-remote-protocol
Flagging as high priority because it makes debugging a program invoked by a shell script much easier. I really like it! tracexec will become a debugger launcher. Solves https://stackoverflow.com/questions/5048112/use-gdb-to-debug-a-c-program-called-from-a-shell-script