简体   繁体   中英

Eclipse - debug a test suite launched through GNU Make

I am working on a C project in Eclipse CDT on Ubuntu. The project has some test suites invoking a binary run_tests with different command-line parameters. The test suites are defined with Makefiles and invoked by running make check in the project root.

My goal is to set up a debugging configuration in Eclipse for debugging the test suites. I want to have the following workflow:

  1. Set a breakpoint in run_tests
  2. Launch debug configuration to run test suites
  3. See the breakpoint being hit inside 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 . However, this will force me to manually configure the command line parameters which make check should figure out for me.

  2. I could edit the makefile rule to run gdb --args run_tests arg1 arg2 instead of run_tests arg1 arg2 . However, will Eclipse recognise and integrate with that gdb instance?

  3. On Windows, I could edit the makefile rule to run vsjitdebugger run_tests arg1 arg2 . Is there an equivalent to vsjitdebugger for Eclipse on Linux?

Here is the solution:

  1. Create a "C/C++ application" debug configuration
  2. Set the C/C++ application to "/usr/bin/make"
  3. Set the command-line argument to "check"
  4. Write the following to the gdbinit file:

     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 . For example, if make spawns /bin/cp 1000 times to copy setup files, then gdb will debug every one of those processes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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