I am trying to use gcov on Linux(Ubuntu) to see frequency of execution for each line of source.
I have added following flags to my gcc compiler and linker flags,
CCFLAGS = -fprofile-arcs -ftest-coverage
LDFLAGS = -fprofile-arcs -lgcov
but after compiling and running the program, i see no *.gcda file created. As a result of which when i run
gcov --object-directory <path to the *.gcno/*.gcda files> myfile.cpp
Shows error:
myfile.gcda:cannot open data file, assuming not executed
File '../../../../../code/myfile.cpp'
Lines executed:0.00% of 2625
Am i missing something. How to fix this?
You can use __gcov_flush() method inside your code. You will need to invoke this from registered signal handler.
See:
https://www.osadl.org/fileadmin/dam/interface/docbook/howtos/coverage.pdf
Using this, you can keep your service running and issue "kill" whenever you need to dump coverage data.
Hope that helps....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With