@@ -972,6 +972,7 @@ the default coverage runtime library, in practice only one use case is
972
972
supported currently: changing the behavior of the
973
973
` ` --dump-channel=base64-stdout` ` instrumentation option.
974
974
975
+ .. _custom_base_64:
975
976
976
977
Customize the ` ` base64-stdout` ` dump channel
977
978
--------------------------------------------
@@ -1037,3 +1038,71 @@ file so that it implements the interface described in the (unmodified)
1037
1038
const char *str;
1038
1039
size_t length;
1039
1040
};
1041
+
1042
+ Building instrumented programs with CCG
1043
+ =======================================
1044
+
1045
+ Programs instrumented with |gcvins| can be built using the
1046
+ ` GNAT Pro Common Code Generator < https://docs.adacore.com/live/wave/gnat-ccg/html/gnatccg_ug/gnat_ccg.html> ` _
1047
+ provided a few modifications are made to the coverage runtime, and
1048
+ respecting some limitations in terms of dump-trigger and dump-channel choice.
1049
+
1050
+ Customizing the runtime
1051
+ -----------------------
1052
+
1053
+ Given the workflow associated with CCG, it is not possible to use the |gcvstp|
1054
+ command to setup the coverage runtime. Instead, it must be prepared manually.
1055
+
1056
+ The coverage runtime contains both Ada and C sources. When using CCG through
1057
+ GPRbuild, projects containing C sources are not well handled and some steps of
1058
+ the build procedure won't be executed. There thus is an external variable to
1059
+ remove all C sources from the project. This means that C sources must be
1060
+ manually managed during the executable compilation later on.
1061
+
1062
+ The first step is to copy the runtime sources in a dedicated directory. For the
1063
+ remainder of this section, it will be denoted by ` ` ccg_gnatcov_rts` ` .
1064
+
1065
+ .. code-block:: sh
1066
+
1067
+ mkdir ccg_gnatcov_rts
1068
+ cp -r <gnatdas_install_dir>/share/gnatcoverage/gnatcov_rts ccg_gnatcov_rts
1069
+
1070
+ Then, C sources not relevant to the coverage runtime for the CCG configuration
1071
+ must be deleted:
1072
+
1073
+ .. code-block:: sh
1074
+
1075
+ rm ccg_gnatcov_rts/gnatcov_rts_c-base-io.c
1076
+ rm ccg_gnatcov_rts/gnatcov_rts_c-trace-output-files.*
1077
+ rm ccg_gnatcov_rts/gnatcov_rts_c-os_interface.*
1078
+
1079
+ Finally, it is necessary to modify the contents of
1080
+ ` ` ccg_gnatcov_rts/gnatcov_rts-base_io.adb` ` to use an alternate medium on which
1081
+ the execution trace will be output. By default this relies on ` ` GNAT.IO` ` ,
1082
+ which is not available in the CCG runtime. It is possible to replace occurrences
1083
+ of this unit by ` ` Ada.Text_IO` ` , which is supported by CCG, but which relies on
1084
+ the C standard function ` ` putchar` ` . Otherwise, see :ref:` custom_base_64` for
1085
+ more details on the expected interface to dump the coverage trace information.
1086
+
1087
+ Building an instrumented program with CCG
1088
+ -----------------------------------------
1089
+
1090
+ Building an instrumented program with CCG is done in the same manner as with
1091
+ any other target, with the exception that GPRbuild must be instructed to use
1092
+ the custom coverage runtime prepared in the previous step, and by setting an
1093
+ external variable to configure the coverage runtime project for a build with
1094
+ CCG:
1095
+
1096
+ .. code-block:: sh
1097
+
1098
+ gprbuild -P <user_project.gpr> --src-subdirs=gnatcov-instr \
1099
+ --implicit-with=ccg_gnatcov_rts/gnatcov_rts.gpr \
1100
+ -XGNATCOV_RTS_FOR_CCG=true \
1101
+ <relevant target cargs>
1102
+
1103
+ After the generation of C sources is complete, all the coverage runtime C sources
1104
+ must be included in the build process of the executable. These can be found
1105
+ under ` ` ccg_gnatcov_rts/` ` for the sources already present before the gprbuild
1106
+ invocation, and under ` ` ccg_gnatcov_rts/obj-gnatcov_rts.static` ` for the sources
1107
+ generated by CCG. The C sources generated from the instrumented Ada sources will
1108
+ be available in the object directory of their corresponding project.
0 commit comments