Linux 如何在 Eclipse 中使用 GDB 进行 C/C++ 调试?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3758794/
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-08-04 23:14:08  来源:igfitidea点击:

How do I use GDB in Eclipse for C/C++ Debugging?

linuxeclipsedebugginggdb

提问by Owen

I'm a Visual Studio user and am used to breakpoints for debugging. I'm now working in a linux environment and am using Eclipse as an IDE. I'm a newbie in linux and eclipse. I don't have any idea how to use gdb in eclipse. I tried using gdb in command line, but is not as easy as having a UI.

我是 Visual Studio 用户,习惯于使用断点进行调试。我现在在 linux 环境中工作,并使用 Eclipse 作为 IDE。我是 linux 和 eclipse 的新手。我不知道如何在 Eclipse 中使用 gdb。我尝试在命令行中使用 gdb,但并不像拥有 UI 那样容易。

How do I use gdb in eclipse?

如何在 Eclipse 中使用 gdb?

采纳答案by Omair

The following instructions are for Eclipse 3.5 (Galileo). For 3.6 (Helios), they are similar except for the link in step 2.

以下说明适用于 Eclipse 3.5 (Galileo)。对于 3.6 (Helios),除了步骤 2 中的链接外,它们是相似的。

  1. Go to Help > Install New Software.
  2. Add the CDT repository http://download.eclipse.org/tools/cdt/releases/galileoto the list of repositories.
  3. Select the CDT Repository. Now you need to install the CDT plugin along with GDB support from the list of available plugins (Select the CDT Main Features as well as CDT GNU Toolchain Debug support).
  1. 转至帮助 > 安装新软件。
  2. 将 CDT 存储库http://download.eclipse.org/tools/cdt/releases/galileo添加到存储库 列表。
  3. 选择 CDT 存储库。现在您需要安装 CDT 插件以及可用插件列表中的 GDB 支持(选择 CDT 主要功能以及 CDT GNU 工具链调试支持)。

You should now be able to set breakpoints and inspect values of variables in Eclipse.

您现在应该能够在 Eclipse 中设置断点并检查变量的值。

An alternative is to install DDD (an GUI frontend for GDB).

另一种方法是安装 DDD(GDB 的 GUI 前端)。