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

痴心易碎 提交于 2019-12-07 16:17:18

问题


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.


回答1:


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".



来源:https://stackoverflow.com/questions/7787179/is-it-possible-to-use-gdb-to-debug-remotely-over-ssh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!