I am trying to get code coverage for an arm based embedded system. Using x86 for cross compilation.So basically, I have a cross profiling question.
For the application I want to generate code coverage data, I have defined a signal handler inside which I call __gcov_flush()
to flush code coverage data to .gcda files. I am sending SIGUSR1 to the application. The application uses multiple .so files where bulk of the code and logic is implemented.
When I send the signal to the process, the .gcda files for just the application get created/updated. The .gcda files for the .so's are not created/updated at all.
Is there a way to make __gcov_flush()
flush all the coverage data for the .so's that the application is using?
I dont want to force the application to exit()
because that would defeat the purpose of what I am trying to do. I need to be able to dump coverage data for the application and the .so it uses at runtime.
Please help!!
Using ARM GCC v4.5.1.
This is what I have done so far to generate code coverage data:
I have defined the following options for GCC in the Master makefile:
CFLAGS += -fprofile-arcs -ftest-coverage
LDFLAGS += -fprofile-arcs -ftest-coverage
I am also exporting GCOV_PREFIX
and GCOV_PREFIX_STRIP
as global environment variables on the target system to force the .gcda files to be created in a specific path. This is working.
My only problem is the .gcda files for the .so's not getting created/update when __gcov_flush()
is called from the application.
This question got answered on GCC mailing list. TLDR: One needs to add a handler inside every shared library used, that will dump the coverage data. Then these handlers need to be called.
Detailed answer from the mailing list follows.
Question from the mailing list
Answer from the mailing list