C语言 如何设置 Eclipse 以使用 gdbserver 进行远程 C 调试?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4038760/
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
How to set up the Eclipse for remote C debugging with gdbserver?
提问by newprint
I am pretty new to Eclipse. Trying to set up to do remote debugging.
我对 Eclipse 很陌生。尝试设置进行远程调试。
Here is situation, I am connecting to remote machine running Linux, I am running Windows.
这是情况,我正在连接到运行 Linux 的远程机器,我正在运行 Windows。
1) I have installed all the necessary tool for Eclipse, and was able to connect to Linux machine.
1) 我已经为 Eclipse 安装了所有必要的工具,并且能够连接到 Linux 机器。
2) Remote machine has gdbserver
2)远程机器有 gdbserver
linux1[1]% gdbserver
Usage: gdbserver [OPTIONS] COMM PROG [ARGS ...]
gdbserver [OPTIONS] --attach COMM PID
gdbserver [OPTIONS] --multi COMM
COMM may either be a tty device (for serial debugging), or
HOST:PORT to listen for a TCP connection.
Options:
--debug Enable debugging output.
Do I need to configure anything in gdbserver???
我需要在gdbserver??? 中配置任何东西?
3) What else should I configure in Eclipse ? for remote debugging ?
3) 我还应该在 Eclipse 中配置什么?用于远程调试?
4) Does it matter that my GDB version is different from remote Machine GDB ?
4) 我的 GDB 版本与远程机器 GDB 不同有关系吗?
采纳答案by dennycrane
gdbserverneeds more arguments. For example, say gdbserver localhost:1337 yourprogram yourprogramargumentsand keep it running.
gdbserver需要更多的论据。例如,说gdbserver localhost:1337 yourprogram yourprogramarguments并保持运行。
Then, in Eclipse, create a new debug configuration for a "C/C++ Application". On the main tab, on the bottom, choose GDB (GSF) Remote System Process Launcheras launcher. On the debugger tab, choose gdbserver Debuggeras the debugger. Under connection, say TCPas connection type and give localhost:1337as address. When you launch the configuration, you may control the remote gdbby entering commands into the console.
然后,在 Eclipse 中,为“C/C++ 应用程序”创建一个新的调试配置。在主选项卡的底部,选择GDB (GSF) Remote System Process Launcher作为启动器。在调试器选项卡上,选择gdbserver Debugger作为调试器。在连接下,说TCP为连接类型并给出localhost:1337地址。当您启动配置时,您可以gdb通过在控制台中输入命令来控制遥控器。
回答by Osama F Elias
Update for Eclipse 2019-03
Eclipse 2019-03 更新
In eclipse 2019, the above steps didn't work, because Eclipse has changed the layout of the configuration in "C/C++ Remote Application".
在 eclipse 2019 中,上述步骤没有奏效,因为 Eclipse 更改了“C/C++远程应用程序”中的配置布局。
Updates of @Ciro post:
@Ciro 帖子的更新:
The following steps worked with me: Under "Debug Configurations" Under "C / C++ Remote Application" Under the tab "Main":
以下步骤对我有用:在“调试配置”下“C/C++远程应用程序”下“主”选项卡下:
- select the "Connection" ==> "Remote Host".
- select "New" , "SSH" (In my case) , then enter the configuration for your remote target machine.
- in "Remote Absolute File Path for C/C++ Application:" set the path of the application in the target/remote device.
- 选择“连接”==>“远程主机”。
- 选择 "New" , "SSH" (In my case) ,然后输入远程目标机器的配置。
- 在“C/C++ 应用程序的远程绝对文件路径:”中设置应用程序在目标/远程设备中的路径。
Under the tab "Debugger":
在“调试器”选项卡下:
- Sub-tab "Connection" has been removed.
- New sub-tab "Gdbserver Settings" has been added.
- Configure "Gdbserver path:" to point to the path of gdbserver. In my case it was "/usr/bin/gdbserver"
- Configure port number
- 子选项卡“连接”已被删除。
- 添加了新的子选项卡“Gdbserver 设置”。
- 配置“gdbserver path:”指向gdbserver的路径。就我而言,它是“/usr/bin/gdbserver”
- 配置端口号
These are the only changes I made so that the previous answer works with me.
这些是我所做的唯一更改,以便之前的答案适用于我。

