Annoying error message: cannot merge previous GCDA file
Asked Answered
S

2

10

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:

Silt answered 20/11, 2017 at 13:38 Comment(0)
D
5

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.

Diviner answered 23/8, 2021 at 18:34 Comment(0)
M
4

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.

Marquita answered 18/12, 2017 at 12:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.