是否有可能使用gdb通过ssh进行远程调试? [英] Is it possible to use gdb to debug remotely over ssh?

查看:379
本文介绍了是否有可能使用gdb通过ssh进行远程调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用本地源文件调试运行在远程目标上的程序吗?



假设我有一个名为hello的程序。 c,在我的家用机器上的 / home / jla / hello 目录中。



在远程机器上,将这个相同的文件放在/ hello目录下,并用
$ gcc -g -o hello hello.c 进行编译,然后删除远程hello.c,但是保留可执行文件。

然后我可以在本地运行gdb,让它进入ssh到远程机器来运行可执行文件,但是使用本地资源作为参考吗?



注意:


  1. 令人烦恼的是,并且不能被改变。它有gdb,但它没有gdbserver

  2. 注意,本地和远程机器有不同的体系结构。在这种特殊情况下,64位和32位英特尔
  3. 我真正想要做的是在emacs / gud下运行它。但这将是一个很好的开始。

  4. 本地机器事情很少。重要的是如何构建 hello gdb gdbserver
    $ b

    从您的描述中可以看出, hello 是为构建的(在远程机器上) x86_64-linux-gnu



    这意味着你需要 x86_64-linux-gnu gdbserver ,还有一个32位GDB,它能够调试 x86_64 二进制文件。您应该可以同时构建这两个文件,将 gdbserver 复制到远程计算机,并调试正常。


    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.

    解决方案

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

    这篇关于是否有可能使用gdb通过ssh进行远程调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆