[英]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: 我想要以下工作流程:
run_tests
在run_tests
设置一个断点 How can I achieve this? 我该如何实现?
My thoughts so far 到目前为止我的想法
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
应该为我确定。
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
实例并与之集成?
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: 解决方法如下:
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.