I'm writing a python script to go through my list of currently executing processes, look for the ones run by a certain user, and then run GDB to hook onto all of those.
I currently get a list of all the processes run by a certain user. (I used http://andreinc.net/2010/11/07/how-to-get-the-active-process-list-on-a-linux-machine-using-python/ for that)
However, I for the life of me can't square that with how to launch gdb and hook onto each of those with a separate inferior from Python. I know how to launch gdb with a Python script, just not with the appropriate sequencing to attach multiple processes inside that gdb and create an inferior for each one.
I know that once you're running gdb, you can create new inferiors with create-inferior, then switch to them and attach a process. Is there a way to add an inferior and immediately have it attach to a process?
Better yet, is there a way to launch gdb with multiple inferiors, each one attaching to a different process in the argument list?
Thanks!