使用 Eclipse CDT/RSE/RDT 远程调试 C++ 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15685104/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 20:17:25  来源:igfitidea点击:

Remote debugging C++ applications with Eclipse CDT/RSE/RDT

c++eclipsegdbremote-debuggingeclipse-cdt

提问by Juve

I am fighting with Eclipse (in Windows) to make it connect to my Linux box and compile and debug C++ code there remotely.

我正在使用 Eclipse(在 Windows 中)使其连接到我的 Linux 机器并远程编译和调试 C++ 代码。

What I have working:

我有什么工作:

  • CDT/RSE/RDT installed (Eclipse Juno, CDT 8.1.2, PTP(RDT) 6.0.4, RSE 3.4)
  • rdt-server runs on Linux box (perl ./daemon.pl 4075)
  • create local C++ projects (Makefile based)
  • compile and debug local C++ projects
  • create remote projects (using the "Linux" connection to the rdt-server)
  • compile remote projects (Makefile based)
  • 已安装 CDT/RSE/RDT(Eclipse Juno、CDT 8.1.2、PTP(RDT) 6.0.4、RSE 3.4)
  • rdt-server 运行在 Linux box ( perl ./daemon.pl 4075)
  • 创建本地 C++ 项目(基于 Makefile)
  • 编译和调试本地 C++ 项目
  • 创建远程项目(使用“Linux”连接到 rdt-server)
  • 编译远程项目(基于 Makefile)

Some manual things I can do (without Eclipse):

我可以做的一些手动操作(没有 Eclipse):

  • "remote" debug my compiled projects: ssh mybox 'cd /path/to/project; gdb main'
  • start a gdbserver: ssh mybox 'cd /path/to/project; gdbserver fqdn:10000 main'
  • “远程”调试我编译的项目: ssh mybox 'cd /path/to/project; gdb main'
  • 启动一个 gdbserver: ssh mybox 'cd /path/to/project; gdbserver fqdn:10000 main'

What is not working: Debug in Eclipse

什么不起作用:在 Eclipse 中调试

  • debug via "C++ application" Error: Program not specified(because I have a no local code)
  • debug via "C++ remote" Error: Program not specified(do I need local code for that?)
  • debug via "C++ attach" (Debugger: "gdbserver")
    • gdbserver running on linuxbox
    • gdb can not talk to the gdbserver (cygwin gdb 7.5, linux gdb/gdbserver 7.3); warning: Architecture rejected target-supplied description.
  • debug via "C++ attach" (Debugger: "gdb") will try to attach to my Windows processes.
  • 通过“C++ 应用程序”调试错误:未指定程序(因为我没有本地代码)
  • 通过“C++ 远程”调试错误:未指定程序(我需要本地代码吗?)
  • 通过“C++ attach”调试(调试器:“gdbserver”)
    • 运行在 linuxbox 上的 gdbserver
    • gdb 无法与 gdbserver 通信(cygwin gdb 7.5,linux gdb/gdbserver 7.3);警告:架构拒绝了目标提供的描述。
  • 通过“C++ attach”(调试器:“gdb”)调试将尝试附加到我的 Windows 进程。

Other things that might cause problems:

其他可能导致问题的事情:

  • I am using the sshbinary provided with MSYS/Git (not on PATH)
  • Cygwin is not on PATH
  • 我正在使用sshMSYS/Git 提供的二进制文件(不在PATH
  • Cygwin 未开启 PATH

I really would like to do remote debugging in Eclipse for my C++ projects. Do you have any suggestions how to proceed from here?

我真的很想在 Eclipse 中为我的 C++ 项目进行远程调试。你有什么建议如何从这里开始吗?

回答by dbrank0

"debug via "C++ remote" Error: Program not specified (do I need local code for that?)"

“通过“C++ 远程”调试错误:未指定程序(我需要本地代码吗?)”

Yes, because symbols are loaded from a local copy of code.

是的,因为符号是从本地代码副本加载的。

In debugger tab of this type of launch configuration you will find the settings for remote server and port. Use machine name and port you specified when you started gdbserver.

在此类启动配置的调试器选项卡中,您将找到远程服务器和端口的设置。使用您在启动 gdbserver 时指定的机器名称和端口。

AFAIK this will still not work as gdb running on your local windows machine will not support debugging linux programs. You will need a cross build of gdb (configured and build with host=mingw-or-something and target=linux).

AFAIK 这仍然不起作用,因为在本地 Windows 机器上运行的 gdb 不支持调试 linux 程序。您将需要 gdb 的交叉构建(使用 host=mingw-or-something 和 target=linux 进行配置和构建)。

回答by Juve

Unfortunately, this question did not yet result in the desired solution. Nevertheless, you might be interested in how I actually "solved" the problem:

不幸的是,这个问题还没有产生想要的解决方案。不过,您可能对我如何实际“解决”问题感兴趣:

We are now directly developing on the Linux boxes, doing everything remotely. We set up desktop users on the Linux boxes and login via VNC to run Eclipse and use it as front-end to gdb. While VNC is not the best solution (maybe we try NX later) this solution frees us from any problems with gdbserveror RSE/RDT.

我们现在直接在 Linux 机器上开发,远程完成所有工作。我们在 Linux 机器上设置桌面用户并通过 VNC 登录以运行 Eclipse 并将其用作gdb. 虽然 VNC 不是最好的解决方案(也许我们稍后会尝试 NX),但该解决方案使我们摆脱了gdbserverRSE/RDT 的任何问题。

回答by Hamid Fadishei

As of now (Luna M6), Eclipse CDT+RDT+RSE seems to be a chain missing some links when you need to:

截至目前(Luna M6),Eclipse CDT+RDT+RSE 似乎是一个缺少某些链接的链,当您需要执行以下操作时:

  • Run IDE on your desktop PC
  • Use the remote toolchain on target system to build instead of installing a local cross toolchain
  • Automate Debug and run to be performed on the remote system by a single click (start gdbserver, attach to it, and provide console output)
  • 在台式 PC 上运行 IDE
  • 使用目标系统上的远程工具链来构建而不是安装本地交叉工具链
  • 通过单击在远程系统上自动调试和运行(启动 gdbserver,附加到它,并提供控制台输出)

These requirements are quite common nowadays regarding the abundance of Linux ARM boards such as Raspberry Pi and OLinuxino. These boards usually have enough resources to run a toolchain but not enough to provide a remote desktop environment to run the IDE remotely.

这些要求如今对于大量的 Linux ARM 板(例如 Raspberry Pi 和 OLinuxino)来说非常普遍。这些板通常有足够的资源来运行工具链,但不足以提供远程桌面环境来远程运行 IDE。

My final solution:After several days of effort, I finally gave up Eclipse CDT+RDT+RSE for NetBeans C/C++ Remote Development Environmentwhich works like a charm for me.

我的最终解决方案:经过几天的努力,我终于放弃了NetBeans C/C++ 远程开发环境的Eclipse CDT+RDT+RSE,这对我来说就像一个魅力。

回答by Mohamed Abdelazim

You can try this pluginwith Eclipse, for parallel application version here is a link

你可以在 Eclipse 中尝试这个插件,对于并行应用程序版本, 这里是一个链接

It works fine in the developing from Windows machine to program on Linux

它适用于从 Windows 机器开发到 Linux 上的程序