public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
To: "Jørgen Kvalsvik" <jorgen.kvalsvik@woven-planet.global>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Add condition coverage profiling
Date: Wed, 6 Apr 2022 09:35:58 +0200	[thread overview]
Message-ID: <119d52c0-713a-b55b-8745-53a2307dfd9f@embedded-brains.de> (raw)
In-Reply-To: <135f1f97-9359-f3fa-7718-4384aa9a376f@woven-planet.global>

On 05/04/2022 22:07, Jørgen Kvalsvik wrote:
>>> 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?
>>
> Yes, 8/8 would mean that the expression is 100% covered (all conditions take on
> both values and have independent effect on the outcome). 

This is really great.

> "not covered" is a
> report of missing coverage, that is "condition  1 not covered (false)" means
> that bit N (N = 1, b in this case) has not taken on false yet, and to achieve
> 100% coverage you need a test case where b = false.
> 
> The wording is arbitrary, and I tried to strike a balance between density,
> clarity, grepability and noise. I am open to other suggestions that would
> improve this.

Ok, for the default output this is good. The output can be explained in 
the documentation. I will try to help here.

In theory, would it be possible to print the state of the truth table 
with the information available in the gcda and gcno files? For example:

Truth table for: a && (b || c)) && d

0 | 1 | 2 | 3 || covered
--+---+---+---++--------
0 | X | X | X || Y
0 | X | X | X || Y
0 | X | X | X || Y
0 | X | X | X || Y
0 | X | X | X || Y
0 | X | X | X || Y
0 | X | X | X || Y
0 | X | X | X || Y
1 | 0 | 0 | X || N
1 | 0 | 0 | X || N
1 | 0 | 1 | 0 || N
1 | 0 | 1 | 1 || N
1 | 1 | X | 0 || Y
1 | 1 | X | 0 || Y
1 | 1 | X | 1 || Y
1 | 1 | X | 1 || Y

Would it be possible to map the condition index to a source code 
snippet? For example condition 1 to "b"?

> 
> Unrelated to this, in typing up some notes on this I found a few minor and one
> quite significant (really, the masking algorithm is broken) error in the
> algorithm, which I am working on correcting. I will propose the new patch with
> these fixes too once I have finished writing and testing it.

Thanks a lot for this work.

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@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	other threads:[~2022-04-06  7:36 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21 11:55 Jørgen Kvalsvik
2022-03-24 16:08 ` Martin Liška
2022-03-25 19:44   ` Jørgen Kvalsvik
2022-03-28 13:39     ` Martin Liška
2022-03-28 13:52     ` Jørgen Kvalsvik
2022-03-28 14:40       ` Jørgen Kvalsvik
2022-04-07 12:04         ` Martin Liška
2022-04-19 14:22           ` Jørgen Kvalsvik
2022-04-07 16:53         ` Sebastian Huber
2022-04-08  7:28           ` Jørgen Kvalsvik
2022-04-08  7:33             ` Jørgen Kvalsvik
2022-04-08  8:50               ` Sebastian Huber
2022-04-04  8:14 ` Sebastian Huber
2022-04-05  7:04   ` Sebastian Huber
2022-04-05 20:07   ` Jørgen Kvalsvik
2022-04-06  7:35     ` Sebastian Huber [this message]
2022-04-17 11:27       ` Jørgen Kvalsvik
2022-04-22  5:37         ` Sebastian Huber
2022-04-22 10:13           ` Jørgen Kvalsvik
2022-07-08 13:45 ` Sebastian Huber
2022-07-11  7:26   ` Jørgen Kvalsvik
2022-07-11 10:02 Jørgen Kvalsvik
2022-07-12 14:05 ` Sebastian Huber
2022-07-13  2:04   ` Jørgen Kvalsvik
2022-07-15 11:39 Jørgen Kvalsvik
2022-07-15 11:47 ` Jørgen Kvalsvik
2022-07-15 13:31   ` Sebastian Huber
2022-07-15 13:47     ` Jørgen Kvalsvik
2022-08-02  7:58       ` Jørgen Kvalsvik
2022-08-04  7:43         ` Sebastian Huber
2022-08-04  9:13           ` Jørgen Kvalsvik
2022-10-12 10:16 Jørgen Kvalsvik
2022-10-18  0:17 ` Hans-Peter Nilsson
2022-10-18 10:13   ` Jørgen Kvalsvik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=119d52c0-713a-b55b-8745-53a2307dfd9f@embedded-brains.de \
    --to=sebastian.huber@embedded-brains.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jorgen.kvalsvik@woven-planet.global \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).