Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Annoying error message: cannot merge previous GCDA file

Problem:

I'm using the following flags to generate the code coverage of my Qt application (.pro file):

QMAKE_CXXFLAGS += --coverage
QMAKE_LFLAGS += --coverage

The code coverage is correctly generated, the problem is that if I want to run only one test function/class (and the GCDA files were already created) I get the following error message:

profiling: /Users/user/.../build-myapp/myclass.gcda: cannot merge previous GCDA file: corrupt arc tag (0x00000000)

Note that the error message is shown for each GCDA file. Also, note that it doesn't seem to affect the test cases.


Workaround:

As explained here, it "is a result of the build tools failing to merge current results into the existing .gcda coverage files". As answered in the question, an option is to delete the GCDA files before running the tests. For example, by adding the following command in the build phase:

find . -name "*.gcda" -print0 | xargs -0 rm

Question:

My problem is that I don't want to delete the old GCDA files every time I run the test cases. As I'm running only one test function/class, I want to keep the old GCDA files as they are, and only merge the GCDA file related to the current class. As I manually checked, it is already being done because only the coverage of my current class is updated, and the old coverages remain the same.

So, is there a command to just ignore (don't show) the error messages related to the GCDA merging problems? Or even better, a command to only update the GCDA files related to the current test class?

Note: I'm using Qt 5.3.2 on macOS Sierra with Clang.


Related questions:

  • Code coverage warnings spam output
  • How to merge multiple versions of gcda files?
  • .gcda files don't merge on multiple runs
like image 357
KelvinS Avatar asked Nov 20 '17 13:11

KelvinS


2 Answers

I came across the same problem. My solution is:

  1. There is a general Test.pro project which uses SUBDIRS to include every test project as subproject.

  2. In each test subproject I have the following line QMAKE_POST_LINK = rm -f "*.gcda"

This deletes the *.gcda files only for the subproject which was just relinked. Unmodified projects keep their *.gcda files.

like image 178
Michal Avatar answered Sep 20 '22 14:09

Michal


When you compile with profiling, the results of each run are stored in a file that ends with .gcda.

The error appears when your existing .gcda file is in a different format than the current program that just finished running.

This happened to me when I had run a Linux version of my executable, then recompiled for MacOS and ran it. The MacOS program saw the existing .gcda file and generated pages of errors.

Eliminate the errors by removing the existing .gcda file.

like image 29
vy32 Avatar answered Sep 22 '22 14:09

vy32