3
votes

I want to do code coverage on c++ source code on an embedded target. Basic idea is, generate an elf along with -frofile-arcs -ftest-coverage turned on using gcc. Download it onto an ARM device and then collect the data to analyze the code coverage using gcov.

How can I generate an elf file using arm-none-eabi-gcc commmand. I have setup the GNU ARM Toolchain and set the env variable. Can I use arm-none-eabi-g++ -c -mthumb -mcpu=cortex-m3 -fprofile-arcs -ftest-coverage filename.cpp -o filename.elf ?

Thanks in advance!

2

2 Answers

1
votes

No, you need to do a lot more. YOu need to link with gcov library. This can be donw with -lgov & -fprofile-arcs linker flags hoping your linker script has .got and .plt sections.

Above would generate only the .gcno files. .gcda files are generated at runtime inside the hardware. Either wait for application to exit or add your own wrapper to create .gcda file.

Finally, you need to find a way to pull out this .gcda file from your hardware.

All abvoe are well explained in
https://mcuoneclipse.com/2014/12/26/code-coverage-for-embedded-target-with-eclipse-gcc-and-gcov/

0
votes

I'm not sure what you're trying to do is actually possible. I think those profiling options in GCC need some operating system support. You're probably better off looking at profiling tools available from Keil/ARM. There's a community version of the Streamline profiler thay may some be useful to you, checkout the ARM webiste.