I need to do unit testing for drivers in an arm based board with the help of gcov tool.When gcov is used in a x86 architecture it will create .gcda file after executing the program.But when it comes to an arm based board the .gcda files are not getting created.So,without that i couldn't use the gcov tool.My question is how to use that gcov tool in cross compilation.?.Thanks in advance.
-
Please [read the manual on this topic](https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Cross-profiling.html#Cross-profiling) and come back if you still have questions. You might like to specify the version. β artless noise Nov 27 '14 at 16:51
-
Your question is already answered in this old discussion: [How to do code coverage on embedded][1] [1]: http://stackoverflow.com/questions/8565031/how-to-do-code-coverage-on-embedded β FlorianB Nov 28 '14 at 08:32
1 Answers
gcov
code/data structures are tied to host filesystem and cross-compiler toolchains do not have any port or a configuration to change this behavior. If your object file is ~/my-project/abc.o
then the gcov
in-memory data structures created/updated by the instrumented code point to ~/my-project/abc.gcda
, and all these paths are on your host machine. The instrumented code running on the remote system (in your case the ARM board), as you can see, cannot access these paths and this is the main reason you don't see the .gcda
files in the ARM board case.
For a general method on getting the .gcda
files to get around this above issue, see https://mcuoneclipse.com/2014/12/26/code-coverage-for-embedded-target-with-eclipse-gcc-and-gcov/. This article presents a hacky method to break into gcov functions and manually dump the gcov data structures into on-host .gcda
files.
I used the above mentioned blog to do code coverage for my ARM project. However; I faced another issue of a gcc bug in my version of the toolchain (the GNU arm toolchain version available in October/November 2016), where you would not be able to break into gcov functions and complete the process mentioned in the above blog, as the relevant gcov functions hang with an infinite loop. You may or may not face this issue because I am not sure if the bug is fixed. In case you face this issue, a solution is available in my blog https://technfoblog.wordpress.com/2016/11/05/code-coverage-using-eclipse-gnu-arm-toolchain-and-gcov-for-embedded-systems/.

- 99
- 4
-
1A link to a potential solution is always welcome, but please add context around the link so your fellow users will have some idea what it is and why itβs there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. β Marcs Nov 14 '16 at 22:55