如何使用Eclipse在Linux上调试C ++程序?

时间:2022-04-03 14:39:55

I don't use Eclipse as an IDE, and have no interest in doing so. However, I do like its source-level debugging.

我不使用Eclipse作为IDE,并且没有兴趣这样做。但是,我确实喜欢它的源代码级调试。

Is there any way I can use it to debug a C++ Linux app without going through the ritual of creating a project? (In effect, can I just use it like a frontend to gdb?)

有没有什么方法可以用它来调试C ++ Linux应用程序而无需通过创建项目的仪式? (实际上,我可以像使用gdb的前端一样使用它吗?)

If not, what are the steps I need to follow to create a project that I can use to just debug an existing C++ program that is built using Makefiles or other tools (SCons, CMake, etc.). I don't want to be able to "develop" in Eclipse; all I need to do is debug.

如果没有,我需要遵循哪些步骤来创建一个项目,我可以使用它来调试使用Makefile或其他工具(SCons,CMake等)构建的现有C ++程序。我不想在Eclipse中“开发”;我需要做的就是调试。

3 个解决方案

#1


10  

Take a look at this question. Create a C/C++-project, use your project's source directory as project directory, select to use the external builder, and change "make" to whatever tool you want.

看看这个问题。创建一个C / C ++项目,使用项目的源目录作为项目目录,选择使用外部构建器,并将“make”更改为您想要的任何工具。

The tricky part is to get the indexer to work correctly and find all your header files.

棘手的部分是让索引器正常工作并找到所有头文件。

EDIT: CMake 2.6.x has support for generating CDT project files, which might be a more straightforward solution.

编辑:CMake 2.6.x支持生成CDT项目文件,这可能是一个更直接的解决方案。

#2


4  

I don't know if this has changed in the 4+ years since the question was posted, but there's a much easier way to do this. I'm on Eclipse Luna (4.4.2).

自问题发布以来的4年多时间里,我不知道这是否已经发生了变化,但是有一种更简单的方法可以做到这一点。我在Eclipse Luna(4.4.2)上。

> eclipse&

then

File > Import > C/C++ > C/C++ Executable > Next > browse to executable > Next > choose a project name > Finish

文件>导入> C / C ++> C / C ++可执行文件>下一步>浏览到可执行文件>下一步>选择项目名称>完成

No other project setup required, no source paths (which should be in the object code). Just like running gdb/insight/etc. Almost makes it worth installing Java.

不需要其他项目设置,没有源路径(应该在目标代码中)。就像运行gdb / insight / etc一样。几乎值得安装Java。

#3


0  

Configuration for debugging in Eclipse.

在Eclipse中进行调试的配置。

In eclipse,

  1. Go to Window->preferences
  2. 转到Window-> preferences

  3. A popup will appear then select C/C++ , click on drop down arrow ,then select Debug and click on drop down arrow.
  4. 将出现一个弹出窗口,然后选择C / C ++,单击下拉箭头,然后选择Debug并单击下拉箭头。

  5. Select Source Lookup Path and then click on Add.
  6. 选择Source Lookup Path,然后单击Add。

  7. After clicking on Add, click on Path Mapping and then click on OK.
  8. 单击“添加”后,单击“路径映射”,然后单击“确定”。

  9. Specify the mapping path name and then click on Add .
  10. 指定映射路径名称,然后单击“添加”。

  11. In compilation path select Cygwin path (need to install) and then click ok .
  12. 在编译路径中选择Cygwin路径(需要安装),然后单击确定。

  13. In debug option,click on source Lookup Path and select Path Mapping:Project source and click on apply and then ok.
  14. 在debug选项中,单击source Lookup Path并选择Path Mapping:Project source并单击apply然后ok。

#1


10  

Take a look at this question. Create a C/C++-project, use your project's source directory as project directory, select to use the external builder, and change "make" to whatever tool you want.

看看这个问题。创建一个C / C ++项目,使用项目的源目录作为项目目录,选择使用外部构建器,并将“make”更改为您想要的任何工具。

The tricky part is to get the indexer to work correctly and find all your header files.

棘手的部分是让索引器正常工作并找到所有头文件。

EDIT: CMake 2.6.x has support for generating CDT project files, which might be a more straightforward solution.

编辑:CMake 2.6.x支持生成CDT项目文件,这可能是一个更直接的解决方案。

#2


4  

I don't know if this has changed in the 4+ years since the question was posted, but there's a much easier way to do this. I'm on Eclipse Luna (4.4.2).

自问题发布以来的4年多时间里,我不知道这是否已经发生了变化,但是有一种更简单的方法可以做到这一点。我在Eclipse Luna(4.4.2)上。

> eclipse&

then

File > Import > C/C++ > C/C++ Executable > Next > browse to executable > Next > choose a project name > Finish

文件>导入> C / C ++> C / C ++可执行文件>下一步>浏览到可执行文件>下一步>选择项目名称>完成

No other project setup required, no source paths (which should be in the object code). Just like running gdb/insight/etc. Almost makes it worth installing Java.

不需要其他项目设置,没有源路径(应该在目标代码中)。就像运行gdb / insight / etc一样。几乎值得安装Java。

#3


0  

Configuration for debugging in Eclipse.

在Eclipse中进行调试的配置。

In eclipse,

  1. Go to Window->preferences
  2. 转到Window-> preferences

  3. A popup will appear then select C/C++ , click on drop down arrow ,then select Debug and click on drop down arrow.
  4. 将出现一个弹出窗口,然后选择C / C ++,单击下拉箭头,然后选择Debug并单击下拉箭头。

  5. Select Source Lookup Path and then click on Add.
  6. 选择Source Lookup Path,然后单击Add。

  7. After clicking on Add, click on Path Mapping and then click on OK.
  8. 单击“添加”后,单击“路径映射”,然后单击“确定”。

  9. Specify the mapping path name and then click on Add .
  10. 指定映射路径名称,然后单击“添加”。

  11. In compilation path select Cygwin path (need to install) and then click ok .
  12. 在编译路径中选择Cygwin路径(需要安装),然后单击确定。

  13. In debug option,click on source Lookup Path and select Path Mapping:Project source and click on apply and then ok.
  14. 在debug选项中,单击source Lookup Path并选择Path Mapping:Project source并单击apply然后ok。