I'm trying to setup my gdbinit to make gdb automatically attach to a certain program on a remote machine.
My script is something like:
define hook-run
target extended-remote | ssh -T remotemachine gdbserver --multi -
attach $pid
... <additional complicated stuff here>
end
My problem, of course, is that I'm missing $pid. I can find it by running ssh remotemachine ps | grep myprogram
, but I'm not sure how to run that from within the gdb script and assign it into that $pid
variable. How can I do that? I'm guessing I'm going to need some Python here...