I have a Python script that launches several external programs as subprocesses and uses pipes to communicate with them. The system runs on Linux. I want to debug one of the children, a specific executable program. How do I attach gdb to it? I have tried several methods but none work.
- Run python under gdb with
set follow-fork-mode child
. Doesn't work because this is not the only child. The first child gets debugged, rather than the one I want. - Run python under gdb with
set detach-on-fork off
. Infeasible because this is not the only child. I need to manually tell gdb to continue debugging the parent process, until the program of interest is launched. Theoretically doable, but too much error-prone manual work. If all this manual work can be automated, this is a viable method. - Replace the executable in question with a script that runs the original executable under gdb. Doesn't work because of pipes. Input and/or output of gdb get redirected to the pipe. I need them to go to the terminal obviously.
How can I accomplish this?