In order to perform coverage analysis of a program using gcov, several steps are needed:
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 switches -fprofile-arcs and -ftest-coverage, and link it using -fprofile-arcs.
$ 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. Subsequent 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 described in the GCC User's Guide, section 'Invoking gcov'.
This will create annotated source files with a
my_main.adb file will be analyzed in