Hello Jørgen,

having support for MC/DC coverage in GCC would be really nice. I tried out your latest patch on an arm cross-compiler with Newlib (inhibit_libc is defined). Could you please add the following fix to your patch:

diff --git a/libgcc/libgcov-merge.c b/libgcc/libgcov-merge.c
index 89741f637e1..9e3e8ee5657 100644
--- a/libgcc/libgcov-merge.c
+++ b/libgcc/libgcov-merge.c
@@ -33,6 +33,11 @@ void __gcov_merge_add (gcov_type *counters __attribute__ ((unused)),
                        unsigned n_counters __attribute__ ((unused))) {}
 #endif

+#ifdef L_gcov_merge_ior
+void __gcov_merge_ior (gcov_type *counters  __attribute__ ((unused)),
+                      unsigned n_counters __attribute__ ((unused))) {}
+#endif
+
 #ifdef L_gcov_merge_topn
 void __gcov_merge_topn (gcov_type *counters  __attribute__ ((unused)),
                        unsigned n_counters __attribute__ ((unused))) {}

It seems that support for the new GCOV_TAG_CONDS is missing in gcov-tool and gcov-dump, see "tag_table" in gcc/gcov-dump.c and libgcc/libgcov-util.c.

On 21/03/2022 12:55, Jørgen Kvalsvik via Gcc-patches wrote:
[...]
Like Wahlen et al this implementation uses bitsets to store conditions,
which gcov later interprets. This is very fast, but introduces an max
limit for the number of terms in a single boolean expression. This limit
is the number of bits in a gcov_unsigned_type (which is typedef'd to
uint64_t), so for most practical purposes this would be acceptable.
limitation can be relaxed with a more sophisticated way of storing and
updating bitsets (for example length-encoding).

For multi-threaded applications using -fprofile-update=atomic is quite important. Unfortunately, not all 32-bit targets support 64-bit atomic operations in hardware. There is a target hook to select the size of gcov_type. Maybe a dedicated 64-bit type should be used for the bitfield using two 32-bit atomic OR if necessary.


In action it looks pretty similar to the branch coverage. The -g short
opt carries no significance, but was chosen because it was an available
option with the upper-case free too.

gcov --conditions:

         3:   17:void fn (int a, int b, int c, int d) {
         3:   18:    if ((a && (b || c)) && d)
conditions covered 5/8
condition  1 not covered (false)
condition  2 not covered (true)
condition  2 not covered (false)
         1:   19:        x = 1;
         -:   20:    else
         2:   21:        x = 2;
         3:   22:}

I have some trouble to understand the output. Would 8/8 mean that we have 100% MC/DC coverage? What does "not covered (false)" or "not covered (true)" mean?

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/

Reply via email to