简体   繁体   English

Eclipse-调试通过GNU Make启动的测试套件

[英]Eclipse - debug a test suite launched through GNU Make

I am working on a C project in Eclipse CDT on Ubuntu. 我正在Ubuntu上的Eclipse CDT中从事C项目。 The project has some test suites invoking a binary run_tests with different command-line parameters. 该项目有一些测试套件, run_tests使用不同的命令行参数调用二进制run_tests The test suites are defined with Makefiles and invoked by running make check in the project root. 测试套件由Makefile定义,并通过在项目根目录中运行make check来调用。

My goal is to set up a debugging configuration in Eclipse for debugging the test suites. 我的目标是在Eclipse中设置调试配置以调试测试套件。 I want to have the following workflow: 我想要以下工作流程:

  1. Set a breakpoint in run_tests run_tests设置一个断点
  2. Launch debug configuration to run test suites 启动调试配置以运行测试套件
  3. See the breakpoint being hit inside Eclipse 看到断点在Eclipse中被击中

How can I achieve this? 我该如何实现?

My thoughts so far 到目前为止我的想法

  1. It is easy to set up a debug configuration to directly run run_tests without using make . 设置调试配置以直接运行run_tests而不使用make很容易。 However, this will force me to manually configure the command line parameters which make check should figure out for me. 但是,这将迫使我手动配置命令行参数, make check应该为我确定。

  2. I could edit the makefile rule to run gdb --args run_tests arg1 arg2 instead of run_tests arg1 arg2 . 我可以编辑makefile规则来运行gdb --args run_tests arg1 arg2而不是run_tests arg1 arg2 However, will Eclipse recognise and integrate with that gdb instance? 但是,Eclipse是否可以识别该gdb实例并与之集成?

  3. On Windows, I could edit the makefile rule to run vsjitdebugger run_tests arg1 arg2 . 在Windows上,我可以编辑makefile规则以运行vsjitdebugger run_tests arg1 arg2 Is there an equivalent to vsjitdebugger for Eclipse on Linux? Linux上是否有与Eclipse相对应的vsjitdebugger的等效vsjitdebugger

Here is the solution: 解决方法如下:

  1. Create a "C/C++ application" debug configuration 创建“ C / C ++应用程序”调试配置
  2. Set the C/C++ application to "/usr/bin/make" 将C / C ++应用程序设置为“ / usr / bin / make”
  3. Set the command-line argument to "check" 将命令行参数设置为“ check”
  4. Write the following to the gdbinit file: 将以下内容写入gdbinit文件:

     set detach-on-fork off set target-async on set non-stop on set pagination off # Not necessary but improves performance set auto-solib-add off 

Note: this solution can be painfully slow, as gdb will follow every fork initiated by make . 注意:此解决方案可能会非常缓慢,因为gdb将遵循make发起的每个派生。 For example, if make spawns /bin/cp 1000 times to copy setup files, then gdb will debug every one of those processes. 例如,如果make spawns /bin/cp生成1000次以复制安装文件,则gdb将调试其中的每个进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM