How can I make gdb automatically attach to a program name on a remote machine?
Question
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...
La solution
I can find it by running
ssh remotemachine ps | grep myprogram
I believe your choices are
- use Python, or
- escape to shell
For (2) you can use something like:
define hook-run
shell gen-remote-run.sh > .remote-cmd.gdb
source .remote-cmd.gdb
end
and put all the "magic" of figuring out remote PID into gen-remote-run.sh
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow