@@ -362,6 +362,31 @@ within the same environment, the variable name for a program can actually be
362362tailored by passing a :cmd-option: `--dump-filename-env-var ` switch to |gcvins |,
363363providing the variable name to use.
364364
365+ Support for preprocessing
366+ -------------------------
367+
368+ |gcvins | automatically detects preprocessor configuration from the compiler
369+ switches present in project files (``-gnatep `` and ``-gnateD `` for Ada sources,
370+ ``-D `` and the like for C/C++ sources). It then runs preprocessing on the
371+ source code *before * the instrumentation itself happens. This allows gnatcov
372+ to compute the code coverage only for code that is left "enabled" by
373+ preprocessing directives: disabled code (for instance what follows ``#if Debug
374+ then `` in Ada when the preprocessing symbol ``Debug `` is set to ``False ``) is
375+ ignored and thus creates no coverage obligation. Note that consolidation will
376+ not help including code from all "preprocessing branches" in coverage reports,
377+ as gnatcov requires (and checks) that coverage obligations are the same for two
378+ units to consolidate.
379+
380+ Ada pecularities
381+ ^^^^^^^^^^^^^^^^
382+
383+ The coverage obligations for code that comes from symbol expansion (for
384+ example, ``$Foo = 42 `` expanded into ``My_Variable = 42 `` with
385+ ``-Dfoo=My_Variable ``) designate expanded code. Even though line numbers are
386+ preserved during preprocessing, column numbers may be different between the
387+ original code and the preprocessed code and thus the coverage report.
388+
389+
365390.. _instr-limitations :
366391
367392|gcvins | limitations
@@ -413,24 +438,24 @@ state. Should the default limit not be satisfactory, it can be tuned with the
413438option :cmd-option: `--path-count-limit `.
414439
415440Other source-traces limitations
416- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
441+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
417442
418443In Ada, variable or type declarations at the package level can yield elaboration
419444code. Such code constructs are thus considered to have corresponding coverage
420- obligations
445+ obligations.
421446
422- In the case where a `pragma Preelaborate ` restriction affects the instrumented
423- unit, variable and type declarations at the package level are not considered as
424- coverage obligations, although some elaboration code may still be emitted in
425- rare instances. Note that declarations within a unit constrained by a
426- ``No_Elaboration_Code `` pragma don't produce coverage obligation either, which
427- is always correct as no executable code can be emitted by the compiler for them.
447+ In the case where a ``pragma Preelaborate `` restriction affects the
448+ instrumented unit, variable and type declarations at the package level are not
449+ considered as coverage obligations, although some elaboration code may still be
450+ emitted in rare instances. Note that declarations within a unit constrained by
451+ a ``No_Elaboration_Code `` pragma don't produce coverage obligation either,
452+ which is always correct as no executable code can be emitted by the compiler
453+ for them.
428454
429455There are also a few limitations concerning the source trace workflow as a
430456whole:
431457
432- - Separate analysis of generic package instances is not supported,
433- - Preprocessing directives are ignored by the source instrumenter.
458+ - Separate analysis of generic package instances is not supported.
434459
435460Toolchain-specific limitations
436461^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -686,7 +711,7 @@ Setting up the coverage runtime
686711^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
687712
688713As seen in the :ref: `instr-rts ` section, we use the ``gnatcov setup `` command to
689- build and install the :term: `coverage runtime <Coverage Runtime> `::
714+ build and install the :term: `coverage runtime <Coverage Runtime> `.
690715
691716For our intended target environment, this would be something like::
692717
0 commit comments