Skip to content

Commit 39fe372

Browse files
committed
Document the support for preprocessing in Ada
1 parent dce3c3f commit 39fe372

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

doc/gnatcov/src_traces.rst

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,31 @@ within the same environment, the variable name for a program can actually be
362362
tailored by passing a :cmd-option:`--dump-filename-env-var` switch to |gcvins|,
363363
providing 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
@@ -417,7 +442,7 @@ Other source-traces limitations
417442

418443
In Ada, variable or type declarations at the package level can yield elaboration
419444
code. Such code constructs are thus considered to have corresponding coverage
420-
obligations
445+
obligations.
421446

422447
In the case where a ``pragma Preelaborate`` restriction affects the
423448
instrumented unit, variable and type declarations at the package level are not
@@ -430,8 +455,7 @@ for them.
430455
There are also a few limitations concerning the source trace workflow as a
431456
whole:
432457

433-
- Separate analysis of generic package instances is not supported,
434-
- Preprocessing directives are ignored by the source instrumenter.
458+
- Separate analysis of generic package instances is not supported.
435459

436460
Toolchain-specific limitations
437461
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)