In order to perform coverage analysis of a program using
steps are needed:
gcovtool to generate the result.
The code instrumentation needed by gcov is created at the object level:
The source code is not modified in any way, because the instrumentation code is
inserted by gcc during the compilation process. To compile your code with code
coverage activated, you need to recompile your whole project using the
-ftest-coverage, and link it using
$ gnatmake -P my_project.gpr -f -cargs -fprofile-arcs -ftest-coverage \ -largs -fprofile-arcs
This compilation process will create .gcno files together with the usual object files.
Once the program is compiled with coverage instrumentation, you can run it as many times as needed - on portions of a test suite for example. The first execution will produce .gcda files at the same location as the .gcno files. The following executions will update those files, so that a cumulative result of the covered portions of the program is generated.
Finally, you need to call the
gcov tool. The different options of
gcov are available in the GCC User's Guide, section 'Invoking gcov'.
This will create annotated source files with a .gcov extension: my_main.adb file will be analysed in my_main.adb.gcov.