First, some background. I run a program by starting a process on a remote_host using ssh:
ssh -T remote_host "cd ~/mydir && ~/myprogram" < input.txt
The program, myprogram, reads stdin, which is attached to a local file input.txt.
Now, I need to remotely debug this program under gdb. If there was no stdin redirection, i.e. < input.txt, I would be able to do this using gdb's target remote, something like this (at gdb prompt):
(gdb) target remote | ssh -T remote_host gdbserver - myprogram
However, in the above example, I don't know how to attach myprogram's stdin to input.txt.
Is there something that would do the trick?
gdbserverdoesn't read from stdin, so the program it invokes will have unfettered access to stdin. You should be able to do this:where
1234is an unused port. Then,A drawback with this is that the
gdb-gdbserverTCP connection won't be encrypted.