Can I debug a program running on a remote target to which I have ssh access, using local source files?
Say I’ve got a program called hello.c, in directory /home/jla/hello on my home machine.
And on the remote machine I put this same file in a directory /hello, and compile it with
$ gcc -g -o hello hello.c, and then delete the remote hello.c, but leave the executable.
Can I then run gdb locally, get it to ssh in to the remote machine to run the executable, but use the local sources as reference?
Notes:
-
Annoyingly, the remote machine is very stripped down and can’t be altered. It has gdb, but it doesn’t have gdbserver
-
Note that the local and the remote machine have different architectures. In this particular case 64bit and 32bit intel
-
What I really want to do is run it under emacs/gud. But this would be a great start.
The architectures of remote and local machines matter very little. What matters is how
hello,gdbandgdbserverare built.It sounds from your description that
hellois built (on remote machine) forx86_64-linux-gnuThat means you need
x86_64-linux-gnugdbserver, and also a 32-bit GDB that is capable of debuggingx86_64binaries. You should be able to build both, copygdbserverto the remote machine, and debug “normally”.