From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 4469938438A1 for ; Tue, 25 Jun 2024 10:23:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4469938438A1 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kam.mff.cuni.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4469938438A1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.113.20.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719311031; cv=none; b=epXmsFafhL6qJuf5Lqtyd6M9lPrQpOHCFVdLnpghHb6YgyDTYiYRu4lC1ucdO/sBygGTT+EWxaVTCd1GpfPQgHLZQvWr3TrDajLl7DKo6SffACQYEv0oB8Pw56YTzsi6MmTDc+uWkXw8Ct5+PlngrdJuoqGh+Yu0+hLNU1+SJFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719311031; c=relaxed/simple; bh=sHt10q1g5gIyGGMHEj8vPT25I1HSENXUkJkyr1rd4Mk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Rd+fh31ZzT2Sw4su50TsToihKgSzcxTzbTnNzWZGO8vhFj9ylxRvYEA5d55ZWYOgKVPUu6mHuJ93/5+rMggTFmuDfLbPLdCZNRqpIv+QDVqwlPbZXyhA+7qKGTJ46EwqSPQsY+4vnAQ78/6Fn0UNSUY3BGXuGRsKPv71cJWr8/M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 2A4A628774D; Tue, 25 Jun 2024 12:23:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1719311028; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wLbjn5BHaDfh0amZkcJQMcE/8l1OWDdg7oWYm2/5MfI=; b=EZMKXxmnOX5e/ULtdcXw9/BpVq9LswgOrcng4Kh5EvJg8NXpcai96RDSCdULy4XF8GfD1S x3vGIxZr3dOoQfHl7uKXOIZU496cHmooK+OU7//JQLxOKMJEw626mJdWJgrrYD46t5piNt doWtiUPN2aHMBxHlcqL1DNHNrufgfd0= Date: Tue, 25 Jun 2024 12:23:48 +0200 From: Jan Hubicka To: =?utf-8?Q?J=C3=B8rgen?= Kvalsvik Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH 2/3] Add section on MC/DC in gcov manual Message-ID: References: <20240625080332.1517736-1-j@lambda.is> <20240625080332.1517736-3-j@lambda.is> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240625080332.1517736-3-j@lambda.is> X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,JMQ_SPF_NEUTRAL,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > gcc/ChangeLog: > > * doc/gcov.texi: Add MC/DC section. OK, thanks! Honza > --- > gcc/doc/gcov.texi | 72 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 72 insertions(+) > > diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi > index dc79bccb8cf..a9221738cce 100644 > --- a/gcc/doc/gcov.texi > +++ b/gcc/doc/gcov.texi > @@ -917,6 +917,78 @@ of times the call was executed will be printed. This will usually be > 100%, but may be less for functions that call @code{exit} or @code{longjmp}, > and thus may not return every time they are called. > > +When you use the @option{-g} option, your output looks like this: > + > +@smallexample > +$ gcov -t -m -g tmp > + -: 0:Source:tmp.cpp > + -: 0:Graph:tmp.gcno > + -: 0:Data:tmp.gcda > + -: 0:Runs:1 > + -: 1:#include > + -: 2: > + -: 3:int > + 1: 4:main (void) > + -: 5:@{ > + -: 6: int i, total; > + 1: 7: total = 0; > + -: 8: > + 11: 9: for (i = 0; i < 10; i++) > +condition outcomes covered 2/2 > + 10: 10: total += i; > + -: 11: > + 1*: 12: int v = total > 100 ? 1 : 2; > +condition outcomes covered 1/2 > +condition 0 not covered (true) > + -: 13: > + 1*: 14: if (total != 45 && v == 1) > +condition outcomes covered 1/4 > +condition 0 not covered (true) > +condition 1 not covered (true false) > + #####: 15: printf ("Failure\n"); > + -: 16: else > + 1: 17: printf ("Success\n"); > + 1: 18: return 0; > + -: 19:@} > +@end smallexample > + > +For every condition the number of taken and total outcomes are > +printed, and if there are uncovered outcomes a line will be printed > +for each condition showing the uncovered outcome in parentheses. > +Conditions are identified by their index -- index 0 is the left-most > +condition. In @code{a || (b && c)}, @var{a} is condition 0, @var{b} > +condition 1, and @var{c} condition 2. > + > +An outcome is considered covered if it has an independent effect on > +the decision, also known as masking MC/DC (Modified Condition/Decision > +Coverage). In this example the decision evaluates to true and @var{a} > +is evaluated, but not covered. This is because @var{a} cannot affect > +the decision independently -- both @var{a} and @var{b} must change > +value for the decision to change. > + > +@smallexample > +$ gcov -t -m -g tmp > + -: 0:Source:tmp.c > + -: 0:Graph:tmp.gcno > + -: 0:Data:tmp.gcda > + -: 0:Runs:1 > + -: 1:#include > + -: 2: > + 1: 3:int main() > + -: 4:@{ > + 1: 5: int a = 1; > + 1: 6: int b = 0; > + -: 7: > + 1: 8: if (a && b) > +condition outcomes covered 1/4 > +condition 0 not covered (true false) > +condition 1 not covered (true) > + #####: 9: printf ("Success!\n"); > + -: 10: else > + 1: 11: printf ("Failure!\n"); > + -: 12:@} > +@end smallexample > + > The execution counts are cumulative. If the example program were > executed again without removing the @file{.gcda} file, the count for the > number of times each line in the source was executed would be added to > -- > 2.39.2 >