John Lawrence Aspden
John Lawrence Aspden

Reputation: 17470

Is it possible to use gdb to debug remotely over ssh?

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:

  1. Annoyingly, the remote machine is very stripped down and can't be altered. It has gdb, but it doesn't have gdbserver

  2. Note that the local and the remote machine have different architectures. In this particular case 64bit and 32bit intel

  3. What I really want to do is run it under emacs/gud. But this would be a great start.

Upvotes: 5

Views: 3566

Answers (1)

Employed Russian
Employed Russian

Reputation: 213375

The architectures of remote and local machines matter very little. What matters is how hello, gdb and gdbserver are built.

It sounds from your description that hello is built (on remote machine) for x86_64-linux-gnu

That means you need x86_64-linux-gnu gdbserver, and also a 32-bit GDB that is capable of debugging x86_64 binaries. You should be able to build both, copy gdbserver to the remote machine, and debug "normally".

Upvotes: 3

Related Questions